一个用参数传入SQL查询条件中where 后的所有内容的过程,不知为什么报错。就差一点就完成了,就是过不去。
就是一个普通的定义游标的存储过程,只是游标的select 语句中的where 后的字段名字和条件及取值都用参数传入,最麻烦的问题都解决了,可调用时就是报错
定义的包为:
CREATE OR REPLACE PACKAGE GET_EMP_NAME
AS
TYPE T_REF IS REF CURSOR;
PROCEDURE GET_ALL_EMPNAME(OPT VARCHAR2,TJ VARCHAR2,T_ID VARCHAR2,L_ID OUT T_REF);
END GET_EMP_NAME;
/
CREATE OR REPLACE PACKAGE BODY GET_EMP_NAME
AS
PROCEDURE GET_ALL_EMPNAME(OPT VARCHAR2,TJ VARCHAR2,T_ID VARCHAR2,L_ID OUT T_REF) AS
STR_SQL VARCHAR2(500);
BEGIN
STR_SQL:= 'OPEN L_ID FOR SELECT TASK_ID FROM EMPLOYEE ';
STR_SQL:= STR_SQL|| 'WHERE '||OPT||TJ|| 'T_ID ';
EXECUTE IMMEDIATE STR_SQL;
END GET_ALL_EMPNAME;
END GET_EMP_NAME;
/
这样调用的:
declare
e_name varchar2(4);
cursor_name get_emp_name.t_ref;
begin
get_emp_name.get_all_empname( 'TASK_ID ', '= ', '1 ',cursor_name);
loop
fetch cursor_name into e_name;
exit when cursor_name%notfound;
dbms_output.put_line(e_name);
end loop;
end;
/
报错:
declare
*
第一行出现错误:
ORA-00900:无效SQL语句 ORA-06512:在”SYSTEM.GET_EMP_NAME”, line 8
ORA-06512:在line 5
请各位看看。
------解决方案--------------------用TOAD跟踪一下 看看你动态构件的SQL语句是否正确 然后再说
------解决方案--------------------zt
那个版本的,版本不同号码不同?
http://www.quest.com/requests/?RequestDefID=49
注册码:5-88860-02883-29060-03749
Toad v7.2
Site Message = Quest
Key = 5-88860-02883-29060-03749
toad v7.3
auth: 5-88860-01683-29060-00749
site message: www
Toad v7.4
5-01171-87532-9058168856
2-46571-48741-24484-88982
TOAD序列号7.0(如果版本不同的可能要一个个去试):
Wu Yung Shan: 1-36835-04383-25740-01513
Trial Version:4-11120-73601-65005-24785
John Doe: 5-88860-05843-29060-02749
www:5-88860-01683-29060-00749
Quest :5-88860-02883-29060-03749
TOAD下载地点:http://www.quest.com/toad/payload/TOADXpertSetup.EXE
toad7.3 SN
Site Message = Quest
Key = 5-88860-02883-29060-03749
==============================
authorization key:
5-88860-01683-29060-00749
这是以前超人家的,希望对你有帮助
TOAD (6 and 7 - For 7, download full with knowledge base, install full TOAD, then the knowledge base won 't ask for serial/activation!):
Authorization: 5-88860-01683-29060-00749
Site Message: ww