Home » Developer & Programmer » Precompilers, OCI & OCCI » Pass an array to a procedure input ([URGENT] Oracle V9, Pro*C only)
Pass an array to a procedure input [message #299466] Tue, 12 February 2008 02:35 Go to next message
mbourret
Messages: 2
Registered: February 2008
Location: France
Junior Member
Hi,

I have an array initialized by a cursor in the Pro*C, and I want to pass this array to my procedure in PL/SQL, how to declare the array in the Pro*C.

I have this in my database: The procedure contrat is in the package pu01. The type is not declare in the package.

create or replace string_array as table of varchar2(10);
procedure contrat(p in string_array) is
begin
forall i in p.first .. p.last
.......
end;

In pro*c I have this:

Char gTableauContrat[1000][10] ;
Short supprimer() {
VARCHAR lcontrat[BUF_LEN] = {0, ""};
Short lcpt = 0
Exec sql declare c1 for
Select c_contrat from tdcontrat;
Exec sql open c1 ;

Exec sql fetch c1 into :lcontrat
If (lcpt < 1000) {
Sprintf(gTableauContrat[lcpt], "%.*s",lcontrat.len,lcontrat.arr);
lcpt++;
} else {
exec sql execute
begin
pu01.contrat(
: gTableauContrat);
end
end-exec;
}

In this case it's a array to 1 dimension.
And I have also an array with two dimension and both elements are differents like my type in oracle:

create or replace type cpt_record as object (cpt varchar2(20), chaine varchar2(10));
create or replace type cpt_array as table of cpt_record;

Thanks.
Re: Pass an array to a procedure input [message #299473 is a reply to message #299466] Tue, 12 February 2008 03:03 Go to previous messageGo to next message
Michel Cadot
Messages: 68624
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
Pro*C/C++ Programmer's Guide
Chapter 18 Collections

Regards
Michel
Re: Pass an array to a procedure input [message #299482 is a reply to message #299466] Tue, 12 February 2008 03:44 Go to previous messageGo to next message
Michel Cadot
Messages: 68624
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
From PM:
mbourret wrote on Tue, 12 February 2008 10:39
Bonjour,

Mon soucis est vraiment entre le package et le pro*c, pour alimenter mon tableau dans le pro*c pas de soucis, par contre quand je fais l'appel à ma procédure, là le compilateur ne vient rien savoir.

Merci quand même pour vos informations.
Cdt.
marius.

Short translation: when I call the procedure, the compiler gives an error.

As you don't post your error it is hard to say but have a look at chapter 19 The Object Type Translator.

Regards
Michel
Re: Pass an array to a procedure input [message #299496 is a reply to message #299482] Tue, 12 February 2008 04:13 Go to previous messageGo to next message
mbourret
Messages: 2
Registered: February 2008
Location: France
Junior Member
Sorry.

The error when I complile is:
PLS-S-00306 wrong number or types of arguments in call to CONTRAT.

I am under Oracle V9 and I don't have access to oci.h.

Regards,
Marius
Re: Pass an array to a procedure input [message #299502 is a reply to message #299496] Tue, 12 February 2008 04:38 Go to previous message
Michel Cadot
Messages: 68624
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
It is the same thing in 9i, just go to this version documentation.

You should have oci.h in your installation.

Regards
Michel
Previous Topic: Proc Pro*C issues in Oracle 10g Really need help
Next Topic: Pro*C Makefile
Goto Forum:
  


Current Time: Thu Mar 28 08:52:28 CDT 2024