Hello, there are two tables, the firm and the firm_pe.
CREATE TABLE firm (fNum NUMBER(4), fName VARCHAR2(50) NOT NULL, fProductType VARCHAR2(50) NOT NULL, fBudget NUMBER(7,3) NOT NULL), CONSTRAINT firm_pk_snum PRIMARY KEY (fnum) ); CREATE TABLE firm_pe ( fpeNum NUMBER(4), fpeName VARCHAR2(50) NOT NULL, fpeProductType VARCHAR2(50) NOT NULL, fpeBudget NUMBER(7,3) NOT NULL, CONSTRAINT fpe_pk PRIMARY KEY (fpeNum) ); Put such a task in the table firm_pe to find a company with the lowest budget and transfer it to the firm table. In this case, you need to use only implicit cursors. But the company should be transferred only if there are no peripheral equipment suppliers in the firm table (that is, the fProductType column does not contain Peripheral). Solved the problem in this way:
DECLARE fpe_num number(4); fpe_name VARCHAR2(20); fpe_type VARCHAR2(20); fpe_budget NUMBER(7,3); BEGIN SELECT fpenum, fpename, fpeproducttype, fpebudget INTO fpe_num, fpe_name, fpe_type, fpe_budget FROM firm_pe WHERE fpebudget = (SELECT min(fpebudget) FROM firm_pe); DBMS_OUTPUT.PUT_LINE(fpe_num||' '||fpe_name||' '||fpe_type||' '||fpe_budget); UPDATE firm SET fnum = fpe_num WHERE fproducttype = 'Peripheral'; IF(SQL%NOTFOUND) THEN INSERT INTO firm(fnum, fname, fproducttype , fbudget) VALUES(fpe_num, fpe_name, fpe_type, fpe_budget); DBMS_OUTPUT.PUT_LINE('Добавлена ' || SQL%ROWCOUNT || ' фирма ' || fpe_name); END IF; COMMIT; END; but when you call again, an error should be generated, and the information is simply updated. Apparently not correctly composed line:
UPDATE firm SET fnum = fpe_num WHERE fproducttype = 'Peripheral';
Tell me how to rewrite and where I was wrong

UPDATE firm SET fnum = fpe_num WHERE fproducttype = 'Peripheral';you change all the entries in the firm's table where fproducttype is equal to Peripheral, and you are trying to change the primary key of this table, which in general is of course allowed, but in practice this does not occur. So I did not understand what you are trying to achieve with this update (and yes, an error on update could be the same if more than one row in the firm’s table has fproducttype = 'Peripheral') - Mikeselect count(1) into CNT from firm where fproducttype = 'Peripheral'and then do IF CNT = 0 THEN - Mike