If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > ANSI SQL > Calling a pl/sql func with OCI - please help

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 08-27-02, 10:31
sasfi sasfi is offline
Registered User
 
Join Date: Aug 2002
Posts: 2
Calling a pl/sql func with OCI - please help

Hi all, I'm trying to call a PL/SQL function within an OCI application using
Oracle8.1.7.

The C client application calls a PL/SQL function which return an object.

The returned object type (CUSTOMERINFO) has 2 attributes: 1 varchar2 (ID) + 1 varray
(VARR_INFO) of object INFO.

____________________________________________
This is the SQL for the defined Oracle types:
____________________________________________

create or replace type INFO as object ( attrib VARCHAR2(256), value
VARCHAR2(256) );

create or replace type VARR_INFO as varray(12) of INFO;


create or replace type CUSTOMERINFO as object ( id VARCHAR2(20),
listParams VARR_INFO );

____________________________________________
This is the stored function called from the client application
____________________________________________

Function testfunc (id varchar2) return CUSTOMERINFO as

resultset_info CUSTOMERINFO;

begin

resultset_info :=CUSTOMERINFO( 'id', VARR_INFO ( INFO(
'attrib1', 'value1'), INFO( 'attrib2', 'value2') ) );

return resultset_info; end testfunc;

__________________________________________________
______
This is the way the client application works:
__________________________________________________
______

/* statement used to call the stored function:

"BEGIN \ :customerinfo := testfunc(:sessionId);\ END;"; */

OCIBindByName for the :sessionId IN parameter

OCIBindByName for the :customerinfo return object OCITypeByName for the type
CUSTOMERINFO OCIBindObject for the :customerinfo. OCIStmtExecute.
__________________________________________________
____


The statement is succesfully executed but I can only manage to access the ID
attribute (varchar2) of the returned CUSTOMERINFO object not the varray attribute
(LISTPARAMS) of the same object.

I've tried to read this attribute using iterators but it does not work causing the
application to abort when calling OCICollSize or OCIIterNext.

I've searched through the Oracle application development manuals and the web but I
could not find some clean example illustrating the way to do it.


How can I read the varray attribute of the returned struct ?

Can you please help?

Thanks, Sasfi.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On