Hi,
I am new to DB2. I am trying to write a simple stored procedure, but getting the error attached below.
ERROR
=============== =============== =============== =============
TGT.AUDIT - Build started.
Create stored procedure returns -440.
TGT.AUDIT: 28: [IBM][CLI Driver][DB2/NT] SQL0440N No authorized routine named "||" of type "FUNCTION" having compatible arguments was found. LINE NUMBER=28. SQLSTATE=42884
TGT.AUDIT - Build failed.
TGT.AUDIT - Roll back completed successfully.
=============== =============== =============== =============
Attched below is the code which I have written. The error statement is marked as *. Can anyone please help me out....
Thanks in Adv.
Girish Dalvi
CREATE PROCEDURE TGT.AUDIT (IN V_TAB_NAME VARCHAR(10) )
------------------------------------------------------------------------
-- SQL Stored Procedure
------------------------------------------------------------------------
dl: BEGIN
DECLARE v_tbl_name varchar(10);
DECLARE I int default 0;
DECLARE v_col_count int;
DECLARE v_col_name varchar(10);
DECLARE v_total INT;
DECLARE v_col varchar(10);
DECLARE SQLSTRING varchar(4000);
DECLARE V_STMT STATEMENT;
DECLARE cur_col_name cursor for select colname from metadata where tname=V_TAB_NAM E;
select count(*) into v_col_count from metadata where tname=V_TAB_NAM E;
insert into tmp values ('the new value is ',v_col_count);
open cur_col_name;
while I < v_col_count
do
fetch cur_col_name into v_col_name;
* SET SQLSTRING = 'SELECT sum(cast('|| v_col_name || ')) into' ||v_total|| ' from ' || V_TAB_NAME;
PREPARE V_STMT FROM SQLSTRING;
Insert into TOTALS values (V_TAB_NAME,v_c ol_name, v_total);
set I=I+1;
end while;
close cur_col_name;
END dl
I am new to DB2. I am trying to write a simple stored procedure, but getting the error attached below.
ERROR
=============== =============== =============== =============
TGT.AUDIT - Build started.
Create stored procedure returns -440.
TGT.AUDIT: 28: [IBM][CLI Driver][DB2/NT] SQL0440N No authorized routine named "||" of type "FUNCTION" having compatible arguments was found. LINE NUMBER=28. SQLSTATE=42884
TGT.AUDIT - Build failed.
TGT.AUDIT - Roll back completed successfully.
=============== =============== =============== =============
Attched below is the code which I have written. The error statement is marked as *. Can anyone please help me out....
Thanks in Adv.
Girish Dalvi
CREATE PROCEDURE TGT.AUDIT (IN V_TAB_NAME VARCHAR(10) )
------------------------------------------------------------------------
-- SQL Stored Procedure
------------------------------------------------------------------------
dl: BEGIN
DECLARE v_tbl_name varchar(10);
DECLARE I int default 0;
DECLARE v_col_count int;
DECLARE v_col_name varchar(10);
DECLARE v_total INT;
DECLARE v_col varchar(10);
DECLARE SQLSTRING varchar(4000);
DECLARE V_STMT STATEMENT;
DECLARE cur_col_name cursor for select colname from metadata where tname=V_TAB_NAM E;
select count(*) into v_col_count from metadata where tname=V_TAB_NAM E;
insert into tmp values ('the new value is ',v_col_count);
open cur_col_name;
while I < v_col_count
do
fetch cur_col_name into v_col_name;
* SET SQLSTRING = 'SELECT sum(cast('|| v_col_name || ')) into' ||v_total|| ' from ' || V_TAB_NAME;
PREPARE V_STMT FROM SQLSTRING;
Insert into TOTALS values (V_TAB_NAME,v_c ol_name, v_total);
set I=I+1;
end while;
close cur_col_name;
END dl
Comment