Error: Writing LOB with Pro*COBOL

Hi,
I'm trying to write an Oracle CLOB object using a COBOL application and Pro*COBOL. The following code is quite similar to the Oracle Documentation Example. However, I would always get the fatal error
Attempt to access item beyond bounds of memory (Signal 10)
Here's my code (erased the EXEC SQL...END-EXEC for readability):
ALLOCATE :WC-MESSAGE-TXT
SELECT MESSAGE INTO :WC-MESSAGE-TXT
FROM T_MESSAGE
WHERE ID = :WV-ID
FOR UPDATE
LOB WRITE :WC-MESSAGE-LEN
FROM :WV-MESSAGE
INTO :WC-MESSAGE-TXT
FREE :WC-MESSAGE-TXT
Can anyone help, please!
Thanks, Ulf

Have you checked the system requirements for using Pro-Cobol with Oracle 11g and Linux? See here:
Pro*COBOL® Programmer's Guide 11g Release 1 (11.1)
http://download.oracle.com/docs/cd/B28359_01/appdev.111/b28428/pcoabops.htm#insertedID1
Hope this helps,
Ben

Similar Messages

  • Environnement with pro-cobol and linux redhat

    Hi,
    I have a linux redhat Linux 2.6.9-55.ELsmp #1 SMP Fri Apr 20 17:03:35 EDT 2007 i686 i686 i386 GNU/Linux
    and oracle 11g database where we have installed Pro-cobol with a launcher xframe ( not me !)
    we want to use command-line with pro-cobol :
    exemples :
    export COBOLOPTS="-dy -shared -M -lxconv -L$XFRAMEHOME/lib -I $PWD -WC,""DLOAD"" -WC,""SOURCE"" -WC,""COPY"" -WC,""XREF"" -WC,""FLAG(E)"" -WC,""MODE(STD)"" -WC,""ALPHAL(WORD)"" -WC,""NOTRUNC"" -WC,""NOSDS"" -WC,""SRF(FIX)"" -WC,""MAP"" -do ./ -dp ./ "
    cobol -o OV1SLSP.e OV1SLSP.pre OV1MADR0.o $ORACLE_HOME/precomp/lib/cobsqlintf.o OV1MADR1.pre.o OV1MSNT0.pre.o 2> OV1SLSP.errors
    execution:
    OV1SLSP.e
    results
    Erreur de segmentation
    we have a this error.
    but when we use xframe launcher :
    execution:
    xrun OV1SLSP
    results
    XRUN: STARTING OV1SLSP
    OV1MADR0 PLANTAGE SQL RNVP : -1012
    SQLERRMC ORA-01012: non connecté
    COBOL:rts: HALT: JMP0015I-U [PID:000004A0 TID:B7FFC940] CANNOT CALL PROGRAM 'COBCANC'. xvsamRts: undefined symbol: COBCANC PGM=OV1MADR0
    XRUN: TERMINATED WITH CODE 134
    =>This message is normal because we have connect to database !
    It's working perfect.
    My question is : what is the correct librairies to have to make static compiling pro-cobol's programs?
    hope to be cleared.
    Thanks.
    Edited by: french_dam on 28 janv. 2011 10:07
    Edited by: french_dam on 28 janv. 2011 10:11

    Have you checked the system requirements for using Pro-Cobol with Oracle 11g and Linux? See here:
    Pro*COBOL® Programmer's Guide 11g Release 1 (11.1)
    http://download.oracle.com/docs/cd/B28359_01/appdev.111/b28428/pcoabops.htm#insertedID1
    Hope this helps,
    Ben

  • Error writing output with iview for xml form builder

    Hi,
    I created a Xml Form Builder's project in which I developed an "Edit" and "ListEdit" sheet.
    I also created an iview for theese in which the code link is:"com.sap.km.cm.xmlform",and the field for Style Sheet for List and for single item are set up correctly,but when I tried the preview the following error message happened:
    com.inqmy.lib.xsl.xslt.XSLOutputException: Error writing output. -> org.w3c.dom.DOMException: Root Element is already present, cannot be appended as a child.
    could someone help me?
    thank's a lot!
    Nick.

    Hi,
    Now I'm confused,what do you mean with create new data? Are users editing existing documents
    (as if they go to a document example.xml > edit) or they are creating new documents (as if they go
    on folder > new > forms)?
    The problem is, in both cases a user would need read/write permissions.
    The normal flow content (data) is created in KM is as follows:
    1. user is assigned to a role
    2. role contains KM Navigation iView
    3. KM Navigation iView executes com.sap.km.cm.navigation component
    4. user chooses New > Form UI command (edit_xml_forms)
    5. edit_xml_forms UI command executes its code (com.sapportals.wcm.rendering.uicommand.cm.UIXMLFormsCreateCommand) and open xml edit for the user
    6. user fill the form and click Save, form is created into folder
    For what I understood so far, your requirement basically asks you to go directly to step 5, it is
    possible to pass a URL that goes directly to step 5, the UI command button, but if you do that
    you won't have a context, so chances that it will work are slim, since a context is required to
    fill the parameters asked by the app (like folder, user, permissions, etc). Even though, in some cases you can
    still pass the parameters via post in the URL but you must know which service/parameters the
    app asks for it, also a URL is static...
    That was the create scenario, I think it's more cons than pros, users would still be
    able to bypass the URL iView created for that, I'd suggest evaluating again if it's really
    a problem having users access cm to manage data
    kind regards,
    Rafael

  • Problems with Pro*Cobol on 10g

    Hi ,
    We are trying to migrate from 9i to 10g. We were using pro*cobol 1.8. Now we are facing many problems while compiling and running these programs on Pro*COBOL: Release 10.2.0.2.0.
    Are there any migration guides available which might have the specific changes to be done.
    Thanks
    Akhila

    Hi 985004,
    This forum if for Web Services. I think you would have more luck posting to the APEX forum:
    Oracle Application Express (APEX)
    Regards Peter

  • Urgent Error : Make file in PRO*COBOL

    Hi All,
    We are trying to Make a COBOL file using Oracle 8.0.5 but ends with an error in a production environment. The OS is Solaris 8.
    cob : Library not found : -lsqlnet
    Make : fatal error : command failed for target "<Prog name> "
    I checked the environment for LD_LIBRARY_PATH set to /usr/ccs/bin:${PATH} also included the $ORACLE_HOME/lib and $ORACLE_HOME/rdbms/lib paths to the above variable. Still it returns the same problem.
    Can any one help me solving this problem as it is very critical.
    Regards,

    Finally ot it to compile successfully by creating a new Makefile in the SpaceTriangle directory with those make commands which had been phonied out in the original Makefile in the 12_Stage3D directory which contains the SpaceTriangle directory. Of course I had to make four changes to the path references when it referred to files in the SpaceTriangle directory.
    I also had to copy the header files AGAL_internal.h and AGAL.h into the SpaceTriangle directory.
    After that I ran the newly created Makefile in the SpaceTriangle directory, and it compiled perfectly (no errors, no warnings, and the expected output).  BUT, the resulting swf, SpaceTriangle.swf, would not run in Flash Player Debugger Version 11.6.602.167 (11.6). Here's the error message from the Flash Player Debugger:
    ReferenceError: Error #1065: Variable __start1 is not defined.
              at com.adobe.flascc::CModule$/start()
              at com.adobe.flascc::CModule$/startAsync()
              at com.adobe.flascc::Console/init()
              at com.adobe.flascc::Console()
              at com.adobe.flascc.preloader::DefaultPreloader/onPreloaderComplete()
    Any ideas anyone?

  • [b]insert into...returning[/b] with Pro*COBOL

    Hi,
    I wrote a COBOL application to insert a row into an Oracle table. It works fine, but when I append the returning clause to return a trigger-generated value (or any other) I would always get an
    ORA-24343: user defined callback error
    no matter what data type I use.
    Can anyone provide a solution to this problem?
    Thanks, Ulf

    I agree. I have read that thread on Tom's site (and/or in his book). I don't know if this is it exactly, but it is along those lines: http://asktom.oracle.com/pls/ask/f?p=4950:8:::::F4950_P8_DISPLAYID:12083187196917
    Here's the main gist:
    Followup:
    that is EXACTLY what I propose in my books :)
    the best (and only) path to database independence is to put all things database
    into the databases stored procedure language.
    you hide the different concurrency models
    you hide the different features
    you are ALLOWED to use (exploit) the different features
    perfection
    Put it all into stored procedures, have the application code hit consistant interfaces and let Oracle be Oracle, let MySQL be MySQL. Oracle != MySQL != SQL Server so don't try and jam that square peg into that round hole.
    Just my $.02

  • Using WITH clause in Pro*Cobol

    Hi!
    I am trying to improve the performance of a query by introducing WITH clause.
    The query is in Pro*Cobol Release 9.2.0.6.0 - Production.
    I got compilation error
    WITH DPTCOST AS (
    ...............1
    PCB-S-00400, Encountered the symbol "DPTCOST" when expecting one of the following:
    END-EXEC
    ....continued
    So I wonder if we could use that clause at all with Pro*Cobol
    Here is the excerp of the code
    EXEC SQL
    DECLARE INPUT_ACTUAL CURSOR FOR
    WITH DPTCOST AS (
    SELECT /*+ rule */
    A.CODE_COMBINATION_ID,
    A.SEGMENT1, A.SEGMENT2, A.SEGMENT3,
    A.SEGMENT6,
    D.COSTING, D.PROCESS,
    D.MTL_CODE, D.FACTOR
    FROM
    GL_CODE_COMBINATION A,
    ALCGL_DEPARTMENT_COSTINGS D
    WHERE
    A.TEMPLATE_ID IS NULL
    AND A.SUMMARY_FLAG <> 'Y'
    AND A.SEGMENT1 = D.PLANT_NUMBER
    AND A.SEGMENT3 <> '6999001'
    AND A.SEGMENT3 <> '6999002'
    AND SUBSTR(A.SEGMENT2,4,3) = D.DEPARTMENT
    AND D.ACTUAL_FLAG = 'A'
    ) ... continued

    Materialized views are basically stored query results. They offer advanced functionality like query rewrite, refresh on commit, and more;
    http://download-west.oracle.com/docs/cd/B19306_01/server.102/b14200/statements_6002.htm
    Unlike a view, they actually store the results of the query - not just the query;
    SQL> create table t (cid number primary key)
    Table created.
    SQL> insert into t select object_id from dba_objects where object_id is not null
    12791 rows created.
    SQL> create materialized view mv
       as select * from t
    Snapshot created.
    SQL> select object_name, object_type from user_objects where object_name ='MV'
    OBJECT_NAME                    OBJECT_TYPE       
    MV                             TABLE             
    MV                             MATERIALIZED VIEW 
    2 rows selected.
    SQL> select segment_name, bytes from user_segments where segment_name in ('T', 'MV')
    SEGMENT_NAME                        BYTES
    T                                  196608
    MV                                 196608
    2 rows selected.Temporary tables are simply tables that are created then dropped. GLOBAL TEMPORARY TABLES have the advantage (or disadvantage) of only existing until commit or the end of the session. They results are visible to the user that inserted the data - but only temporarily;
    http://download-west.oracle.com/docs/cd/B19306_01/server.102/b14200/statements_7002.htm#sthref7483

  • NVL2 in pro cobol giving the error.

    For some reason we are getting an compiler error when we use NVL2 function in embedded sql statement in a pro-cobol module. Here is the output from the compiler. Do we have to add any options to recognize the new functions/keywords?
    procob iname=vas107h2.pco include=/oracle/home/product/9.2.0/precomp/public ireclen=132 oreclen=132 sqlcheck=full ltype=none
    " PICX=VARCHAR2 include=/jsbatch/vista/dev/cobol/cpy
    Pro*COBOL: Release 9.2.0.7.0 - Production on Tue Oct 31 13:49:35 2006
    Copyright (c) 1982, 2002, Oracle Corporation. All rights reserved.
    System default option values taken from: /oracle/home/product/9.2.0/precomp/admin/pcbcfg.cfg
    Error at line 595, column 12 in file vas107h2.pco
    EXEC SQL DECLARE DRIVER CURSOR FOR
    ...........1
    PCB-S-00576, PLS-201: identifier 'NVL2' must be declared
    Error at line 595, column 12 in file vas107h2.pco
    EXEC SQL DECLARE DRIVER CURSOR FOR
    ...........1
    PCB-S-00576, PLS-0: SQL Statement ignored
    *** Error code 1
    make: Fatal error: Command failed for target `vas107h2'
    Thanks,

    I'm not familiar with Pro*Cobol, but there's a similar issue with Pro*C, the parser does not recognize this built-in function. Given workaround is:
    1) Use NVL() instead of NVL2().
    2) Use Dynamic Sql in Pro*C. For example:
    EXEC SQL EXECUTE
    declare
    v_var varchar2(100);
    BEGIN
    execute immediate 'select nvl2(user, user, 'N/A') from dual' into v_var;
    END;
    END-EXEC;
    If that doesn't help, you should contact Oracle support.
    Werner

  • PRO*COBOL/Oracle 9.2 Error

    I am trying to run a COBOL program using SQL. The program is pre-compiled with PRO*COBOL and the then with Microfocus NET Express. At runtime i get the following error.
    $ ./testsample
    Execution error : file 'sample1'
    error code: 114, pc=0, call=1, seg=0
    114 Attempt to access item beyond bounds of memory (Signal 10)
    HP/MF COBOL Version: B.13.45
    HP-UX hptest B.11.11 U 9000/800
    pid: 22012 gid: 102 uid: 104
    Thu Nov 21 19:03:12 2002
    7:03pm up 36 days, 6:23, 34 users, load average: 0.28, 0.16, 0.13
    Thread mode: No Threads
    RTS Error: COBOL
    Sync Signals: COBOL
    ASync Signals: COBOL
    cobtidy on exception: False
    I get the same error with the sample program. Any idea what the cause may be?

    Hello,
    Reason: Your data might contain some foreign characters [non-english] ie., your server nls_lang settings might be different to the client nls_lang settings, as a result the new nls_lang characters will occupy extra bytes because of which even though it is apparent that you are using around 2000 bytes you may be using more than 4000 bytes. Examples Japanese characters seem to take 2 bytes per character, similarly russian takes 3 bytes per character.
    The ojdbc14.jar seems to be doing some check on this and if the characters are more than 4000 bytes it gives u the ora-01461 error but the new 10G ojdbc14.jar allows this.
    On the other hand you may be genuinely trying to insert more than 4000 bytes characters into varchar [example trying to insert the text values into a varchar()]
    You may want to try this:
    * Please download ojdbc14.jar from
    http://www.oracle.com/technology/software/tech/java/sqlj_jdbc/index.htmla>
    * Replace the old $omwb_home/lib/ojdbc14.jar with the ojdbc14.jar that you have downloaded in the step above.
    Try a capture now.
    Thank you.
    Srinivas

  • PRO*COBOL Oracle 9.2

    I am trying to run a COBOL program using SQL. The program is pre-compiled with PRO*COBOL and the then with Microfocus NET Express. At runtime i get the following error.
    $ ./testsample
    Execution error : file 'sample1'
    error code: 114, pc=0, call=1, seg=0
    114 Attempt to access item beyond bounds of memory (Signal 10)
    HP/MF COBOL Version: B.13.45
    HP-UX hptest B.11.11 U 9000/800
    pid: 22012 gid: 102 uid: 104
    Thu Nov 21 19:03:12 2002
    7:03pm up 36 days, 6:23, 34 users, load average: 0.28, 0.16, 0.13
    Thread mode: No Threads
    RTS Error: COBOL
    Sync Signals: COBOL
    ASync Signals: COBOL
    cobtidy on exception: False
    I get the same error with the sample program. Any idea what the cause may be?

    after some research I found out that the Pro Cobol compiler is not available on the HP Itanium for version 9.2.0.1, 9.2.0.2 and 9.2.0.3. I will not be available until 9.2.0.4 or later per Oracle on Metalink

  • Error 1310.Error writing to file for CS2 install on Win7 for Adobe 7 Pro

    I have Adobe 7 Pro that needs to be installed on a Win7 machine that is not supported by Adobe.  They provide a CS2 version with a new serial number for replacement of my product since my product cannot be activated anymore.
    When I try to install it, I get the following error after the install process has started.
    Error 1310.Error writing to file: C:\Program Files (x86)\Adobe\Acrobat 7.0\Active X\AcroPDF.DEU.  Verify that you have access to that directory.
    I am the admin for my machine and I also tried installing their version as the admin as well.
    Any help on getting thru this?

    Hi shooter-1971,
    Acrobat 7 is not supported on windows 7.
    But you might want to refer to the troubleshooting steps mentioned in the KB Doc : http://helpx.adobe.com/creative-suite/kb/error-1310-error-writing-file.html
    Error 1310 is usually related to insufficient permissions on the folder. Please try enabling the hidden Admin account on Windows 7 and try installing the software and check.
    To enable hidden admin account you can refer : http://social.technet.microsoft.com/wiki/contents/articles/3040.enable-disable-the-local-h idden-built-in-administrator-account-in-windows-7.aspx

  • PRO * COBOL with Oracle 9i

    We are in the process of Database upgrades and a pro*cobol program which was working in HP UX 11 / Oracle 7.3.4 was not working in HP UX 11 / Oracle 9i. We are getting the following error when trying to compile it (make) -
    sh: 11139 Memory fault(coredump)
    *** Error exit code 139
    Can anybody help me with this issue.

    I posted this in the wrong place. Please ignore this.

  • Can't compile old Cobol Programs with Oracle9i Pro*Cobol.

    I'm a Cobol and Oracle greenhorn - so please apologise my question.
    Here are the details:
    We want to switch our db from
    Oracle8i Enterprise Edition Release 8.1.7.0.0
    to
    Oracle9i Enterprise Edition Release 9.2.0.4.0
    If I have the "Oracle 8i client" installed on my developing system (using procob precompiler) my program compiles without problems. Connecting to our old 8i db works fine.
    On connecting to our new 9i db my program crashes on the first EXEC SQL statement with:
    114 Attempt to access item beyond bounds of memory
    So I have installed the "Oracle 9i client" to use the new precompiler
    Pro*COBOL: Release 9.2.0.1.0
    BUT now I can't execute my program because procob inserts some CALL "ORASQL8" which doesn't exist in my Oracle installation. Maybe ORASQL9 would work, because there are some files with this name in my Oracle dir.
    How can I make my NET Express Version 3.1.11 Service Pack 1 work together with Oracle9i?
    Here are my current (old) Precompilersettings from the file cobol.dir:
    p(cobsql) csqlt=ora8 cbl2ora8 sqldebug end-c ireclen=132 oreclen=132 maxliteral=160 picx=varchar2 p(cp) sy endp copyext (pco,cbl,cpy,cob) osext(pco);
    This forum is my last resort. Maybe anyone can help?
    Thanks in advance
    lual

    ...solved by myself.
    After wasting a lot of time, i've found a quick and dirty solution...
    C:\oracle9i\bin\ORASQL9.DLL
    duplicated and renamed to ORASQL8.DLL
    C:\oracle9i\precomp\lib\msvc\oraSQL9.LIB
    duplicated and renamed to oraSQL8.LIB
    C:\oracle9i\precomp\lib\orasql9.lib
    duplicated and renamed to orasql8.lib
    ...now my old programs run again without errors.
    lual

  • Pro*Cobol  compilation error

    Hi all,
    We have two Identical servers DEV1 and PROD1 with same SunOS and Oracle Db versions.
    Then we have a pro*cobol program "prog1" which compile clean at DEV1, but when copied to PROD1 and compiled it does not
    go clean compile.
    Can you help me how to troubleshoot this problem please.
    Is there a bug in Oracle pro*cobol that I may not be aware of?
    How do I compare the pro*cobol version of the 2 servers?
    I also tried to check the server OS versions:
    @DEV1
    uname -a
    SunOS DEV1 5.10 Generic_144488-12 sun4v sparc SUNW,T5440
    @PROD1
    uname -a
    SunOS PROD1 5.10 Generic_118833-17 sun4u sparc SUNW,Sun-Fire-V440Are our OS in sync?
    MF cobol version:
    check cobrun:
    DEV1 MF Cobol Version:
    V5.1 revision 0 build 10/10/2 G; 07109. Run Time System RXCTI/AA0/00000Q.
    DEV2 MF Cobol Version:
    V5.1 revision 0 build 10/10/2 G; 07209. Run Time System RXCTI/AA0/00000QIs our cobol compiler in sync?
    Thanks a lot,
    Edited by: KinsaKaUy? on 16-Sep-2011 02:44

    What kind of error it throw ??
    Are both server have similar hardware configuration??
    Thanks
    Cheeta

  • Help with Pro*C/C++ precompiler error

    Hello.
    I have a little experience working with Pro*C/C++ and now I am trying to learn more by my own.
    I think this is an easy question. I am trying to precompile the Thread_example1.pc code from Pro*C/C++ Precompiler Programmer's Guide, Release 9.2 (I am trying it in a windows machine because I have pthreads for windows installed, so that I have commented the DCE_THREADS references).
    The thing is I am not able to precompile the code (I have tried several precompiler options).
    Now I am getting the error (I am sorry it is in Spanish):
    Error semßntico en la lÝnea 126, columna 32, archivo d:\Ejercicios_ProC\MultithreadExample\Thread_example1.pc:
    EXEC SQL CONTEXT ALLOCATE :ctx;
    ...............................1
    PCC-S-02322, se ha encontrado un identificador no definido
    The thing is that it is defined (outside a EXEC SQL DECLARE section but the precompiler CODE is set to default that does not need to be inside).
    If I declare it inside a EXEC SQL DECLARE section I get:
    Error semßntico en la lÝnea 105, columna 18, archivo d:\Ejercicios_ProC\MultithreadExample\Thread_example1.pc:
    sql_context ctx[THREADS];
    .................1
    PCC-S-02322, se ha encontrado un identificador no definido
    I have also tried writing EXEC SQL CONTEXT USE :ctx[THREADS]; just before the declare section but I get the same error than before.
    Can someone help me?

    Hmm, try the updated one (mltthrd1.pc). I've tried it (and a converted-to-pthread version on Linux). Both work fine. What version of Pro*C are you using?
    NAME
      MltThrd1
    FUNCTION
    NOTES
      32-bit Pro*C/C++ Multithreaded sample program from Pro*C/C++ User's Guide.
    Requirements
      The program requires a table ACCOUNTS to be in the schema
      SCOTT/TIGER. The description of ACCOUNTS is.
    SQL> desc accounts
    Name                  Null?   Type
    ACCOUNT                       NUMBER(10)
    BALANCE                       NUMBER(12,2)
    For proper execution, the table should be filled with the
    accounts 10001 to 10008.
         shsu: run MltThrd1.sql first.
    OWNER
    DATE
    MODIFIED
      rahmed     10/10/96 - ported for WIN32 port.
    #include <windows.h>
    #include <stdio.h>
    #include <stdlib.h>
    #include <string.h>
    #include <sqlca.h>
    #define CONNINFO "SCOTT/TIGER"
    #define THREADS 3
    EXEC SQL BEGIN DECLARE SECTION;
         struct parameters
              sql_context * ctx;
              int thread_id;
         typedef struct parameters parameters;
         struct record_log
              char action;
              unsigned int from_account;
              unsigned int to_account;
              double amount;
         typedef struct record_log record_log;
    EXEC SQL END DECLARE SECTION;
    /* Function prototypes   */
    void err_report(struct sqlca);
    void do_transaction(parameters *);
    void get_transaction(record_log**);
    void logon(sql_context,char *);
    void logoff(sql_context);
    record_log records[]= { { 'M', 10001, 10002, 12.50 },
                   { 'M', 10001, 10003, 25.00 },
                   { 'M', 10001, 10003, 123.00 },
                   { 'M', 10001, 10003, 125.00 },
                   { 'M', 10002, 10006, 12.23 },
                   { 'M', 10007, 10008, 225.23 },
                   { 'M', 10002, 10008, 0.70 },
                   { 'M', 10001, 10003, 11.30 },
                   { 'M', 10003, 10002, 47.50 },
                   { 'M', 10002, 10006, 125.00 },
                   { 'M', 10007, 10008, 225.00 },
                   { 'M', 10002, 10008, 0.70 },
                   { 'M', 10001, 10003, 11.00 },
                   { 'M', 10003, 10002, 47.50 },
                   { 'M', 10002, 10006, 125.00 },
                   { 'M', 10007, 10008, 225.00 },
                   { 'M', 10002, 10008, 0.70 },
                   { 'M', 10001, 10003, 11.00 },
                   { 'M', 10003, 10002, 47.50 },
                   { 'M', 10008, 10001, 1034.54}};
    static unsigned int trx_nr=0;
    HANDLE hMutex;
    void main()
         EXEC SQL BEGIN DECLARE SECTION;
              sql_context ctx[THREADS];
         EXEC SQL END DECLARE SECTION;  
         HANDLE thread[THREADS];
         parameters params[THREADS];
         int j;
         DWORD ThreadId ;
         /* Initialize a process in which to spawn threads. */
         EXEC SQL ENABLE THREADS;
         EXEC SQL WHENEVER SQLERROR DO err_report(sqlca);
         /* Create THREADS sessions by connecting THREADS times, each
         connection in a separate runtime context. */
         for(i=0; i<THREADS; i++){
              printf("Start Session %d....\n",i);
              EXEC SQL CONTEXT ALLOCATE :ctx[j];
              logon(ctx[j],CONNINFO);
         /* Create mutex for transaction retrieval.
            Created an unnamed/unowned mutex. */
         hMutex=CreateMutex(NULL,FALSE,NULL);
         if (!hMutex){
              printf("Can't initialize mutex\n");
              exit(1);
         /* Spawn threads. */
         for(i=0; i<THREADS; i++){
              params[j].ctx=ctx[j];
              params[j].thread_id=i;
              printf("Thread %d... ",i);
              thread[j]=CreateThread(NULL,0,(LPTHREAD_START_ROUTINE)do_transaction,
                                     &params[j],0,&ThreadId);
              if (!thread[j])
                   printf("Cant create thread %d\n",i);
              else
                   printf("Created\n");
         /* Logoff sessions. */
         for(i=0;i<THREADS;i++){
              printf("Waiting for Thread %d to stop....",i); /* waiting for thread to end */
              if(WaitForSingleObject(
                             thread[j],                       /* handle of thread  */
                             INFINITE) != WAIT_OBJECT_0)      /* time-out interval */
                   printf("Error waiting for thread % to terminate\n", i);
              else
                   printf("Thread %d stopped\n",i);
              printf("Stop Session %d....\n",i);
              logoff(ctx[j]);
              EXEC SQL CONTEXT FREE :ctx[j];
    } /* end main() */
    * Function: do_transaction()
    * Description: This function executes one transaction out of
    *                          the records array. The records array is managed
    *                          by get_transaction().
    void do_transaction(parameters *params)
    struct sqlca sqlca;
    EXEC SQL BEGIN DECLARE SECTION;
         record_log *trx;
    EXEC SQL END DECLARE SECTION;
    sql_context ctx;
    ctx = params->ctx;
         /* Done all transactions ? */
         while (trx_nr < (sizeof(records)/sizeof(record_log))){
              get_transaction(&trx);
              EXEC SQL WHENEVER SQLERROR DO err_report(sqlca);
              /* Use the specified SQL context to perform the executable SQL
              statements that follow. */
              EXEC SQL CONTEXT USE :ctx;
              printf("Thread %d executing transaction # %d\n",params->thread_id,trx_nr);
              switch(trx->action){
                   case 'M':       EXEC SQL UPDATE ACCOUNTS
                                  SET BALANCE=BALANCE+:trx->amount
                                  WHERE ACCOUNT=:trx->to_account;
                                  EXEC SQL UPDATE ACCOUNTS
                                  SET BALANCE=BALANCE-:trx->amount
                                  WHERE ACCOUNT=:trx->from_account;
                                  break;
                   default:
                                  break;
              EXEC SQL COMMIT;
    * Function: err_report()
    * Description: This routine prints the most recent error.
    void err_report(struct sqlca sqlca)
         if (sqlca.sqlcode < 0)
              printf("\n%.*s\n\n",sqlca.sqlerrm.sqlerrml,sqlca.sqlerrm.sqlerrmc);
         exit(1);
    * Function: logon()
    * Description: This routine logs on to Oracle.
    void logon(sql_context ctx,char *conninfo){
         EXEC SQL BEGIN DECLARE SECTION;
              char connstr[20];
         EXEC SQL END DECLARE SECTION;
         EXEC SQL CONTEXT USE :ctx;
         strcpy(&connstr[0],(char*)conninfo);
         EXEC SQL CONNECT :connstr;
    * Function: logoff()
    * Description: This routine logs off from Oracle.
    void logoff(sql_context ctx)
         EXEC SQL CONTEXT USE :ctx;
         EXEC SQL COMMIT WORK RELEASE;
    * Function: get_transaction()
    * Description: This functions manages the records array.
    void get_transaction(record_log** temp)
    DWORD dwWaitResult;
         /* Request ownership of mutex. */
         dwWaitResult=WaitForSingleObject(
                             hMutex,      /* handle of mutex   */
                             INFINITE);       /* time-out interval */
         switch (dwWaitResult) {
        /* The thread got mutex ownership. */
        case WAIT_OBJECT_0:
                        *temp = &records[trx_nr];
                        trx_nr++;
                        /* Release ownership of the mutex object. */
         if (! ReleaseMutex(hMutex))
                             printf("Not able to release mutex\n");
         break;
        /* Cannot get mutex ownership due to time-out. */
        case WAIT_TIMEOUT:
                             printf("Cannot get mutex ownership due to time-out\n");
        /* Got ownership of the abandoned mutex object. */
        case WAIT_ABANDONED:
                             printf("Got ownership of the abandoned mutex object\n");
    }

Maybe you are looking for