Using transactions in a multithreaded application

Is it possible to share a single OracleConnection object amongst multiple worker threads (avoiding all the problems of a connection pool), but still be able to begin/commit/and rollback transactions enlisted per thread?
Here is a sample of my wish list code:
On Thread One we want to be able to to this:
     Dim tx as new OracleTransaction = m_OraConnection.BeginTransaction()
          [Do Oracle stuff here]
     tx.Commit
     [This thread’s tx.commit will only commit this one transaction
On Thread Two we want to be able to do this:
     Dim tx as new OracleTransaction = m_OraConnection.BeginTransaction()
          [Do Oracle stuff here]
     tx.Rollback
     [This thread’s tx.rollback will only rollback this one transaction
Both of these threads use the same m_OraConnection object and this is what is unclear.  Will it work as shown in the sample?                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

Did not follow a specific pattern as this application is an upgrade and not a complete rewrite. If there is a specific pattern that shows this usage can you recommend it?
The threading part is straight forward enough, but I was wondering if it was possible to share the one connection amongs the 5 - 8 threads and thus avoid the issue that seem prevalent using the connection pooling.
This is where the question arises as if all threads are using the same conneciton object, will thier individual commits and rollbacks affect the other threads?

Similar Messages

  • Using time() function in multithreaded application

    I am using time() function in a multithreaded application with NULL argument for getting current time.
    Some time it's observed that we get a time one minute earlier than current time (3600 seconds).
    Is there a problem in the usage of the function?
    I am using expression : currenttime = time(NULL);
    I had seen some people using following way - time(&currenttime );
    Will above two behaves differently in multithreaded environment?
    [I  am using  Sun C++ 5.5 compiler on Solaris 8]

    How do you compare actual time against the time seen by your threads? If your threads are printing the value from time(2) to stdout, it's possible that you're seeing an artifact of thread scheduling and/or output buffering.
    I really doubt that you have a concurrency problem, but anyway make sure that you include the -mt option on your compile line:
    CC -mt blahblahblah...

  • Calling a custom BSP application in CRM2007  ICWC using transaction launche

    Hi Experts,
    I created a Z BSP application in se80 which is a statefull application.Now I created a direct link in ICWC for this Bsp application using transaction launcher.
    Now my problem is that the session of this BSP remains active even if I click on some other link in the navigation bar.
    I need a way to end the session as soon as we navigate to some other link on the navigation bar.
    It would also be helpful if I just know the code for killing the session programatically.
    Helpful Answers will be rewarded!!
    Thanks,
    Ashish.

    Hi,
    I am not sure, but according to my understanding u can use CL_BSP_SERVER_SIDE_COOKIE class in ur BSP application to get refrence of ur BSP page.
    When u r in Web UI by the help of this class u can check whether u r in BSP related view or in other then view. If u r in other view then u can set runtime->keep_context = 0.
    Take help from this link for the class related info.
    http://help.sap.com/saphelp_nw04/helpdata/en/e9/bb153aab4a0c0ee10000000a114084/frameset.htm
    Regards
    Gaurav

  • Extending field catalog of application ME using transaction NACE

    Hello,
    I extended the field catalog of application ME using Transaction NACE. I inserted material field as ZZMATNR but I couldn't find this field at IMG->Materials Management->Inventory Management and Physical Inventory->Output Determination->Maintain Condition Tables->Output: Create Conditions Table ->FieldCatalog.
    How can I use ZZMATNR?
    Thank you.
    Yasar Unalp

    Follow the OSS note below (OSS note - 39462) you need to follow the same for your field.
    Summary
    Symptom
    In the message determination for purchasing, the field catalog in Transaction M/60 should be enhanced, for example, with a field for the user ID.
    Other terms
    USNAM, condition table
    Reason and Prerequisites
    The communication structure to be maintained can be taken from table T681Z. Table T681Z can be displayed with Transaction SE16.Use 'B' for message determination and application EF for purchase order.
    Thus the structure for purchase orders to be maintained is KOMKBEA.
    The following section describes how to include field 'User ID' in the structure.If other applications or fields are used, the following example can be used in a modified form.
    Solution
    1. You must include field ZZUSNAM in communication structure KOMKBEA.In this structure there is an include that is provided for additional fields.In this Include KOMKBZ you must include the field with the name ZZUSNAM. ERNAM can be used as the domain in this case.
    2. The same field must also be included in structure KOMB in Include KOMBZ (the same procedure as under point 1).
    3. In table T681F use Transaction SM31 with key B, EF to add the same field. You can do this by overwriting an existing field.
                  As of Release 4. 0 you can use view V_T681F in Transaction SM30 for that purpose. Enter usage 'B', your application and field group '001'.
    4. In the message determination, the system runs perform USEREXIT_KOMKBEA_FILL. This perform is in program RVCOMFZZ.
    The source code should be changed as follows:
    FORM_USEREXIT_KOMKBEA_FILL.
    COM_KBEA-ZZUSNAM = SY-UNAME.

  • Is it supported to use Microsoft JDBC driver use in Java 7 (and 8) multithreaded applications?

    Hello everone
    is it supported to use Microsoft JDBC driver (the latest version) with Java 7 multithreaded application?
    I am planning to use standard Java 7 threads library and use separate JDBC objects per each thread, i.e. Java threads will not share any JDBC objects among them, only the thread-safe Java collections/data structures will be shared between threads (such as
    ConcurrentHashMap etc). The JDBC connections, resultsets, statements, etc will be created and dedicated per each individual thread.
    If it is supported - do you expect this design to scale-up well or am I better off using multiple but single-threaded Java/JBDC programs to access SQL Server 2012/2014 from Microsoft JDBC driver?
    Thanks
    Yuri Budilov
    Yuri Budilov Melbourne Australia

    >is it supported to use Microsoft JDBC driver (the latest version) with Java 7 multithreaded application?
    Yes, so long as:
    > Java threads will not share any JDBC objects among them,
    >do you expect this design to scale-up well or am I better off using multiple but single-threaded Java/JBDC programs >to access SQL Server 2012/2014 from Microsoft JDBC driver?
    Using threads should scale better than using processes (at least on Windows), as there is quite a bit of overhead with a process.  Each process has it's own JRE, it's own GC heap, its own threads...
    The bigger question, though, is how this scales on the SQL Server.  Your throughput may be limited by resources on your database server, and the thread's workloads may not be able to run concurrently because of locking. 
    David
    David http://blogs.msdn.com/b/dbrowne/

  • How to configure ENV and DB for multithreaded application?

    Hi,
    From document, I know DB_THREAD must be checked for both ENV and DB, but , I don't know which one is best choice for multithreaded application while facing DB_INIT_LOCK and DB_INIT_CDB. In my application, there maybe multi readers and writers at the same time, should I use DB_INIT_LOCK instead of DB_INIT_CDB? what other flags should I use?
    DB_INIT_CDB provides multiple reader/single writer access while DB_INIT_LOCK should be used when multiple processes or threads are going to be reading and writing a Berkeley DB database.
    Thanks for your seggestions and answers.

    Thanks for the explanation,
    The Berkeley DB Concurrent Data Store product
    allows for multiple reader/single writer access
    to a database. This means that at any point in time,
    there may be either multiple readers accessing a
    database or a single writer updating the database.
    Berkeley DB Concurrent Data Store is intended for
    applications that need support for concurrent updates
    to a database that is largely used for reading.
    If you are looking to support multiple readers and
    multiple writers then take a look at the Transactional
    Data Store product
    (http://download.oracle.com/docs/cd/E17076_02/html/programmer_reference/transapp.html)
    In this case the Environment is typically opened with:
    DB_INIT_MPOOL, DB_INIT_LOCK, DB_INIT_LOG, and DB_INIT_TXN.
    Let me know if I missed any of your question.
    Thanks,
    Sandra

  • PersistenceManager Patterns for Multithreaded Applications

    Hi,
    I'm looking for a good way, how to use Kodo JDO in a multithread application
    (actually Tomcat ;). The most easy thing is perhaps, to use only one
    persistence
    manager for the entire application, i.e. for all threads. Another solution
    might be,
    to create a PersistenceManager for each HTTP request. I don't like the
    solution,
    to have one PeristenceManager per session, because I expect thousands
    concurrent
    users. What I'm concerned with is the number of data base connections in
    this
    case.
    So my question to you is, what pattern do you use in your web applications?
    When do you create and close the PersistenceManagers to free resources?
    Has anybody alreay tried different patterns and compared the performance?
    Is there something like a best practice?
    Michael

    The other nice thing about the filter is that it should be easy to
    selectivly store and retrieve the PM in a user's session if they have a
    longer running transaction that spans multiple requests.
    So far, I've simply been passing the PM to each service method, although I
    don't particularliy like that approach. I haven't had time to try anything
    different yet and it isn't TOO bad, although I have a few ideas:
    1. The hashtable method you mentioned. I see there is a "Registry" pattern
    in the "Patterns of Enterprise Application Architecture" book I'm currently
    reading, but haven't gotten to it yet. I think it is close to what you
    mentioned.
    2. Retrieve the PM through JNDI. I don't know, however, if I can set up a
    PM in JNDI the way that the CurrentTransaction JNDI lookup works with
    container managed transactions.
    "Michael" <[email protected]> wrote in message
    news:[email protected]...
    I've never used a servlet filter before but I must say that is the most
    elegant approach I've seen, thanks for sharing that. How do you pass thePM
    to the service layer? Do you store it in a hashtable with the current
    thread as a key or do you pass it in to each service method?
    Thanks,
    Michael
    "Nathan Voxland" <[email protected]> wrote in message
    news:[email protected]...
    We've created the PersistenceManager in a filter and attached it to the
    request object. That way, the persistence manager can be accessed fromthe
    Struts Action, JSP Page, and anything else we do, plus we don't have to
    worry about closing it because it is closed by the filter after
    everything
    is done (Even if an exception is thrown)
    Here is the code:
    public void doFilter(final ServletRequest request, final ServletResponse
    response, FilterChain chain) throws IOException, ServletException {
    PersistenceManager pm = getPersistenceManager();
    request.setAttribute(JDO_PERSISTENCE_MANAGER, pm);
    try {
    chain.doFilter(request, response);
    } finally {
    if (pm.currentTransaction().isActive()) {
    pm.currentTransaction().rollback();
    pm.close();
    "Michael" <[email protected]> wrote in message
    news:[email protected]...
    I currently doing exactly this: getting a persistence manager at the
    beginning of a jsp page and close it at the end of the jsp page.
    When you use <jsp:include ...>, you must be careful not to close the
    persistence manager to early. I do it like this:
    This sounds like a good approach, especially the hashtable with the
    thread
    as the key. The only issue I see is if you create the PM in the JSPpage,
    often an Action is executed before the JSP is called. This is why I
    was
    thinking of creating the PM in the struts request processor, it'salways
    called for every request.

  • Pro*c multithreaded application has memory leak

    Hi there,
    I posted this message a week ago in OCI section, nobody answer me.
    I am really curious if my application has a bug or the pro*c has a bug.
    Anyone can compile the sample code and test it easily.
    I made multithreaded application which queries dynamic SQL, it works.
    But the memory leaks when i query the SQL statement.
    The more memory leaks, the more i query the SQL statement, even same SQL
    statement.
    I check it with top, shell command.
    My machine is SUN E450, Solaris 8. Oracle 9.2.0.1
    Compiler : gcc (GCC) 3.2.2
    I changed source code which is from
    $(ORACLE_HOME)/precomp/demo/proc/sample10.pc
    the sample10 doesn't need to be multithreaded. But i think it has to work
    correctly if i changed it to multithreaded application.
    the make file and source code will be placed below.
    I have to figure out the problem.
    Please help
    Thanks in advance,
    the make file is below
    HOME = /user/jkku
    ORA = $(ORACLE_HOME)
    CC = gcc
    PROC = proc
    LC_INCL = -I$(HOME)/work/dbmss/libs/include
    lc_incl = include=$(HOME)/work/dbmss/libs/include
    SYS_INCL =
    sys_incl =
    ORA_INCL = -I. \
    -I$(ORA)/precomp/public \
    -I$(ORA)/rdbms/public \
    -I$(ORA)/rdbms/demo \
    -I$(ORA)/rdbms/pbsql/public \
    -I$(ORA)/network/public \
    -DSLMXMX_ENABLE -DSLTS_ENABLE -D_SVID_GETTOD
    INCLUDES = $(LC_INCL) $(SYS_INCL) $(ORA_INCL)
    includes = $(lc_incl) $(sys_incl)
    LC_LIBS =
    SYS_LIBS = -lpthread -lsocket -lnsl -lrt
    ORA_LIBS = -L$(ORA)/lib/ -lclntsh
    LIBS = $(LC_LIBS) $(SYS_LIBS) $(ORA_LIBS)
    # Define C Compiler flags
    CFLAGS += -D_Solaris64_ -m64
    CFLAGS += -g -D_REENTRANT
    # Define pro*c Compiler flags
    PROCFLAGS += THREADS=YES
    PROCFLAGS += CPOOL=YES
    # Our object files
    PRECOMPS = sample10.c
    OBJS = sample10.o
    .SUFFIXES: .o .c .pc
    .c.o:
    $(CC) -c $(CFLAGS) $(INCLUDES) $*.c
    .pc.c:
    $(PROC) $(PROCFLAGS) $(includes) $*.pc $*.c
    all: sample10
    sample10: $(PRECOMPS) $(OBJS)
    $(CC) $(CFLAGS) -o sample10 $(OBJS) $(LIBS)
    clean:
    rm -rf *.o sample10 sample10.c
    the source code is below which i changed the oracle sample10.pc to
    multithreaded application.
    Sample Program 10: Dynamic SQL Method 4
    This program connects you to ORACLE using your username and
    password, then prompts you for a SQL statement. You can enter
    any legal SQL statement. Use regular SQL syntax, not embedded SQL.
    Your statement will be processed. If it is a query, the rows
    fetched are displayed.
    You can enter multi-line statements. The limit is 1023 characters.
    This sample program only processes up to MAX_ITEMS bind variables and
    MAX_ITEMS select-list items. MAX_ITEMS is #defined to be 40.
    #include <stdio.h>
    #include <string.h>
    #include <setjmp.h>
    #include <sqlda.h>
    #include <stdlib.h>
    #include <sqlcpr.h>
    /* Maximum number of select-list items or bind variables. */
    #define MAX_ITEMS 40
    /* Maximum lengths of the names of the
    select-list items or indicator variables. */
    #define MAX_VNAME_LEN 30
    #define MAX_INAME_LEN 30
    #ifndef NULL
    #define NULL 0
    #endif
    /* Prototypes */
    #if defined(__STDC__)
    void sql_error(void);
    int oracle_connect(void);
    int alloc_descriptors(int, int, int);
    int get_dyn_statement(void);
    void set_bind_variables(void);
    void process_select_list(void);
    void help(void);
    #else
    void sql_error(/*_ void _*/);
    int oracle_connect(/*_ void _*/);
    int alloc_descriptors(/*_ int, int, int _*/);
    int get_dyn_statement(/* void _*/);
    void set_bind_variables(/*_ void -*/);
    void process_select_list(/*_ void _*/);
    void help(/*_ void _*/);
    #endif
    char *dml_commands[] = {"SELECT", "select", "INSERT", "insert",
    "UPDATE", "update", "DELETE", "delete"};
    EXEC SQL INCLUDE sqlda;
    EXEC SQL INCLUDE sqlca;
    EXEC SQL BEGIN DECLARE SECTION;
    char dyn_statement[1024];
    EXEC SQL VAR dyn_statement IS STRING(1024);
    EXEC SQL END DECLARE SECTION;
    EXEC ORACLE OPTION (ORACA=YES);
    EXEC ORACLE OPTION (RELEASE_CURSOR=YES);
    SQLDA *bind_dp;
    SQLDA *select_dp;
    /* Define a buffer to hold longjmp state info. */
    jmp_buf jmp_continue;
    char *db_uid="dbmuser/dbmuser@dbmdb";
    sql_context ctx;
    int err_sql;
    enum{
    SQL_SUCC=0,
    SQL_ERR,
    SQL_NOTFOUND,
    SQL_UNIQUE,
    SQL_DISCONNECT,
    SQL_NOTNULL
    int main()
    int i;
    EXEC SQL ENABLE THREADS;
    EXEC SQL WHENEVER SQLERROR DO sql_error();
    EXEC SQL WHENEVER NOT FOUND DO sql_not_found();
    /* Connect to the database. */
    if (connect_database() < 0)
    exit(1);
    EXEC SQL CONTEXT USE :ctx;
    /* Process SQL statements. */
    for (;;)
    /* Allocate memory for the select and bind descriptors. */
    if (alloc_descriptors(MAX_ITEMS, MAX_VNAME_LEN, NAME_LEN) != 0)
    exit(1);
    (void) setjmp(jmp_continue);
    /* Get the statement. Break on "exit". */
    if (get_dyn_statement() != 0)
    break;
    EXEC SQL PREPARE S FROM :dyn_statement;
    EXEC SQL DECLARE C CURSOR FOR S;
    /* Set the bind variables for any placeholders in the
    SQL statement. */
    set_bind_variables();
    /* Open the cursor and execute the statement.
    * If the statement is not a query (SELECT), the
    * statement processing is completed after the
    * OPEN.
    EXEC SQL OPEN C USING DESCRIPTOR bind_dp;
    /* Call the function that processes the select-list.
    * If the statement is not a query, this function
    * just returns, doing nothing.
    process_select_list();
    /* Tell user how many rows processed. */
    for (i = 0; i < 8; i++)
    if (strncmp(dyn_statement, dml_commands, 6) == 0)
    printf("\n\n%d row%c processed.\n", sqlca.sqlerrd[2], sqlca.sqlerrd[2] == 1 ? '\0' : 's');
    break;
    /* Close the cursor. */
    EXEC SQL CLOSE C;
    /* When done, free the memory allocated for pointers in the bind and
    select descriptors. */
    for (i = 0; i < MAX_ITEMS; i++)
    if (bind_dp->V != (char *) 0)
    free(bind_dp->V);
    free(bind_dp->I); /* MAX_ITEMS were allocated. */
    if (select_dp->V != (char *) 0)
    free(select_dp->V);
    free(select_dp->I); /* MAX_ITEMS were allocated. */
    /* Free space used by the descriptors themselves. */
    SQLSQLDAFree(ctx, bind_dp);
    SQLSQLDAFree(ctx, select_dp);
    } /* end of for(;;) statement-processing loop */
    disconnect_database();
    EXEC SQL WHENEVER SQLERROR CONTINUE;
    EXEC SQL COMMIT WORK RELEASE;
    puts("\nHave a good day!\n");
    return;
    * Allocate the BIND and SELECT descriptors using sqlald().
    * Also allocate the pointers to indicator variables
    * in each descriptor. The pointers to the actual bind
    * variables and the select-list items are realloc'ed in
    * the set_bind_variables() or process_select_list()
    * routines. This routine allocates 1 byte for select_dp->V
    * and bind_dp->V, so the realloc will work correctly.
    alloc_descriptors(size, max_vname_len, max_iname_len)
    int size;
    int max_vname_len;
    int max_iname_len;
    int i;
    * The first sqlald parameter determines the maximum number of
    * array elements in each variable in the descriptor. In
    * other words, it determines the maximum number of bind
    * variables or select-list items in the SQL statement.
    * The second parameter determines the maximum length of
    * strings used to hold the names of select-list items
    * or placeholders. The maximum length of column
    * names in ORACLE is 30, but you can allocate more or less
    * as needed.
    * The third parameter determines the maximum length of
    * strings used to hold the names of any indicator
    * variables. To follow ORACLE standards, the maximum
    * length of these should be 30. But, you can allocate
    * more or less as needed.
    if ((bind_dp =
    SQLSQLDAAlloc(ctx, size, max_vname_len, max_iname_len)) ==
    (SQLDA *) 0)
    fprintf(stderr,
    "Cannot allocate memory for bind descriptor.");
    return -1; /* Have to exit in this case. */
    if ((select_dp =
    SQLSQLDAAlloc(ctx, size, max_vname_len, max_iname_len)) == (SQLDA *)
    0)
    fprintf(stderr,
    "Cannot allocate memory for select descriptor.");
    return -1;
    select_dp->N = MAX_ITEMS;
    /* Allocate the pointers to the indicator variables, and the
    actual data. */
    for (i = 0; i < MAX_ITEMS; i++) {
    bind_dp->I = (short *) malloc(sizeof (short));
    select_dp->I = (short *) malloc(sizeof(short));
    bind_dp->V = (char *) malloc(1);
    select_dp->V = (char *) malloc(1);
    return 0;
    int get_dyn_statement()
    char *cp, linebuf[256];
    int iter, plsql;
    for (plsql = 0, iter = 1; ;)
    if (iter == 1)
    printf("\nSQL> ");
    dyn_statement[0] = '\0';
    fgets(linebuf, sizeof linebuf, stdin);
    cp = strrchr(linebuf, '\n');
    if (cp && cp != linebuf)
    *cp = ' ';
    else if (cp == linebuf)
    continue;
    if ((strncmp(linebuf, "EXIT", 4) == 0) ||
    (strncmp(linebuf, "exit", 4) == 0))
    return -1;
    else if (linebuf[0] == '?' ||
    (strncmp(linebuf, "HELP", 4) == 0) ||
    (strncmp(linebuf, "help", 4) == 0))
    help();
    iter = 1;
    continue;
    if (strstr(linebuf, "BEGIN") ||
    (strstr(linebuf, "begin")))
    plsql = 1;
    strcat(dyn_statement, linebuf);
    if ((plsql && (cp = strrchr(dyn_statement, '/'))) ||
    (!plsql && (cp = strrchr(dyn_statement, ';'))))
    *cp = '\0';
    break;
    else
    iter++;
    printf("%3d ", iter);
    return 0;
    void set_bind_variables()
    int i, n;
    char bind_var[64];
    /* Describe any bind variables (input host variables) */
    EXEC SQL WHENEVER SQLERROR DO sql_error();
    bind_dp->N = MAX_ITEMS; /* Initialize count of array elements. */
    EXEC SQL DESCRIBE BIND VARIABLES FOR S INTO bind_dp;
    /* If F is negative, there were more bind variables
    than originally allocated by sqlald(). */
    if (bind_dp->F < 0)
    printf ("\nToo many bind variables (%d), maximum is %d\n.",
    -bind_dp->F, MAX_ITEMS);
    return;
    /* Set the maximum number of array elements in the
    descriptor to the number found. */
    bind_dp->N = bind_dp->F;
    /* Get the value of each bind variable as a
    * character string.
    * C contains the length of the bind variable
    * name used in the SQL statement.
    * S contains the actual name of the bind variable
    * used in the SQL statement.
    * L will contain the length of the data value
    * entered.
    * V will contain the address of the data value
    * entered.
    * T is always set to 1 because in this sample program
    * data values for all bind variables are entered
    * as character strings.
    * ORACLE converts to the table value from CHAR.
    * I will point to the indicator value, which is
    * set to -1 when the bind variable value is "null".
    for (i = 0; i < bind_dp->F; i++)
    printf ("\nEnter value for bind variable %.*s: ",
    (int)bind_dp->C, bind_dp->S);
    fgets(bind_var, sizeof bind_var, stdin);
    /* Get length and remove the new line character. */
    n = strlen(bind_var) - 1;
    /* Set it in the descriptor. */
    bind_dp->L = n;
    /* (re-)allocate the buffer for the value.
    sqlald() reserves a pointer location for
    V but does not allocate the full space for
    the pointer. */
    bind_dp->V = (char *) realloc(bind_dp->V, (bind_dp->L + 1));
    /* And copy it in. */
    strncpy(bind_dp->V, bind_var, n);
    /* Set the indicator variable's value. */
    if ((strncmp(bind_dp->V, "NULL", 4) == 0) ||
    (strncmp(bind_dp->V, "null", 4) == 0))
    *bind_dp->I = -1;
    else
    *bind_dp->I = 0;
    /* Set the bind datatype to 1 for CHAR. */
    bind_dp->T = 1;
    return;
    void process_select_list()
    int i, null_ok, precision, scale;
    if ((strncmp(dyn_statement, "SELECT", 6) != 0) &&
    (strncmp(dyn_statement, "select", 6) != 0))
    select_dp->F = 0;
    return;
    /* If the SQL statement is a SELECT, describe the
    select-list items. The DESCRIBE function returns
    their names, datatypes, lengths (including precision
    and scale), and NULL/NOT NULL statuses. */
    select_dp->N = MAX_ITEMS;
    EXEC SQL DESCRIBE SELECT LIST FOR S INTO select_dp;
    /* If F is negative, there were more select-list
    items than originally allocated by sqlald(). */
    if (select_dp->F < 0)
    printf ("\nToo many select-list items (%d), maximum is %d\n",
    -(select_dp->F), MAX_ITEMS);
    return;
    /* Set the maximum number of array elements in the
    descriptor to the number found. */
    select_dp->N = select_dp->F;
    /* Allocate storage for each select-list item.
    sqlprc() is used to extract precision and scale
    from the length (select_dp->L).
    sqlnul() is used to reset the high-order bit of
    the datatype and to check whether the column
    is NOT NULL.
    CHAR datatypes have length, but zero precision and
    scale. The length is defined at CREATE time.
    NUMBER datatypes have precision and scale only if
    defined at CREATE time. If the column
    definition was just NUMBER, the precision
    and scale are zero, and you must allocate
    the required maximum length.
    DATE datatypes return a length of 7 if the default
    format is used. This should be increased to
    9 to store the actual date character string.
    If you use the TO_CHAR function, the maximum
    length could be 75, but will probably be less
    (you can see the effects of this in SQL*Plus).
    ROWID datatype always returns a fixed length of 18 if
    coerced to CHAR.
    LONG and
    LONG RAW datatypes return a length of 0 (zero),
    so you need to set a maximum. In this example,
    it is 240 characters.
    printf ("\n");
    for (i = 0; i < select_dp->F; i++)
    char title[MAX_VNAME_LEN];
    /* Turn off high-order bit of datatype (in this example,
    it does not matter if the column is NOT NULL). */
    sqlnul ((unsigned short *)&(select_dp->T), (unsigned short
    *)&(select_dp->T), &null_ok);
    switch (select_dp->T)
    case 1 : /* CHAR datatype: no change in length
    needed, except possibly for TO_CHAR
    conversions (not handled here). */
    break;
    case 2 : /* NUMBER datatype: use sqlprc() to
    extract precision and scale. */
    sqlprc ((unsigned int *)&(select_dp->L), &precision,
    &scale);
    /* Allow for maximum size of NUMBER. */
    if (precision == 0) precision = 40;
    /* Also allow for decimal point and
    possible sign. */
    /* convert NUMBER datatype to FLOAT if scale > 0,
    INT otherwise. */
    if (scale > 0)
    select_dp->L = sizeof(float);
    else
    select_dp->L = sizeof(int);
    break;
    case 8 : /* LONG datatype */
    select_dp->L = 240;
    break;
    case 11 : /* ROWID datatype */
    case 104 : /* Universal ROWID datatype */
    select_dp->L = 18;
    break;
    case 12 : /* DATE datatype */
    select_dp->L = 9;
    break;
    case 23 : /* RAW datatype */
    break;
    case 24 : /* LONG RAW datatype */
    select_dp->L = 240;
    break;
    /* Allocate space for the select-list data values.
    sqlald() reserves a pointer location for
    V but does not allocate the full space for
    the pointer. */
    if (select_dp->T != 2)
    select_dp->V = (char *) realloc(select_dp->V,
    select_dp->L + 1);
    else
    select_dp->V = (char *) realloc(select_dp->V,
    select_dp->L);
    /* Print column headings, right-justifying number
    column headings. */
    /* Copy to temporary buffer in case name is null-terminated */
    memset(title, ' ', MAX_VNAME_LEN);
    strncpy(title, select_dp->S, select_dp->C);
    if (select_dp->T == 2)
    if (scale > 0)
    printf ("%.*s ", select_dp->L+3, title);
    else
    printf ("%.*s ", select_dp->L, title);
    else
    printf("%-.*s ", select_dp->L, title);
    /* Coerce ALL datatypes except for LONG RAW and NUMBER to
    character. */
    if (select_dp->T != 24 && select_dp->T != 2)
    select_dp->T = 1;
    /* Coerce the datatypes of NUMBERs to float or int depending on
    the scale. */
    if (select_dp->T == 2)
    if (scale > 0)
    select_dp->T = 4; /* float */
    else
    select_dp->T = 3; /* int */
    printf ("\n\n");
    /* FETCH each row selected and print the column values. */
    EXEC SQL WHENEVER NOT FOUND GOTO end_select_loop;
    for (;;)
    EXEC SQL FETCH C USING DESCRIPTOR select_dp;
    /* Since each variable returned has been coerced to a
    character string, int, or float very little processing
    is required here. This routine just prints out the
    values on the terminal. */
    for (i = 0; i < select_dp->F; i++)
    if (*select_dp->I < 0)
    if (select_dp->T == 4)
    printf ("%-*c ",(int)select_dp->L+3, ' ');
    else
    printf ("%-*c ",(int)select_dp->L, ' ');
    else
    if (select_dp->T == 3) /* int datatype */
    printf ("%*d ", (int)select_dp->L,
    *(int *)select_dp->V);
    else if (select_dp->T == 4) /* float datatype */
    printf ("%*.2f ", (int)select_dp->L,
    *(float *)select_dp->V);
    else /* character string */
    printf ("%-*.*s ", (int)select_dp->L,
    (int)select_dp->L, select_dp->V);
    printf ("\n");
    end_select_loop:
    return;
    void help()
    puts("\n\nEnter a SQL statement or a PL/SQL block at the SQL> prompt.");
    puts("Statements can be continued over several lines, except");
    puts("within string literals.");
    puts("Terminate a SQL statement with a semicolon.");
    puts("Terminate a PL/SQL block (which can contain embedded
    semicolons)");
    puts("with a slash (/).");
    puts("Typing \"exit\" (no semicolon needed) exits the program.");
    puts("You typed \"?\" or \"help\" to get this message.\n\n");
    int connect_database()
    err_sql = SQL_SUCC;
    EXEC SQL WHENEVER SQLERROR DO sql_error();
    EXEC SQL WHENEVER NOT FOUND DO sql_not_found();
    EXEC SQL CONTEXT ALLOCATE :ctx;
    EXEC SQL CONTEXT USE :ctx;
    EXEC SQL CONNECT :db_uid;
    if(err_sql != SQL_SUCC){
    printf("err => connect database(ctx:%ld, uid:%s) failed!\n", ctx, db_uid);
    return -1;
    return 1;
    int disconnect_database()
    err_sql = SQL_SUCC;
    EXEC SQL WHENEVER SQLERROR DO sql_error();
    EXEC SQL WHENEVER NOT FOUND DO sql_not_found();
    EXEC SQL CONTEXT USE :ctx;
    EXEC SQL COMMIT WORK RELEASE;
    EXEC SQL CONTEXT FREE:ctx;
    return 1;
    void sql_error()
    printf("err => %.*s", sqlca.sqlerrm.sqlerrml, sqlca.sqlerrm.sqlerrmc);
    printf("in \"%.*s...\'\n", oraca.orastxt.orastxtl, oraca.orastxt.orastxtc);
    printf("on line %d of %.*s.\n\n", oraca.oraslnr, oraca.orasfnm.orasfnml,
    oraca.orasfnm.orasfnmc);
    switch(sqlca.sqlcode) {
    case -1: /* unique constraint violated */
    err_sql = SQL_UNIQUE;
    break;
    case -1012: /* not logged on */
    case -1089:
    case -3133:
    case -1041:
    case -3114:
    case -3113:
    /* �6�Ŭ�� shutdown�ǰų� �α��� ���°� �ƴҶ� ��b�� �õ� */
    /* immediate shutdown in progress - no operations are permitted */
    /* end-of-file on communication channel */
    /* internal error. hostdef extension doesn't exist */
    err_sql = SQL_DISCONNECT;
    break;
    case -1400:
    err_sql = SQL_NOTNULL;
    break;
    default:
    err_sql = SQL_ERR;
    break;
    EXEC SQL CONTEXT USE :ctx;
    EXEC SQL WHENEVER SQLERROR CONTINUE;
    EXEC SQL ROLLBACK WORK;
    void sql_not_found()
    err_sql = SQL_NOTFOUND;

    Hi Jane,
    What version of Berkeley DB XML are you using?
    What is your operating system and your hardware platform?
    For how long have been the application running?
    What is your current container size?
    What's set for EnvironmentConfig.setThreaded?
    Do you know if containers have previously not been closed correctly?
    Can you please post the entire error output?
    What's the JDK version, 1.4 or 1.5?
    Thanks,
    Bogdan

  • Why multiple  log files are created while using transaction in berkeley db

    we are using berkeleydb java edition db base api, we have already read/write CDRFile of 9 lack rows with transaction and
    without transaction implementing secondary database concept the issues we are getting are as follows:-
    with transaction----------size of database environment 1.63gb which is due to no. of log files created each of 10 mb.
    without transaction-------size of database environment 588mb and here only one log file is created which is of 10mb. so we want to know how REASON CONCRETE CONCLUSION ..
    how log files are created and what is meant of using transaction and not using transaction in db environment and what are this db files db.001,db.002,_db.003,_db.004,__db.005 and log files like log.0000000001.....plz reply soon

    we are using berkeleydb java edition db base api, If you are seeing __db.NNN files in your environment root directory, these are environment's shared region files. And since you see these you are using Berkeley DB Core (with the Java/JNI Base API), not Berkeley DB Java Edition.
    with transaction ...
    without transaction ...First of all, do you need transactions or not? Review the documentation section called "Why transactions?" in the Berkeley DB Programmer's Reference Guide.
    without transaction-------size of database environment 588mb and here only one log file is created which is of 10mb.There should be no logs created when transactions are not used. That single log file has likely remained there from the previous transactional run.
    how log files are created and what is meant of using transaction and not using transaction in db environment and what are this db files db.001,db.002,_db.003,_db.004,__db.005 and log files like log.0000000001Have you reviewed the basic documentations references for Berkeley DB Core?
    - Berkeley DB Programmer's Reference Guide
    in particular sections: The Berkeley DB products, Shared memory regions, Chapter 11. Berkeley DB Transactional Data Store Applications, Chapter 17. The Logging Subsystem.
    - Getting Started with Berkeley DB (Java API Guide) and Getting Started with Berkeley DB Transaction Processing (Java API Guide).
    If so, you would have had the answers to these questions; the __db.NNN files are the environment shared region files needed by the environment's subsystems (transaction, locking, logging, memory pool buffer, mutexes), and the log.MMMMMMMMMM are the log files needed for recoverability and created when running with transactions.
    --Andrei                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • Error while creating logical file using transaction FILE

    Hello there,
    I am facing an error while creating Logical File name definition using transaction FILE
    This is the input which I'm trying to give
    Logical file name: ZTEST
    Name : ZTEST
    Physical file : ZTEST_1<DATE><TIME>.csv
    Data format: ASC
    Application area: BW
    Logical path:ZTEST_1_DATAOUT
    when I tried to save it throws me an error like  ASSIGN_SUBSTRING_NOT_ALLOWED
    Please help.

    Hi,
    Please check the OSS Notes :
    Note 792061 - SP Case Locator: Dump: ASSIGN to a substring isn't allowed.
    SAP Note 1297989 - Short dump ASSIGN_SUBSTRING_NOT_ALLOWED
    Hope this solves the problem.
    -Vikram

  • Can I create a file using pl/sql code in application server ?

    Hi
    I wanted to create a file(any kind of file .txt .csv .exe etc..) using pl/sql code in application server?
    Please help me with an example...in this regard
    Regards
    Sa

    864334 wrote:
    I wanted to create a file(any kind of file .txt .csv .exe etc..) using pl/sql code in application server?And how is this "file" to be delivered?
    Files can be created by PL/SQL code and stored in the Oracle database as CLOBs. This a fairly easy and robust process. It runs entirely in the database. It conforms to transaction processing. The "file" (as a CLOB) resides in the database and can thus be secured via database security, is part of database backups and so on.
    The basic issue is how to deliver the contents of the CLOB to the user. If via FTP, then the database can directly FTP the contents of the CLOB to the FTP server as a file. If via HTTP, the database can deliver the CLOB as a HTTP download directly to the web browser.
    If the client is Java or .Net, then the CLOB contents can be delivered via SQL or DBMS_LOB or a custom PL/SQL interface.
    In such cases, there is no need to step outside the secure and flexible database environment and create a physical o/s file in the wild (outside the controls of database security, data integrity and transaction processing). This is thus recommended and is the preference.

  • Query on using Collection object in Multithreading

    All,
    I have a query on multithreading, I have a collection object-eg. HashMap which needs to be shared
    among threads, I my have 3 options
    1st option is to synchronize the method which does some manipulation on the collection object,
    2nd option is to hold a lock on that object like
    synchronized(object){
    //do some work
    3rd option - to make use of class ConcurrentHashMap available in java.util.concurrent package; which claims to be
    Thread safe but also says the following in the API - They do not throw ConcurrentModificationException. However,
    iterators are designed to be used by only one thread at a time
    My queston is - how do I choose between these 3?
    I know the decison needs to be taken by keeping performance issue in mind and also the number of times the values in HashMap will be updated by the threads. Can some one explain to me when/under what circumstances do I use options 1 || 2 || 3

    My application has actually gone live now - after doing some load/performance testing
    and comming to the conclusion that performance is satisfactory [I am designing a SMS gateway
    that receives/buffers/stores/sends SMS]
    Initially I used Hashmap and a LinkedList to store objects in memory and I had a mixture
    of places where some times I made the entire method that modifies the LinkedList & hashmap
    synchronized and some places where I held a lock on the object alone (I wasnt too sure which to use where)
    Then upon movin to 1.5 I rechanged the the data structure to use ConcurrentLinkedQueue & ConcurrenthashMap.
    But i have places where I still hold synchronized locks over those objects (which i think is unnecessary and removing the locks may improve the performance)
    So can i come to the conclusion that classes in java.util.concurrent are all threadsafe and we can stop holding locks on the objects and let java take care of itself [or should I still hold a lock when doing structural modification] [though the APi states that a oncurrentmodificationexception will not be thrown & iterators are designed to be used by only one thread at a time]

  • Using transaction launcher to connect CRM 7.0 to a CRM 6.0 system

    Hello Experts,
    We are considering integrating two IC Web client applications one on CRM 6.0 and the other on CRM 7.0 as transition step before the two systems are fully integrated.
    We would like to create a transaction launcher transaction in CRM 7.0 that takes the user to Interaction History bsp page in CRM 6.0.  Is there a simple way to do this using transaction launcher?
    Best Regards,
    Tom Halloran

    Hi,
    You can use the transaction launcher and the transaction launcher profile, which is part of the IC WebClient profile, to start SAP GUI for HTML transactions via the Internet Transaction Server (ITS) from both Enterprise R/3, SAP CRM transactions from SAP CRM. Starting from CRM 4.0 Add-on, you can use transaction launcher to launch URL and front-office based transactions also.
    Agents have access to launch transactions from the IC WebClient navigation bar.
    In your case you can include the link for you CRM 6.0 from CRM 7.0 can be grouped under workcenter link group or direct link group of a navbarprofile.
    regards,
    Muralidhar Prasad.C

  • JDev 9.0.3.3 Commit issue when using Transaction DataSource

    Hi,
    Env: JDev 9.0.3.3/WL 6.0 sp1/Oracle 8i
    We have successfully deployed our application in 3-tier(remote mode) in JDev 9.0.3.2. using JClient, EO/VO, EJB Session Facade (BMT).
    Now we are planning to use JDev 9.0.3.3
    In JDev 9033 with the same code base we have issues after Commit.
    We are using ejb.txn.type=global (default) and Weblogic Transactional DataSource. It gives following error after Committing and when we navigate to some other row:
    =====================================================
    [690] BaseSQLBuilder Executing DML ... (Update)
    [691] Executing DML...
    [692] UPDATE CISDBA.DCX_X_SAVED_SEARCH SavedSearch SET DCX_MODEL_YEAR=?,DCX_USAGE_VEHICLE_FAMILY=?,DCX_END_ITEMS=?,DCX_RECORD_STATUS=? WHERE DCX_ID=?
    [693] cStmt = conn.prepareCall(" UPDATE CISDBA.DCX_X_SAVED_SEARCH SavedSearch SET DCX_MODEL_YEAR=?,DCX_USAGE_VEHICLE_FAMILY=?,DCX_END_ITEMS=?,DCX_RECORD_STATUS=? WHERE DCX_ID=?"); // JBO-JDBC-INTERACT
    [694] cStmt.setObject(1, "2004"); /*DcxModelYear*/ // JBO-JDBC-INTERACT
    [695] cStmt.setObject(2, "LX"); /*DcxUsageVehicleFamily*/ // JBO-JDBC-INTERACT
    [696] cStmt.setObject(3, "All"); /*DcxEndItems*/ // JBO-JDBC-INTERACT
    [697] cStmt.setObject(4, "All"); /*DcxRecordStatus*/ // JBO-JDBC-INTERACT
    [698] // ERROR: Unknown data type java.lang.Long // JBO-JDBC-INTERACT
    [699] cStmt.setObject(5, "206"); /*DcxId*/ // JBO-JDBC-INTERACT
    [700] cStmt.execute(); // JBO-JDBC-INTERACT
    [701] cStmt.close(); // JBO-JDBC-INTERACT
    BaseCostInvestCost VO before postChanges...
    this.getWhereClause(): null
    isDirty() before executeQuery...
    this.getWhereClause(): null
    isDirty() after executeQuery...
    BaseCostInvestCost VO before postChanges...
    this.getWhereClause(): null
    isDirty() before executeQuery...
    this.getWhereClause(): null
    isDirty() after executeQuery...
    [702] BaseSQLBuilder: releaseSavepoint 'BO_SP' ignored
    [703] BaseSQLBuilder: setSavepoint 'BO_SP' ignored
    BaseCostInvestCost VO before postChanges...
    this.getWhereClause(): null
    isDirty() before executeQuery...
    this.getWhereClause(): null
    isDirty() after executeQuery...
    BaseCostInvestCost VO before postChanges...
    this.getWhereClause(): null
    isDirty() before executeQuery...
    this.getWhereClause(): null
    isDirty() after executeQuery...
    [704] BaseSQLBuilder: releaseSavepoint 'BO_SP' ignored
    [705] EJBTxnHandler: Commited txn
    [706] BaseCostInvestCostView2 notify COMMIT ...
    [707] BaseCostInvestCostView1 notify COMMIT ...
    [708] StdCostView1 notify COMMIT ...
    [709] AltCostView1 notify COMMIT ...
    [710] PaperCarView1 notify COMMIT ...
    [711] InvestCostItemView1 notify COMMIT ...
    [712] SavedSearchView1 notify COMMIT ...
    [713] AltCostView1_BaseInvestToAltViewLink_AltCostView notify COMMIT ...
    [714] InvestCostItemView1_BaseInvestToInvestItemViewLink_InvestCostItemView notify COMMIT ...
    [715] PaperCarView_BaseCostTrackedVehicleViewLink_PaperCarView notify COMMIT ...
    [716] VehicleProgramLOV1 notify COMMIT ...
    [717] SubDeptLOV1 notify COMMIT ...
    [718] Transaction timeout set to 28800 secs
    [719] Column count: 14
    [720] ViewObject : Reusing defined prepared Statement
    [721] QueryCollection.executeQuery failed...
    [722] java.sql.SQLException: The transaction is no longer active (status = Committed). No further JDBC access is allowed within this transaction.
         void weblogic.jdbcbase.jts.Connection.checkIfRolledBack()
              Connection.java:468
         void weblogic.jdbcbase.jts.Statement.setMaxRows(int)
              Statement.java:179
         void weblogic.jdbc.rmi.internal.StatementImpl.setMaxRows(int)
              StatementImpl.java:82
         void weblogic.jdbc.rmi.SerialStatement.setMaxRows(int)
              SerialStatement.java:132
         void oracle.jbo.server.QueryCollection.executeQuery(java.lang.Object[], int)
              QueryCollection.java:534
         void
    ===================================================

    Hi Carsten,
    I tried to reproduce your problem, but couldn't. Let me explain what steps I executed and perhaps you can advise where I've not matched your steps.
    --Using build jdeveloper 9.0.3.3.1203, I built a new bc4j project containing a dept-emp default bc4j project (deptEntity, empEntity, deptView, empView, deptempFKAssoc, deptempFKViewLink, ApplicationModule).
    --In dos shell, I went to the directory \jdevdir\jdev\bin and ran setvars -go to set the correct jdk version
    --In the dos shell, in the directory \jdevdir\j2ee\home I executed the following command to install oc4j:
    java -jar oc4j.jar (defaults pswd to welcome for admin)
    --I remoted the appmodule to EJB Session Bean (BMT) and created a new deployment profile using the 9ias configuration for the application module.
    --I deployed the bc4j objects to oc4j
    --I created a new project
    --In this project I created a new jclient master-detail form using the above project's application module for the data model
    --I saved all and compiled the jclient project
    --I ran the jclient form and inserted a master record
    --I committed the transaction successfully
    --I browsed records, then edited a record
    --I committed the transaction successfully, then browsed.
    Is there something I've missed? Did you migrate your project and not start by creating a new project? Is there something special about the database schema you are using?
    Thanks,
    Amy

  • Dup2 after fork in multithreaded application

    I am working on a multithreaded application (C++) that must create several
    Java processes and capture their output though pipes.
    For a single threaded application, I know it is possible to call dup2 (in the child)
    after the fork to set up the proper connections.
    I am aware that it is not safe to make particular function calls between a fork
    and an exec. Is dup2 a call that is known to be safe?
    If not, is there a better alternative?
    Thanks.

    I'm using Oracle 10g2 on Windows Server 2003 on a Dell PowerEdge 1850 server.
    Both threads run the same code. Each thread performs multiple database queries though.
    This query is performed first:
    update my_table set my_data_processed='true' where my_data_processed='false' and rownum=1 returning my_index into :x
    Then the query with the getBlob is performed with <some_number> = my_index.
    Some background info: I have a lot of data in my_table that needs a very slow operation performed on the my_data blob in each row. I will eventually run this application on multiple servers in parallel and need a way to determine the next row that hasn't been processed yet then process it.
    The table is
    create table my_table (
    my_index int,
    my_data_processed varchar(10),
    my_data blob
    -Glen

Maybe you are looking for

  • How do I use a precompiled dylib in my xcode project?

    Hello all you brainiacs out there! I want to use mongoDB as my database for my iPhone projects. I have compiled their code, with instructions from http://api.mongodb.org/c/current/building.html... successfully. I ran all the tests, successfully. I ha

  • Custom code after creating a new user via CUA

    Hi experts! In our landscape we are using CUA for adding users in CRM 7.0. A new requirement is to adjust some default Web UI related settings for every new user created. There is no standard customizing setting for that, but it is possible to progra

  • How do i update an iPhone 3G (without the S) with IOS 4.2.1 to 4.3

    Itunes says the phone is up-to-date and wont update to latest 4.3 build. Alternatively, can I reverse the XCode native support I apparently got for 4.3  to support my 4.2.1 iPhone to allow me to test applications built in XCode? Also Xcode doesn't al

  • 'missing xobject' in simple test file

    I get a 'missing Xobject Im1' error when I try to read the test PDF file below, using Acrobat 8.1.3 (and others), but it works when I read it with Ghostscript. Why is this? Regards, Terry %PDF-1.7 1 0 obj << /Type /Catalog /Outlines 2 0 R /Pages 3 0

  • GRC 10 PC Integration with AC

    Hello Experts, I have a following scenario where in i have to map Mitigation controls of AC to one of the controls/Control objective in Process controls. Is it possible to do this kind of integration in GRC 10? If yes, Is there any configurable setti