[BUG]: Dll modifies input array constant

Hi,
Not really an important one, but some of you (Ben might like it... Tested
in LV6, 6.1, 7.0 and 7.1.
When a dll function modifies more (1d or 2d) input arrays, one constant is
used to initialize them and less then all indicators are wired, LV
overwrites the constant values...
To reproduce this, I created a two dlls (one in assembler and one in
LabVIEW, assembler one is attached). The dll fills the array with the number
2.
Run the VI, update the diagram (close and open again, or scroll). The values
in the constant array now have the same values as the output array!
This behavior is reproducible with (at least) 1d and 2d arrays, and (at
least) U32 and DBLs.
I'm sure other array data types (SGL, U8, I8 etc.) s
how the same behavior,
but pointers to scalar values do not. Perhaps strings also do this?
Try putting a flat sequence frame around it, and put a few seconds wait
before and after it. You can see the constant changing while the vi is
running.
Regards,
Wiebe.
[Attachment Callbug.dll, see below]
[Attachment Callbug.vi, see below]
Attachments:
Callbug.dll ‏3 KB
Callbug.vi ‏13 KB

Ben,
The topic from the advanced course does seem to be describing this. So this
behavior doesn't seem to be a bug. I couldn't find anything about this in
the "Using External Code in LabVIEW" manual.
When pointers to values are used, the constants are not updated, so that is
inconsistent, but it does say "may receive", so that is covered...
Perhaps the only bug is the fact that the block diagram is not refreshed
properly, after the values are changed... Just kidding...
Next question is how to make use of this?
Regards,
Wiebe.
"Ben" wrote in message
news:50650000000500000078D30100-1079395200000@exch​ange.ni.com...
> Hi Wiebe
>
> Your question reminds me of a phrase from proverbs
>
> "A wise man goes into his store house and brings forth treasures both
> old and new".
>
> I was not able to find documentaion on the the call library function
> that talks about this issue but I did find the following in the
> "LabVIEW Advanced 1 Course Manual, August 1998 Edition, part number
> 321366C-01 page 242".
>
> "If you do not wire an indicator to the output terminal of a terminal
> pair, LabVIEW assumes that the CIN will not modify the value you pass
> to it. If another node uses the input data, LabVIEW does not make a
> copy of the data.
>
> Note: If you don't wire the output terminal, the source code should
> not modify the value passed into the terminal. Nodes connected to the
> input terminal wire may receive the modified data.
> "
>
> This topic brought our class to a stand still when we(those who were
> still awake) realized that data could flow backwards through a wire!
>
> I believe the behaviour you have observed is correct and the quote I
> cited above.
>
> I will venture a guess that the requirement from the CLA exam
> "CLD-VPP-03-04 ...Review a LabVIEW application for run-time behavoiur
> and memory management issue, ....Destructive and non-destructive
> buffer reads on branched wires"
>
> had the behaviour in mind.
>
> I posted a Q re:this req years ago but never got a definative answer.
>
> All of the above is just my opinion.
>
> I would love to hear from others.
>
> What do you think?
>
> Ben
>
> BTW: I do not think they teach that anymore.

Similar Messages

  • Creating string array constant

    Hey, this is probably a stupid question but I am still trying to figure out everything in LabVIEW. Is there a way to create an array constant that holds strings? I know you can define an numerical array constant but can you also do one for strings, or do I just have to pass multiple text fields into a "build array" function.
    Thanks,
    Paul

    Another tip:
    Many times, you already have a function on the diagram that expects an array of strings (or whatever you specifically need), so the easiest is to right-click the connector and select "create constant". You will get an diagram constant of the default type for that input or output terminal.
    LabVIEW Champion . Do more with less code and in less time .

  • String Array Constant Addition

    Is there an elegant way of marking the last element in a string array
    constant? i.e. I take an Array constant, and add a simple string to it,
    so that it becomes a String Array Constant. Now I add elements 1 and 2
    and 3. But now I want to take element 3 out. If I just delete Element 3
    contents from the string control, that is fine, but the # of Array
    elements is still 3. It is just that the 3rd elelment is null. How can I
    make the array length 2? Now I know that starting over is one option
    (just creat a new array constant, and add the two elements) but what if
    my array constant has 100 elements and I want to make it 99. I also
    know that programatically I can remove these elelents, but I am taking
    about in the programming of th
    is constant. I must be over looking
    something... Any ideas???
    Sent via Deja.com http://www.deja.com/
    Before you buy.

    [email protected] wrote:
    > Is there an elegant way of marking the last element in a string array
    > constant? i.e. I take an Array constant, and add a simple string to it,
    > so that it becomes a String Array Constant
    Arrays must be all the same type. If the last element is a constant, all
    elements are
    > Now I add elements 1 and 2
    > and 3. But now I want to take element 3 out. If I just delete Element 3
    > contents from the string control, that is fine, but the # of Array
    > elements is still 3. It is just that the 3rd elelment is null.
    In a string, yes, Empty strings are essentially nulls.
    > How can I
    > make the array length 2? Now I know that starting over is one option
    > (just creat a new array constant, and add the two elements) but what if
    > my array cons
    tant has 100 elements and I want to make it 99. I also
    > know that programatically I can remove these elelents, but I am taking
    > about in the programming of this constant. I must be over looking
    > something... Any ideas???
    This is one of my problems. It is easy to size an array up, but hard to size
    down.
    Of course you can resize at run time but the only way I know to do this
    when editing is to start over.
    Kevin Kent
    Attachments:
    Kevin.Kent.vcf ‏1 KB

  • Generate output based on the analysis of a input array

    Hello!
    I would appreciate some help with this:
    - I have an input array X. It is a phase array, in other words, it has values from -pi to pi. 
    - I want to create digital pulses that match with certain values of phases in X. Example: If a value of X, in position "5", is -3*pi/2, i would like to generate , in the output array Y, a value of 1 in its position "5".
    My problem here is that i am not being able to detect the position of the array where my condition is met. I tried to use a case structure and a for to do this, without success.
    I hope i was clear enough, thank you very much.

    Ok, now that i Got the phases, i have to generate the output. Knowing the period of the phases wave and the timing of a certain phase, i want to generate a digital output in a future time that falls in the specified phase. It's a closed-loop of stimulation. What i'm trying to do is this:
    - First of all, I get the phases like Altenbach said.
    - Then, i do the time calculus to predict time intervals that i would wait to generate my pulse, and that pulse should fall in the specified phase of the input waveform, since its a closed-loop system.
    I'm attaching the current vi that i designed, and I appreciate any help. 
    The real trouble now is generate the output pulse/ boolean in the right time, with a duration of, i dont know, 10ms, just to make it work. something like this: _______|              |________
                                                                                                                                                                                                                                                <--10ms-->
    Best Regards,
    Attachments:
    PLOT_SIGNAL_ALTERNATIVA.vi ‏67 KB

  • Array constant grey entry

    Say I have a array constant with 3 elements
    I want to delete the 3rd element and grey it out, so it look like this
    Can't seem to find a good way to do this other than remake the entire array. It is fine when the array only has a few elements, but when it is an array of shared variable reference of 50, it takes some time.
    Thanks
    Solved!
    Go to Solution.

    Exactly like that.
    /Y
    LabVIEW 8.2 - 2014
    "Only dead fish swim downstream" - "My life for Kudos!" - "Dumb people repeat old mistakes - smart ones create new ones."
    G# - Free award winning reference based OOP for LV

  • Error : Array constants can only be used in initializers

    Hello All,
    I am using tableview model and declared two-dimensional array.
    Getting error Array constants can only be used in initializers in the line retVal<i>[j] =  {  {  createBy,desc,dispName }  };
    String[][] retVal;
    retVal = new String[20][20]
    //Fetching IResorce propeties here
    int resourceCounter = 0;
    for (int i = 0; i < list.size(); i++) {
       for (int j = 0; j < i; j++) {
          IResource ir = list.get(i);
          createBy = ir.getCreatedBy();
          desc = ir.getDescription();
            dispName = ir.getDisplayName();
         retVal<i>[j] =  {  {  createBy,desc,dispName }  };
         resourceCounter++;
    return retVal;
    Please help me out.
    Thanks
    Risha                              }

    I created ArrayList 
    static public String[] colnames =
                   "News Title",
                   "Short Description",
                   "Published",
                   "Valid To",
                   "Read Count",
                   "Users Details",
                   "Reply" };
         public ArrayList createData() {
               ArrayList rowArrList = new ArrayList();
              ArrayList tableArrList = new ArrayList();
              String createBy = null;
              String desc = null;
              String dispName = null;
              String lastMod = null;
              String name = null;
              String resType = null;
              try {
                   com.sapportals.portal.security.usermanagement.IUser user = null;
                   user = WPUMFactory.getUserFactory().getEP5User(request.getUser());
                   IResourceContext resourceContext = new ResourceContext(user);
                   String path = "/documents/Australia/News";
                   RID rid = RID.getRID(path);
                   com.sapportals.wcm.repository.IResource res =
                        ResourceFactory.getInstance().getResource(rid, resourceContext);
                   IProperty prop = null;
                   String propValue = null;
                   PropertyName propName = null;
                   if (res != null) {
                        if (res.isCollection()) {
                             ICollection collection = (ICollection) res;
                             IResourceList list = collection.getChildren();
                             int resourceCounter = 0;
                             for (int i = 0; i < list.size(); i++) {                              
    //                              for (int j = 0; j < i; j++) {
                                       IResource ir = list.get(i);
                                       createBy = ir.getCreatedBy();
                                       desc = ir.getDescription();
                                       dispName = ir.getDisplayName();
                                       lastMod = ir.getLastModifiedBy();
                                       name = ir.getName();
                                       resType = ir.getResourceType();
                                       rowArrList.add(createBy);
                                       rowArrList.add(desc);
                                       rowArrList.add(dispName);
                                       rowArrList.add(lastMod);
                                       rowArrList.add(name);
                                       rowArrList.add(resType);
                                       tableArrList.add(i,rowArrList);
                                  //}//Inside for loop
                             }//First for loop
                        }//Inside If
              } catch (ResourceException e) {
                   // TODO Auto-generated catch block
                   response.write("Error " + e.getMessage());
              } catch (UserManagementException ex) {
                   ex.printStackTrace();
                   response.write("Error " + ex.getMessage());
              return tableArrList;
          * Constructor.
         public TableViewBean() {
              ArrayList tabArr = createData();
              String[][] data = (String[][])tabArr.toArray();          
              model = new DefaultTableViewModel(data, colnames);
    Edited by: Risha on May 26, 2011 8:52 AM

  • Populate input array with spreadsheet values

    Is it possible to populate an input array with values from a text or spreadsheet file? If so, how is it done?
    Solved!
    Go to Solution.

    Hi Joseph,
    "to be more exact":
    load the [text] file and use "spreadsheet string to array" (older LV versions) or use "read spreadsheet file" (LV8+)
    Best regards,
    GerdW
    CLAD, using 2009SP1 + LV2011SP1 + LV2014SP1 on WinXP+Win7+cRIO
    Kudos are welcome

  • Bug: Universal app input controls (i.e. Start Menu, Task view buttons) ignoring and missing interpretative translation for legacy input control context request (right-click)

    Redundant post - however the topic (title) is different to point out the potential of adding translation for right-click to universal app input controls. The part about a solution for translation is in bold at the bottom of this post ...
    Bug: Universal app input controls (i.e. Start Menu, Task view buttons) ignoring and missing interpretation translating right-click to a left-click to activate context (menu) in universal app web style (similar to oo context menu for oo legacy style).
    Bug: Task view: OO context menu: Should show "nothing" (like right-click Start Menu button) - but right click Task view shows the oo context menu for the Task bar (wrong context)
    Besides behaving wrongly (should be like right clicking the Start button) ....
    the problem is the user is likely to look for actions on that context menu.
    However to activate the context menu for this universal app kind of behavior you actually need to left-click the button for the Task view ... and then you get the universal app like context menu.
    Microsoft must have been trying to figure out what to do about this kind of voupling mismatch between legacy (right-click) and universal app (left-click) conmtext menus. confusing for users it weill become nevertheless.
    But the left-click style supports touch.
    One solution though is to support right-click on i.e. Task view and Start button. Thus for new kind (universal app kind-of)input controls - right-click will work (instead of just being ignored) just like left-click. Allthough not a correct left-click
    - it will be helpful and interpretive translating the intension of receiving a context. A practical solution with right-click translating into left-click for universal app controls considering that the context menu actually has become a hybrid of left-click
    and right-click (with a precedence for left-click though)

    This is a great post.
    I couldn't have written it myself better.
    I'm also in dying need of Korean input as I can't communicate with my Korean friends.
    But I second every point.
    I hope the tech teams are reading this.

  • LabVIEW 2014 array constant change

    Why did the "graying out" of array constants change between LabVIEW 2014 and LabVIEW 2013? In 2014 the effect is much more subtle and it's far harder to tell the # of elements in an array constant. Please change this back ASAP!

    My only thought was that they tried to make the disabled elements more readable.
    There are only two ways to tell somebody thanks: Kudos and Marked Solutions
    Unofficial Forum Rules and Guidelines
    Attachments:
    Disabled Elements.PNG ‏24 KB

  • BD Array Constant cannot be "browsed"?

    I've been annoyed by this in the past and a quick search did not yield any answer, so here is it:
    Is there a good reason why an array constant on the BD cannot be looked at, in the sense that the array index is no clickable?
    For instance, I am parsing a header using an array of strings and while I am debugging the process, I'd like to rapidly check what the index of entry "this" or "that" is so that I can put some conditional probe that will get me there quickly. The problem is, the array is too large to be seen at once on the diagram. Moreover, what I want to do is bring the item I am interested in to the top of the list so that I can check its index:
    The problem is, once I step through the code, the array is "frozen" and I can't play with the index control.
    That should not change anything to the code, so I don't understand why I am prevented from doing that.
    I can browse through cases of a structure or a sequence. Why not an array constant?
    Tested in LV 2011, but has been here forever.

    You are specifically talking about run mode, right (in edit mode you can change the index).
    You can show the scroll bar of the array container. It seems that still works in run mode, but I agree that the index should maybe also keep working.
    LabVIEW Champion . Do more with less code and in less time .

  • Labview Calling DLL with 2D array input and output

    Hi all,
        I have to call  a dll which a 2D double array as an input and also a 2D double array as an output.The dll is made by me and written in c language , I need it to work  efficiently.
    If i define the program in labview like this
    The 2 2Darrays sent into CLN were "Array data pointer",then how to define the function in c laguage? just like  -----int  myfunction (Parameter1,Parameter2,Parameter3,Parameter4)
    If the function in the dll is defined like this         int myfunction (double  **A, int sx,int sy ,double **B,int ix,int iy),then what will the program in labview will be ?
    sx ,sy ix ,iy are the array's size.

    ylongwu wrote:
    If the function in the dll is defined like this         int myfunction (double  **A, int sx,int sy ,double **B,int ix,int iy),then what will the program in labview will be ?
    sx ,sy ix ,iy are the array's size.
    Your proposed prototype double ** seems to indicate that you want an array of pointers to the rows of the array. That is not how LabVIEW stores multidimensional arrays (nor how this is usually done in C for such arrays).
    LabVIEW and most C libraries threat multi dimensional array as one single block of memory where the rows are located one after the other. So as DFGray has already pointed out you should use double * instead as datatype or since you create the DLL yourself and if it doesn't need to be compatible with other environments than LabVIEW change that altogether into:
    typedef struct {
       int32 dimSize1;
       int32 dimSize2;
       double elm[1];
    } 2DDblArrRec, **2DDblArrHdl;
    int myfunction (2DDblArrHdl A, 2DDblArrHdl B);
    then change the Call Library Node parameters for the arrays to pass the array as Data Handle (the native LabVIEW datatype) and leave away the extra dimensions since they are already inside the handle structure.
    Last but not least if you want to be very fancy you can even use NumericArrayResize() on the output handle to resize it to the correct size before filling in your information and leave away the Initialize Array function on the LabVIEW diagram.
    Message Edited by rolfk on 05-26-2010 09:11 AM
    Rolf Kalbermatter
    CIT Engineering Netherlands
    a division of Test & Measurement Solutions

  • Call dll with 1D array parameter

    Hi, I am trying to interface a Keyence laser displacement sensor controller with labview. Keyence has a dll API and I wrote a wrapper in C with DEV-C++. The wrapper is compiled into another DLL so I can call in my application. (Keyence DLL cannot be called directly for some reason)
    These are tested in Matlab and worked well. The problem is when I try to use the "Call Library Function Node " in Labview, it always report me errors. The C code is pasted as below. The arrays are 1-D and not been resized in the function call.
    Any input is highly appreciated.
    Bo 
     DLLIMPORT int AcqData(float *DataA, float *DataB)
      typedef int (_stdcall *DataStorageStartPtr) (void);
      typedef int (_stdcall *DataStorageStopPtr) (void);
      typedef int (_stdcall *DataStorageInitPtr) (void);
      typedef int (_stdcall *DataStorageGetDataPtr) (int OutNo,int NumOutBuffer, LKIF_FLOATVALUE *OutBuffer, int *NumReceived);
      typedef int (_stdcall *DataStorageGetStatusPtr) (int OutNo, int *IsStorage, int *NumStorageData);
      DataStorageStartPtr DataStorageStart;
      DataStorageStopPtr DataStorageStop;
      DataStorageInitPtr DataStorageInit;
      DataStorageGetDataPtr DataStorageGetData;
      DataStorageGetStatusPtr DataStorageGetStatus;
      HINSTANCE hLib;
      int feedback;
      int OutNo;
      int NumOutBuffer = MAX_NUM_DATA;
      int IsStorageA, IsStorageB;
      int NumStorageData;
      int NumReceivedA, NumReceivedB;
      LKIF_FLOATVALUE OutBufferA[NumOutBuffer];
      LKIF_FLOATVALUE OutBufferB[NumOutBuffer];
      //---------------- Import the DLL --------------------//
      hLib = LoadLibrary("LkIF.dll");
      if(!hLib)
       return -1;
      //---------------- Get the addresses of functions ---------------//
      DataStorageStart = (DataStorageStartPtr)GetProcAddress(hLib, "LKIF_DataStorageStart");
      if(DataStorageStart == NULL)
       return -2;
      DataStorageStop = (DataStorageStopPtr)GetProcAddress(hLib, "LKIF_DataStorageStop");
      if(DataStorageStop == NULL)
       return -3;
      DataStorageInit = (DataStorageInitPtr)GetProcAddress(hLib, "LKIF_DataStorageInit");
      if(DataStorageInit == NULL)
       return -4;
      DataStorageGetData = (DataStorageGetDataPtr)GetProcAddress(hLib, "LKIF_DataStorageGetData");
      if(DataStorageGetData == NULL)
       return -5;
      DataStorageGetStatus = (DataStorageGetStatusPtr)GetProcAddress(hLib, "LKIF_DataStorageGetStatus");
      if(DataStorageGetStatus == NULL)
       return -6;
      //---------------------------- Data Acqusition --------------------------//
      feedback = (DataStorageInit)();
      if(!feedback)
        return -7;
      feedback = (DataStorageStart)();
      if(!feedback)
        return -8;
      sleep(10000);
      sleep(500);
      OutNo = 0;
      feedback = (DataStorageGetStatus)(OutNo, &IsStorageA, &NumStorageData);
      if(!feedback)
       return -9;
      OutNo = 1;
      feedback = (DataStorageGetStatus)(OutNo, &IsStorageB, &NumStorageData);
      if(!feedback)
       return -10;
      while(IsStorageA || IsStorageB)
       sleep(500);
       OutNo = 0;
       feedback = (DataStorageGetStatus)(OutNo, &IsStorageA, &NumStorageData);
       if(!feedback)
        return -9;
       OutNo = 1;
       feedback = (DataStorageGetStatus)(OutNo, &IsStorageB, &NumStorageData);
       if(!feedback)
        return -10;
      feedback = (DataStorageStop)();
      if(!feedback)
       return -11;
      OutNo = 0;
      feedback = (DataStorageGetData)(OutNo,NumOutBuffer,&OutBufferA[0],&NumReceivedA);
      if(!feedback)
       return -12;
      OutNo = 1;
      feedback = (DataStorageGetData)(OutNo,NumOutBuffer,&OutBufferB[0],&NumReceivedB);
      if(!feedback)
       return -13;
      int i;
      for(i = 0; i < NumReceivedA; i++)
        DataA[i] = OutBufferA[i].Value;
      for(i = 0; i < NumReceivedB; i++)
        DataB[i] = OutBufferB[i].Value;
      return 0;
    Attachments:
    program.JPG ‏49 KB
    error.JPG ‏15 KB

    I notice you have corrections dot on the input side. Check the type used then building the array at the input side. Then you build a array on the input side, you do this to reserve memory for the dll. If you have not reserved the correct amount of memory before you call the function an erreor or a crash might happend. A float in C is 4 byte wide, equal to SGL in labview. A double is 8 byte wide, equal to DBL
    Besides which, my opinion is that Express VIs Carthage must be destroyed deleted
    (Sorry no Labview "brag list" so far)

  • A Bug in 11.1 array interface

    I have just encounter some code that runs fine in Oracle 9 to 10 but in 11.1 I am getting a different result.
    basically I have this SQL
    "INSERT INTO $table ( row_1, row_2, row_3) VALUES (?,?,?)"
    and bind all three to this array
    @var2 = (2,2,2,2,'s',2,2,2,2,2);
    using OCIBindByName and OCIBindDynamic and then execute them with
    OCIStmtExecute, with a mode (IN)
    of OCI_BATCH_ERRORS OCI_COMMIT_ON_SUCCESS (or 160)
    what happens is the commit does not happen in 11 but does happen in 9~10?
    Did something change in the execute in 11 or should I raise this up to a bug status??

    Ok here is a trace of the OCI Calls I use, and yes I the last one I give is a OCITransCommit
    st_execute_array INSERT count=10 (ARRAY(0x1a725c8) ARRAY(0x1a934c4) undef)
    OCIBindByName(876dad8,19cab00,8755e68,":p1",3,0,1,1,0,0,0,0,0,DATA_AT_EXEC)=SUCCESS
    OCIBindDynamic(876eda8,8755e68,19caadc, phs_in,19caadc,phs_out)=SUCCESS
    OCIBindByName(876dad8,1a27810,8755e68,":p2",3,0,1,1,0,0,0,0,0,DATA_AT_EXEC)=SUCCESS
    OCIBindDynamic(876ec68,8755e68,1a277ec,phs_in,1a277ec,phs_out)=SUCCESS
    OCIBindByName(876dad8,1a2bc18,8755e68,":p3",3,0,1,1,0,0,0,0,0,DATA_AT_EXEC)=SUCCESS
    OCIBindDynamic(876eb28,8755e68,1a2bbf4,phs_in,1a2bbf4,phs_out)=SUCCESS
    OCIStmtExecute(8755db0,876dad8,8755e68,10,0,0,0,160)=SUCCESS_WITH_INFO ->(OCI_BATCH_ERRORS|OCI_COMMIT_ON_SUCCESS)<--
    OCIAttrGet(876dad8,OCI_HTYPE_STMT,140f4ec,0,129,8755e68)=SUCCESS
    OCIErrorGet(8755e68,1,"<NULL>",140f48c,"ORA-24381: error(s) in array DML",1024,2)=SUCCESS
    OCIErrorGet(8755e68,2,"<NULL>",140f48c,"ORA-24381: error(s) in array DML",1024,2)=NO_DATA
    OCIAttrGet(876dad8,OCI_HTYPE_STMT,140f55c,0,73,8755e68)=SUCCESS
    st_execute_array 1 errors in batch.
    OCIHandleAlloc(8727940,140f578,OCI_HTYPE_ERROR,0,0)=SUCCESS
    OCIHandleAlloc(8727940,140f570,OCI_HTYPE_ERROR,0,0)=SUCCESS
    OCIParamGet(8755e68,2,876c3c0,140f578,0)=SUCCESS
    OCIAttrGet(876c968,OCI_HTYPE_ERROR,140f550,0,74,8755e68)=SUCCESS
    st_execute_array error in row 4.
    OCIErrorGet(876c968,1,"<NULL>",140f4cc,"ORA-01722: invalid number",1024,2)=SUCCESS
         OCIErrorGet(876c968,2,"<NULL>",140f4cc,"ORA-01722: invalid number",1024,2)=NO_DATA
    OCIHandleFree(876c3c0,OCI_HTYPE_ERROR)=SUCCESS
    OCIHandleFree(876c968,OCI_HTYPE_ERROR)=SUCCESS
    OCITransCommit(8755db0,8755e68,0)=SUCCESS
    st_execute_array warning: ORA-24381: error(s) in array DML (SUCCESS_WITH_
    INFO: error possibly near <*> indicator at char 56 in 'INSERT INTO test_ea( row_1, row_2,
    row_3) VALUES (:p1,:<*>p2,:p3)') [for Statement "INSERT INTO test_ea( row_1,  row_2, row_
    3) VALUES (?,?,?)"]
    and here is the code snipits but it is take out of a larger program so I will not run
    sb4
    phs_in(dvoid octxp, OCIBind bindp, ub4 iter, ub4 index,
         dvoid **bufpp, ub4 alenp, ub1 piecep, dvoid **indpp)
         phs_t phs = (phs_t)octxp;
    STRLEN phs_len;
    AV *tuples_av;
         SV *sv;
         AV *av;
         SV **sv_p;
         /* Check for bind values supplied by tuple array. */
         tuples_av = phs->imp_sth->bind_tuples;
         if(tuples_av) {
              /* NOTE: we already checked the validity in ora_st_bind_for_array_exec(). */
              sv_p = av_fetch(tuples_av, phs->imp_sth->rowwise ? (int)iter : phs->idx, 0);
              av = (AV*)SvRV(*sv_p);
              sv_p = av_fetch(av, phs->imp_sth->rowwise ? phs->idx : (int)iter, 0);
              sv = *sv_p;
              if(SvOK(sv)) {
              *bufpp = SvPV(sv, phs_len);
              phs->alen = (phs->alen_incnull) ? phs_len+1 : phs_len;
              phs->indp = 0;
              } else {
              *bufpp = SvPVX(sv);
              phs->alen = 0;
              phs->indp = -1;
    *alenp  = phs->alen;
    *indpp  = &phs->indp;
    *piecep = OCI_ONE_PIECE;
    if (!tuples_av && (index > 0 || iter > 0))
              croak(" Arrays and multiple iterations not currently supported (in %d/%d)", index,iter);
    return OCI_CONTINUE;
    sb4
    phs_out(dvoid octxp, OCIBind bindp,
         ub4 iter,     /* execution itteration (0...)     */
         ub4 index,     /* array index (0..)          */
         dvoid **bufpp,     /* A pointer to a buffer to write the bind value/piece.     */
         ub4 **alenpp,     /* A pointer to a storage for OCI to fill in the size     */
                   /* of the bind value/piece after it has been read.     */
         ub1 piecep,     / */
         dvoid **indpp,     /* Return a pointer to contain the indicator value which either an sb2     */
                   /* value or a pointer to an indicator structure for named data types.     */
         ub2 **rcodepp)     /* Returns a pointer to contains the return code.     */
    phs_t phs = (phs_t)octxp;     /* context */
    if (phs->desc_h) { /* a  descriptor if present  (LOBs etc)*/
              *bufpp  = phs->desc_h;
              phs->alen = 0;
    } else {
              SV *sv = phs->sv;
              if (SvTYPE(sv) == SVt_RV && SvTYPE(SvRV(sv)) == SVt_PVAV) {
              sv = av_fetch((AV)SvRV(sv), (IV)iter, 1);
              if (!SvOK(sv))
                        sv_setpv(sv,"");
              bufpp = SvGROW(sv, (size_t)(((phs->maxlen < 28) ? 28 : phs->maxlen)+1)/for null*/);
              phs->alen = SvLEN(sv);     /* max buffer size now, actual data len later */
    *alenpp = &phs->alen;
    *indpp  = &phs->indp;
    *rcodepp= &phs->arcode;
    *piecep = OCI_ONE_PIECE;
    return OCI_CONTINUE;
    static int
    do_bind_array_exec(sth, imp_sth, phs)
    SV *sth;
    imp_sth_t *imp_sth;
    phs_t *phs;
         dTHX;
    sword status;
    OCIBindByName_log(imp_sth->stmhp, &phs->bndhp, imp_sth->errhp,
    (text*)phs->name, (sb4)strlen(phs->name),
    0,
    phs->maxlen ? (sb4)phs->maxlen : 1, /* else bind "" fails */
    (ub2)phs->ftype, 0,
    NULL, /* ub2 alen_ptr not needed with OCIBindDynamic /
    0,
    0, /* max elements that can fit in allocated array */
    NULL, /* (ptr to) current number of elements in array */
    (ub4)OCI_DATA_AT_EXEC,
    status);
    if (status != OCI_SUCCESS) {
    oci_error(sth, imp_sth->errhp, status, "OCIBindByName");
    return 0;
    OCIBindDynamic_log(phs->bndhp, imp_sth->errhp,
    (dvoid *)phs, phs_in,
    (dvoid *)phs, phs_out, status);
    if (status != OCI_SUCCESS) {
    oci_error(sth, imp_sth->errhp, status, "OCIBindDynamic");
    return 0;
    return 1;
    static void
    init_bind_for_array_exec(phs)
    phs_t *phs;
         dTHX;
    if (phs->sv == &sv_undef) { /* first bind for this placeholder  */
    phs->is_inout = 0;
    phs->maxlen = 1;
    /* treat Oracle7 SQLT_CUR as SQLT_RSET for Oracle8 */
    if (phs->ftype==102)
    phs->ftype = 116;
    /* some types require the trailing null included in the length. */
    /* SQLT_STR=5=STRING, SQLT_AVC=97=VARCHAR */
    phs->alen_incnull = (phs->ftype==SQLT_STR || phs->ftype==SQLT_AVC);
    int
    st_execute_array(sth, imp_sth, tuples, tuples_status, columns, exe_count)
    SV *sth;
    imp_sth_t *imp_sth;
    SV *tuples;
    SV *tuples_status;
    SV *columns;
    ub4 exe_count;
         sword status, exe_status;
    int is_select = (imp_sth->stmt_type == OCI_STMT_SELECT);
    AV tuples_av, tuples_status_av, *columns_av;
    ub4 oci_mode;
    ub4 num_errs;
    int i,j;
    int autocommit = 1;
    SV **sv_p;
         phs_t **phs;
         SV *sv;
         AV *av;
    int param_count;
    char namebuf[30];
    STRLEN len;
    int outparams = (imp_sth->out_params_av) ? AvFILL(imp_sth->out_params_av)+1 : 0;
    tuples_av = (AV*)SvRV(tuples);
    /* Check the `columns' parameter. */
    if(SvTRUE(columns)) {
    if(!SvROK(columns) || SvTYPE(SvRV(columns)) != SVt_PVAV) {
    croak("ora_st_execute_array(): columns not an array peference.");
    columns_av = (AV*)SvRV(columns);
    } else {
    columns_av = NULL;
    /* Check the `tuples_status' parameter. */
    if(SvTRUE(tuples_status)) {
    if(!SvROK(tuples_status) || SvTYPE(SvRV(tuples_status)) != SVt_PVAV) {
         croak("ora_st_execute_array(): tuples_status not an array reference.");
    tuples_status_av = (AV*)SvRV(tuples_status);
    av_fill(tuples_status_av, exe_count - 1);
    /* Fill in 'unknown' exe count in every element (know not how to get
    individual execute row counts from OCI). */
    for(i = 0; (unsigned int) i < exe_count; i++) {
    av_store(tuples_status_av, i, newSViv((IV)-1));
    } else {
    tuples_status_av = NULL;
    /* Nothing to do if no tuples. */
    if(exe_count <= 0)
    return 0;
    param_count=c_NUM_PARAMS(imp_sth);/*returns the # of parameters on the imp_sth struct*/
         phs = safemalloc(param_count*sizeof(*phs));
    memset(phs, 0, param_count*sizeof(*phs));
         for(j = 0; (unsigned int) j < exe_count; j++) {
         sv_p = av_fetch(tuples_av, j, 0);
    if(sv_p == NULL) {
    Safefree(phs);
    croak("Cannot fetch tuple %d", j);
    sv = *sv_p;
    if(!SvROK(sv) || SvTYPE(SvRV(sv)) != SVt_PVAV) {
    Safefree(phs);
    croak("Not an array ref in element %d", j);
    av = (AV*)SvRV(sv);
    for(i = 0; i < param_count; i++) {
    if(!phs) {
    SV **phs_svp;
    sprintf(namebuf, ":p%d", i+1);
    phs_svp = hv_fetch(imp_sth->all_params_hv,
    namebuf, strlen(namebuf), 0);
    if (phs_svp == NULL) {
    Safefree(phs);
    croak("Can't execute for non-existent placeholder :%d", i);
    phs[i] = (phs_t*)(void*)SvPVX(*phs_svp); /* placeholder struct */
    if(phs[i]->idx < 0) {
    Safefree(phs);
    croak("Placeholder %d not of ?/:1 type", i);
    init_bind_for_array_exec(phs[i]); /*bind the value */
    sv_p = av_fetch(av, phs[i]->idx, 0);
    if(sv_p == NULL) {
    Safefree(phs);
    croak("Cannot fetch value for param %d in entry %d", i, j);
                   sv = *sv_p;
         /*check to see if value sv is a null (undef) if it is upgrade it*/
                   if (!SvOK(sv))     {
                        if(SvUPGRADE(sv, SVt_PV)){} /* For GCC not to warn on unused result */
                   else {
              SvPV(sv, len);
         /* Find the value length, and increase maxlen if needed. */
         if(SvROK(sv)) {
         Safefree(phs);
         croak("Can't bind a reference (%s) for param %d, entry %d",
         neatsvpv(sv,0), i, j);
         if(len > (unsigned int) phs[i]->maxlen)
         phs[i]->maxlen = len;
         /* Do OCI bind calls on last iteration. */
         if( ((unsigned int) j ) == exe_count - 1 ) {
         if(!do_bind_array_exec(sth, imp_sth, phs[i])) {
         Safefree(phs);
         Safefree(phs);
    /* Store array of bind typles, for use in OCIBindDynamic() callback. */
    imp_sth->bind_tuples = tuples_av;
    imp_sth->rowwise = (columns_av == NULL);
    oci_mode = OCI_BATCH_ERRORS;
    if(autocommit)
    oci_mode |= OCI_COMMIT_ON_SUCCESS;
         OCIStmtExecute_log(imp_sth->svchp, imp_sth->stmhp, imp_sth->errhp,
    exe_count, 0, 0, 0, oci_mode, exe_status);
         imp_sth->bind_tuples = NULL;
    if (exe_status != OCI_SUCCESS) {
              oci_error(sth, imp_sth->errhp, exe_status, ora_sql_error(imp_sth,"OCIStmtExecute"));
    if(exe_status != OCI_SUCCESS_WITH_INFO)
    return -2;
    OCIAttrGet_log(imp_sth, &num_errs, 0, OCI_ATTR_NUM_DML_ERRORS, status);
    if(num_errs && tuples_status_av) {
    OCIError row_errhp, tmp_errhp;
    ub4 row_off;
    SV *err_svs[2];
    /*AV err_av;/
    sb4 err_code;
    err_svs[0] = newSViv((IV)0);
    err_svs[1] = newSVpvn("", 0);
    OCIHandleAlloc_log(imp_sth->envhp, &row_errhp, OCI_HTYPE_ERROR, status);
    OCIHandleAlloc_log(imp_sth->envhp, &tmp_errhp, OCI_HTYPE_ERROR, status);
    for(i = 0; (unsigned int) i < num_errs; i++) {
    OCIParamGet_log(imp_sth->errhp, OCI_HTYPE_ERROR,
    tmp_errhp, (dvoid *)&row_errhp,
    (ub4)i, status);
    OCIAttrGet_log(row_errhp, OCI_HTYPE_ERROR, &row_off, 0,
    OCI_ATTR_DML_ROW_OFFSET, imp_sth->errhp, status);
    sv_setpv(err_svs[1], "");
    err_code = oci_error_get(row_errhp, exe_status, NULL, err_svs[1], debug);
    sv_setiv(err_svs[0], (IV)err_code);
    av_store(tuples_status_av, row_off,
    newRV_noinc((SV *)(av_make(2, err_svs))));
    OCIHandleFree_log(tmp_errhp, OCI_HTYPE_ERROR, status);
    OCIHandleFree_log(row_errhp, OCI_HTYPE_ERROR, status);
    /* Do a commit here if autocommit is set, since Oracle
    doesn't do that for us when some rows are in error. */
    if(autocommit) {
    OCITransCommit_log(imp_sth->svchp, imp_sth->errhp,
    OCI_DEFAULT, status);
    if (status != OCI_SUCCESS) {
    oci_error(sth, imp_sth->errhp, status, "OCITransCommit");
    return -2;
    if(num_errs) {
    return -2;
    } else {
    ub4 row_count = 0;
              OCIAttrGet_stmhp_log(imp_sth, &row_count, 0, OCI_ATTR_ROW_COUNT, status);
    return row_count;

  • How to append input array parameter to a conditon in where clause

    CREATE OR REPLACE PROCEDURE file_upload(p_array_code IN DIAG_CODE,p_desc_code IN DIAG_CODE_DESC,p_code_result OUT DIAG_CODE_TABLE) IS
    v_count NUMBER;
    v_range1 VARCHAR2(8);
    v_range2 VARCHAR2(8);
    l_count pls_integer := 0;
    l_diag_code_table1 DIAG_CODE_TABLE;
    l_diag_code_table2 DIAG_CODE_TABLE;
    l_loop_diag_code_table1 DIAG_CODE_TABLE;
    l_loop_diag_code_table2 DIAG_CODE_TABLE;
    BEGIN
    l_loop_diag_code_table1 := diag_code_table();
    l_loop_diag_code_table2 := diag_code_table();
    FOR i IN 1..p_array_code.count
    LOOP
    SELECT diag_code_rec(d.icd9_pcs_text_href,
    d.icd9_procedure_deci_code,
    d.icd9_procedure_long_desc,
    d.icd9_pcs_gem_flag_desc,
    g.gem_icd9_icd10pcs_flag,
    dc.icd10_procedure_code,
    dc.icd10_procedure_long_desc)
    BULK COLLECT INTO l_diag_code_table2
    FROM icd9_procedure_codes d,
    icd10_procedure_codes dc ,
    gem_icd9_icd10pcs g
    WHERE d.icd9_procedure_code=g.gem_icd9_pcs_code
    AND g.gem_icd10_pcs_code=dc.icd10_procedure_code(+)
    AND d.ICD9_PROCEDURE_code like p_array_code(i)||'%' ;
    FOR j IN 1..l_diag_code_table1.count
    LOOP
    l_loop_diag_code_table1.extend;
    l_loop_diag_code_table1 (l_loop_diag_code_table1.last):= l_diag_code_table1(j) ;
    END LOOP;
    END LOOP;
    p_code_result := l_loop_diag_code_table1 ;
    END;
    DIAG_CODE_DESC is declared as type
    create or replace type DIAG_CODE_DESC as table of varchar2(300);
    p_desc_code contains array of keywords
    I need to add one more condition to the above select query using the p_desc_code as
    (regexp_like(S.ICD9_PROCEDURE_LONG_DESC, '(p_desc_code (1)') AND regexp_like(S.ICD9_PROCEDURE_LONG_DESC, '(p_desc_code (2))' and ... upto inpu array limit.
    Could anyone help me through in writing the above the sql with the additional condition?
    I would really appreciate the help.
    Thanks,
    in advance

    Below are the requirements:
    A file will be uploaded from front end .
    Data from the file will be sent as arrays from java code:
    Two types of data
    1. values from file
    2. array of string values
    data format from file
    1.Sample data
    1000
    2000
    3000
    4000
    array of strings upto 5 strings limiy
    2.'abc','def',..upto 5
    Both the input values are varchar.
    create table ICD9_PROCEDURE_CODES(
    ICD9_Procedure_Code          Varchar2(6)     Primary Key,
    ICD9_Procedure_Deci_Code     Varchar2(7),     
    ICD9_Procedure_Long_Desc     Varchar2(300),     
    ICD9_Procedure_Short_Desc     Varchar2(100),     
    ICD9_PCS_Gem_Flag_Desc          Varchar2(500),     
    ICD9_Version               Varchar2(10));     
    insert into icd9_procedure_code(ICD9_PROCEDURE_CODE , ICD9_PROCEDURE_DECI_CODE,
    ICD9_PCS_TEXT_HREF, ICD9_PCS_GEM_FLAG_DESC)
    values(0441 ,04.41 ,Decompression trigem ,Scenaroio0 ,Scenario0:text_href)
    insert into icd9_procedure_code(ICD9_PROCEDURE_CODE , ICD9_PROCEDURE_DECI_CODE,
    ICD9_PCS_TEXT_HREF, ICD9_PCS_GEM_FLAG_DESC)
    0442, 04.42 ,Other carnial Cran ,Scenario1 ,Scenario1: text_href)
    create table ICD10_PROCEDURE_CODES(
    ICD10_PCS_Order_Num               Varchar2(7),     
    ICD10_Procedure_Code               Varchar2(8)     Primary Key,
    ICD10_Procedure_Decimal_Code          Varchar2(9),     
    ICD10_PCS_Code_Header               Number(1),     
    ICD10_Procedure_Short_Desc     Varchar2(60),
    ICD10_Procedure_Long_Desc     Varchar2(300),     
    ICD10_PCS_Gem_Flag_Description          Varchar2(500),     
    Version               Varchar2(10),
    insert into icd10_procedure_codes
    ( ICD10_PROCEDURE_CODE, ICD10_PROCEDURE_LONG_DESC, ICD10_PCS_TEXT_HREF, ICD10_PCS_GEM_FLAG_DESCRIPTION)
    values
    (00NK0ZZ,00N.K0ZZ, Release Nerve, Scenario0, Scenario0:text_href
    00NK3ZZ, 00N.K3ZZ,Diabetes Neuropathy, Scenario11, Scenario11: text_href
    00NK4ZZ, 00NK.4ZZ,Nerve disorder, Scenario12 ,Scenario12: text_href
    create table GEM_ICD9_ICD10PCS(
    GEM_ICD9_PCS_Code          Varchar2(6),
    GEM_ICD10_PCS_Code          Varchar2(8),     
    GEM_ICD9_ICD10PCS_Flag          Number(5),     
    GEM_Version          Varchar2(10),
    constaraint GEM_ICD9_ICD10PCS_PK PRIMARY KEY (GEM_ICD9_PCS_Code,GEM_ICD10_PCS_Code,GEM_ICD9_ICD10PCS_Flag))
    insert into gem_icd9_icd10pcs (GEM_ICD9_PCS_Code,GEM_ICD10_PCS_Code,GEM_Version)
    values
    ('0441','00NK0ZZ','10000');
    ('0441','00NK3ZZ','10000');
    ('0441','00NK4ZZ','10000');
    Thanks for looking into this thread

  • How to create a chart with x and y input arrays

    I am trying to create a chart that receives chunks of data from a while loop.  I know how to create a chart in order to append new data points to those points already in the display, but a regular chart doesn't let me specify the x axis data points.  Is there a way to create a chart with x and y array inputs?
    Thanx,
    Tom

    It's called an XY Graph. If you need an XY graph to behave like a chart, look at the shipping example called XY Chart.

Maybe you are looking for