Search code examples
oraclestored-proceduresplsqlprocoracle-pro-c

Oracle Pro*C Object Type Convert To C Structures


Hi We have a server with a flow to process each incoming request it is like this:

Serialize C struct request to string(VARCHAR2) and send it to Oracle Package1 as IN OUT NOCOPY variable.

In Package1 find values by searching through serialized request string and process phase1.

Get back serialized request string and print phase1 result.

...

Send serialized request string to Oracle PackageN as IN OUT NOCOPY variable.

In PackageN find values by searching through serialized request string and process phaseN.

Get back serialized request string and print phaseN result.

Deserialze request string into struct and generate response and pass it to send response functions.


Our big problem is cost of find variables which uses a lot of CPU Resource and Actually consumes whole CPU Resource for searching and fetching string from string a lot of times.


My solution for this problem is to create an Oracle Object Type and store all variables in that Type and pass it to Package1 to PackageN one by one and so getting variableM is as v_obj.variableM instead of searching string. I'm trying to use ProC Objects capabilities, this document ProC/C++ Programmer's Guide - Chapter 17 Objects says to generate C structs using OTT tool and include it in C source.

the OTT command is:

ott intype=autho_row_obj_in.typ hfile=AuthoRowObj.h outtype=autho_row_obj_out.typ code=c userid=scott/tiger

the INTYPE file is:

CASE=LOWER
  TYPE TLV_UTILS.AUTHO_ROW_OBJ AS AuthoRowObj

OTT command end successfully and header file is created

I added this into pcscfg.cfg:

OBJECTS=YES
intype=autho_row_obj_out.typ

but I get proc Semantic error for ALLOCATE, FREE and passing pointer to ott generated struct to PLSQL bloc like this:

{
AuthoRowObj *pRow, AuthoRowObj_ind *pRowInd;
EXEC SQL BEGIN DECLARE SECTION;
    VARCHAR         T_tlv_Data    [ 4096];
EXEC SQL END DECLARE SECTION;
EXEC SQL EXECUTE
BEGIN
    :pRow:pRowInd := TO_AUTHO_OBJ(:T_tlv_Data);
END;
}

the error is:

PLS-S-00382, expression is of wrong type

Solution

  • This error is related to proc parameters:

    intype=/src/inc/autho_row_obj_out.typ
    

    This post helps: OraFAQ: Pro*C compilation error