By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
457,903 Members | 1,593 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 457,903 IT Pros & Developers. It's quick & easy.

Executing procedure

P: n/a
Hi,

In the past I have been dealing mainly with sql server, and recently
been given the task of supporting software that uses db2 on as400.

Simple tasks such as executing a stored procedure from a query window
have proven more troublesome than I expected.

The procedure I'm trying to call has an output argument. I can't seem
to declare a variable to pass outside of a procedure or function, and
passing 0 or null throws an error:

[SQL0469] IN, OUT, or INOUT not valid for parameter 1 in procedure
PR_myproc in *N. Cause . . . . . : The IN, INOUT, or OUT attribute
specified for parameter 1 on the DECLARE PROCEDURE or CREATE PROCEDURE
statement is not valid.

Is there an OUT or IN keyword I should use when passing the parameter?

Also, can anyone tell me a good tool for writing sql scripts for db2 on
iseries? Something that provides color coding and can generate
formatted scripts from objects would be great. I spent a while looking
but didn't find anything great (toad looked promising until i realised
it wouldnt work for db2 on the as400).

Thanks for your help,

Lee.

Feb 2 '06 #1
Share this Question
Share on Google+
9 Replies


P: n/a
"Leedrick" <le******@gmail.com> wrote in message
news:11*********************@o13g2000cwo.googlegro ups.com...
Hi,

In the past I have been dealing mainly with sql server, and recently
been given the task of supporting software that uses db2 on as400.

Simple tasks such as executing a stored procedure from a query window
have proven more troublesome than I expected.

The procedure I'm trying to call has an output argument. I can't seem
to declare a variable to pass outside of a procedure or function, and
passing 0 or null throws an error:

[SQL0469] IN, OUT, or INOUT not valid for parameter 1 in procedure
PR_myproc in *N. Cause . . . . . : The IN, INOUT, or OUT attribute
specified for parameter 1 on the DECLARE PROCEDURE or CREATE PROCEDURE
statement is not valid.

Is there an OUT or IN keyword I should use when passing the parameter?

Also, can anyone tell me a good tool for writing sql scripts for db2 on
iseries? Something that provides color coding and can generate
formatted scripts from objects would be great. I spent a while looking
but didn't find anything great (toad looked promising until i realised
it wouldnt work for db2 on the as400).

Thanks for your help,

Lee.


I don't know how DB2 for iSeries works, but for DB2 for LUW here is call
syntax from the command line:

db2 "call sp_name (parm1, parm2 ,parm3)"

where parm1, parm2, parm3 are the data supplied for in or inout parms. If
the data is character, use tickmarks as usual).
Feb 2 '06 #2

P: n/a
Leedrick wrote:
Hi,

In the past I have been dealing mainly with sql server, and recently
been given the task of supporting software that uses db2 on as400.

Simple tasks such as executing a stored procedure from a query window
have proven more troublesome than I expected.

The procedure I'm trying to call has an output argument. I can't seem
to declare a variable to pass outside of a procedure or function, and
passing 0 or null throws an error:

[SQL0469] IN, OUT, or INOUT not valid for parameter 1 in procedure
PR_myproc in *N. Cause . . . . . : The IN, INOUT, or OUT attribute
specified for parameter 1 on the DECLARE PROCEDURE or CREATE PROCEDURE
statement is not valid.

Is there an OUT or IN keyword I should use when passing the parameter?

Also, can anyone tell me a good tool for writing sql scripts for db2 on
iseries? Something that provides color coding and can generate
formatted scripts from objects would be great. I spent a while looking
but didn't find anything great (toad looked promising until i realised
it wouldnt work for db2 on the as400).

Thanks for your help,

Lee.

Maybe best explained with an example...

CREATE PROCEDURE p(IN a INT, INOUT b VARCHAR(10), OUT c INT)
......

-- Note the parameter marker (question mark) for the OUT parameter
CALL p(5, 6, ?)

In a program of course you can pass variables....
Cheers
Serge

--
Serge Rielau
DB2 Solutions Development
DB2 UDB for Linux, Unix, Windows
IBM Toronto Lab
Feb 2 '06 #3

P: n/a
Thanks guys,

Unfortunately when I pass ? as an argument I get the following error:

"The number of parameter values set or registered does not match the
number of parameters."

The header of the procedure is as follows:

create procedure pr_calctsrebate
(out success integer)
language sql
called on null input

and my call is:

call pr_calctsrebate(?);

Lee.

Feb 2 '06 #4

P: n/a
"Leedrick" <le******@gmail.com> wrote in message
news:11**********************@g47g2000cwa.googlegr oups.com...
Thanks guys,

Unfortunately when I pass ? as an argument I get the following error:

"The number of parameter values set or registered does not match the
number of parameters."

The header of the procedure is as follows:

create procedure pr_calctsrebate
(out success integer)
language sql
called on null input

and my call is:

call pr_calctsrebate(?);

Lee.


That stored procedure has no input parms that I can see. Try:

call pr_calctsrebate
Feb 2 '06 #5

P: n/a
how about the output int called "success"?

If i run without passing anything, I get:

[SQL0440] Routine PR_CALCTSREBATE in *N not found with specified
parameters. Cause . . . . . : A function or procedure with the
specified name and compatible arguments was not found.

Feb 2 '06 #6

P: n/a
Hello.

Unfortunately, you can't call from clp or any standard tool (iSeries
Navigator, for example) stored procedure that has an output parameter
in udb db2 for as400 like you do it for udb db2 for LUW...
You have to use some programming language.

Sincerely,
Mark B.
Hi,

In the past I have been dealing mainly with sql server, and recently
been given the task of supporting software that uses db2 on as400.

Simple tasks such as executing a stored procedure from a query window
have proven more troublesome than I expected.

The procedure I'm trying to call has an output argument. I can't seem
to declare a variable to pass outside of a procedure or function, and
passing 0 or null throws an error:

[SQL0469] IN, OUT, or INOUT not valid for parameter 1 in procedure
PR_myproc in *N. Cause . . . . . : The IN, INOUT, or OUT attribute
specified for parameter 1 on the DECLARE PROCEDURE or CREATE PROCEDURE
statement is not valid.

Is there an OUT or IN keyword I should use when passing the parameter?

Also, can anyone tell me a good tool for writing sql scripts for db2 on
iseries? Something that provides color coding and can generate
formatted scripts from objects would be great. I spent a while looking
but didn't find anything great (toad looked promising until i realised
it wouldnt work for db2 on the as400).

Thanks for your help,

Lee.


Feb 2 '06 #7

P: n/a
Appears you're using an old release of iSeries Navigator.

Options would be:
-Updating to a more current release
-Write a simple SQL procedure that calls the procedure using locals
variables
-Look at DB2 Development Center
Leedrick wrote:
how about the output int called "success"?

If i run without passing anything, I get:

[SQL0440] Routine PR_CALCTSREBATE in *N not found with specified
parameters. Cause . . . . . : A function or procedure with the
specified name and compatible arguments was not found.

Feb 2 '06 #8

P: n/a
Leedrick wrote:
Thanks guys,

Unfortunately when I pass ? as an argument I get the following error:

"The number of parameter values set or registered does not match the
number of parameters."

The header of the procedure is as follows:

create procedure pr_calctsrebate
(out success integer)
language sql
called on null input

and my call is:

call pr_calctsrebate(?);


Using Run SQL Scripts (iSeries Navigator), try using "set current
schema" and "set current path" for unqualified names. Example:

set current schema xyz ;
set current path xyz ;
create procedure parmtst (out success integer)
language sql
begin
select count(*) into success from qsys2.qsqptabl;
end ;
call parmtst(?) ;

--
Karl Hanson
Feb 2 '06 #9

P: n/a
I'm sorry for my previous post here.
That is right: after applying latest fixpack on iSeries Navigator I
have got this feature.
Thanks a lot!

Sincerely,
Mark B.

Feb 3 '06 #10

This discussion thread is closed

Replies have been disabled for this discussion.