Calling an Oracle Stored Procedure

Calling an Oracle Stored Procedure

Post by Marc Scheun » Sun, 31 Dec 1899 09:00:00




>PROCEDURE C3_GETMATRIXTABLE
>(matrix_id_in IN matrix.matrix_id%TYPE,
> matrix_rec_out OUT matrix%ROWTYPE)
>from Delphi. What is the best way of doing this? In particular, how is the
>parameter binding done? Can Delphi automatically resolve
>matrix.matrix_id%TYPE, or do I have to explicitly define the datatype? Is
>there a Delphi datatype that maps to a row such as matrix%ROWTYPE?

First of all, you can't use %ROWTYPE, Delphi can't handle that, define
your out parameter(s) using *ONLY* basic data types (like VARCHAR2,
NUMBER, DATE).

Then:

1) Drop a TStoredProc on your delphi form or data module and connect
it to the appropriate database (using a TDatabase object, preferably)

2) Set the StoredProcName property (your stored proc might not show up
in the dropdown list, but you can always type in the name)

3) You'll need to manually define the parameters, either in the
"Params" property editor, or in code (using the CreateParams call).
And be sure to use EXACTLY the same names as in your Oracle
definition! It's picky, even capital / non-capital letters are
important!)

4) Set the IN parameter in code:
MyStoredProc.ParamByName('matrix_id_in').AsInteger := 0
(or whatever it is)

5) Call MyStoredProc.ExecProc

6) Read out the OUT parameter by using:
myVar := MyStoredProc.ParamByName('outparam1').AsString;

HTH
Marc

--------------------------------------------------------------------------
Marc Scheuner                            Berner Versicherungen, Dept. ISV
May the Source be With You               Laupenstrasse 27

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

 
 
 

Calling an Oracle Stored Procedure

Post by Oleg Roshchi » Sun, 31 Dec 1899 09:00:00


You also can call your stored procedure or function programmatically.
Below is the example of procedure call with two parameters: "func" and
"current_id".
If you call function you can get the result as it was written before by Marc
Scheuner:
myVar := EL.ParamByName('outparam1').AsString;

procedure Wri*tryStatus(v_NameFunc: string; v_id: integer);
var EL: TStoredProc;
begin
  EL := TStoredProc.Create(nil);
  with EL  do
    begin
      DatabaseName := Session.Databases[0].DatabaseName ;
      StoredProcName := 'ENTRY_P.LOOP_ENTRY';    // Entry_p is a package,
Loop_Entry is a procedure
      Prepare;
// you need this if call programmatically!
      parambyname('FUNC').asSTRING:=v_namefunc ;
      parambyname('CURRENT_ID').asInteger:=v_id ;
      execproc ;
      destroy;
    end;
end;

Cheers,
Oleg

Moscow, Russia



>PROCEDURE C3_GETMATRIXTABLE
>(matrix_id_in IN matrix.matrix_id%TYPE,
> matrix_rec_out OUT matrix%ROWTYPE)
>from Delphi. What is the best way of doing this? In particular, how is the
>parameter binding done? Can Delphi automatically resolve
>matrix.matrix_id%TYPE, or do I have to explicitly define the datatype? Is
>there a Delphi datatype that maps to a row such as matrix%ROWTYPE?

First of all, you can't use %ROWTYPE, Delphi can't handle that, define
your out parameter(s) using *ONLY* basic data types (like VARCHAR2,
NUMBER, DATE).

Then:

1) Drop a TStoredProc on your delphi form or data module and connect
it to the appropriate database (using a TDatabase object, preferably)

2) Set the StoredProcName property (your stored proc might not show up
in the dropdown list, but you can always type in the name)

3) You'll need to manually define the parameters, either in the
"Params" property editor, or in code (using the CreateParams call).
And be sure to use EXACTLY the same names as in your Oracle
definition! It's picky, even capital / non-capital letters are
important!)

4) Set the IN parameter in code:
MyStoredProc.ParamByName('matrix_id_in').AsInteger := 0
(or whatever it is)

5) Call MyStoredProc.ExecProc

6) Read out the OUT parameter by using:
myVar := MyStoredProc.ParamByName('outparam1').AsString;

HTH
Marc

--------------------------------------------------------------------------
Marc Scheuner                            Berner Versicherungen, Dept. ISV
May the Source be With You               Laupenstrasse 27

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

 
 
 

1. How to call an Oracle Stored procedure from MSSQL Server Stored Procedure

Anyone on this list know how to call an Oracle Stored procedure (a function
which returns a number) from within a Microsoft SQL Server stored procedure?

We are just using plain ODBC connections.  We have a function called func
and it takes 3 parameters, and returns a number.

The function is defined as:

func (str1, str2, str3) return NUMBER;

How, in SQL Server do I set up the three strings, then make the call, then
get the NUMBER.  I have seen a few articles on various web pages, but they
are primarily for procedures, not functions, and they use ADO.  I'm only
really interested in an ODBC  solution at the present time.

If you have any suggestions, or links, please email me at ericl at
broderbund dot com, or post your responses here.

Thanks!

2. Help to restore SQL database mdf files

3. Call an Oracle Stored Procedure from DTS

4. Concatenated primary key using VB Code

5. How to call an Oracle stored procedure from VB

6. How to get .sdf file?

7. ADO: Calling Multiple Oracle Stored Procedures at once

8. Oracle Financials Release 11i

9. Calling an Oracle Stored Procedure via SQL Passthrough in Access 97

10. Calling an Oracle Stored Procedure

11. Calling an Oracle Stored Procedure from Vb using Q+E