Call Oracle stored procedure problem

Hi All!

I’am inexperienced user of LotusNotes. I try to call Oracle procedure from LotusScript with following code:

Option Explicit

Uselsx “*lsxlc”

Sub Click(Source As Button)

'Messagebox "Start!"



'On Error Goto handler

Dim sess As New LCSession

Dim conn As New LCConnection("Oracle")

conn.server = "yaro"

conn.userid = "scott"

conn.password = "tiger"	

conn.Connect

conn.owner = "scott"

conn.procedure  = "lntest.test"



Dim ins As New LCFieldList

Dim outs As New LCFieldList



Dim num As New LCField(1, LCTYPE_INT)

Dim out_ As New LCField(1, LCTYPE_TEXT)

Set num = ins.Append("num", LCTYPE_INT)



num.Value = 123

Dim out As Double

out = conn.Call(ins, 1, outs)



'out = conn.Fetch(outs)

'Set out_ = outs.GetField(1)

conn.Disconnect

'Messagebox out_.value

Messagebox "Done!"

’ End

'handler:

’ Dim text As String

’ Dim extcode As Long

’ Dim exttext As String

’ Call sess.GetStatus (text, extcode, exttext)

’ Print text

’ Print extcode

’ Print exttext

’ Print Error$

’ End

End Sub

Sub Initialize

End Sub

so I have an error on out = conn.Call(ins, 1, outs) like

Error: ORA-06550: Line 1, Column 7:

ORA-00221: ‘TEST’ is not procedure or not defined

ORA-06550: Line 1, column 7

Here, Oracle stored procedure code

create or replace package lntest is

function test(num in number) return varchar2;

end;

/

create or replace package body lntest is

function test(num in number) return varchar2

is

ret varchar2(100);

begin

ret := concat(to_char(num),' yaro');

return ret;

end;

end;

/

Where I made an error? Any ideas…

Thanks a lot

Subject: call Oracle stored procedure problem

Calling Oracle Stored Procedures can be VERY tricky, start testing with a few simple procedures and add one feature at a time. Try to take a look at the error messages at the Oracle system itself, too, they may be helpful.

A few tips:

You probably get the error “‘TEST’ is not a procedure or not defined” because your procedure is in a package. Try a procedure that’s not in a package. (It’s been a while, but I think procedures in a package don’t work.)

It looks like you return a value from the stored procedure (“return varchar2”). You can ONLY return values from an Oracle stored procedure by using output parameters. You will have to specify something like

“function test(num in number, retval inout varchar2)”.

Note that I use an “inout” parameter here, not an “out” parameter. There are some problems if you use “out” parameters.

Every parameter that is specified as “in” or “inout” must be in the input fieldlist. To get the output parameter(s) in the output fieldlist, you have to specify the exact Oracle names(!) of the “out” or “inout” parameters in the FieldNames parameter of the LC Connection, like

conn.FieldNames = “retval”

If you have more than one output parameter, use a comma to separate them:

conn.FieldNames = “retval, anotherparam, …, yetanotherparam”

Details about this are in the Designer Help for the Oracle connectors. Don’t just look at the general documentation for stored procedures, the Oracle connectors do it differently!

Hope this helps and good luck!

Subject: RE: call Oracle stored procedure problem

I see you’re using the “oracle” connector, so I guess you are using Oracle version 7, is that correct?

Subject: RE: call Oracle stored procedure problem

No, I have Oracle 9i (9.2.0.1), but there is no oracle9 connector, and I leave only oracle. With oracle8 I have the same error.

Subject: RE: call Oracle stored procedure problem

Oracle8 is the correct connector to use for 9i.

I wouldn’t have expected that message, but you can’t read a return value from a stored procedure using the LC LSX. You can only fetch rows from a result set generated by the procedure.

Subject: RE: call Oracle stored procedure problem

Excuse me, could You post any example?

I make the procedure without any parameters and get error that parameters number or parameters types missing.

Subject: RE: call Oracle stored procedure problem

I’m not so good with Oracle to give you an example. I’m not saying you should not have parameters. I’m saying you should not have a return value.