Pass values to Guid collection/array parameter for anonymous pl/sql block

The following code pops the System.ArgumentException: Invalid parameter binding
Parameter name: p_userguids
at Oracle.DataAccess.Client.OracleParameter.GetBindingSize_Raw(Int32 idx)
at Oracle.DataAccess.Client.OracleParameter.PreBind_Raw()
at Oracle.DataAccess.Client.OracleParameter.PreBind(OracleConnection conn, IntPtr errCtx, Int32 arraySize)
at Oracle.DataAccess.Client.OracleCommand.ExecuteNonQuery()
Any help or advice ?
anonymous pl/sql block text:
DECLARE
TYPE t_guidtable IS TABLE OF RAW(16);
p_userguids t_guidtable;
BEGIN
DELETE testTable where groupname=:groupname;
INSERT INTO testTable (userguid, groupname)
SELECT column_value, :groupname FROM TABLE(p_userguids);
END;
c# code:
public static void SetGroupUsers(string group, List<Guid> users)
OracleConnection conn = Database.ConnectionEssentus;
try
conn.Open();
OracleCommand sqlCmd = new OracleCommand();
sqlCmd.CommandText = sqls["SetGroupUsers"]; // above anonymous block
sqlCmd.Connection = conn;
sqlCmd.BindByName = true;
OracleParameter p_guidCollection = sqlCmd.Parameters.Add("p_userguids", OracleDbType.Raw);
p_guidCollection.Size = users.Count;
p_guidCollection.CollectionType = OracleCollectionType.PLSQLAssociativeArray;
p_guidCollection.UdtTypeName = "t_guidtable";
p_guidCollection.Value = users.ToArray();
sqlCmd.Parameters.Add("groupname", OracleDbType.Varchar2, 30).Value = group;
sqlCmd.ExecuteNonQuery();
catch(Exception ex)
System.Diagnostics.Debug.WriteLine(ex.ToString());
finally
conn.Close();
}

New question,
How can I select records using "in" condition clause likes the following sentence?
SELECT userguid, firstname, lastname FROM UserTable WHERE userguid in (SELECT column_value FROM TABLE(p_userguids))
I tried using PIPE ROW like this, but ORACLE said "PLS-00629: PIPE statement cannot be used in non-pipelined functions"
FOR i in p_userguids.first .. p_userguids.last
LOOP
SELECT userguid, firstname, lastname INTO l_userrecord FROM UserTable WHERE userguid=p_userguids(i);
PIPE ROW(l_userrecord);
END LOOP;

Similar Messages

  • Create publicsynonyms for anonymous pl/sql block

    Hi,
    How do I create a public synonym for an anonymous PL/SQL block?
    BEGIN
         IF a IS NOT NULL
         THEN
              OPEN b;
              LOOP
                   FETCH b INTO Func;
              EXIT WHEN b%NOTFOUND;
                   c := c || Func || ',';
              END LOOP;
              CLOSE b;
              c := SUBSTR(c, 1, LENGTH(TRIM(c))-1);
         END IF;
         return c;
    END abc;
    ERROR at line 2:
    ORA-06550: line 2, column 5:
    PLS-00201: identifier 'a' must be declared
    ORA-06550: line 2, column 2:
    PL/SQL: Statement ignored
    ORA-06550: line 19, column 2:
    PLS-00372: In a procedure, RETURN statement cannot contain an expression
    ORA-06550: line 19, column 2:
    PL/SQL: Statement ignored

    Hi,
    CrackerJack wrote:
    Hi,
    How do I create a public synonym for an anonymous PL/SQL block?A synonym is an alternate name.
    Anonymous bblocks, by definition, don't have names, so they can't have alternate names. Also, they're not stored, so what good would it do if you could have synonyms for them?
    An anonymous block is just a quick and dirty alternative to a procedure, anyway. Why not make a procedure, or a function?
    BEGIN
         IF a IS NOT NULL
         THEN
              OPEN b;
              LOOP
                   FETCH b INTO Func;
              EXIT WHEN b%NOTFOUND;
                   c := c || Func || ',';
              END LOOP;
              CLOSE b;
              c := SUBSTR(c, 1, LENGTH(TRIM(c))-1);
         END IF;
         return c;
    END abc;
    ERROR at line 2:
    ORA-06550: line 2, column 5:
    PLS-00201: identifier 'a' must be declared
    ORA-06550: line 2, column 2:
    PL/SQL: Statement ignored
    ORA-06550: line 19, column 2:
    PLS-00372: In a procedure, RETURN statement cannot contain an expression
    ORA-06550: line 19, column 2:
    PL/SQL: Statement ignoredThis code looks like part of a function, that was named abc. Where is the beginning part of that function? The errors are caused because it is missing the part where this was declared as a function, and the part where the local variables a, c and func, and the cursor b, were defined.
    Does thsi function have something to do with the original question: "How do I create a public synonym for an anonymous PL/SQL block?"?
    What are you trying to do?

  • Execute anonymous PL/SQL block via JDBC - OUT parameter not available

    I have a simple proc on the database:
    CREATE PROCEDURE TEST(X OUT BINARY_INTEGER, Y IN VARCHAR) AS
    BEGIN
      X := 33;
    END; I am trying to invoke it via JDBC using an anonymous PL/SQL block:
            try {
                Connection connection =
                  DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:ORCL",
                    "scott", "tiger");
                CallableStatement stproc_stmt = connection.prepareCall(
                    "DECLARE\n" +
                    " X_TARGET BINARY_INTEGER;\n" +
                    " Y_TARGET VARCHAR(20) := :2;\n" +
                    "BEGIN\n" +
                    " TEST(X=>X_TARGET, Y=>Y_TARGET);\n" +
                    " :1 := X_TARGET;\n" +
                    "END;"
                stproc_stmt.registerOutParameter(1, Types.NUMERIC);
                stproc_stmt.setString(2, "test");
                stproc_stmt.executeUpdate();
                Object o = stproc_stmt.getObject(1);
            catch (Exception e) {
                e.printStackTrace();
            } No exceptions are thrown, but the Object o does not get the value '33' - it is NULL.
    Any ideas?
    thanks in advance,
    Mike Norman

    I think the issue may be in how JDBC parameter binding is being managed throughout the block's lifecycle.
    The slightly-different TEST2 works:
    CREATE PROCEDURE TEST2(Y IN VARCHAR, X OUT BINARY_INTEGER) AS
    BEGIN
      X := 33;
    END;
    try {
        Connection connection =
          DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:ORCL",
         "scott", "tiger");
        CallableStatement stproc_stmt = connection.prepareCall(
         "DECLARE\n" +
         " Y_TARGET VARCHAR(20) := :1;\n" +
         " X_TARGET BINARY_INTEGER;\n" +
         "BEGIN\n" +
         " TEST2(Y=>Y_TARGET, X=>X_TARGET);\n" +
         " :2 := X_TARGET;\n" +
         "END;"
        stproc_stmt.setString(1, "test");
        stproc_stmt.registerOutParameter(2, Types.NUMERIC);
        stproc_stmt.executeUpdate();
        Object o = stproc_stmt.getObject(1);
    catch (Exception e) {
        e.printStackTrace();
    }The order of the bind indices ':1' and ':2' are reversed in the above anonymous block - we are returning via ':2'.
    I am wondering if 'under the covers' there isn't perhaps a cursor issue. When the original block is parsed and the first bind index is found to be position 2, somehow we can't go back to position 1 - a forwards-only cursor?

  • Anonymous PL SQL block runs in 2 minutes but runs for 4 hours in Applicatio

    We are facing an issue with a custom code. When we run the custom code as anonymous pl/sql block , it completes in 2 minutes.
    But when we run the same from Oracle Application as a concurrent program, it runs for more than 4 hours.
    There is absolute no change in the code.
    Anyone faced this issue?

    Does your code use context sensitive views such as po_headers?
    Maybe you have not set the context in the pl/sql block so the view returns 0 records.
    But when you run it in Apps, the context is automatically set and so it processes a large number of records.
    Set the context if you have not and then try again.
    begin
    dbms_application_info.set_client_info('&org_id'); --
    end;
    Sandeep Gandhi

  • Passing value from Portal Form as parameter to portal report

    I have a portal form that I have created using the custom form layout editor to build/modify the display of the form. When I run the form and I have a record queried I would like to be able to click a link and pass the value of a field as a parameter to a portal report. For example, lets say I have a field on my portal form called assignment_id, and after I query a record assignment_id equals 1. I would like to use the value 1 from assignment_id as a parameter to a portal report. I am not sure how to reference the value of a form field, can this be done within the header, body or footer of the custom layout editor? Or can I somehow reference the value of a form field from the Additional PL/SQL Code section?
    Has anyone tried this with success? Any info is appreciated.
    Regards
    Mark

    Hi,
    You can get the values of the variables from the session variables. Here is an example which gets the value of the field FLIGHT_NO and passes it on to a report.
    While accessing the value of a field you should prefix it with "A_" (A_FLIGHT_NO)
    declare
    flightno number;
    blk varchar2(10) := 'DEFAULT';
    begin
    flightno := p_session.get_value_as_varchar2(
    p_block_name => blk,
    p_attribute_name => 'A_FLIGHT_NO');
    call('SJDEMO30.report1.show?p_arg_names=flightno&p_arg_values='||flightno);
    end;
    Thanks,
    Sharmila

  • How can I dynamically pass values to the DayOfWeek array given below?

    I have this below code:
    var onMondayAndTuesday = DailyTimeIntervalScheduleBuilder.Create()
    .OnDaysOfTheWeek(new DayOfWeek[] { DayOfWeek.Monday, DayOfWeek.Tuesday });
    var trigger = TriggerBuilder.Create()
    .StartAt(DateBuilder.DateOf(StartHour, StartMinute, StartSeconds, StartDate, StartMonth, StartYear))
    .WithSchedule(onMondayAndTuesday)
    .WithCalendarIntervalSchedule(x => x.WithIntervalInWeeks(Int32.Parse(nWeekInterval)))
    .EndAt(DateBuilder.DateOf(0, 0, 0, EndDay, EndMonth, EndYear))
    .WithIdentity(triggerKey)
    .Build();
    Here depending on the days users have selected any weekday would be passed in to the DaysOfWeek array. It might be just monday or monday
    and friday etc. How can I achieve this? Please advice.
    mayooran99

    Try this:
    DayOfWeek[] days = new DayOfWeek[7];
    days[0] = DayOfWeek.Friday;
    days[1] = DayOfWeek.Monday;
    days[2] = DayOfWeek.Saturday;
    var onMondayAndTuesday = DailyTimeIntervalScheduleBuilder.Create()
    .OnDaysOfTheWeek(days);
    also you can use it as a list:
    List<DayOfWeek> d = new List<DayOfWeek>();
    d.Add(DayOfWeek.Friday);
    Fouad Roumieh

  • Pass values to parent report's parameter  when click "Return to prev.."

    We have one report A which has parameters(use prompt to select value, not URL) to filter data, A has drill across action to report B(replace current report), we now can pass A's parameters to B.
    But if we click the "Return to previous Report" in B, all parameters in A dismiss. A report lose parameters used before, and we do not know how to pass parameter to A again, (all action must replace current report)
    Edited by: Jeffrey Yan on Mar 8, 2010 6:49 PM

    While creating prompt for Report A, you can set its default value (in prompt window before the last step where it lists all the values from the data object, you can click on the value and then click the arrow button). This way, when you return to A from B, at least it will open up with the default prompt value.

  • Null values not allowed in object-parameter for esb proxy invocation

    When I create a proxy service for my esb webservice and try to invoke this service from my ADF Application I was always getting the exception 'unexpected null value for literal data'.
    I've figured out what went wrong through debugging the proxy-classes of the esb-service.
    You need to define an input-value for each attribute of which your object is constituted. After I've initialized each variable in the object, which is the input-parameter of my esb proxy, everything works fine.

    When I create a proxy service for my esb webservice and try to invoke this service from my ADF Application I was always getting the exception 'unexpected null value for literal data'.
    I've figured out what went wrong through debugging the proxy-classes of the esb-service.
    You need to define an input-value for each attribute of which your object is constituted. After I've initialized each variable in the object, which is the input-parameter of my esb proxy, everything works fine.

  • Passing a table to an import parameter for a FM

    Hello experts,
    The goal is to update the date of  a record from the database table ZSHIPM_PLAN05.
    In   ABAP dictionnany I define a structure ZST_SHIPM_PLAN05 based on a database table in ZSHIPM_PLAN05
    Further I define a variable import in function Module(FM): IV_SHIPMENT type ZST_SHIPM_PLAN05.
    But I get the following error when compiling the FM: "IV_SHIPMENT" is neither specified under "TABLES"  nor defined as a internal table.
    Thank you for your Help.
    In the top_include I have :
    TYPES: BEGIN OF tt_ZST_SHIPM_PLAN05.
            INCLUDE STRUCTURE ZST_SHIPM_PLAN05.
    END OF tt_ZST_SHIPM_PLAN05.
    DATA: gt_outtab TYPE TABLE OF tt_ZSHIPM_PLAN05,
                 wa_ZSHIPM_PLAN05 LIKE LINE OF gt_outtab.
        CALL FUNCTION 'Z_SHIPM_PLAN_SAVE05'
          EXPORTING
            iv_shipment = gt_outtab
          IMPORTING
            es_return   = gty_bapiret2.
    FUNCTION Z_SHIPM_PLAN_SAVE05.
    ""Local Interface:
    *"  IMPORTING
    *"     REFERENCE(IV_SHIPMENT) TYPE  ZST_SHIPM_PLAN05
    *"  EXPORTING
    *"     REFERENCE(ES_RETURN) TYPE  BAPIRET2
    LOOP AT IV_SHIPMENT INTO wa_ZST_SHIPM_PLAN05.
    settings the color
      IF wa_ZST_SHIPM_PLAN05-art = 'AA02' and wa_ZST_SHIPM_PLAN05-descr = 'ci0017'.
        wa_ZSHIPM_PLAN05-crea_date = sy-date.
      ENDIF.
      MODIFY gt_outtab FROM wa_ZST_SHIPM_PLAN05 TRANSPORTING crea_date.
    ENDLOOP.
          "MESSAGE 'Do you want save' type 'I'.
           SET SCREEN 0.
    ENDFUNCTION.

    Hi,
    Assign IV_SHIPMENT under changing or tables Parameter because import and Export statement holds a field not structure or table.
    Thanks
    Arbind

  • Passing values in a vector list as bind variables in sql query.

    Hi,
    I have a vector list containing values 12,13,14.
    vector<string> v;
    v has values 12,13 and 14.
    Here the number of values in vector list are not fixed.
    I want to pass these values as bind variables to sql query.
    Can anyone suggest me how to do this.
    Thanks in advance!!

    Ah, the it's the classic 'Varying In-List' again
    See:
    The Tom Kyte Blog: Varying in lists...
    http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:110612348061 (started more than a decade ago, so scroll down for more recent examples)

  • Passing values to anonymous pl/sql block error

    Hi,
    I have update_table.sql sql script which updates the table MST_TOT. The sql script is being called from
    unix shell script in loop with 2 parameters values. 1. str# 2. rtl#.
    e.g. The shell script will call 5 time sql script with different str# and rtl#.
    update_table.sql
    DECLARE CURSOR cur_qty IS
    SELECT
    COL1,
    COL2
    FROM MST_DTL
    WHERE
         AND STR = &1
         AND RTL = &2;
    l_COL1 NUMBER;
    l_COL2 NUMBER;
    BEGIN
    OPEN cur_qty;
    LOOP
    FETCH cur_qty INTO l_COLtrans_dt, l_COL1, l_COL2;
    EXIT WHEN cur_qty%NOTFOUND;
    UPDATE MST_TOT
    SET item_total = l_COL1
    WHERE str_num = &1
    AND rtl_co_num = l_COL2
    END LOOP;
    CLOSE cur_qty;
    COMMIT;
    EXCEPTION
    WHEN OTHERS THEN
    ROLLBACK;
    END;
    Problem: It completes first sql call and terminates with following error.
    old 32:      AND STR = &1
    new 32:      AND STR = 40
    old 33:      AND RTL = &2
    new 33:      RTL = 12
    PL/SQL procedure successfully completed.
    SP2-0042: unknown command "48|12|" - rest of line ignored.
    Any suggetion?
    Thanks in advance!!
    Dip

    At first sight I miss the semicolon at the end of your update statement:
    UPDATE MST_TOT
    SET item_total = l_COL1
    WHERE str_num = &1
    AND rtl_co_num = l_COL2;Additionally there may be a problem with your &-variables.
    If the columns/values are of varchar type you should put them into quotes inside your code:
    e.g.
    AND STR = '&1'

  • Problem when register parameter for conc program through backend

    Hi all,
    i register the executable and corresponding conc program through backend.
    But when i tried to register the parameter from backend using fnd_program.paramter procedure i got many error.
    So can any of u guys help me out to find my ways ,how to successfully register parameter thoregh backend.
    below mentioned the code i taken
    begin
    fnd_program.parameter(     program_short_name=>'BACK_END_TEST1_CONC_PRO',
         application=>'SQLXXXUSER2',
         sequence=>1,
         parameter=>'DEPTNO',
         value_set=>'V11',
         required=>'Y',
         display_size=>2,
         description_size=>50,
         concatenated_description_size=>25,
         prompt=>'DEPTNO',
         token=>'DEPTNO'
    END;
    please help guys
    Thanks,
    Tune_to_urs

    The fnd_program.parameter call that you have is passing values for all of the necessary procedure parameters. To me, that means that the errors you are getting are related to the data that you are passing into the call.
    Possible errors with the values you are passing (I cannot tell because I don't know what data you have in your environment) are:
    - invalid program short name
    - invalid application name (needs to be the full application name rather than the short name)
    - parameter with same sequence already exists
    - value set does not exist
    - you can only specify tokens for certain types of concurrent programs (ie Oracle Reports)
    Just running the anonymous PL/SQL block like you have shown, the errors that are preventing it being saved should be displayed.

  • Pass value Process request  to Process Form Request

    Hi,
    Can any one tell me how we can pass particular value from process request to process form request?
    Thanks

    Hi,
    u can use params to pass values.. please see code below for reference.
    if(pageContext.getParameter("saveBtn") != null)
    String userId = String.valueOf(pageContext.getUserId());
    Serializable param[] = {
    invAmt, userId
    oam.invokeMethod("saveHandle", param);
    OADBTransaction trx = oam.getOADBTransaction();
    trx.setClearCacheOnCommit(true);
    trx.commit();
    OAException successMsg = new OAException("Records saved successfully", (byte)3);
    pageContext.putDialogMessage(successMsg);
    pageContext.forwardImmediately("OA.jsp?page=/custom/oracle/apps/fnd/wf/worklist/webui/ssrInvoicePG", null, (byte)0, null, null, true, "N");
    trx.closeTransaction();
    }

  • How to pass value between two forms.

    Hi all,
    how to pass value between two forms(using :parameter),...
    Thanks
    Rajesh

    To use parameters, create a parameterlist with the named parameters
    DECLARE
      pl_id PARAMLIST;
      pl_name VARCHAR2(10) := 'tempdata';
    BEGIN
      pl_id := Get_Parameter_List(pl_name);
      IF not Id_Null(pl_id) THEN
        DESTROY_PARAMETER_LIST(pl_id);
      END IF;
      pl_id := Create_Parameter_List(pl_name);
      ADD_PARAMETER (pl_id,'MYPARAMETER',TEXT_PARAMETER,:BLOCK.VALUE);      
      CALL_FORM('MYNEWFORM', NO_HIDE, DO_REPLACE, NO_QUERY_ONLY, pl_id);
    END;In the new form you can then just access the parameters via :PARAMETER.MYPARAMETER;
    An alternative is the usage of globals:
    :GLOBAL.MYPARAM:=:BLOCK.VALUE;
    -- call the emp-form
    CALL_FORM('MYNEWFORM', NO_HIDE, DO_REPLACE);and in the new form use:
    DEFAULT_VALUE(NULL, 'GLOBAL.MYPARAM');
    IF :GLOBAL.MYPARAM IS NOT NULL THEN
    ...The advantage of gloabls is that they can also return values back to the calling form, which is not possible using parameters

  • How to pass a value to the export parameter for a method (public instance)?

    Hello,
      I am trying ABAP OO newly. How to pass a value to the export parameter for a method (public instance) called in a report? This *export parameter has a reference type of structure.
    Thanks in advance,
    Ranjini

    Hi,
    "class definition
    class lcl... definition.
      public section.
        method m1 imporitng par type ref to data.  "now you can pass any reference to the method, but this way you have to maintain this reference dynamically inside the method (you can't be sure what that reference is really "pointing" at)
    endclass.
    "in program
    data: r_lcl type ref to lcl...
    create object r_lcl.
    call method r_lcl
      exporting
         par    =  "pass any reference variable here
    Regards
    Marcin

Maybe you are looking for

  • Help with exporting DB Shema as backup

    Can someone please tell me how to backup a DB shema and restore it via Export/Import! Can I restore a db shema from dmp file in another oracleDB? Is there any script on the internet whitch I could use? Any help would be greatly apriciated! Thanx!

  • Safari Hangs on Startup

    This just started happening to me the morning. I launch safari, the window opens but remains blank and I get the beachball forever. Tried deleting preferences for safari, have also reinstalled safari completely. Tried safari in a new user account and

  • Is there a way to dial voicemail in SDK?

    Is there a way to dial voicemail in SDK? Maybe a special number I can dial to redirect to the voicemail? Thanks

  • N80 V 4.0632.0.38 VS 4.0623.0.42

    Hi 2 all! Today I have updated my N80 SW to the version to 4.0623.0.42. As it shows NOKIA SOFTWARE UPDATER this is the newest avaliable version. Actually i have not noticed any noticeable changes. The reason of updating was the hope of increasing of

  • /usr/bin/login Terminal start gives error

    When i try to start up the terminal via standard /usr/bin/login, i get the following error: login: PAM Error: Module is unkown only been a problem since 10.4.6 update. Already repaired permissions. I can change the shell command to bash, and it works