473,659 Members | 2,839 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 1837
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 myOutputVariabl e INTEGER)
LANGUAGE SQL
BEGIN

SET myOutputVariabl e = 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******** *****@individua l.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 myOutputVariabl e INTEGER)
LANGUAGE SQL
BEGIN

SET myOutputVariabl e = 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******** *****@individua l.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******** *****@individua l.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

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

Similar topics

7
5473
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
8850
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 want my users to be able to select a report, click on a command button on a form, which will then automatically create the report as a pdf file and save it to the user's machine. I am using Adobe Acrobat (5.0 I think) and have Adobe Distiller as a
24
3099
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 (primary key) FirstName MiddleName LastName
9
4498
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 with the same symptoms). 1) Working database, Compile/Save All works, Create MDE works 2) Touch the references (mark a new reference, OK, then Unmark) 3) Create MDE works 4) Compile/Save All works 5) Now try creating MDE from the compiled...
9
2298
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 server from the 1st machine, but I receive an 'HTTP/1.1 500 Internal Server error" from my Web Server. My userid/password are the same on all 3 machines.
4
6193
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). The Module is registered via Web.config. The registration is OK. When asking for an existing .aspx page, the eventhandler is called as it should. HOWEVER - if the request url is for a non-existant file, I get a 404 - file
2
3048
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 what I'm hoping to achieve. I've never before had to use Javascript closures, but now I do, so I'm making an effort to understand them. I've been giving this essay a re-read: http://jibbering.com/faq/faq_notes/closures.html
1
5160
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: CREATE TABLE d_kunden(id INT NOT NULL AUTO_INCREMENT,
0
801
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 interested in, I need to add my own block <MyTag>.....</MyTagto the pulldom tree I'm building in memory. The documentation on PullDom is worse than atrocious. It is simply non-
0
8332
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8746
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8525
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8627
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7356
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5649
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4175
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
1975
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1737
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.