Hello everyone
I want to call a DB2 7.2 stored procedure via ADO in VC++ 7.1
It has 4 parameters, the 1st and the 4th are OUTPUT and the others are INPUT
params.
My code looks like this:
(spCMD is a Command, spCON a Connection, spRS a Resultset, and spPARAM
are Parameters)
spCMD->Name = "mySPname";
spCMD->ActiveConnecti on = spCON;
spCMD->CommandText = "CALL SYSPROC.mySPnam e(?, char('a string',8),
char('31.10.200 3',10), ?)";
spPARAM1 = spCMD->CreateParamete r("RETCODE", adSmallInt,
adParamOutput, 2, NULL);
spCMD->Parameters->Append(spPARAM 1);
spPARAM2 = spCMD->CreateParamete r("RETCHAR", adChar,
adParamOutput, 2, NULL);
spCMD->Parameters->Append(spPARAM 2);
spRS = spCMD->Execute(NULL , NULL, adCmdText);
When I execute I have the following error message:
[IBM][CLI Driver][DB2] SQL0440N No function by the name "mySPname"
having compatible arguments was found in the function path SQLSTATE=42884
The following SQL command works in DB2 Command Center:
CALL SYSPROC.MYSPNAM E(?, 'a string', '31.10.2003', ?)
It displays the 2 output params correctly.
I've checked in DB2: the SP prototype is (OUT SmallInt, IN Char 8, IN Char
10, OUT Char 2).
So I guess my problem has to do with using ADO correctly... With a simple
SELECT statement it works fine.
So what did I do wrong with a parameterized stored procedure?
Regards,
Chris 3 7956
Here's a chunk of code I use to call a stored proc with in and out
variables :
One of the key things - CLOSE the recordset BEFORE using the return
value(s)
Public Function GetNewKeyValue( sTableName As String) As Long
Dim rstSequence As ADODB.Recordset
Dim cTmp As New ADODB.Connectio n
Dim lNewKey As Long
Dim sSeq As String
Dim cmd As New ADODB.Command
Dim parm1 As New ADODB.Parameter
Dim parm2 As New ADODB.Parameter
Dim nCount As Integer
lNewKey = 0
nCount = 0
On Error GoTo Err_GetNewKeyVa lue
repeat_call:
nCount = nCount + 1
cTmp.Connection String = sConnectString
cTmp.CursorLoca tion = adUseClient
cTmp.Open
cmd.ActiveConne ction = cTmp
cmd.CommandText = "KWOOD.GETNEWKE Y"
cmd.CommandType = adCmdStoredProc
Set parm1 = cmd.CreateParam eter("Sseq", adVarChar, adParamInput,
30, sTableName)
cmd.Parameters. Append parm1
Set parm2 = cmd.CreateParam eter("lKeyValue ", adBigInt,
adParamOutput, 8)
cmd.Parameters. Append parm2
Set rstSequence = cmd.Execute
Set rstSequence = Nothing
lNewKey = cmd(1).Value
On Thu, 6 Nov 2003 08:40:01 +0100, "Chris"
<ch************ ****@swisscom.c om> wrote: Hello everyone
I want to call a DB2 7.2 stored procedure via ADO in VC++ 7.1 It has 4 parameters, the 1st and the 4th are OUTPUT and the others are INPUT params.
My code looks like this: (spCMD is a Command, spCON a Connection, spRS a Resultset, and spPARAM are Parameters) spCMD->Name = "mySPname"; spCMD->ActiveConnecti on = spCON; spCMD->CommandText = "CALL SYSPROC.mySPnam e(?, char('a string',8), char('31.10.20 03',10), ?)"; spPARAM1 = spCMD->CreateParamete r("RETCODE", adSmallInt, adParamOutpu t, 2, NULL); spCMD->Parameters->Append(spPARAM 1); spPARAM2 = spCMD->CreateParamete r("RETCHAR", adChar, adParamOutpu t, 2, NULL); spCMD->Parameters->Append(spPARAM 2); spRS = spCMD->Execute(NULL , NULL, adCmdText);
When I execute I have the following error message: [IBM][CLI Driver][DB2] SQL0440N No function by the name "mySPname" having compatible arguments was found in the function path SQLSTATE=42884
The following SQL command works in DB2 Command Center: CALL SYSPROC.MYSPNAM E(?, 'a string', '31.10.2003', ?) It displays the 2 output params correctly. I've checked in DB2: the SP prototype is (OUT SmallInt, IN Char 8, IN Char 10, OUT Char 2). So I guess my problem has to do with using ADO correctly... With a simple SELECT statement it works fine. So what did I do wrong with a parameterized stored procedure?
Regards, Chris
Thanks for your reply!
I've found out that I can execute the stored procedure if I set every
parameter
spCMD->CommandText = "CALL SYSPROC.ST1RTCH ECKBEZMM(?, ?, ?, ?)";
But there is another problem when I try to get the return values of the
parameters...
After I've called Execute the recordset is in a closed state already:
spRS = spCMD->Execute(NULL , NULL, adCmdText);
(spRS->State == adStateClosed)
In C++ it seems I cannot access the parameters collection as easily as you
do in VB.
I tried the get_item method but I always get a NULL pointer :-(
Regards
Chris
"Remove the obvious for replies" <kurt.wood@NO** @M.state.mn.us> a écrit dans
le message de news: 3f************* *@news.state.mn .us... Here's a chunk of code I use to call a stored proc with in and out variables : One of the key things - CLOSE the recordset BEFORE using the return value(s)
Public Function GetNewKeyValue( sTableName As String) As Long
Dim rstSequence As ADODB.Recordset Dim cTmp As New ADODB.Connectio n Dim lNewKey As Long Dim sSeq As String Dim cmd As New ADODB.Command Dim parm1 As New ADODB.Parameter Dim parm2 As New ADODB.Parameter Dim nCount As Integer
lNewKey = 0 nCount = 0 On Error GoTo Err_GetNewKeyVa lue
repeat_call: nCount = nCount + 1 cTmp.Connection String = sConnectString cTmp.CursorLoca tion = adUseClient cTmp.Open
cmd.ActiveConne ction = cTmp cmd.CommandText = "KWOOD.GETNEWKE Y" cmd.CommandType = adCmdStoredProc
Set parm1 = cmd.CreateParam eter("Sseq", adVarChar, adParamInput, 30, sTableName) cmd.Parameters. Append parm1 Set parm2 = cmd.CreateParam eter("lKeyValue ", adBigInt, adParamOutput, 8) cmd.Parameters. Append parm2
Set rstSequence = cmd.Execute Set rstSequence = Nothing
lNewKey = cmd(1).Value
On Thu, 6 Nov 2003 08:40:01 +0100, "Chris" <ch************ ****@swisscom.c om> wrote:
Hello everyone
I want to call a DB2 7.2 stored procedure via ADO in VC++ 7.1 It has 4 parameters, the 1st and the 4th are OUTPUT and the others are
INPUTparams.
My code looks like this: (spCMD is a Command, spCON a Connection, spRS a Resultset, and
spPARAMare Parameters) spCMD->Name = "mySPname"; spCMD->ActiveConnecti on = spCON; spCMD->CommandText = "CALL SYSPROC.mySPnam e(?, char('a
string',8),char('31.10.20 03',10), ?)"; spPARAM1 = spCMD->CreateParamete r("RETCODE", adSmallInt, adParamOutpu t, 2, NULL); spCMD->Parameters->Append(spPARAM 1); spPARAM2 = spCMD->CreateParamete r("RETCHAR", adChar, adParamOutpu t, 2, NULL); spCMD->Parameters->Append(spPARAM 2); spRS = spCMD->Execute(NULL , NULL, adCmdText);
When I execute I have the following error message: [IBM][CLI Driver][DB2] SQL0440N No function by the name
"mySPname"having compatible arguments was found in the function path SQLSTATE=42884
The following SQL command works in DB2 Command Center: CALL SYSPROC.MYSPNAM E(?, 'a string', '31.10.2003', ?) It displays the 2 output params correctly. I've checked in DB2: the SP prototype is (OUT SmallInt, IN Char 8, IN
Char10, OUT Char 2). So I guess my problem has to do with using ADO correctly... With a simple SELECT statement it works fine. So what did I do wrong with a parameterized stored procedure?
Regards, Chris
I can't help you with C++, I know there certainly was some putz work
in getting VB to work...
On Mon, 10 Nov 2003 17:02:20 +0100, "Chris"
<ch************ ****@swisscom.c om> wrote: Thanks for your reply!
I've found out that I can execute the stored procedure if I set every parameter spCMD->CommandText = "CALL SYSPROC.ST1RTCH ECKBEZMM(?, ?, ?, ?)";
But there is another problem when I try to get the return values of the parameters.. .
After I've called Execute the recordset is in a closed state already: spRS = spCMD->Execute(NULL , NULL, adCmdText); (spRS->State == adStateClosed)
In C++ it seems I cannot access the parameters collection as easily as you do in VB. I tried the get_item method but I always get a NULL pointer :-(
Regards Chris
"Remove the obvious for replies" <kurt.wood@NO** @M.state.mn.us> a écrit dans le message de news: 3f************* *@news.state.mn .us... Here's a chunk of code I use to call a stored proc with in and out variables : One of the key things - CLOSE the recordset BEFORE using the return value(s)
Public Function GetNewKeyValue( sTableName As String) As Long
Dim rstSequence As ADODB.Recordset Dim cTmp As New ADODB.Connectio n Dim lNewKey As Long Dim sSeq As String Dim cmd As New ADODB.Command Dim parm1 As New ADODB.Parameter Dim parm2 As New ADODB.Parameter Dim nCount As Integer
lNewKey = 0 nCount = 0 On Error GoTo Err_GetNewKeyVa lue
repeat_call: nCount = nCount + 1 cTmp.Connection String = sConnectString cTmp.CursorLoca tion = adUseClient cTmp.Open
cmd.ActiveConne ction = cTmp cmd.CommandText = "KWOOD.GETNEWKE Y" cmd.CommandType = adCmdStoredProc
Set parm1 = cmd.CreateParam eter("Sseq", adVarChar, adParamInput, 30, sTableName) cmd.Parameters. Append parm1 Set parm2 = cmd.CreateParam eter("lKeyValue ", adBigInt, adParamOutput, 8) cmd.Parameters. Append parm2
Set rstSequence = cmd.Execute Set rstSequence = Nothing
lNewKey = cmd(1).Value
On Thu, 6 Nov 2003 08:40:01 +0100, "Chris" <ch************ ****@swisscom.c om> wrote:
>Hello everyone > >I want to call a DB2 7.2 stored procedure via ADO in VC++ 7.1 >It has 4 parameters, the 1st and the 4th are OUTPUT and the others areINPUT >params. > >My code looks like this: > (spCMD is a Command, spCON a Connection, spRS a Resultset, andspPARAM >are Parameters) > spCMD->Name = "mySPname"; > spCMD->ActiveConnecti on = spCON; > spCMD->CommandText = "CALL SYSPROC.mySPnam e(?, char('astring',8), >char('31.10.20 03',10), ?)"; > spPARAM1 = spCMD->CreateParamete r("RETCODE", adSmallInt, >adParamOutpu t, 2, NULL); > spCMD->Parameters->Append(spPARAM 1); > spPARAM2 = spCMD->CreateParamete r("RETCHAR", adChar, >adParamOutpu t, 2, NULL); > spCMD->Parameters->Append(spPARAM 2); > spRS = spCMD->Execute(NULL , NULL, adCmdText); > >When I execute I have the following error message: > [IBM][CLI Driver][DB2] SQL0440N No function by the name"mySPname" >having compatible arguments was found in the function path SQLSTATE=42884 > >The following SQL command works in DB2 Command Center: > CALL SYSPROC.MYSPNAM E(?, 'a string', '31.10.2003', ?) >It displays the 2 output params correctly. >I've checked in DB2: the SP prototype is (OUT SmallInt, IN Char 8, INChar >10, OUT Char 2). >So I guess my problem has to do with using ADO correctly... With a simple >SELECT statement it works fine. >So what did I do wrong with a parameterized stored procedure? > >Regards, >Chris > > >
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Mariusz |
last post by:
I want to write function to call another function which name is
parameter to first function. Other parameters should be passed to
called function.
If I call it function('f1',10) it should call f1(10). If I call it
function('f2',5) it should call f2(5).
So far i tried something like
CREATE FUNCTION . (@f varchar(50),@m money)
RETURNS varchar(50) AS
|
by: bughunter |
last post by:
When I try call sql stored procedure on version 7 (win) server from 8.2
fixpack 9 (win32) I got:
C:\SQLLIB\bnd>db2 "call proc(1)"
SQL1109N The specified DLL "SYSIBM.SQLPROCEDURECOLS" could not be
loaded.
DB21085I Instance "DB2TST" uses DB2 code release "SQL07029" with level
identifier "030A0105" and informational tokens "DB2 v7.1.0.98",
"n040510" and
|
by: Tim Marshall |
last post by:
I was following the thread "Re: Access Treeview - Is it Safe Yet?" with
interest and on reading the post describing Lauren Quantrell's
SmartTree, I've run into something I don't understand: Stored
Procedures. I thought stored pricedures were an Oracle/MS SQL Server
thing and don't know how they work with Access Jet. I've looked at some
of the help on stored procedures in A2003, but really don't understand
what's going on.
Can someone...
|
by: mike |
last post by:
H
There are two ways to execute a stored procedure using ADO.NE
- call "exec sp_myproc val1,val2" statement over SqlCommand myCommand = new SqlCommand(SQLQuery, mySqlConnection)
- use Command/Parameters objects to initialize and call the stored procedure
Which is a efficient way and wh
Appreciate your respons
|
by: John |
last post by:
Hi
When developing vb.bet winform apps bound to sql server datasource, is it
preferable to use SELECTs or stored procedure to read and write data from/to
SQL Server? Why?
Thanks
Regards
| |
by: Larry Menard |
last post by:
Test code:
$dbconn = odbc_connect($dbname, $username, $password);
$path = "C:\Temp\myJar.jar";
$statement = "CALL SQLJ.INSTALL_JAR('file://$path', 'myJarId')";
$result = odbc_exec($dbconn, $statement);
Result:
PHP Warning: odbc_exec(): SQL error: CLI0119E Unexpected system failure.
|
by: mooreit |
last post by:
The purpose for my questions is accessing these technologies from
applications. I develop both applications and databases. Working with
Microsoft C#.NET and Microsoft SQL Server 2000 Production and 2005 Test
Environments.
What is the purpose of a view if I can just copy the vode from a view
and put it into a stored procedure?
Should I be accessing views from stored procedures?
|
by: Radhakrishnans |
last post by:
hai friends
i am new to java and mysql.i have created stored procedures in mysql.Now i want to call that stored procedures in java.All works fine.but it show the following error.
unreported exception java.lang.InstantiationException; must be caught or declared to be thrown
Class.forName ("com.mysql.jdbc.Driver").newInstance();
I need code sample along with connection string.please....
My codings here
CallableStatement proc =...
|
by: mandible |
last post by:
I'm trying to call one stored procedure inside another.
I was wondering if this is possible
Some ideas I was toying with is putting the first stored procedure
inside of a temp table but haven't been able to get this idea to work.
|
by: peter |
last post by:
I am trying to get a SQL stored procedure to use user maintained MQT
implicitly which raises questions on when they are used or not used.
In theory you would expect the stored procedure to pick up the MQT at
the time it is bound on the creation of the static SQL. This raises
the question on how you stop it or start it using a MQT as there is no
option on the bind. What happens when it is rebound? What happens if
the plan is made invalid...
|
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
| |
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
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,...
|
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...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
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();...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
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...
| |