ASP and DB2 Stored Procedures

This is a discussion on "ASP and DB2 Stored Procedures" within the Classic ASP section. This forum, and the thread "ASP and DB2 Stored Procedures are both part of the Program Your Website category.



 Subscribe in a reader

Go Back   Webforumz.com > Main Forums > Program Your Website > Classic ASP

Notices


Closed Thread
 
LinkBack Thread Tools
  #1  
Old Nov 26th, 2003, 17:34
New Member
Join Date: Nov 2003
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
ASP and DB2 Stored Procedures

I am having problems returning values from a db2 stored procedure to my ASP page. Unfortunately, I am stuck using the Microsoft ODBC driver and DB2 stored procedure. I know there are many limitations when combining these, but from what I have read, I should be able to set an output parameter in my stored procedure and access it in my ASP page.

Here is the code for the stored procedure:

CREATE PROCEDURE CIS.CISEU004
(OUT ROW_COUNT INT)
FENCED
RESULT SET 1
LANGUAGE SQL
EXTERNAL NAME CISEU004
NOT DETERMINISTIC
NO DBINFO
COLLID CISSP
WLM ENVIRONMENT DSNDWMD0
ASUTIME LIMIT 52700
STAY RESIDENT NO
PROGRAM TYPE MAIN
SECURITY DB2
COMMIT ON RETURN NO
MODIFIES SQL DATA
RUN OPTIONS 'NOTEST(ALL,*,,VADTCPIP&172.29.136.146:*)'
------------------------------------------------------------------------
-- SQL STORED PROCEDURE ------------------------------------------------------------------------
P1: BEGIN
DECLARE ROWCOUNT INT;
SELECT COUNT(*) INTO ROWCOUNT FROM SYSIBM.SYSTABLES;
SET ROW_COUNT = ROWCOUNT;
END P1

My command object in my ASP page is set up as folows:
set cmd = (our command object)
with cmd
.NamedParameters = true
.CommandType = adCmdText
.CommandText = "CALL CIS.CISEU004 (?)"
end with
cmd.Parameters.Append cmd.CreateParameter("RC", adInteger, adParamOutput)

Then I execute the stored procedure:

cmd.Execute

We get an "Unspecified Error" at this point at the execute line.

Any helpful knowledge on this subject would be appreciated.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!

  #2  
Old Nov 26th, 2003, 19:31
Most Reputable Member
Join Date: Jul 2003
Posts: 1,856
Thanks: 0
Thanked 0 Times in 0 Posts
I would try on of the two following changes:

1) change to .CommandType = adCmdStoredProc and .CommandText = "CISEU004"

or

2) change to .CommandText = "{?=CALL CIS.CISEU004 (?)}"

Also before you append the parameter I would put:
cmd.Parameters.Append cmd.CreateParameter("RetVal", adInteger, _
adParamReturnValue)
and change adParamOutput to adParamInput on the append you've got.
Then you can get the return value of the query by using cmd("RetVal") after it's executed.

I assume you also have a line like:
cmd.Parameters("RC") = somenumber
to set the value of the parameter before executing the query.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
  #3  
Old Nov 26th, 2003, 19:52
New Member
Join Date: Nov 2003
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Thanks for the reply.

When I frist set this up, I did as you sugggested in 1). I get a "catastrophic error" in this case. Microsoft has documentation on the .commandtype stating that you cannot use adCmdStoredProc and must use adCmdText.

I was told when I was setting this up that I had to set the parameters the way I stated instead of as you suggest, but I will gladly try what you suggest and see what happens.

I haven't seen the syntax you show in 2) "{?=CALL CIS.CISEU004 (?)}".
What are the "?" for?

Thanks for your help
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
  #4  
Old Nov 26th, 2003, 20:07
Most Reputable Member
Join Date: Jul 2003
Posts: 1,856
Thanks: 0
Thanked 0 Times in 0 Posts
The first ?= is optional i think and i believe it represents the return value.

The second represents the passed parameter. The syntax you used is fine I think, other than missing the { }.

There are a few other ways to call a stored procedure from ASP, so if this method still causes you problems I can point you to one of them.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
  #5  
Old Dec 1st, 2003, 17:24
New Member
Join Date: Nov 2003
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Still having trouble, but I made a bit of progress if that's what you want to call it. According to everything I've found out up to this point, the problem lies with using the Microsoft ODBC driver with DB2 stored procedures. There are a lot of limitations.

To get the Stored Procedure to run without the "Unspecified Error", I created a useless select statement in the Sp. In my ASP, instead of just issuing a cmd.Execute, I did the following:

Set myRS = cmd.Execute

This returned a record set that I was able to get values from, but I also set the ROW_COUNT as before, and still can not get a value from it.

The new Stored Proc is as follows:

CREATE PROCEDURE CIS.CISEU004
(OUT ROW_COUNT INT)
FENCED
RESULT SET 1
LANGUAGE SQL
EXTERNAL NAME CISEU004
NOT DETERMINISTIC
NO DBINFO
COLLID CISSP
WLM ENVIRONMENT DSNDWMD0
ASUTIME LIMIT 52700
STAY RESIDENT NO
PROGRAM TYPE MAIN
SECURITY DB2
COMMIT ON RETURN NO
MODIFIES SQL DATA
RUN OPTIONS 'NOTEST(ALL,*,,VADTCPIP&172.29.136.146:*)'
------------------------------------------------------------------------
-- SQL STORED PROCEDURE ------------------------------------------------------------------------
P1: BEGIN
DECLARE ROWCOUNT INT;
DECLARE C1 CURSOR WITH RETURN FOR
SELECT NAME
FROM SYSIBM.SYSTABLES;
OPEN C1;
SELECT COUNT(*) INTO ROWCOUNT FROM SYSIBM.SYSTABLES;
SET ROW_COUNT = ROWCOUNT;
END P1
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Closed Thread

Tags
asp, db2, stored, procedures

Thread Tools

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Update two tables using Stored Procedure in SQL Wheatus7 Databases 5 Jul 1st, 2007 17:42
stored proc neoandzuco Databases 1 Feb 14th, 2007 14:39
Email stored in db tazek0 Classic ASP 1 Mar 3rd, 2006 12:20
Dynamic Stored Proc kebi Databases 0 Nov 2nd, 2005 05:25
Stored proc kebi Databases 0 Oct 28th, 2005 11:17


All times are GMT. The time now is 14:37.


Powered by vBulletin®
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0 RC8
© 2003-2008 Webforumz.com : All Rights Reserved

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42