Binding an array of integers using OCI for WHERE IN clause

Is it possible to bind lists of integers using OCIBindByPos(), for use with a WHERE IN clause?
In our application, we very often have statements like this:
SELECT ...
WHERE col1 IN (3, 54, 65, 76, 112, 232, 343)where the number of integers in the list is variable.
These lists sometimes can become very large (several thousands of entries); Oracle ADDM then indicates that these statements are hard to parse and recommends to use bind variables instead.
Is is possible to change the statement into something like
SELECT ...
WHERE col1 IN (:1)and to bind the integer list using OCIBindByPos()?
Or is there an even better way to do this? (Please note: the integer list is not the result of a previous SELECT statement, i.e. we cannot use joins or subqueries here.)
Regards
- Frank

Turns out it's possible after all, albeit not quite written in the most obvious way.
See Re: Binding collection to right-hand-side of WHERE num_col in (:1) clause? for details.

Similar Messages

  • Removing Outer Single Quotes for WHERE IN Clause from Join(Parameters)

    Hello,
    I am passing a multi-valued parameter into a dataset from a TypeBusiness dropdown list:
    =join(Parameters!prmTypeBusiness.Value,",")
    Here is the dataset query behind the TypeBusiness dropdown parameter list:
    SELECT     type_bus_code, bus_desc
    FROM       business
    WHERE     (type_bus_code IS NOT NULL)
    Here is the WHERE clause from the main dataset query (dsMainData) which gets the parameter values:
    WHERE  WEKAVG.BUSINESS_CODE IN(@prmTypeBusiness) 
    Here is the error I get when selecting values from the TypeBusiness dropdown list then previewing the report:
    "Cannot read the next data row for the dataset dsMainData.
    Conversion failed when converting the nvarchar value '1,2' to data type smallint."
    The value is a small int coming from the dataset query behind the TypeBusiness dropdown list, and the data type in the column expecting this value (in the main dataset query) is also a small int.
    I have tried many things, including a replace in the =join(Parameters!prmTypeBusiness.Value,","), a replace in the WHERE clause, a Split function, CAST to varchar, have researched this online and cannot solve this error.
    If someone could please help me save what little gray hairs I have left I would greatly appreciate any help, suggestion or point in the right direction.
    Thanks,
    Buster

    Thank you for the sample, but it returns no records. Is there something I need to change in this snippet you sent?
    DECLARE @prmTypeBusiness VARCHAR(20) = '1,2,4' -- say selected parameter values
    DECLARE @business TABLE (type_bus_code INT, bus_desc VARCHAR(20))
    INSERT @business SELECT 1,'A'
    INSERT @business SELECT 2,'B'
    INSERT @business SELECT 3,'C'
    INSERT @business SELECT 4,'D'
    ;WITH CTE1
    AS
    SELECT CAST(('<i><j>' + REPLACE(@prmTypeBusiness, ',', '</j></i><i><j>') + '</j></i>' ) AS XML) CSV
    ),CTE2
    AS
    SELECT CAST(i.query('./text()') AS VARCHAR(100))CSV
    FROM CTE1
    CROSS APPLY CSV.nodes('/i/j') As x(i)
    SELECT type_bus_code,
    bus_desc
    FROM @business
    WHERE type_bus_code IN (SELECT * FROM CTE2)
    sathya - www.allaboutmssql.com ** Mark as answered if my post solved your problem and Vote as helpful if my post was useful **.

  • Is OCI for 24/7 applications?

    We are using OCI for interfacing to Oracle. Recently we found that there were some memory leaks in the application. On debugging, most of the leaks could be traced to OCI calls.
    Is OCI designed to be executed for this type of applications?
    -- KD
    null

    If there are memory leaks, you may be able to find a workaround, but that's generally not too fun.
    In 99% of the cases I've seen users run into memory leaks with OCI, the leaks have been fixed in the latest patchkit. Since almost all the Oracle client components use OCI, memory leaks generally get identified and fixed reasonably quickly.
    Note that the patchkits have to be installed on the Oracle client machine, not on the database, to fix OCI issues. Double-check that your DBA is installing them on both client & server machines.
    Justin

  • How to bind arrays to PL/SQL stored procedure using OCI?

    Hi,
    We are having problems trying to bind arrays to PL/SQL stored procedure using OCI. Here is the situation:
    - We have a stored procedure called "GetVEPFindTasks" with the following interface:
    PROCEDURE GetVEPFindTasks (
    p_ErrorCode OUT NUMBER,
    p_ErrorMsg OUT VARCHAR2,
    p_RowCount OUT NUMBER,
    p_VEPFindTasks OUT t_VEPFindTaskRecordTable,
    p_MaxTask IN NUMBER);
    t_VEPFindTaskRecordTable is a record with the following entries:
    TYPE t_VEPFindTaskRecord IS RECORD (
    RTCID NUMBER,
    TransNum NUMBER,
    TransTimestamp VARCHAR2(20),
    Pathname1 image_data.pathname%TYPE,
    Pathname2 image_data.pathname%TYPE,
    Pathname3 image_data.pathname%TYPE,
    OperatorID operator.id%TYPE);
    - Now, we are trying to call the stored procedure from C++ using OCI (in UNIX). The call that we use are: OCIBindByName and OCIBindArrayOfStruct to bind the parameters to the corresponding buffers. We bind all parameters in the interface by name. Now, we do bind the record's individual item by name (RTCID, TransNum, etc.), and not as a record. I don't know if this is going to work. Then, we use the bind handles of the binded record items (only record items such as RTCID, TransNum, and NOT error_code which is not part of the record) to bind the arrays (using OCIBindArrayOfStruct).
    All of the parameters that are binded as arrays are OUTPUT parameters. The rest are either INPUT or INPUT/OUTPUT parameters. Now, when we try to execute, OCI returns with an error "Invalid number or types of arguments" (or something to that sort... the number was something like ORA-06550). Please help...
    Is there any sample on how to use the OCIBindArrayOfStruct with PL/SQL stored procedures? The sample provided from Oracle is only for a straight SQL statement.
    Thank's for all your help.
    ** Dannil Chan **

    As you said:
    You have to pass in an array for every field and deconstruct/construct the record in the procedure. There is no support for record type or an array of records. Can you give me a example? I'am very urgently need it.
    thanks
    email: [email protected]

  • Best way of saving an array of integers to use later?

    I am having trouble figuring out where to initialize an array of integers so it is available everywhere. It's just a simple array of integers to be used as indices into another array. So I figured an ordinary C array like this is sufficient:
    int arrayOfIndices[] = {3, 11, 12, 25, 26, 43, 50, 53, 58, 59, 62, 76, 77, 81, 94, 95, 110, 113, 114, 117, 118, 123, 136, 152};
    It's ok to just use an ordinary C array for this, right? It seems that it is much harder to initialize a similar NSArray of integers. Or is there an easy way to do that?
    One problem I'm having is I'm having trouble figure out where to stick the above array so that it is usable through the program. With my NSArray objects I've been defining them in the interface, then initializing them in viewDidLoad with retain.
    Is there something analogous I can do with ordinary C int arrays? Or, alternatively, an easy way to initialize an NSArray of integers so I can deal with them like I do with other NSArrays?
    Thanks,
    doug

    Never mind. It looks like just not putting anything in the interface file and sticking the definition of the C int array at the top of my implementation file where I import files and define some other stuff works fine.
    doug

  • Using a For loop to call one array element at a time

    I have been working on a VI that reads a GPS unit, parses the data, outputs what I need, compares the actual GPS location to the desired location, determines a desired heading and moves on from there.  My question pertains to the number of desired locations I can input right now.  I need to be able to input a predtermined number of locations (not just the one that I can input right now).  I was told that it is possible to use a For Loop with an array and have the first set of Lat and Long values run through the VI and when everything is complete that the next set of values will be chosen.  Does this mean that I need to put the entire VI inside a For Loop and have the array update as soon as the VI has completed its first mission?  I understand the concept of how this work from other programming languages but I'm not sure how to implement the solution in LabVIEW.  Any help would be appreciated.
    Adam

    adamoutlaw wrote:
    Here is a portion of the VI.  I need two separate arrays, one for Latitude and one for Longitude, of the same size.
    I don't see any arrays in your code. Do you want to generate arrays form individual data points or do you want to process arrays, one element at a time? Both can take advantage of autoindexing. Here's a simple picture.
    Your VI contains a weird mix of DBL and EXT precision. Most likely all you need is DBL. Keep your representations consistent!
    Message Edited by altenbach on 08-02-2007 07:14 AM
    LabVIEW Champion . Do more with less code and in less time .
    Attachments:
    Indexing.png ‏4 KB

  • LOG Q0I= NiIBindSocket: bind (98: Address already in use) [nixxi.cpp 3740] [Thr 140207008876384] *** ERROR = NiIBindSocket: SiBind failed for hdl 17/sock 7

    Dear All ,
    I am installing SAP Netveiwer 7.2 with oracle 11 g database in suse linux 11  but i am getting one error in Start instance phase , my message server is not getting connected , when i am trying to start manually  then my instance is connected but in this phase sap check message server is up or not , here i am attaching log of message server where i am getting error  , if any buddy knw Plz help me ....
    log file -
    trc file: "dev_ms.new", trc level: 1, release: "720"
    [Thr 140207008876384] Tue Jun 10 01:34:56 2014
    [Thr 140207008876384] ms/http_max_clients = 500 -> 500
    [Thr 140207008876384] MsSSetTrcLog: trc logging active, max size = 52428800 bytes
    systemid   390 (AMD/Intel x86_64 with Linux)
    relno      7200
    patchlevel 0
    patchno    413
    intno      20020600
    make       multithreaded, Unicode, 64 bit, optimized
    pid        7294
    [Thr 140207008876384] ***LOG Q01=> MsSInit, MSStart (Msg Server 1 7294) [msxxserv_mt. 2280]
    [Thr 140207008876384] SigISetDefaultAction : default handling for signal SIGCHLD
    [Thr 140207008876384] ***LOG Q0I=> NiIBindSocket: bind (98: Address already in use) [nixxi.cpp 3740]
    [Thr 140207008876384] *** ERROR => NiIBindSocket: SiBind failed for hdl 17/sock 7
        (SI_EPORT_INUSE/98; I4; ST; 0.0.0.0:3601) [nixxi.cpp    3740]
    [Thr 140207008876384] *** ERROR => MsSCommInit: NiBufListen(sapmsINI) (rc=NIESERV_USED) [msxxserv_mt. 12225]
    [Thr 140207008876384] *** ERROR => MsSInit: MsSCommInit [msxxserv_mt. 2324]
    [Thr 140207008876384] *** ERROR => MsSInit failed, see dev_ms.new for details
    [msxxserv_mt. 7572]
    [Thr 140207008876384] ***LOG Q02=> MsSHalt, MSStop (Msg Server 7294) [msxxserv_mt. 7631]

    Hello Shyam,
    I don't see how updating the kernel would help in this case.
    If the port was already in use, any kernel version would give the same error.
    Hello Arpit,
    Since this is a Linux server, you can also run "lsof -nP|grep 3601" (may need to be logged on as "root"). This should give you more details than "netstat" (e.g., it will give you the PID of the process that's already using the port).
    The solution has already being pointed on this thread. You need to find out which process is using the port, and stop this other process.
    Cheers,
    Isaías

  • Transposing data in an array using a For Loop

    I am trying to transpose some data in an array using a  for loop starting from the size of the array then decrement down to 0. Can someone please help if you have an example?
    Solved!
    Go to Solution.

    I feel as if reverse 1D array may help
    Edit: misunderstood what your second post meant.
    CLA, LabVIEW Versions 2010-2013

  • Using a For Loop Index for Array Element Number?

    Hi.  Thanks in advance for the help.  I can't seem to find what I want to do here using the search function... probably because I don't know how to frame the question appropriately.  Ignore the title to this post cause it's probably wrong vocabulary for what I want to do.
    Here's the situation:
    I have a 2D array where the first column is the X data and each subsequent column is Y data (call it Y1...Yn).  The n-value varies from run to run (some runs have 4 columns of data, some have 20), but that is easily gathered when reading the data file.  I need to perform a number of operations on each set of data, the least of which is smoothing the data and graphing it, so I'm limiting my discussion to these 2 operations.
    What I want is a for loop structure where the indexing of the loop tracks the Y1...Yn columns, grabs each column for the iteration, performs the relevant analysis, and spits out the result, but in a stackable manner.  Thus the title; I want to use the for loop's index to mark the array element for building a new array.
    See the image attached.  A 2D array of 9 columns (X, Y1...Y8) is analyzed such that each data set, (X, Y1), (X, Y2)...(X, Y8) is bundled, graphed, run through a B-spline Fit, of which is also graphed.  I need to replace this with something that looks like the for loop structure shown.  
    I just don't know how to get those two data bundles [(X, Yi) and it's smoothed pair] out of the for loop in a stacked set from every iteration of the for loop.
    Again the title, I think I want to build a new array where i use the index of the for loop to control the entries of the new array.  But I can't see how to do that.
    Any help would be appreciated.
    Attachments:
    NeedForLoopForThis.PNG ‏30 KB

    Hello H.R. Dunham, and welcome to the forum!
    It seems that you may be looking for Auto-Indexing, a basic feature of loops in LabVIEW.  You'll need to transpose your array before wiring it into the for loop, as elements are auto-indexed by row before column, but at that point you should be able to operate on each column and output an array of n cluster elements corresponding to your input columns.  Auto-indexing tunnels look like brackets to indicate each element will be indexed automatically- this should be the default when wiring an array into a for loop or when wiring anything out of a for loop.
    As for how to build your pairs, I suggest removing the X column and creating a "starter" cluster containing your X data and placeholder Y data before entering your "Y" processing loop.  Use the bundle by name function in the for loop to insert your processed column data into the cluster and auto-index the cluster output. Flow would be something like this:
    1) Gather data
    2) Split X and Y using standard array operations
    3) Create "template" cluster with shared X data
    4) Pass template cluster and Y-column array into an auto-indexed for loop.
    5) Insert processed Y data into cluster inside loop.
    6) Auto-index cluster data out of loop.
    This tutorial is probably also a good place to get started:
    Getting Started with NI LabVIEW Module 3: Loops
    http://www.ni.com/white-paper/7528/en/
    Hope that helps!
    Regards,
    Tom L.

  • I have used a 'for loop' to create an array of output data, however I want the each of the data sets from the array to be placed into a 1-D array. How do I concatenate the output of the for loop into a 1-D array?

    I am using this to create a data set that will be passed as an anolog output therefore it needs to have the correct array dimensions to go into the analog write vi.

    I'm updating my request... I've figured out how to do this by copying an example that uses a simple FOR loop (as seen in the attached current version of my VI). My question now becomes this: Is there a way to save the Y values corresponding to those X values into two more arrays? That is, just for argument's sake, let's say I took the first 100 elements from the X array, and found them to be positive. Then I would like to take the first 100 elements of the Y array and put them into a 'Y Values for X > 0' array. ...And likewise with the negative X values, they should have a separate array of corresponding 'Y values for X < 0' array.
    I can see that I should somehow save the indices of the positive X values from the large arrray wh
    en I sort them out, and use those indices to pick out the elements from the main Y array with the same indices.
    I just can't seem to set up the code necessary to do this. ...Can anyone help, please?
    Attachments:
    Poling_Data_Reader_5i.vi ‏79 KB
    30BLEND.txt ‏3 KB

  • I'm creating an array using a for loop, how do I get the values outside the loop while it is running? thanks

    I'm creating a set of values using a for loop and a shift register inside the loop. I want access to these values outside the loop as they are being created inside. When I connect a wire from the shift register to a display outside, it doesn't work. How do I do this? Thank you.
    Attachments:
    tamko_new.vi ‏29 KB

    I tried to create the local variable that was wired to numeric indicator inside the loop. If I try to connect this to the analog output outside the loop, the loop just starts blinking and nothing happens, am I doing something wrong? Thanks again.
    Attachments:
    tamko_new2.vi ‏29 KB

  • Varray Using OCI

    Hi,
    While sending Varray as an input parameter
    to an Oracle Stored Procedure, the following OCI calls
    are returning no error.
    OCITypeByName(),
    OCIObjectNew(),
    OCICollAppend(),
    OCIBindByPos(),
    OCIBindByObject()
    But OCIStmtExecute() hangs without giving any error.
    Can You PLEASE send me an example code
    for achieving the same.
    Also Could You suggest some books which deal with OCI function calls (with examples) in detail.
    CAN I EXPECT A REPLY from Mr.Ravikanth for this....Thanks for your previous reply
    Thanks & Regards,
    Alamelu
    null

    Hi Alamelu,
    I am sending some sample code snippets
    that show usage of collections.
    No, there are currently no books written on OCI. You can definitely look at some of the demo programs using OCI.
    static CONST text CONST_W_PTR selar = (text )
    "SELECT * from customer_va";
    static CONST text CONST_W_PTR insar = (text )
    "insert into customer_va (custno, names) values (:custno, :names)";
    static CONST text CONST_W_PTR modar = (text )
    "update customer_va set names=:names where custno=:custno";
    ** execute "selar" statement which select an array column from a table.
    void selectar(envhp, svchp, stmthp, stmthp1, errhp, recurse)
    OCIEnv *envhp;
    OCISvcCtx *svchp;
    OCIStmt *stmthp;
    OCIStmt *stmthp1;
    OCIError *errhp;
    boolean recurse;
    OCIType *names_ar_tdo;
    OCIDefine defn1p, defn2p;
    OCIColl names_ar = (OCIColl ) 0;
    sword custno =0;
    sword status;
    sb4 index;
    dvoid *elem;
    OCIString *names;
    OCIInd names_null = (OCIInd ) 0;
    boolean exist, eoc, boc;
    OCIIter itr = (OCIIter ) 0;
    OCIBind bnd1p, bnd2p;
    int amount;
    OCIInd ind = -1;
    OCIInd *indp = &ind;
    sb4 collsiz;
    DISCARD printf("\n******** Entering selectar *********\n");
    /* define the application request */
    checkerr(errhp, OCIStmtPrepare(stmthp, errhp, (text *) selar,
    (ub4) strlen((const char *) selar),
    (ub4) OCI_NTV_SYNTAX, (ub4) OCI_DEFAULT));
    /* bind the input variable */
    checkerr(errhp, OCIDefineByPos(stmthp, &defn1p, errhp, (ub4) 1, (dvoid *) &custno,
    (sb4) sizeof(sword), SQLT_INT, (dvoid *) 0, (ub2 *)0,
    (ub2 *)0, (ub4) OCI_DEFAULT));
    checkerr(errhp, OCIDefineByPos(stmthp, &defn2p, errhp, (ub4) 2, (dvoid *) 0,
    (sb4) 0, SQLT_NTY, (dvoid *) 0, (ub2 *)0,
    (ub2 *)0, (ub4) OCI_DEFAULT));
    checkerr(errhp, OCITypeByName(envhp, errhp, svchp, (const text *) "",
    (ub4) strlen((const char *) ""),
    (const text *) "VCHAR_TAB",
    (ub4) strlen((const char *) "VCHAR_TAB"),
    (CONST text *) 0, (ub4) 0,
    OCI_DURATION_SESSION, OCI_TYPEGET_HEADER,
    &names_ar_tdo));
    checkerr(errhp, OCIDefineObject(defn2p, errhp, names_ar_tdo, (dvoid **) &names_ar,
    (ub4 *) 0, (dvoid **) &indp, (ub4 *) 0));
    checkerr(errhp, OCIStmtExecute(svchp, stmthp, errhp, (ub4) 0, (ub4) 0, (OCISnapshot *)
    NULL, (OCISnapshot *) NULL, (ub4) OCI_DEFAULT));
    /* execute and fetch */
    DISCARD printf(" Execute and fetch.\n");
    while ((status = OCIStmtFetch(stmthp, errhp, (ub4) 1, (ub4) OCI_FETCH_NEXT,
    (ub4) OCI_DEFAULT)) == OCI_SUCCESS &#0124; &#0124;
    status == OCI_SUCCESS_WITH_INFO)
    /* print the customer number */
    DISCARD printf("\nThe customer number is : %d.\n", custno);
    if (*indp == -1)
    DISCARD printf("The varray is NULL.\n\n");
    continue;
    /* check how many elements in the typed table */
    checkerr(errhp, OCICollSize(envhp, errhp, (CONST OCIColl *) names_ar,
    &collsiz));
    DISCARD printf("---> There are %d elements in the varray.\n", collsiz);
    DISCARD printf("\n---> Dump the array from the top to the bottom.\n");
    checkerr(errhp, OCIIterCreate(envhp, errhp, names_ar, &itr));
    for(eoc = FALSE;!OCIIterNext(envhp, errhp, itr, (dvoid **) &elem,
    (dvoid **) &names_null, &eoc) && !eoc;)
    names = *(OCIString **) elem;
    DISCARD printf(" The names is %s\n", OCIStringPtr(envhp, names));
    DISCARD printf(" atomic null indicator is %d\n", *names_null);
    DISCARD printf("\n---> Dump the array from the bottom to the top.\n");
    checkerr(errhp, OCIIterGetCurrent(envhp, errhp, itr, (dvoid **) &elem,
    (dvoid **) &names_null));
    names = *(OCIString **) elem;
    DISCARD printf(" The names is %s\n", OCIStringPtr(envhp, names));
    DISCARD printf(" atomic null indicator is %d\n", *names_null);
    for(boc = FALSE;!OCIIterPrev(envhp, errhp, itr, (dvoid **) &elem,
    (dvoid **) &names_null, &boc) && !boc;)
    names = *(OCIString **) elem;
    DISCARD printf(" The names is %s\n", OCIStringPtr(envhp, names));
    DISCARD printf(" atomic null indicator is %d\n", *names_null);
    checkerr(errhp, OCI IterDelete(envhp, errhp, &itr));
    /* insert into the same table, then dump the info again */
    if (recurse)
    custno = custno * 10;
    checkerr(errhp, OCIStmtPrepare(stmthp1, errhp, (text *) insar,
    (ub4) strlen((const char *) insar),
    (ub4) OCI_NTV_SYNTAX, (ub4) OCI_DEFAULT));
    /* bind the input variable */
    checkerr(errhp, OCIBindByName(stmthp1, &bnd1p, errhp, (text *) ":custno",
    (sb4) -1, (dvoid *) &custno,
    (sb4) sizeof(sword), SQLT_INT,
    (dvoid *) 0, (ub2 *)0, (ub2 *)0, (ub4) 0, (ub4 *) 0,
    (ub4) OCI_DEFAULT));
    checkerr(errhp, OCIBindByName(stmthp1, &bnd2p, errhp, (text *) ":names",
    (sb4) -1, (dvoid *) 0,
    (sb4) 0, SQLT_NTY, (dvoid *) 0, (ub2 *)0, (ub2 *)0,
    (ub4) 0, (ub4 *) 0, (ub4) OCI_DEFAULT));
    /* if custno == 20, then insert null nested table */
    *indp = -1;
    checkerr(errhp, OCIBindObject(bnd2p, errhp, names_ar_tdo,
    (dvoid **) &names_ar,
    (ub4 *) 0, (custno == 20) ? (dvoid **) &indp :
    (dvoid **) 0, (ub4 *) 0));
    checkerr(errhp, OCIStmtExecute(svchp, stmthp1, errhp, (ub4) 1,
    (ub4) 0, (OCISnapshot *) NULL,
    (OCISnapshot *) NULL, (ub4) OCI_DEFAULT));
    checkerr(errhp, OCITransCommit(svchp, errhp, (ub4) 0));
    if ( status!= OCI_NO_DATA )
    checkerr(errhp, status);
    if (recurse)
    selectar(envhp, svchp, stmthp, stmthp1, errhp, FALSE);
    DISCARD printf("\n\n");
    ** execute "selar" statement which select an array column from a table,
    ** then execute "modar" to modify the array.
    void modifyar(envhp, svchp, stmthp, stmthp1, errhp, recurse)
    OCIEnv *envhp;
    OCISvcCtx *svchp;
    OCIStmt *stmthp;
    OCIStmt *stmthp1;
    OCIError *errhp;
    boolean recurse;
    OCIType *names_ar_tdo;
    OCIDefine defn1p, defn2p;
    OCIColl names_ar = (OCIColl ) 0;
    sword custno =0;
    sword status;
    sb4 index, counter = 0;
    OCIString *names;
    dvoid *elem;
    OCIInd names_null = (OCIInd ) 0;
    boolean exist, eoc, boc;
    OCIIter itr = (OCIIter ) 0;
    OCIBind bnd1p, bnd2p;
    int amount;
    OCIInd ind = -1;
    OCIInd *indp = &ind;
    sb4 collsiz;
    DISCARD printf("\n******** Entering modifyar *********\n");
    /* define the application request */
    checkerr(errhp, OCIStmtPrepare(stmthp, errhp, (text *) selar,
    (ub4) strlen((const char *) selar),
    (ub4) OCI_NTV_SYNTAX, (ub4) OCI_DEFAULT));
    /* bind the input variable */
    checkerr(errhp, OCIDefineByPos(stmthp, &defn1p, errhp, (ub4) 1, (dvoid *) &custno,
    (sb4) sizeof(sword), SQLT_INT, (dvoid *) 0, (ub2 *)0,
    (ub2 *)0, (ub4) OCI_DEFAULT));
    checkerr(errhp, OCIDefineByPos(stmthp, &defn2p, errhp, (ub4) 2, (dvoid *) 0,
    (sb4) 0, SQLT_NTY, (dvoid *) 0, (ub2 *)0,
    (ub2 *)0, (ub4) OCI_DEFAULT));
    checkerr(errhp, OCITypeByName(envhp, errhp, svchp, (const text *) "",
    (ub4) strlen((const char *) ""),
    (const text *) "VCHAR_TAB",
    (ub4) strlen((const char *) "VCHAR_TAB"),
    (CONST text *) 0, (ub4) 0,
    OCI_DURATION_SESSION, OCI_TYPEGET_HEADER,
    &names_ar_tdo));
    checkerr(errhp, OCIDefineObject(defn2p, errhp, names_ar_tdo, (dvoid **) &names_ar,
    (ub4 *) 0, (dvoid **) &indp, (ub4 *) 0));
    checkerr(errhp, OCIStmtExecute(svchp, stmthp, errhp, (ub4) 0, (ub4) 0, (OCISnapshot *)
    NULL, (OCISnapshot *) NULL, (ub4) OCI_DEFAULT));
    /* execute and fetch */
    DISCARD printf("\n Execute and fetch.\n");
    while ((status = OCIStmtFetch(stmthp, errhp, (ub4) 1, (ub4) OCI_FETCH_NEXT,
    (ub4) OCI_DEFAULT)) == OCI_SUCCESS &#0124; &#0124;
    status == OCI_SUCCESS_WITH_INFO)
    /* print the customer number */
    DISCARD printf("\nThe customer id is : %d.\n", custno);
    if (*indp == -1)
    DISCARD printf("The varray is NULL.\n\n");
    continue;
    /* check how many elements in the varray */
    checkerr(errhp, OCICollSize(envhp, errhp, (CONST OCIColl *) names_ar,
    &collsiz));
    DISCARD printf("---> There are %d elements in the varray.\n", collsiz);
    DISCARD printf("\n---> Dump the table from the top to the bottom.\n");
    checkerr(errhp, OCIIterCreate(envhp, errhp, names_ar, &itr));
    for(eoc = FALSE;!OCIIterNext(envhp, errhp, itr, (dvoid **) &elem,
    (d void **) &names_null, &eoc) && !eoc;)
    names = *(OCIString **) elem;
    DISCARD printf(" The names is %s\n", OCIStringPtr(envhp, names));
    DISCARD printf(" atomic null indicator is %d\n", *names_null);
    /* modify records */
    if (recurse)
    if (!counter)
    /* nullify the array */
    for(;!OCICollTrim(envhp, errhp, (sb4) 1, names_ar););
    else
    if (counter %2)
    /* trim one row at the end */
    checkerr(errhp, OCICollTrim(envhp, errhp, (sb4) 1, names_ar));
    else
    /* append one row to the end */
    checkerr(errhp, OCICollAppend(envhp, errhp, (CONST dvoid *) names,
    (CONST dvoid *) names_null, names_ar));
    counter ++;
    checkerr(errhp, OCIStmtPrepare(stmthp1, errhp, (text *) modar,
    (ub4) strlen((const char *) modar),
    (ub4) OCI_NTV_SYNTAX, (ub4) OCI_DEFAULT));
    /* bind the input variable */
    checkerr(errhp, OCIBindByName(stmthp1, &bnd1p, errhp, (text *) ":custno",
    (sb4) -1, (dvoid *) &custno,
    (sb4) sizeof(sword), SQLT_INT,
    (dvoid *) 0, (ub2 *)0, (ub2 *)0, (ub4) 0, (ub4 *) 0,
    (ub4) OCI_DEFAULT));
    checkerr(errhp, OCIBindByName(stmthp1, &bnd2p, errhp, (text *) ":names",
    (sb4) -1, (dvoid *) 0,
    (sb4) 0, SQLT_NTY, (dvoid *) 0, (ub2 *)0, (ub2 *)0,
    (ub4) 0, (ub4 *) 0, (ub4) OCI_DEFAULT));
    /* try modify the varray into NULL if custno == 30 */
    if (custno == 30)
    *indp = -1;
    checkerr(errhp, OCIBindObject(bnd2p, errhp, names_ar_tdo,
    (dvoid **) &names_ar, (ub4 *) 0,
    (dvoid **) &indp, (ub4 *) 0));
    checkerr(errhp, OCIStmtExecute(svchp, stmthp1, errhp, (ub4) 1,
    (ub4) 0, (OCISnapshot *) NULL,
    (OCISnapshot *) NULL, (ub4) OCI_DEFAULT));
    checkerr(errhp, OCITransCommit(svchp, errhp, (ub4) 0));
    if ( status!= OCI_NO_DATA )
    checkerr(errhp, status);
    if (recurse)
    modifyar(envhp, svchp, stmthp, stmthp1, errhp, FALSE);
    DISCARD printf("\n\n");
    null

  • Constructing a linked list from an array of integers

    How do I create a linked list from an array of 28 integers in a constructor? The array of integers can be of any value that we desire. However we must use that array to test and debug methods such as getFirst(), getLast(), etc...
    I also have a method int getPosition(int position) where its suppose to return an element at the specified position. However, I get an error that says cannot find symbol: variable data or method next()
    public int getPosition(int position){
         LinkedListIterator iter=new LinkedListIterator();
         Node previous=null;
         Node current=first;
         if(position==0)
         return current.data;
         while(iter.hasMore()){
         iter.next();
         if(position==1)
         return iter.data;
         iter.next();
         if(position==2)
         return iter.data;
         iter.next();
         if(position==3)
         return iter.data;
         iter.next();
         if(position==4)
         return iter.data;
         iter.next();
         if(position==5)
         return iter.data;
         iter.next();
         if(position==6)
         return iter.data;
         iter.next();
         if(position==7)
         return iter.data;
         iter.next();
         if(position==8)
         return iter.data;
         iter.next();
         if(position==9)
         return iter.data;
         iter.next();
         if(position==10)
         return iter.data;
         iter.next();
         if(position==11)
         return iter.data;
         iter.next();
         if(position==12)
         return iter.data;
         iter.next();
         if(position==13)
         return iter.data;
         iter.next();
         if(position==14)
         return iter.data;
         iter.next();
         if(position==15)
         return iter.data;
         iter.next();
         if(position==16)
         return iter.data;
         iter.next();
         if(position==17)
         return iter.data;
         iter.next();
         if(position==18)
         return iter.data;
         iter.next();
         if(position==19)
         return iter.data;
         iter.next();
         if(position==20)
         return iter.data;
         iter.next();
         if(position==21)
         return iter.data;
         iter.next();
         if(position==22)
         return iter.data;
         iter.next();
         if(position==23)
         return iter.data;
         iter.next();
         if(position==24)
         return iter.data;
         iter.next();
         if(position==25)
         return iter.data;
         iter.next();
         if(position==26)
         return iter.data;
         iter.next();
         if(position==27)
         return iter.data;
         iter.next();
         if(position==28)
         return iter.data;
         if(position>28 || position<0)
         throw new NoSuchElementException();
         }

    How do I create a linked list from an array of 28 integers
    in a constructor? In a LinkedList constructor? If you check the LinkedList class (google 'java LinkedList'), there is no constructor that accepts an integer array.
    In a constructor of your own class? Use a for loop to step through your array and use the LinkedList add() method to add the elements of your array to your LinkedList.
    I get an error that
    says cannot find symbol: variable data or method
    next()If you look at the LinkedListIterator class (google, wait for it...."java LinkedListIterator"), you will see there is no next() method. Instead, you typically do the following to get an iterator:
    LinkedList myLL = new LinkedList();
    Iterator iter = myLL.iterator();
    The Iterator class has a next() method.

  • Is there more simple interface library than OCI for C.

    I read OCI 8.0 documentation and I think that API like CLI XOpen standard but this standard is much complicated. So I am looking for a way to interacting with server in manner such as PostgreSQL interface library or MYSQL interface library or Sybase
    DB-Library. I don't want to bind variables; I do not want to start transactions. I just need 7 functions like this.
    Connect () - initialize and make connection to server.
    SendQuery () - send query to the server (I do not want to know the type of query DML or Select I just want to send query to server which query server to execute) (each query is in its own transaction so I do not need to commit or rollback.
    StoreResult () - retrieve result set if any or information about last executed query.
    GetValue (row, field) - just retrieve data for given field without any binding do you understand that binding do not allow to write code which is not care from executed query and returned result set.
    GetResultSet info () - to have a capability to ask for type of each field in a result set.
    FreeResultSet () - free data allocated for result set.
    CloseConnection () - when connection is not more needed.
    P.S to learn how to write documentation just see Description of PostgreSQL interface library of C, which is about 30 pages.
    I hope someone will answer my question or company where I work will discard Oracle as database server to resell to our clients.

    Try downloading libsqlora. It is a wrapper around OCI but hides all complicated parameter passing to OCI calls. Searching on google or altavista would give you link to download. It is either called libsqlora or libsqlora8. It is also very simple in documentation (just about 10-12 pages as far as I can remember).
    However, just because OCI is complicated, one would discard Oracle seems to be a bit hasty thinking. Oracle has much more than just OCI. And about 70% of oracle developers either do not use OCI or use it just for minimal functions. That is because Oracle has (especially after 8i), superb 4GL (PL/SQL) for all your development needs. And if you have Oracle APP server, you could do wonder enterprise wide applications in quickest possible time. Of course I am not working for Oracle nor am I in database marketing, but these feelings I also had when I was new to Oracle that oh is it so complicated. Hope this helps?

  • Write an algorithm to sort an array of integers

    "Write an algorithm to sort an array of integers"
    I was asked this at an interview and required to do it in 5 mins. I don't think you can use sort them by putting them in a collection, i think you need to write an algorithm from scartch. Any idea what the best way to do this would have been?

    Depends what you mean by "best."
    BubbleSort is probably the only one I could write off the top of my head in five minutes, but as sorting routines go for practical use, it sucks. If you know how to write MergeSort or QuickSort or dman near anything off off the top of your head, that would proabably be better.
    No one sorting algorithm is "best" without any context, however.
    If you don't know any sorting algorithms, use google or your data structures and algorithms textbook.

Maybe you are looking for

  • Interface errors

    Is there an script that can monitor interface errors (input and output errors) and send an email out when it reaches threshold? Thanks Sent from Cisco Technical Support iPhone App

  • How to Capture Addl. Info in the Timecard(HXT and HXC) apart from Hours?

    We run Payroll and OTL. We need to configure the timecard for one of the payroll element (HXT and possibly the HXC) to capture additional information apart from Hours (Using and LOV). To accomplish that, I've done the following steps as per the User

  • R12 links between GL and AR through XLA

    Hello, I have a requirement where in I need to modify standard account analysis report to show Customer name, ReceiptNumber/Invoice Number, Invoice Date etc going from GL. I have noticed that this has to be a UNION ALL query as AR data resides in mul

  • Faster way to search linked list?

    I'm pretty new to programming and I have to write a kind of psuedo implementation of a cache using a linked list (has to be a linked list). The problem is when I'm setting the maximum size of the linked list to a high number (like 2000), it goes incr

  • How do I get my bookmarks to sinc to my PC from My Iphone 5s

    I have bookmarks in Firefox home app that I would like to sinc to my PC