If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > DB2 > Build stored procedures in a sql file?

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 06-28-04, 05:09
AStefan AStefan is offline
Registered User
 
Join Date: Jun 2004
Posts: 57
Exclamation Build stored procedures in a sql file?

I have a .sql file who generate the stored procedures in a db2 database.
Something like that:

Create procedure sp1 ...
@
Create procedure sp1 ...
etc.

I have two questions:
1) Is it necessary to build the procedures in this .sql file?
When the application (written in Java) will call the procedures these must be already build?
IF yes, please tell me if is it possible to build the procedures in this .sql file. If it is possible, please tell me how (a little tip).
Thanks in advanced.
Reply With Quote
  #2 (permalink)  
Old 06-28-04, 08:26
ARWinner ARWinner is offline
Registered User
 
Join Date: Jan 2003
Posts: 3,575
1) No, it is not 100% necessary to build the SPs from the .sql script, but they do need to be built before they can be called. And building them from the script is one way to do that. Sps can be built using scripts such as this, the Development Center in V8.1 (Stored Procedure Builder in V7), or through some other method that can execute SQL (since a CREATE PROCEDURE is just SQL).

To build then from the script, from the DB2 command window:

db2 -td@ -svf myscript.sql

HTH

Andy
Reply With Quote
  #3 (permalink)  
Old 08-10-04, 04:54
AStefan AStefan is offline
Registered User
 
Join Date: Jun 2004
Posts: 57
Build sp in a sql file

I finished all the scripts who generate the database and all the objects.
I have only one problem, the script muts build the procedures.
The stored procedures in the script are separated by @.
I use the syntax db2 -td@ -svf MyScript.sql but I met the error Db21005E with the message "An error occured while accessing the file MyScript.sql".
I try to change the extension in db2 instead of sql but I receive the same message.
Can anyone tell me wht syinax to use so the stored procedures not only be generated but build too? Tnahk you very much.
Reply With Quote
  #4 (permalink)  
Old 08-10-04, 08:16
ARWinner ARWinner is offline
Registered User
 
Join Date: Jan 2003
Posts: 3,575
What OS and DB2 version?

Andy
Reply With Quote
  #5 (permalink)  
Old 08-10-04, 11:06
AStefan AStefan is offline
Registered User
 
Join Date: Jun 2004
Posts: 57
Build SP in sql file?

WIndows 2000 and udb express 8.1
Reply With Quote
  #6 (permalink)  
Old 08-10-04, 11:19
ARWinner ARWinner is offline
Registered User
 
Join Date: Jan 2003
Posts: 3,575
I looked the error you are getting:
--------------------------------------------
DB21005E An error occurred while accessing the file
"<filename>".

Explanation:

The following could have caused the error:

o file permissions do not allow file access

o the file does not exist



User Response:

Correct the error and try again.

-----------------------------------

Make sure you are executing the script from the correct place.
For example:
Location of script: d:\myscript.sql

Bring up "Command Window"
switch to D drive:
Switch to directory (CD \)
run db2 -td@ -svf myscript.sql

If this fails with the same error, check the permissions of the file.

You can also run the script from the Command Center off of the Script tab.

HTH

Andy
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On