一个新手的困惑

[复制链接]
查看11 | 回复6 | 2006-4-13 07:34:50 | 显示全部楼层 |阅读模式
哪位老大指点一下,为何这个块在运行时,总报非法的零长度标识符?ORA-01741
declare
--variable define
V_item variable;
v_countnumber;
begin
select item_id into V_item
fromitem_person_xref
where item_person_xref.person_id='00128';

if(V_item!="&quot

then v_count:=1
else v_count:=0;

DBMS_OUTPUT.put_line(V_item);
dbms_output.put_line(v_count);
end;

新手!


回复

使用道具 举报

千问 | 2006-4-13 07:34:50 | 显示全部楼层
V_item variable;
可以这么定义么?
回复

使用道具 举报

千问 | 2006-4-13 07:34:50 | 显示全部楼层
还有,不是
if(V_item!="&quot

而应该是单引号
if(V_item!='')
回复

使用道具 举报

千问 | 2006-4-13 07:34:50 | 显示全部楼层
if then
else
end if
判断不等于 ,!=是java的写法吧,没试过在pl/sql里这样写
回复

使用道具 举报

千问 | 2006-4-13 07:34:50 | 显示全部楼层
最初由 freepigfly 发布
[B]if then
else
end if
判断不等于 ,!=是java的写法吧,没试过在pl/sql里这样写 [/B]
!=也是可以的
回复

使用道具 举报

千问 | 2006-4-13 07:34:50 | 显示全部楼层
select item_id
into V_item
from item_person_xref
where item_person_xref.person_id = '00128';
要是查不到值就会报错。。用count进行判断
回复

使用道具 举报

千问 | 2006-4-13 07:34:50 | 显示全部楼层
declare
--variable define
V_item variable;
v_count number;
v_record number;
begin

select count(*) into v_record from item_person_xref
where item_person_xref.person_id='00128';
if v_record>0 then
select item_id into V_item
from item_person_xref
where item_person_xref.person_id='00128';
if(V_item!="&quot

then v_count:=1
else v_count:=0;
DBMS_OUTPUT.put_line(V_item);
dbms_output.put_line(v_count);
end if;
end;
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行