Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.misc -> Pro*C stored procedure with table of rec out parameter

Pro*C stored procedure with table of rec out parameter

From: Ondrej 'Andy' Brablc <brablc_at_seznam.nospam>
Date: Thu, 1 Apr 1999 14:33:47 +0200
Message-ID: <Oa#n0vDf#GA.178@rpc1284.daytonoh.ncr.com>


Hi overthere,

I'm trying to write Pro*C program, but I have problems with structures. I have this in package ANDYT:

type t_rec_subject is record (
  uname VARCHAR2(10),
  ident VARCHAR2(10),
  length integer
);
type t_tab_rec_subject is table of t_rec_subject index by binary_integer; procedure demo_proc(p_uname in varchar2, p_subj out ANDYT.t_tab_rec_subject);

And I want to get all lines from output parameter:

EXEC SQL BEGIN DECLARE SECTION;
VARCHAR Username[10];
 VARCHAR Ident[10];
int Length;
 int Count;
EXEC SQL END DECLARE SECTION; EXEC SQL EXECUTE
  declare
   S ANDYT.t_tab_rec_subject;
  begin
   ANDYT.demo_proc(:Username,S);
   :Count := S.count;
   for i in 1..S.count loop
:Username := S(i).uname;
:Ident := S(i).ident;
:Length := S(i).length;

   end loop;
  end;
END-EXEC; I know that I will get only the last row from S, but I need them all. I've tried to make a structure in C simillar to t_rec_subject, and then an array of this structure, let say Subj[20], but it doesn't work. I cannot even pass Subj instead of S to procedure call neither can I assign Subj[i-1].Username := S(i).uname. It seems that host variables cannot be of type structure or moreover array of structures.

My idea is about to call external function from the PL/SQL block, which will allocate enough memory in the array and insert one row after another into this array.

EXEC SQL EXECUTE
  declare
   S ANDYT.t_tab_rec_subject;
  begin
   ANDYT.demo_proc(:Username,S);
   array_allocate(S.count);
   for i in 1..S.count loop

      array_insert(S(i).uname,S(i).ident,S(i).length);    end loop;
  end;
END-EXEC; Is it possible to do it and to have this external function defined in the same Pro*C file? Or is there any other way how to do this job.

I have not manual for precompilers and it cannot be bought in any shop in Prague (Czech republic). This is also the only thing I need to know, so I hope that this newsgroup will be faster then ordering this book.

          Andy

--
Replace ".nospam" with ".cz" to reply Received on Thu Apr 01 1999 - 06:33:47 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US