473,406 Members | 2,956 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

Create an SP that references a non existant SP

I can not create a stored procedure that calls another not yet created
stored procedure?

In MS SQL I get a warning that the calling procedure does not exist but the
new stored

Procedure gets created anyhow. I believe Oracle works similarly.

I can not make this possible in DB2?

Thank you


Nov 12 '05 #1
10 1809
serge wrote:
I can not create a stored procedure that calls another not yet created
stored procedure?

In MS SQL I get a warning that the calling procedure does not exist but the
new stored

Procedure gets created anyhow. I believe Oracle works similarly.

I can not make this possible in DB2?

Sure you can, just use a dynamic statement:
EXECUTE IMMEDIATE CALL .... USING

Cheers
Serge

--
Serge Rielau
DB2 SQL Compiler Development
IBM Toronto Lab
Nov 12 '05 #2
If i take this example:

--DROP PROCEDURE proc1;
CREATE PROCEDURE proc1()
LANGUAGE SQL
BEGIN

DECLARE varInput INTEGER;
DECLARE varOutput INTEGER;

SET varInput = 2;

CALL proc2(varInput, varOutput);

END
;

--DROP PROCEDURE proc2;
CREATE PROCEDURE proc2(IN myInputVariable INTEGER,
OUT myOutputVariable INTEGER)
LANGUAGE SQL
BEGIN

SET myOutputVariable = myInputVariable + 5;

END
;

When i run this I get error:

21:01:22.836 DBMS MODEL0 -- Error: [IBM][CLI Driver][DB2/NT] SQL0440N
No authorized routine named "PROC2" of type "PROCEDURE" having compatible
arguments was found. LINE NUMBER=11. SQLSTATE=42884
Can you please tell me how you write the statement below?

EXECUTE IMMEDIATE CALL .... USING

An important question i have: If the procedure statement has Input and

Output parameters

CALL proc2(varInput, varOutput);

will the values of the parameters exist in the scope of the calling
procedure,

in this case proc1?

Thank you


"Serge Rielau" <sr*****@ca.ibm.com> wrote in message
news:3a*************@individual.net...
serge wrote:
I can not create a stored procedure that calls another not yet created
stored procedure?

In MS SQL I get a warning that the calling procedure does not exist but
the new stored

Procedure gets created anyhow. I believe Oracle works similarly.

I can not make this possible in DB2?

Sure you can, just use a dynamic statement:
EXECUTE IMMEDIATE CALL .... USING

Cheers
Serge

--
Serge Rielau
DB2 SQL Compiler Development
IBM Toronto Lab

Nov 12 '05 #3
If i take this example:

--DROP PROCEDURE proc1;
CREATE PROCEDURE proc1()
LANGUAGE SQL
BEGIN

DECLARE varInput INTEGER;
DECLARE varOutput INTEGER;

SET varInput = 2;

CALL proc2(varInput, varOutput);

END
;

--DROP PROCEDURE proc2;
CREATE PROCEDURE proc2(IN myInputVariable INTEGER,
OUT myOutputVariable INTEGER)
LANGUAGE SQL
BEGIN

SET myOutputVariable = myInputVariable + 5;

END
;

When i run this I get error:

21:01:22.836 DBMS MODEL0 -- Error: [IBM][CLI Driver][DB2/NT] SQL0440N
No authorized routine named "PROC2" of type "PROCEDURE" having compatible
arguments was found. LINE NUMBER=11. SQLSTATE=42884
Can you please tell me how you write the statement below?

EXECUTE IMMEDIATE CALL .... USING

An important question i have: If the procedure statement has Input and

Output parameters

CALL proc2(varInput, varOutput);

will the values of the parameters exist in the scope of the calling
procedure,

in this case proc1?

Thank you


"Serge Rielau" <sr*****@ca.ibm.com> wrote in message
news:3a*************@individual.net...
serge wrote:
I can not create a stored procedure that calls another not yet created
stored procedure?

In MS SQL I get a warning that the calling procedure does not exist but
the new stored

Procedure gets created anyhow. I believe Oracle works similarly.

I can not make this possible in DB2?

Sure you can, just use a dynamic statement:
EXECUTE IMMEDIATE CALL .... USING

Cheers
Serge

--
Serge Rielau
DB2 SQL Compiler Development
IBM Toronto Lab


Nov 12 '05 #4
OK, I took a closer peek. Here is how you need to do it:

--DROP PROCEDURE proc1;
CREATE PROCEDURE proc1()
LANGUAGE SQL
BEGIN

DECLARE varInput INTEGER;
DECLARE varOutput INTEGER;
DECLARE txt VARCHAR(100);
DECLARE s STATEMENT;

SET varInput = 2;
SET txt = 'CALL proc2(?, ?)';
PREPARE s FROM txt;
EXECUTE INTO varOutput USING varInput;

END
;

See:
http://publib.boulder.ibm.com/infoce...n/r0000948.htm
--
Serge Rielau
DB2 SQL Compiler Development
IBM Toronto Lab
Nov 12 '05 #5
I think you made a little mistake.
EXECUTE INTO varOutput USING varInput;
You forgot to add the "s", i was wondering what that "s" was being used for?

It should be:

EXECUTE s INTO varOutput USING varInput;

I ran this and got no error, i also quickly read the online help link you
gave me. This looks very interesting.

I'll continue working on this to learn exactly what the online help talks
about.

Thank you very much Serge!


"Serge Rielau" <sr*****@ca.ibm.com> wrote in message
news:3a*************@individual.net... OK, I took a closer peek. Here is how you need to do it:

--DROP PROCEDURE proc1;
CREATE PROCEDURE proc1()
LANGUAGE SQL
BEGIN

DECLARE varInput INTEGER;
DECLARE varOutput INTEGER;
DECLARE txt VARCHAR(100);
DECLARE s STATEMENT;

SET varInput = 2;
SET txt = 'CALL proc2(?, ?)';
PREPARE s FROM txt;
EXECUTE INTO varOutput USING varInput;

END
;

See:
http://publib.boulder.ibm.com/infoce...n/r0000948.htm
--
Serge Rielau
DB2 SQL Compiler Development
IBM Toronto Lab

Nov 12 '05 #6
However when i run in the Command Line Processor:

CALL PROC1()

I get

Return Status = 0
I can't understand why it's not working. I expect the result to be 7,
rather than 0.

I'll continue tomorrow to try to understand what might be wrong.

Thank you
Nov 12 '05 #7
serge wrote:
However when i run in the Command Line Processor:

CALL PROC1()

I get

Return Status = 0
I can't understand why it's not working. I expect the result to be 7,
rather than 0.

I'll continue tomorrow to try to understand what might be wrong.

Thank you

TEh result of proc1? What you get is a return status, usually used as
teh error-code.
If you want a result back you need to add OUT parameters to the
procedure and set them.
To change the return status use the RETURN statement.
You shoudl not this statement to return data though. That would be an
abuse of the feature. Various client interfaces would not be happy.

Cheers
Serge

--
Serge Rielau
DB2 SQL Compiler Development
IBM Toronto Lab
Nov 12 '05 #8
serge wrote:
I think you made a little mistake.

EXECUTE INTO varOutput USING varInput;

You forgot to add the "s", i was wondering what that "s" was being used for?

s is a handle for the compiled statement.
I post way too much to be able to test every example. So what you get
from me are "fill in the blanks" type of hints. The price of free
Level-0 support from the Lab. One gets what on pays for *chuckle*

Cheers
Serge
--
Serge Rielau
DB2 SQL Compiler Development
IBM Toronto Lab
Nov 12 '05 #9
> You shoudl not this statement to return data though. That would be an
abuse of the feature. Various client interfaces would not be happy.


Then should I conclude that it's not a good idea to use this method if
i have output parameters?

The only reason i wanted to do this is to be able to compile my stored
procedures. Since proc2 gets compiled after proc1, i should simply
make sure i always compile procedures that get called like proc2,
before compiling proc1?

Thank you
Nov 12 '05 #10
serge wrote:
You shoudl not this statement to return data though. That would be an
abuse of the feature. Various client interfaces would not be happy.

Then should I conclude that it's not a good idea to use this method if
i have output parameters?

The only reason i wanted to do this is to be able to compile my stored
procedures. Since proc2 gets compiled after proc1, i should simply
make sure i always compile procedures that get called like proc2,
before compiling proc1?

Thank you

These are two different issues.
Feel free to use dynamic calls and dynamic SQL in general.

Static or dynamic don't use the RETURN statement do get
the results for procedures other than status. That's what OUT parameters
are for.
DB2 Dev. added the RETURN statement explicitly to support client
interfaces looking for this status indicator.
It is not even part of the SQL/PSM standard.

Cheers
Serge
--
Serge Rielau
DB2 SQL Compiler Development
IBM Toronto Lab
Nov 12 '05 #11

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Mike | last post by:
Hi How can I make it so my web hosting server will redirect all hits to non existant web pages to the main index.html page? Thanks in advance
7
by: dog | last post by:
I've seen plenty of articles on this topic but none of them have been able to solve my problem. I am working with an Access 97 database on an NT4.0 machine, which has many Access reports. I...
24
by: flkeyman | last post by:
Work in legal office. Trying to create solid designed database structure. This is list of tables w/fields and primary keys. Any comments/advice greatly appreciated. tbl-Defendants CaseNumber...
9
by: fishbaugher | last post by:
I have encountered some interesting crashes lately (Access97). Here is the symptom (after several days of different kinds of rebuilds including import and LoadFromText, all resulting in databases...
9
by: Marc Miller | last post by:
Hi all, I have 2 dev. machines, the 1st is Win 2000 with .NET 7.0 and the 2nd is XP Pro with .NET 2003. My Web Server is Win 2000 Server with IIS 5.0. I can create a new project on my test...
4
by: | last post by:
I have earlier used an HttpModule that did URL rewrites on the BeginRequest event. Now I am trying to use the same module in a different application on a new and upgraded machine (winxp sp2). ...
2
by: Jake Barnes | last post by:
Using javascript closures to create singletons to ensure the survival of a reference to an HTML block when removeChild() may remove the last reference to the block and thus destory the block is...
1
by: Fischi | last post by:
Hi, I am getting the error message Script line: 84 Can't create table '.\dwh\f_umsatz.frm' (errno: 150) during execution of the following script on a windows system and mysql 5.0: ...
0
by: susan_ali | last post by:
I'm using xml.dom.pulldom to parse through an XML file. I use expandNode() to scrutinize certain blocks of it that I'm interested in. Once I find a block of XML in the input file that I'm...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.