declare maxnum VARCHAR100;maxnum = SELECT MAXAUFNR+1 FROM SAPIFEDI_ZTPP037 WHERE AUFNR LIKE 11000;BEGININSERT INTO SAPIFEDI_ZTPP037MANDT AUFNR WERKS MATNR MAKTX VALUES 800 maxnum 2010 AAUTA161-K004CFP
It seems like you are trying to execute Oracle code in a PostgreSQL database. The syntax for declaring and initializing a variable is different in PostgreSQL. Here's the corrected code:
DECLARE maxnum VARCHAR(100); BEGIN SELECT (MAX(AUFNR)+1) INTO maxnum FROM "SAPIF"."EDI_ZTPP037" WHERE AUFNR LIKE '11000%'; INSERT INTO "SAPIF"."EDI_ZTPP037"("MANDT", "AUFNR", "WERKS", "MATNR", "MAKTX") VALUES ('800', maxnum, '2010', 'AAUTA161-K004CF', 'PCI-E 98P;POST;PA9T黑;磷青銅15u";3.10;PIP'); END;
This code declares a variable called "maxnum", assigns it the value returned by the SELECT statement, and then uses it in the INSERT statement. Note that the SELECT statement has been modified to use the INTO keyword to store the result in the variable
原文地址: https://www.cveoy.top/t/topic/g1Ro 著作权归作者所有。请勿转载和采集!