[英]error of running a stored proceudre in IBM netezza SQL database
I need to create a stored procedure in IBM netezza SQL database from IBM Aginity workbench. 我需要从IBM Aginity工作台在IBM netezza SQL数据库中创建一个存储过程。
This is my SQL code to create the SP: 这是我创建SP的SQL代码:
CREATE OR REPLACE PROCEDURE "SP_drop_a_table_if_exists"(varchar(128))
RETURNS boolean
EXECUTE AS OWNER
LANGUAGE NZPLSQL AS
BEGIN_PROC
declare
oname alias for $1;
o record;
begin
select otype into o
from (
select 'TABLE' otype from _v_table where tablename = upper(oname)
union all
select 'VIEW' otype from _v_view where viewname = upper(oname)
) x;
if found then
execute immediate 'DROP '||o.otype||' '||oname;
end if;
end;
END_PROC;
I created successfully. 我创建成功。
But, when I ran it, 但是,当我运行它时,
CALL SP_drop_a_table_if_exists('test_a_table':: varchar(128))
I got error: 我收到错误消息:
ERROR[42S02] error: function 'sp_drop_a_table_if_exists(varchar)' does not exists
unable to identify a function that satisdy the given argument types
you may need to add explicit typecasts
Any help would be appreciated ! 任何帮助,将不胜感激 !
You created your stored procedure with mixed case inside of double quotes... 您使用双引号内的混合大小写创建了存储过程...
CREATE OR REPLACE PROCEDURE "SP_drop_a_table_if_exists"(varchar(128))
...but when you call the stored procedure you don't use double quotes, so the name is being converted all upper case. ...但是当您调用存储过程时,您不会使用双引号,因此名称将全部转换为大写。
CALL SP_drop_a_table_if_exists('test_a_table':: varchar(128))
Try this instead: 尝试以下方法:
CALL "SP_drop_a_table_if_exists"('test_a_table':: varchar(128)) 呼叫“ SP_drop_a_table_if_exists”('test_a_table':: varchar(128))
I should also mention that more recent versions of NPS support this syntax for the DROP TABLE command: 我还应该提到,最新版本的NPS支持DROP TABLE命令的此语法:
DROP TABLE TABLENAME IF EXISTS;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.