当前位置: 代码迷 >> Oracle开发 >> 请教出现SP2-0552: 未说明结合变量是什么原因
  详细解决方案

请教出现SP2-0552: 未说明结合变量是什么原因

热度:28   发布时间:2016-04-24 07:32:43.0
请问出现SP2-0552: 未说明结合变量是什么原因
代码如下:
declare :dcidnum number(20)
begin
insert into DATACHANGE(CTYPE,USERID,CROW,CONDCID,CTABLE,CSTATE,CTIME) values('1','001',0,-1,'','1',to_date('2012-4-11 17:26:39','yyyy-mm-dd hh24:mi:ss')); 
:dcidnum=select DCID from DATACHANGE where CTIME= to_date('2012-4-11 17:26:39','yyyy-mm-dd hh24:mi:ss');
select :dcidnum;
end

拜托各位大神解析...

------解决方案--------------------
语法不正确
SQL code
VARIABLE dcidnum numberbegininsert into DATACHANGE(CTYPE,USERID,CROW,CONDCID,CTABLE,CSTATE,CTIME) values('1','001',0,-1,'','1',to_date('2012-4-11 17:26:39','yyyy-mm-dd hh24:mi:ss'));  select DCID INTO :dcidnum from DATACHANGE where CTIME= to_date('2012-4-11 17:26:39','yyyy-mm-dd hh24:mi:ss');end;/print dcidnum
------解决方案--------------------
请参考:
SQL code
DECLARE       dcidnum NUMBER(20);BEGIN      INSERT INTO DATACHANGE(CTYPE,USERID,CROW,CONDCID,CTABLE,CSTATE,CTIME)     VALUES('1','001',0,-1,'','1',to_date('2012-4-11 17:26:39','yyyy-mm-dd hh24:mi:ss'));     SELECT DCID INTO dcidnum FROM DATACHANGE WHERE CTIME= to_date('2012-4-11 17:26:39','yyyy-mm-dd hh24:mi:ss');    DBMS_OUTPUT.PUT_LINE(dcidnum);END;