oracel新手求助
创建了这样一张表
create table testTbl(
ID INTEGER PRIMARY KEY NOT NULL,
I_PIHAO VARCHAR2(50) UNIQUE,
S_CID VARCHAR2(50)
)
和函数
CREATE SEQUENCE testTbl_SEQUENCE
INCREMENT BY 1
NOCACHE
NOMAXVALUE
NOCYCLE
CREATE OR REPLACE FUNCTION FUNC_testTBL return INTEGER is
begin
V_ID INTEGER;
SELECT testTbl_SEQUENCE.Nextval INTO V_ID FROM DUAL;
RETURN (V_ID);
end testTBL;
然后在执行一下存储过程 一直报错
列在此处不允许
和无效SQL语句两个错误
不知是什么原因,求高手相助
CREATE OR REPLACE PROCEDURAL P_TBLTEST
(
V_ID OUT integer,
I_PIHAO VARCHAR2,
S_CID VARCHAR2
)
IS
BEGIN
V_ID:=FUNC_testTBL();
INSERT INTO TESTTBL (testTbl.Id,testTbl.i_Pihao,testTbl.s_Cid) VALUES(V_ID,I_PIHAO,S_CID);
END P_TBLTEST;
------解决方案--------------------
这样写还可以一步到位:
SQL code
CREATE OR REPLACE PROCEDURAL P_TBLTEST
(
V_ID OUT integer,
I_PIHAO VARCHAR2,
S_CID VARCHAR2
)
IS
BEGIN
INSERT INTO TESTTBL (Id,i_Pihao,s_Cid)
VALUES(testTbl_SEQUENCE.Nextval,I_PIHAO,S_CID) RETURNING ID INTO V_ID;
END P_TBLTEST;