DECLARE count NUMBER;
SELECT max(to_number(param_code))+1 INTO count from abc where interface_code='PQR' ;
INSERT INTO abc
( INTERFACE_CODE
, PARAM_CODE
, DSCR
, PARAM_CHAR
, PARAM_NUMBER
, PARAM_DATE
, TRGA_CODE
)
VALUES
( 'PQR'
, count
, 'xyz'
, ''
, ''
, ''
, '*'
)
我想在Oracle中将这3个语句作为脚本执行。 但这给了我错误。
请帮忙
答案 0 :(得分:3)
DECLARE
MY_COUNT NUMBER;
BEGIN
SELECT MAX(to_number(param_code))+1
INTO MY_COUNT
FROM abc
WHERE interface_code='PQR' ;
INSERT
INTO abc
(
INTERFACE_CODE ,
PARAM_CODE ,
DSCR ,
PARAM_CHAR ,
PARAM_NUMBER ,
PARAM_DATE ,
TRGA_CODE
)
VALUES
(
'PQR' ,
MY_COUNT ,
'xyz' ,
'' ,
'' ,
'' ,
'*'
);
EXCEPTION
WHEN OTHERS THEN
DBMS_OUTPUT.PUT_LINE(SQLERRM);
END;
/