|
Hello,
I have a Visual Basic 6 program using ADO and the iSeries ODBC driver
for getting data off the iSeries (V5R2.
I use a variety of stored procedures currently with no problem, until
I tried doing a LIKE clause.
The stored procedure runs, but it returns a NULL value. When I run
the SQL in the "run scripts" window of NAvigator, it returns data,
like it should. I went over code a lot and I can see nothign I am
doing different from the other stored procedures I am calling. I am
curious if anyone has any ideas.
Here is the definituion of the stored procedure I am calling:
CREATE PROCEDURE CLSDFILES.LAST_BOX (
IN CRITERIA VARCHAR(50) )
DYNAMIC RESULT SETS 1
LANGUAGE SQL
SPECIFIC CLSDFILES.LAST_BOX
NOT DETERMINISTIC
READS SQL DATA
CALLED ON NULL INPUT
BEGIN DECLARE C1 CURSOR WITH RETURN FOR SELECT MAX ( BOX ) AS
RETURNED FROM CLSDFILES . CLOSEDFILES WHERE BOX LIKE '%CRITERIA%' ;
OPEN C1 ; END ;
And here is the Visual Basic code I am calling it with:
Set MyCommand = New ADODB.Command
With MyCommand
.ActiveConnection = MyConnection
.CommandText = "CLSDFILES.LAST_BOX"
.CommandType = adCmdStoredProc
.Parameters("criteria") = criteria
End With
Set rcdset = New ADODB.Recordset
With rcdset
.CursorType = adOpenStatic
.LockType = adLockReadOnly
Set .Source = MyCommand
.Open
End With
If IsNull(rcdset.Fields.Item(0).Value) Then
MsgBox "No boxes with that search criteria."
Else
MsgBox rcdset.Fields.Item(0).Value
End If
Also of note. When I call the SQL directly from VB, it also works
that it is supposed to:
'sSQL = "SELECT max(BOX) FROM CLSDFILES . CLOSEDFILES WHERE BOX LIKE
'%" & criteria & "%'"
'
'Set rcdset = MyConnection.Execute(sSQL)
'
'If IsNull(rcdset.Fields.Item(0).Value) Then
' MsgBox "No boxes with that search criteria."
'Else
' MsgBox rcdset.Fields.Item(0).Value
'End If
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2025 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].
Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.