一个PL/SQL的问题

[复制链接]
查看11 | 回复2 | 2012-5-15 15:24:11 | 显示全部楼层 |阅读模式
1:创建以下的PL/SQL过程,报Warning: Procedure created with compilation errors.
SQL> createprocedure inquire(stu_no in students.no%type,

stu_name out students.name%type )
is
BEGIN
select name into stu_name from students where no=stu_no;
END;
end inquire;
/
2:执行时报
SQL> execute inquire(02,:inq_name);
begin inquire(02,:inq_name); end;
*
ERROR at line 1:
ORA-06550: line 1, column 7:
PLS-00905: object FJRUN.INQUIRE is invalid
ORA-06550: line 1, column 7:
PL/SQL: Statement ignored
3:inq_name值为空。
回复

使用道具 举报

千问 | 2012-5-15 15:24:11 | 显示全部楼层
15:49:08 SQL> create table students (
15:50:41 2novarchar2(10),
15:50:41 3namevarchar2(100)
15:50:41 4);
表已建立.
15:51:57 SQL>
15:52:28 SQL> insert into students values('02','ewewew');
插入一个记录.
real: 50
15:52:48 SQL> commit;
完全提交.
real: 270
15:50:42 SQL> create procedure inquire(stu_no in students.no%type,
15:50:55 2stu_name out students.name%type )
15:50:55 3is
15:50:55 4BEGIN
15:50:55 5select name into stu_name from students where no=stu_no;
15:50:55 6END;
15:50:55 7/
分区已建立.
real: 160
15:51:47 SQL>var ppp varchar2(10);
real: 220
15:53:12 SQL>exec inquire('02',

pp)
PL/SQL过程完全成功.
15:53:20 SQL> print ppp
PPP
----------------------------------------------------------------
ewewew
回复

使用道具 举报

千问 | 2012-5-15 15:24:11 | 显示全部楼层
我的错误有两个:
1:CREATE时多了个END PROCEDURE。
2:EXEC时字符型要用单引号。
回复

使用道具 举报

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

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行