日期:2014-05-16  浏览次数:20957 次

用C#执行SQL语句出错,在PL/SQL里面却正常?
我在前台用C#生成如下的SQL语句抛到数据库中,提示出错。把SQL粘贴到PL/SQL里面执行却能正常通过,这是怎么回事啊?
SQL语句如下:
BEGIN
declare TMP_IDKEY INTEGER;
TMP_NUM INTEGER;
BEGIN
delete jzx.jzxlcxjhb where 类型='卸船' and 标志='0' and 进口船名='新万丰' and 进口航次='0816' and 箱号='CSAU5409867';
SELECT JZX.JZXLCXJHB_SEQ.NEXTVAL INTO TMP_IDKEY FROM DUAL;
insert into jzx.jzxlcxjhb(箱号,进口船名,进口航次,设定温度,设定湿度,设定通风器,是否预冷,冷冻机型,除霜间隔,货名,出口船名,出口航次,卸货港,备注,类型,标志,录入者,录入时间,确认者,确认时间,IDKEY)
values('CSAU5409867','新万丰','0816',3,33,'3','是','123','123','weq','','','','2123','卸船','0','陈钟运',sysdate,'',null,TMP_IDKEY);
select count(*) into TMP_NUM from jzx.jzxlcxzlb where 进口船名='新万丰' and 进口航次='0816' and 箱号='CSAU5409867';
if TMP_NUM>0 then
update jzx.jzxlcxzlb set 设定IDKEY=TMP_IDKEY where 箱号='CSAU5409867' and 进口船名='新万丰' and 进口航次='0816';
else
INSERT INTO jzx.jzxlcxzlb(箱号,进口船名,进口航次,设定IDKEY)
VALUES('CSAU5409867','新万丰','0816',TMP_IDKEY);
END IF;
delete jzx.jzxlcxjhb where 类型='卸船' and 标志='0' and 进口船名='新万丰' and 进口航次='0816' and 箱号='NPAU5180610';
SELECT JZX.JZXLCXJHB_SEQ.NEXTVAL INTO TMP_IDKEY FROM DUAL;
insert into jzx.jzxlcxjhb(箱号,进口船名,进口航次,设定温度,设定湿度,设定通风器,是否预冷,冷冻机型,除霜间隔,货名,出口船名,出口航次,卸货港,备注,类型,标志,录入者,录入时间,确认者,确认时间,IDKEY)
values('NPAU5180610','新万丰','0816',1,123,'123','否','33','12','qq','','','','3','卸船','0','陈钟运',sysdate,'',null,TMP_IDKEY);
select count(*) into TMP_NUM from jzx.jzxlcxzlb where 进口船名='新万丰' and 进口航次='0816' and 箱号='NPAU5180610';
if TMP_NUM>0 then
update jzx.jzxlcxzlb set 设定IDKEY=TMP_IDKEY where 箱号='NPAU5180610' and 进口船名='新万丰' and 进口航次='0816';
else
INSERT INTO jzx.jzxlcxzlb(箱号,进口船名,进口航次,设定IDKEY)
VALUES('NPAU5180610','新万丰','0816',TMP_IDKEY);
END IF;
end;
END;

C#错误提示:

ORA-06550: 第 1 行, 第 6 列: 
PLS-00103: 出现符号 ""在需要下列之一时:
 begin case declare exit for
  goto if loop mod null pragma raise return select update while
  with <an identifier> <a double-quoted delimited-identifier>
  <a bind variable> << close current delete fetch lock insert
  open rollback savepoint set sql execute commit forall merge
  pipe
符号 "begin在 "" 继续之前已插入。
ORA-06550: 第 2 行, 第 27 列: 
PLS-00103: 出现符号 ""在需要下列之一时:
 begin function package pragma
  procedure subtype type use <an identifier>
  <a double-quoted delimited-identifier> form current cursor

------解决方案--------------------
INTEGER
------解决方案--------------------
这种代码能用c#调用么?
我还以为是plsql专有的呢
------解决方案--------------------
我认为是不行
等待高手解答
------解决方案--------------------
oracle 的版本是多少啊?