Dynamic Initialization of PL/SQL collection ...

Hi,
I trying to initialize table type using execute immediate but get the following error:
DECLARE
     TYPE SCHEMA_LIST IS TABLE OF ALL_USERS.USERNAME%TYPE;
     L_SCHEMAS SCHEMA_LIST;
BEGIN
EXECUTE IMMEDIATE ' BEGIN :b1 := SCHEMA_LIST ('''||FN_GET_CONFIGVALUE ('PRAM1')||'''); END; ' USING OUT L_SCHEMAS;
FOR L_IDX IN L_SCHEMAS.FIRST..L_SCHEMAS.LAST LOOP
DBMS_OUTPUT.PUT_LINE
               L_SCHEMAS(L_IDX)
END LOOP;
END;
ERROR at line 7:
ORA-06550: line 7, column 138:
PLS-00457: expressions have to be of SQL types
ORA-06550: line 7, column 9:
PL/SQL: Statement ignored
The function FN_GET_CONFIGVALUE ('PRAM1') which takes one input parameter would return a comma seperated list which I would then initialize to the table type.
Any Idea ?
Thanks !
Pat

Patza,
It seems one cannot initialize( i.e. "USING" and "RETURNING" ) index-table, record and boolean-type expressions in dynamic SQL, only true PL/SQL expressions can be used. Since you are trying to initialize a table type, this is where the problem lies. If I may suggest, perhaps accepting the output in some alternative way (i.e. variables or somesuch) might fix the problem.
Kindest regards,
Stefan
Message was edited by:
Stefan Bexkens

Similar Messages

  • Declare and initialize a varray of collection Object and pass it as OUT Par

    Hi ,
    How to declare and initialize a varray of collection Object and pass it as OUT Parameter to a procedure.
    Following is the Object and VARRAY Type 's I have created and trying to pass the EmployeeList varray type variable as an OUT parameter to my stored procedure, but it is not working. I tried different possibilities of declaring and initializing the varray type variable but it did not work. Any help would be appreciated.
    CREATE TYPE Employee IS Object
              employeeId     Number,
              employeeName VARCHAR2(31),
              employeeType     VARCHAR2(20),
    CREATE TYPE EmployeeList IS VARRAY(100) OF Employee;
    /* Procedure execution block */
    declare
    employees EmployeeList;
    begin
    EXECUTE displayEmployeeDetails(100, employees);
    end;
    Thanks in advance,
    Raghu.

    but it is not workingWhat's the definition of not working?
    Error messages are always helpful.
    SQL> CREATE OR REPLACE TYPE Employee IS Object
      2  (
      3  employeeId Number,
      4  employeeName VARCHAR2(31),
      5  employeeType VARCHAR2(30)
      6  );
      7  /
    Type created.
    SQL>
    SQL> CREATE OR REPLACE TYPE EmployeeList IS VARRAY(100) OF Employee;
      2  /
    Type created.
    SQL> CREATE OR REPLACE PROCEDURE getEmployeeDetails (
      2    o_employees OUT employeelist
      3  )
      4  AS
      5  BEGIN
      6   o_employees := employeelist();
      7   o_employees.EXTEND;
      8   o_employees(1) := employee(1,'Penry','Mild Mannered Janitor');
      9  END;
    10  /
    Procedure created.
    SQL> set serveroutput on
    SQL> declare
      2   employees employeelist;
      3  begin
      4   getemployeedetails(employees);
      5   for i in 1 .. employees.count
      6   loop
      7    dbms_output.put_line(employees(i).employeeid||' '||
      8                         employees(i).employeename||' '||
      9                         employees(i).employeetype);
    10   end loop;
    11  end;
    12  /
    1 Penry Mild Mannered Janitor
    PL/SQL procedure successfully completed.
    SQL>

  • 10g: parallel pipelined table func. using table(cast(SQL collect.))?

    Hi,
    i try to distribute SQL data objects - stored in a SQL data type TABLE OF <object-Type> - to multiple (parallel) instances of a table function,
    by passing a CURSOR(...) to the table function, which selects from the SQL TABLE OF storage via "select * from TABLE(CAST(<storage> as <storage-type>)".
    But oracle always only uses a single table function instance :-(
    whatever hints i provide or setting i use for the parallel table function (parallel_enable ...)
    Could it be, that this is due to the fact, that my data are not
    globally available, but only in the main thread data?
    Can someone confirm, that it's not possible to start multiple parallel table functions
    for selecting on SQL data type TABLE OF <object>storages?
    Here's an example sqlplus program to show the issue:
    -------------------- snip ---------------------------------------------
    set serveroutput on;
    drop table test_table;
    drop type ton_t;
    drop type test_list;
    drop type test_obj;
    create table test_table
         a number(19,0),
         b timestamp with time zone,
         c varchar2(256)
    create or replace type test_obj as object(
         a number(19,0),
         b timestamp with time zone,
         c varchar2(256)
    create or replace type test_list as table of test_obj;
    create or replace type ton_t as table of number;
    create or replace package test_pkg
    as
         type test_rec is record (
              a number(19,0),
              b timestamp with time zone,
              c varchar2(256)
         type test_tab is table of test_rec;
         type test_cur is ref cursor return test_rec;
         function TF(mycur test_cur)
    return test_list pipelined
    parallel_enable(partition mycur by hash(a));
    end;
    create or replace package body test_pkg
    as
         function TF(mycur test_cur)
    return test_list pipelined
    parallel_enable(partition mycur by hash(a))
    is
              sid number;
              counter number(19,0) := 0;
              myrec test_rec;
              mytab test_tab;
              mytab2 test_list := test_list();
         begin
              select userenv('SID') into sid from dual;
              dbms_output.put_line('test_pkg.TF( sid => '''|| sid || ''' ): enter');
              loop
                   fetch mycur into myRec;
                   exit when mycur%NOTFOUND;
                   mytab2.extend;
                   mytab2(mytab2.last) := test_obj(myRec.a, myRec.b, myRec.c);
              end loop;
              for i in mytab2.first..mytab2.last loop
                   -- attention: saves own SID in test_obj.a for indication to caller
                   --     how many sids have been involved
                   pipe row(test_obj(sid, mytab2(i).b, mytab2(i).c));
                   counter := counter + 1;
              end loop;
              dbms_output.put_line('test_pkg.TF( sid => '''|| sid || ''' ): exit, piped #' || counter || ' records');
         end;
    end;
    declare
         myList test_list := test_list();
         myList2 test_list := test_list();
         sids ton_t := ton_t();
    begin
         for i in 1..10000 loop
              myList.extend; myList(myList.last) := test_obj(i, sysdate, to_char(i+2));
         end loop;
         -- save into the real table
         insert into test_table select * from table(cast (myList as test_list));
         dbms_output.put_line(chr(10) || 'copy ''mylist'' to ''mylist2'' by streaming via table function...');
         select test_obj(a, b, c) bulk collect into myList2
         from table(test_pkg.TF(CURSOR(select /*+ parallel(tab,10) */ * from table(cast (myList as test_list)) tab)));
         dbms_output.put_line('... saved #' || myList2.count || ' records');
         select distinct(tab.a) bulk collect into sids from table(cast (myList2 as test_list)) tab;
         dbms_output.put_line('worker thread''s sid list:');
         for i in sids.first..sids.last loop
              dbms_output.put_line('sid #' || sids(i));
         end loop;
         dbms_output.put_line(chr(10) || 'copy physical ''test_table'' to ''mylist2'' by streaming via table function:');
         select test_obj(a, b, c) bulk collect into myList2
         from table(test_pkg.TF(CURSOR(select /*+ parallel(tab,10) */ * from test_table tab)));
         dbms_output.put_line('... saved #' || myList2.count || ' records');
         select distinct(tab.a) bulk collect into sids from table(cast (myList2 as test_list)) tab;
         dbms_output.put_line('worker thread''s sid list:');
         for i in sids.first..sids.last loop
              dbms_output.put_line('sid #' || sids(i));
         end loop;
    end;
    -------------------- snap ---------------------------------------------
    Here's the output:
    -------------------- snip ---------------------------------------------
    copy 'mylist' to 'mylist2' by streaming via table function...
    test_pkg.TF( sid => '98' ): enter
    test_pkg.TF( sid => '98' ): exit, piped #10000 records
    ... saved #10000 records
    worker thread's sid list:
    sid #98 -- ONLY A SINGLE SID HERE!
    copy physical 'test_table' to 'mylist2' by streaming via table function:
    ... saved #10000 records
    worker thread's sid list:
    sid #128 -- A LIST OF SIDS HERE!
    sid #141
    sid #85
    sid #125
    sid #254
    sid #101
    sid #124
    sid #109
    sid #142
    sid #92
    PL/SQL procedure successfully completed.
    -------------------- snap ---------------------------------------------
    I posted it to newsgroup comp.databases.oracle.server.
    (summary: "10g: parallel pipelined table functions with cursor selecting from table(cast(SQL collection)) doesn't work ")
    But i didn't get a response.
    There i also wrote some background information about my application:
    -------------------- snip ---------------------------------------------
    My application has a #2 steps/stages data selection.
    A 1st select for minimal context base data
    - mainly to evaluate for due driving data records.
    And a 2nd select for all the "real" data to process a context
    (joining much more other tables here, which i don't want to do for non-due records).
    So it's doing stage #1 select first, then stage #2 select - based on stage #1 results - next.
    The first implementation of the application did the stage #1 select in the main session of the pl/sql code.
    And for the stage #2 select there was done a dispatch to multiple parallel table functions (in multiple worker sessions) for the "real work".
    That worked.
    However there was a flaw:
    Between records from stage #1 selection and records from stage #2 selection there is a 1:n relation (via key / foreign key relation).
    Means, for #1 resulting record from stage #1 selection, there are #x records from stage #2 selection.
    That forced me to use "cluster curStage2 by (theKey)".
    Because the worker sessions need to evaluate the all-over status for a context of #1 record from stage #1 and #x records from stage #2
    (so it needs to have #x records of stage #2 together).
    This then resulted in delay for starting up the worker sessions (i didn't find a way to get rid of this).
    So i wanted to shift the invocation of the worker sessions to the stage #1 selection.
    Then i don't need the "cluster curStage2 by (theKey)" anymore!
    But: i also need to do an update of the primary driving data!
    So the stage #1 select is a 'select ... for update ...'.
    But you can't use such in CURSOR for table functions (which i can understand, why it's not possible).
    So i have to do my stage #1 selection in two steps:
    1. 'select for update' by main session and collect result in SQL collection.
    2. pass collected data to parallel table functions
    And for 2. i recognized, that it doesn't start up multiple parallel table function instances.
    As a work-around
    - if it's just not possible to start multiple parallel pipelined table functions for dispatching from 'select * from TABLE(CAST(... as ...))' -
    i need to select again on the base tables - driven by the SQL collection data.
    But before i do so, i wanted to verify, if it's really not possible.
    Maybe i just miss a special oracle hint or whatever you can get "out of another box" :-)
    -------------------- snap ---------------------------------------------
    - many thanks!
    rgds,
    Frank

    Hi,
    i try to distribute SQL data objects - stored in a SQL data type TABLE OF <object-Type> - to multiple (parallel) instances of a table function,
    by passing a CURSOR(...) to the table function, which selects from the SQL TABLE OF storage via "select * from TABLE(CAST(<storage> as <storage-type>)".
    But oracle always only uses a single table function instance :-(
    whatever hints i provide or setting i use for the parallel table function (parallel_enable ...)
    Could it be, that this is due to the fact, that my data are not
    globally available, but only in the main thread data?
    Can someone confirm, that it's not possible to start multiple parallel table functions
    for selecting on SQL data type TABLE OF <object>storages?
    Here's an example sqlplus program to show the issue:
    -------------------- snip ---------------------------------------------
    set serveroutput on;
    drop table test_table;
    drop type ton_t;
    drop type test_list;
    drop type test_obj;
    create table test_table
         a number(19,0),
         b timestamp with time zone,
         c varchar2(256)
    create or replace type test_obj as object(
         a number(19,0),
         b timestamp with time zone,
         c varchar2(256)
    create or replace type test_list as table of test_obj;
    create or replace type ton_t as table of number;
    create or replace package test_pkg
    as
         type test_rec is record (
              a number(19,0),
              b timestamp with time zone,
              c varchar2(256)
         type test_tab is table of test_rec;
         type test_cur is ref cursor return test_rec;
         function TF(mycur test_cur)
    return test_list pipelined
    parallel_enable(partition mycur by hash(a));
    end;
    create or replace package body test_pkg
    as
         function TF(mycur test_cur)
    return test_list pipelined
    parallel_enable(partition mycur by hash(a))
    is
              sid number;
              counter number(19,0) := 0;
              myrec test_rec;
              mytab test_tab;
              mytab2 test_list := test_list();
         begin
              select userenv('SID') into sid from dual;
              dbms_output.put_line('test_pkg.TF( sid => '''|| sid || ''' ): enter');
              loop
                   fetch mycur into myRec;
                   exit when mycur%NOTFOUND;
                   mytab2.extend;
                   mytab2(mytab2.last) := test_obj(myRec.a, myRec.b, myRec.c);
              end loop;
              for i in mytab2.first..mytab2.last loop
                   -- attention: saves own SID in test_obj.a for indication to caller
                   --     how many sids have been involved
                   pipe row(test_obj(sid, mytab2(i).b, mytab2(i).c));
                   counter := counter + 1;
              end loop;
              dbms_output.put_line('test_pkg.TF( sid => '''|| sid || ''' ): exit, piped #' || counter || ' records');
         end;
    end;
    declare
         myList test_list := test_list();
         myList2 test_list := test_list();
         sids ton_t := ton_t();
    begin
         for i in 1..10000 loop
              myList.extend; myList(myList.last) := test_obj(i, sysdate, to_char(i+2));
         end loop;
         -- save into the real table
         insert into test_table select * from table(cast (myList as test_list));
         dbms_output.put_line(chr(10) || 'copy ''mylist'' to ''mylist2'' by streaming via table function...');
         select test_obj(a, b, c) bulk collect into myList2
         from table(test_pkg.TF(CURSOR(select /*+ parallel(tab,10) */ * from table(cast (myList as test_list)) tab)));
         dbms_output.put_line('... saved #' || myList2.count || ' records');
         select distinct(tab.a) bulk collect into sids from table(cast (myList2 as test_list)) tab;
         dbms_output.put_line('worker thread''s sid list:');
         for i in sids.first..sids.last loop
              dbms_output.put_line('sid #' || sids(i));
         end loop;
         dbms_output.put_line(chr(10) || 'copy physical ''test_table'' to ''mylist2'' by streaming via table function:');
         select test_obj(a, b, c) bulk collect into myList2
         from table(test_pkg.TF(CURSOR(select /*+ parallel(tab,10) */ * from test_table tab)));
         dbms_output.put_line('... saved #' || myList2.count || ' records');
         select distinct(tab.a) bulk collect into sids from table(cast (myList2 as test_list)) tab;
         dbms_output.put_line('worker thread''s sid list:');
         for i in sids.first..sids.last loop
              dbms_output.put_line('sid #' || sids(i));
         end loop;
    end;
    -------------------- snap ---------------------------------------------
    Here's the output:
    -------------------- snip ---------------------------------------------
    copy 'mylist' to 'mylist2' by streaming via table function...
    test_pkg.TF( sid => '98' ): enter
    test_pkg.TF( sid => '98' ): exit, piped #10000 records
    ... saved #10000 records
    worker thread's sid list:
    sid #98 -- ONLY A SINGLE SID HERE!
    copy physical 'test_table' to 'mylist2' by streaming via table function:
    ... saved #10000 records
    worker thread's sid list:
    sid #128 -- A LIST OF SIDS HERE!
    sid #141
    sid #85
    sid #125
    sid #254
    sid #101
    sid #124
    sid #109
    sid #142
    sid #92
    PL/SQL procedure successfully completed.
    -------------------- snap ---------------------------------------------
    I posted it to newsgroup comp.databases.oracle.server.
    (summary: "10g: parallel pipelined table functions with cursor selecting from table(cast(SQL collection)) doesn't work ")
    But i didn't get a response.
    There i also wrote some background information about my application:
    -------------------- snip ---------------------------------------------
    My application has a #2 steps/stages data selection.
    A 1st select for minimal context base data
    - mainly to evaluate for due driving data records.
    And a 2nd select for all the "real" data to process a context
    (joining much more other tables here, which i don't want to do for non-due records).
    So it's doing stage #1 select first, then stage #2 select - based on stage #1 results - next.
    The first implementation of the application did the stage #1 select in the main session of the pl/sql code.
    And for the stage #2 select there was done a dispatch to multiple parallel table functions (in multiple worker sessions) for the "real work".
    That worked.
    However there was a flaw:
    Between records from stage #1 selection and records from stage #2 selection there is a 1:n relation (via key / foreign key relation).
    Means, for #1 resulting record from stage #1 selection, there are #x records from stage #2 selection.
    That forced me to use "cluster curStage2 by (theKey)".
    Because the worker sessions need to evaluate the all-over status for a context of #1 record from stage #1 and #x records from stage #2
    (so it needs to have #x records of stage #2 together).
    This then resulted in delay for starting up the worker sessions (i didn't find a way to get rid of this).
    So i wanted to shift the invocation of the worker sessions to the stage #1 selection.
    Then i don't need the "cluster curStage2 by (theKey)" anymore!
    But: i also need to do an update of the primary driving data!
    So the stage #1 select is a 'select ... for update ...'.
    But you can't use such in CURSOR for table functions (which i can understand, why it's not possible).
    So i have to do my stage #1 selection in two steps:
    1. 'select for update' by main session and collect result in SQL collection.
    2. pass collected data to parallel table functions
    And for 2. i recognized, that it doesn't start up multiple parallel table function instances.
    As a work-around
    - if it's just not possible to start multiple parallel pipelined table functions for dispatching from 'select * from TABLE(CAST(... as ...))' -
    i need to select again on the base tables - driven by the SQL collection data.
    But before i do so, i wanted to verify, if it's really not possible.
    Maybe i just miss a special oracle hint or whatever you can get "out of another box" :-)
    -------------------- snap ---------------------------------------------
    - many thanks!
    rgds,
    Frank

  • Dynamic table pulled from SQL database, Need to Search

    My table results are not static, they are pulled into a
    dynamic table from a SQL database. Each table displays 10 records
    with an option at the bottom to display additional records
    (next/previous), for my query. I also have an option set up to
    allow users to click for a detail view of a record in the table. If
    the table data was static, I would be able to set up a search
    option and a results page for it, but I'm dealing with dynamic data
    on an .ASP page. I'd like to set up a search box to limit the
    records displayed in the table. I haven't found any code samples
    that are designed for dynamic data.
    Here is a copy of the code from my table.

    Hi,
    I think the code on this URL will get you the solution
    http://www.asp.happycodings.com/Array/code3.html
    Cheers,
    ~Maneet

  • Binding parameters to dynamic VO with PL/SQL API call with no where clause

    Hi all,
    I am required to change exisiting queries to queries with "bind" parameters. Some of our VOs are dynamic and with PL/SQL api calls like below:
    String stmtStr = "selectXXX_API_UTILS.chk_urg_since_last_prg("
    + projectId + "," + PPCId + ",'XYZ_TASKS'," + taskId+ ")"
    +" from dual ";
    ViewObject tmpVO = transaction.createViewObjectFromQueryStmt(stmtStr);
    In this regard, I am unsure how to bind the PPCId and taskId parameters to the VO. setWhereClauseParams() would not work here as there is now where clause.
    Thanks in advance,
    Srini

    In case of preparedStatement, we mention bind parameters to be passed using "?". Then we pass paramters sequencially.
    But in the your case following is enough:
    int projectId = 100 ; (hardcoding values for example)
    int taskId = 500 ;
    String stmtStr = "selectXXX_API_UTILS.chk_urg_since_last_prg("
    + projectId + "," + PPCId + ",'XYZ_TASKS'," + taskId+ ")"
    +" from dual ";
    -Anand

  • Creating Crystal Reports Dynamically from an incoming SQL query

    Hi,
    I have a requirement where a sql query will be entered by the user in a text box and in the back end java code, i have to create a crystal report dynamically based on that sql query and show it in the crystalviewer object.
    For example if the user writes "select x,y from xtable ", i should be able to create a report with 2 fields, and if the user says "select x,y,z from xtable" then i should be able create and show a report with 3 fileds...thsi report creation should be done in the click event.
    Is this possible in java? I have found something similar in .NET... pls have a look at this 
    http://vb.net-informations.com/crystal-report/dynamic_crystal_report_from_sql_query_string.htm
    Thanks,
    Preethi

    Hi Preethi,
    Can you please share the steps with me? I am also looking for dynamic SQL being applied to the crystal report.
    Thank you so much for your help in advance.
    Regards,
    Janakiram D.

  • Reg: How to Filter from PL/SQL Collection

    like SQL queries ...any otherway is there to filter from the PL/SQL collection ( PL/SQL table )...
    Edited by: user12159093 on Nov 28, 2010 7:24 PM

    LOOP
       IF
       THEN
       END IF
    END LOOP
    when all else fails Read The Fine Manual
    http://download.oracle.com/docs/cd/B19306_01/appdev.102/b14261/toc.htm
    http://asktom.oracle.com contains many fine coding examples
    Edited by: sb92075 on Nov 28, 2010 7:26 PM

  • Using Dynamic VIEW better pl/sql ?

    Hi,
    Would like to know your suggestion,
    Currently i need to process 5 tables and put the data into a new single Table.
    The number of Rows are many, 1000000 and could be even more.
    Now i am planning to Create a View from the 5 Tables and then
    form the View i am planning to do the Processing and
    after which i will put the processed data into the newly created table.
    Alternatively i was thinking of having a Collection of Objects(Nested Table) instead of VIEW,
    since the number of rows which need to be processed are more i felt this would not be a better option.
    Can we go-ahead creating VIEW dynamically, Or is there any better design Solution that you can think of ?
    regards,
    Alex

    Hi,
    I have Place the Sample Structure here along with the data .... and the expected output below.
    How can we BUILD a SQL Smt for the below :
    CREATE TABLE One_T (
    one_no NUMBER,
    one_message varchar2(20)
    CREATE TABLE Two_T (
    two_no NUMBER,
    two_message varchar2(20)
    CREATE TABLE Three_T (
    three_no NUMBER,
    three_message varchar2(20)
    CREATE TABLE Four_T (
    four_no NUMBER,
    four_message varchar2(20)
    CREATE TABLE Five_T (
    five_no NUMBER,
    five_message varchar2(20)
    CREATE TABLE Six_T (
    six_col1 varchar2(20),
    six_col2 varchar2(20),
    six_col3 varchar2(20)
    CREATE TABLE New_Table (
    New_Table_col1 varchar2(20),
    New_Table_col2 varchar2(20),
    New_Table_col3 varchar2(20),
    New_Table_col4 varchar2(20),
    New_Table_col5 varchar2(20),
    New_Table_col6 varchar2(20),
    New_Table_col7 varchar2(20)
    INSERT ALL
    INTO One_T(one_no,one_message) VALUES(1,'Message11')
    INTO One_T(one_no,one_message) VALUES(2,'Message12')
    INTO One_T(one_no,one_message) VALUES(3,'Message13')
    INTO One_T(one_no,one_message) VALUES(4,'Message14')
    INTO One_T(one_no,one_message) VALUES(5,'Message15')
    INTO Two_T(two_no,two_message) VALUES(1,'Message21')
    INTO Two_T(two_no,two_message) VALUES(2,'Message22')
    INTO Two_T(two_no,two_message) VALUES(3,'Message23')
    INTO Two_T(two_no,two_message) VALUES(4,'Message24')
    INTO Two_T(two_no,two_message) VALUES(5,'Message25')
    INTO Three_T(three_no,three_message) VALUES(1,'Message31')
    INTO Three_T(three_no,three_message) VALUES(2,'Message32')
    INTO Three_T(three_no,three_message) VALUES(3,'Message33')
    INTO Three_T(three_no,three_message) VALUES(4,'Message34')
    INTO Three_T(three_no,three_message) VALUES(5,'Message35')
    INTO Four_T(four_no,four_message) VALUES(1,'Message41')
    INTO Four_T(four_no,four_message) VALUES(2,'Message42')
    INTO Four_T(four_no,four_message) VALUES(3,'Message43')
    INTO Four_T(four_no,four_message) VALUES(4,'Message44')
    INTO Four_T(four_no,four_message) VALUES(5,'Message45')
    INTO Five_T(five_no,five_message) VALUES(1,'Message51')
    INTO Five_T(five_no,five_message) VALUES(2,'Message52')
    INTO Five_T(five_no,five_message) VALUES(3,'Message53')
    INTO Five_T(five_no,five_message) VALUES(4,'Message54')
    INTO Five_T(five_no,five_message) VALUES(5,'Message55')
    INTO Six_T(six_col1,six_col2,six_col3) VALUES(1,'MessageCol111','MessageCol211')
    INTO Six_T(six_col1,six_col2,six_col3) VALUES(1,'MessageCol112','MessageCol212')
    INTO Six_T(six_col1,six_col2,six_col3) VALUES(2,'MessageCol211','MessageCol221')
    INTO Six_T(six_col1,six_col2,six_col3) VALUES(2,'MessageCol221','MessageCol222')
    INTO Six_T(six_col1,six_col2,six_col3) VALUES(2,'MessageCol222','MessageCol223')
    SELECT * FROM dual;
    OUTPUT :
    New_Table
    MessageCol111, MessageCol211,Message11,Message21,Message31,Message41,Message51
    MessageCol112, MessageCol212,Message11,Message21,Message31,Message41,Message51
    ...

  • Help with dynamic statement returning values into collection

    Hi All
    I am trying to use dynamic statement to return values into a collection using the returning clause. However, I get an ORA-00933 error. Here is a simple setup:
    create table t(
        pk number,
        id_batch varchar2(30),
        date_created date,
        constraint t_pk primary key ( pk )
    create or replace type num_ntt is table of number;
    create or replace type vc2_ntt is table of varchar2(30);
    create or replace
    package pkg
    as
      type rec is record(
          pk        num_ntt,    
          id_batch  vc2_ntt
      procedure p(
          p_count in number,
          p_rt    out nocopy rec
    end pkg;
    create or replace
    package body pkg
    as
      procedure p(
          p_count in number,
          p_rt    out nocopy rec
      is
      begin
          execute immediate '
          insert into t
          select level, ''x'' || level, sysdate
          from   dual
          connect by level <= :p_count
          returning pk, id_batch into :pk, :id_batch'
          using p_count returning bulk collect into p_rt.pk, p_rt.id_batch;
      end p;
    end pkg;
    declare
      r  pkg.rec;
    begin
      pkg.p( 5, r );
    end;
    /

    sanjeevchauhan wrote:
    but I am working with dynamic statement and returning multiple fields into a collection.And using an INSERT...SELECT statement combined with a RETURNING INTO clause still does not work. Whether it's dynamic SQL or not: it doesn't work. The link describes a workaround.
    By the way, I don't see why you are using dynamic SQL here. Static SQL will do just fine. And so you can literally copy Adrian's setup.
    Regards,
    Rob.

  • How do I pass selected values from dynamic LOV to Command SQL in Oracle

    My environment:
    Crystal 11
    Oracle 10
    I've created and tuned a SQL script for a report.  In the Database Expert, I've copied the SQL into a Command.   I've modified the Command to create 3 parameters. 
    I need help with the following:
    1) How do I create a dynamic, cascading LOV and associated prompt group for the three parameters defined in the Command?
    2) How do I pass the user selected valueS from the prompt group into the Command SQL as limits applied to the query executed against the database?

    I have the same problem with same environment .
    The main report is having a  2 level cascading dynamic parameters.
    I created a sub report with a command as below.
    *select * from (*
    select DATUM,MSEC,CNT,B1_NAME,B2_NAME,B3_NAME,ELEM_NAME,INFO_NAME,m.INFOTYPE,V.NAME,rank()
    over (partition by B1_NAME,B2_NAME,B3_NAME order by DATUM desc ,MSEC desc,CNT desc) currentRank
    from MESSAGES m,INTYDE i,VANAME v
    where  DATUM <=SYSDATE  and trim(B1_NAME)='{?B1Name}'
    and trim(B2_NAME)='{?B2Name}'
    and m.INFOTYPE=i.INFOTYPE
    and i.VALUE_NAME_NUMBER = v.VALNUM) where currentRank=1
    I needs to pass cmbination of B1Name and B2Name from main report. I created a formula like
    formula=Join({?B1Name},{?B2Name}),'|');  But this is showing some error.
    and How I will substitute this in my command . As I new to Crystal XI  help expected.

  • Problem setting a hidden item value when button clicked with dynamic action or pl/sql process

    Apex 4.1
    Oracle 11g
    I have a page that consists of a main region and several sub regions.  I have a pl/sql process in After Header SET_DISPLAY(:P400_DISPLAY :='MAIN';)
    Three subregions have a contional display where P400_DISPLAY = STORE.  This works in hiding the sub regions.
    Now I want to change the P400_DISPLAY value to STORE to show the subregions when I hit a button.
    I tried creating a dynamic action for on click of the add button but get the following error:
    The selected button uses a 'Button Template' that does not contain the #BUTTON_ID# substitution string
    I went to the templates and found:
    Substitution Strings
    Substitution strings are used within sub templates to reference component values. This report details substitution string usage for this template.
    Substitution String
    Referenced
    From
    Description
    #LINK#
    Yes
    Template
    To be used in an "href" attribute
    #JAVASCRIPT#
    No
    To be used in an "onclick" attribute
    #LABEL#
    Yes
    Template
    Button Label
    #BUTTON_ATTRIBUTES#
    No
    Button Attributes
    #BUTTON_ID#
    No
    Generated button ID will be either the button's Static ID if defined, or if not will be an internally generated ID in the format 'B' || [Internal Button ID]
    I then tried creating a page process, pl/sql, :P400_DISPLAY :='STORE'; when the appropriate button is pressed.  The button action is submit page. However, it does not change the P400_DISPLAY value and the subregions stay hidden.
    Suggestions please on how to fix the template or change the P400_DISPLAY value?

    The root issue is that, although you change the value of your page item, it isn't visible to other areas of the page until it is in the session. So, any other action based on the value of your page item; the visibility of a control, a report based on the item's value, etc. will all be unaffected by changing the value of the page item until it has been changed in the session. Even after this the items are stored in the session, you must thereafter do something to cause the value to be reevaluated. To see the effect of this, observe that your page loads and evaluates the value of your page item, it sees that is "MAIN" and hides the regions. However, it doesn't reevaluate them after this.
    So; your choices to get this value set in the session are to either Submit the page, or use JavaScript to set the value in the session. If you use the latter of these, you'll have to do some further work to cause the visibility tests to be re-run, So, let's stick with with the submit method.
    What you've done above sounds correct for this but, there are a lot of decisions you could have made that might have caused things not to happen in the correct sequence.
    Firstly, let's confirm that what I describe above is your problem. From the development environment, load the page, click the button to change the value and submit. Now, click the link labelled Session. Is it still set to MAIN? If so; this is your issue.
    Let's start with the your After Header computation. Did you set it to *only* run if the current value of your page item is NULL??? If not, that's your problem.
    Load Page -> Item set to 'Main' by Computation -> Click Button -> Item set to STORE -> Submit -> Load Page -> Item set to 'Main' by Computation
    See the problem?
    Assuming this isn't the issue, you created a Branch to the same page, right? What is your process point for the Branch? Is it *After* Validation, Computation etc? Because if not, you aren't changing the value before the submit happens.
    I bet it is the first issue but, take a look at these.
    Cheers,
    -Joe

  • How to set dynamic table name in sql query?

    I want set dynamic table name by parameter in sql query,just like:
    select * from :tbname
    but run report is error,BI P report table name is invalidation.
    What can i do? Thanks!

    Hi,
    that's only possible inside a data template with a lexical parameter.
    Regards
    Rainer

  • Dynamic header creation using SQL

    Hi Gurus,
    I need your help again. I have a query which uses a date parameter to populate a report. The report pulls out data from the user entered date to minus eleven months. The report counts totals calls registered each month. I have the query working fine but I need help in populating the header.
    For ex - suppose I run the query on todays date (18-Jan-2012)
    The report header will be -
    Jan Feb Mar Apr ....Dec
    But I want the header to be populated in the following format -
    Jan 2012 Feb 2011 Mar 2011 Apr 2011....Dec 2011
    And for ex if I run the report for a future date say (21-May-2012)
    The header will be in the following format -
    Jan 2012....May 2012 Jun 2011 Jul 2011 .......Dec 2011.
    Please let me know if I can populate the header using SQL. Any help is greatly appreciated.

    Hi Tenacious,
    You wrote:
    I want the header to be populated in the dynamic format with the year value concanated to the Month column.My script does that; you can look one more time at the output in my first post, and also in my second post.
    And if you want another example, when we replace 18-Jan-2012 by 21-May-2012, we have the following:
    SQL> select to_char(col,'Monyyyy') col_date
      2  from
      3  (select
      4         add_months(to_date('21-May-2012','dd-Mon-yyyy'),
      5                      -level + 1) col
      6  from dual
      7  connect by level <= extract(month from to_date('21-May-2012','dd-Mon-yyyy')
      8  union
      9  select
    10         add_months(to_date('21-May-2012','dd-Mon-yyyy')
    11                    , level - 12 )
    12  from dual
    13  connect by level <= 12 - extract(month from to_date('21-May-2012','dd-Mon-y
    yyy')))
    14  order by extract(year from col) desc, extract(month from col);
    COL_DAT
    Jan2012
    Feb2012
    Mar2012
    Apr2012
    May2012
    Jun2011
    Jul2011
    Aug2011
    Sep2011
    Oct2011
    Nov2011
    COL_DAT
    Dec2011
    12 rows selected.
    SQL>

  • Pass PL/SQL collection as function parameter over DBLink

    Hi all,
    I am trying to do the following;
    ---Remote database
    --create SQL type
    create type attributeidarray as table of varchar2(255);
    --create a package specs
    CREATE OR REPLACE PACKAGE testp
    AS
    TYPE ref_res IS REF CURSOR;
    FUNCTION foo (i NUMBER)
    RETURN NUMBER;
    FUNCTION foo1 (i NUMBER, j attributeidarray)
    RETURN NUMBER;
    END;
    --create package body
    CREATE OR REPLACE PACKAGE BODY testp
    IS
    --Function does nothing other than return number
    FUNCTION foo (i NUMBER)
    RETURN NUMBER
    IS
    res ref_res;
    a array_n;
    BEGIN
    OPEN res
    FOR
    SELECT *
    FROM DUAL;
    RETURN 1;
    END;
    --Function takes the collection as imput and does nothing with it. Function just returns number
    FUNCTION foo1 (i NUMBER, j attributeidarray)
    RETURN NUMBER
    IS
    res ref_res;
    a array_n;
    BEGIN
    OPEN res
    FOR
    SELECT *
    FROM DUAL;
    RETURN 1;
    END;
    END;
    --"Near" Database ..
    --create a SQL type
    --This is the exactly the same as in remote database
    create type attributeidarray as table of varchar2(255);
    --create a DBLink
    create database link con_to_remote_db
    connect to remotedbuser
    identified by "swordfish"
    using 'remotedb'
    --call the remote functions and pass a collection object
    SQL> DECLARE
    2 a attributeidarray;
    3 BEGIN
    4 SELECT CAST (attributeidarray (1, 2) AS attributeidarray)
    5 INTO a
    6 FROM DUAL;
    7
    8 :b := testp.foo@con_to_remote_db (2);
    9 END;
    10 /
    PL/SQL procedure successfully completed.
    SQL> print b
    B
    1
    SQL>
    --so far so good...
    SQL> DECLARE
    2 a attributeidarray;
    3 BEGIN
    4 SELECT CAST (attributeidarray (1, 2) AS attributeidarray)
    5 INTO a
    6 FROM DUAL;
    7
    8 :b := testp.foo1@con_to_remote_db (2, a);
    9 END;
    10 /
    :b := testp.foo1@con_to_remote_db (2, a);
    ERROR at line 8:
    ORA-06550: line 8, column 10:
    PLS-00306: wrong number or types of arguments in call to 'FOO1'
    ORA-06550: line 8, column 4:
    PL/SQL: Statement ignored
    --Oops...doesn't seem to recognize the collection type :( /b]
    So I wish to know the following;
    - Even though the definition for type is the same, why is the remote DB not recognizing my type?
    - It would be helpful if any one can let me know the correct method to pass a collection type with a example.
    I would appreciate any help in resolving this issue.
    Thanks,
    prashant

    Not possible. For valid technical reasons.
    Definitions are local to a database. You can define a SQL user type called TMyType in your database. I can define one in mine with the same name.
    Can you now call my database, passing a collection of your TMyType to me? How do we (or Oracle) know that your definition and my definition is the same? Or if they were the same when you compiled your code (and your Oracle checked my Oracle to confirm), that they still are the same and that I did not in the meantime altered the type? Or even dropped it?
    For types/collections to be transparently passed across to database links, we need something along the lines of:
    a) global types
    b) runtime checking of types
    Both are problematic to implement and maintain. With (a) there is the issue of dependencies. The global type cannot be changed before all dependencies on all subscribers have been resolved. With (b) there is the issue of performance, checking the type definitions with every single call on the local & remote instances to compare.
    It would be a nice feature to have... but it would fail to live up to expectation if not implemented in a robust and performant way.
    Alternative. "Insert" data via a remote proc into a remote collection. This allows you to push data into a PGA memory structure on the remote side and when done, allows you to tell that remote proc to "flush" (forall insert/update/delete) the contents of that structure to disk.

  • Dynamic Dimesion Building using SQL Interface

    I am attempting to use SQL Interface in Essbase 6.5 to dynamically build the account dimension from a PeopleSoft tree. The view works fine in SQL worksheet, but the last UNION statement does not work using the SQL interface. Here is the SQL that is generated: [SELECT * FROM ps_n_pre_acc_vw WHERE 1 = 1 order by 6,4,5,3] is generated. Here is the view:SELECT B.TREE_NODE AS PARENT , A.TREE_NODE AS CHILD , (A.TREE_NODE||' : '||C.DESCR) , b.tree_node_num AS num , a.tree_node_num AS c_tree_node_num , 'A' AS ord FROM SYSADM.PSTREENODE A , SYSADM.PSTREENODE B , SYSADM.PS_TREE_NODE_TBL C WHERE A.TREE_NAME = 'PRE_CUBE' AND A.SETID = 'NW' AND A.EFFDT = ( SELECT MAX(EFFDT) FROM PSTREELEAF WHERE TREE_NAME = 'PRE_CUBE') AND A.TREE_NAME = B.TREE_NAME AND A.SETID = B.SETID AND A.EFFDT = B.EFFDT AND A.PARENT_NODE_NUM = B.TREE_NODE_NUM AND A.TREE_NODE = C.TREE_NODE AND A.SETID = C.SETID AND C.EFF_STATUS = 'A' AND C.EFFDT = ( SELECT MAX(EFFDT) FROM SYSADM.PS_TREE_NODE_TBL X WHERE C.TREE_NODE = X.TREE_NODE AND C.SETID = X.SETID) UNION SELECT B.TREE_NODE AS PARENT , (A.RANGE_FROM||' : '||DESCR) AS child , A.RANGE_FROM , b.tree_node_num AS num , a.tree_node_num AS c_tree_node_num , 'B' AS ord FROM SYSADM.PSTREELEAF A , SYSADM.PSTREENODE B , SYSADM.PS_GL_ACCOUNT_TBL C WHERE A.TREE_NAME = 'PRE_CUBE' AND A.SETID = 'NW' AND A.EFFDT = ( SELECT MAX(EFFDT) FROM PSTREELEAF WHERE TREE_NAME = 'PRE_CUBE') AND A.TREE_NAME = B.TREE_NAME AND A.EFFDT = B.EFFDT AND A.SETID = B.SETID AND A.TREE_NODE_NUM = B.TREE_NODE_NUM AND C.SETID = A.SETID AND A.RANGE_FROM = C.ACCOUNT AND C.EFFDT = ( SELECT MAX(EFFDT) FROM SYSADM.PS_GL_ACCOUNT_TBL X WHERE C.ACCOUNT = X.ACCOUNT AND c.setid = x.setid) UNION SELECT B.TREE_NODE AS PARENT , (D.ACCOUNT||' : '||DESCR) AS child , D.ACCOUNT , b.tree_node_num AS num , a.tree_node_num AS c_tree_node_num , 'B' AS ord FROM pstreeleaf a , pstreenode b , PS_GL_ACCOUNT_TBL D WHERE a.tree_name = 'PRE_CUBE' AND a.effdt = '01-JAN-2001' AND A.SETID = 'NW' AND A.RANGE_FROM <> A.RANGE_TO AND A.TREE_NAME = B.TREE_NAME AND A.SETID = B.SETID AND A.EFFDT = B.EFFDT AND A.TREE_NODE_NUM = B.TREE_NODE_NUM AND D.ACCOUNT BETWEEN A.RANGE_FROM AND A.RANGE_TO AND D.SETID = 'NW' AND D.EFFDT = ( SELECT MAX(EFFDT) FROM PS_GL_ACCOUNT_TBL X WHERE D.ACCOUNT = X.ACCOUNT AND D.SETID = X.SETID)I created a view from the last union section of the SQL and Essbase returns a zero rows found error, although when I ran the view in SQL worksheet I was able to get rows returned. Any ideas on why the view does not return the expected results in Essbase?

    before your query do:
    <cfsavecontent
    variable="emailmessagebody"><cfinclude
    template="#mancbPath#/mancb_body.cfm"></cfsavecontent>
    then in your query instead of using '<cfinclude ...>'
    use
    '#emailmessagebody#'
    Azadi Saryev
    Sabai-dee.com
    http://www.sabai-dee.com/

Maybe you are looking for

  • Is it possible to check the log of IP accounts tha...

    I would like to check if certain people have been hacking into my skype and reading my conversations, if not the IP address then would it be possible to check the general location of people logging into your skype?

  • IPad 4th gen won't charge?

    I have recently got an iPad 4th gen (3 with lightning charger). Last night I was on youtube watching videos, when suddenly the screen went black. I plugged it into the wall, pressed the on switch.. it turned on and it was 1%. So I let it charge overn

  • Custom Portal issues

    I created three "views".  They are called PlantAllocations.aspx, WhereUsed.aspx, and Default.aspx where Default.aspx is just a copy of SamplePortal.aspx from the MockCustomPortalPlugins sample solution that was provided.  My issue is when I try to go

  • Add additional button to BBPSC08 internet service (SRM)

    Hi, is it possible to add an additional button to the webform screen of internet service BBPSC08 of the SRM Shopping Cart functionality ? Right now we have only one button 'Change'. This internet service BBPSC08 is triggered by a workflow task. The a

  • [FATAL] [INS-30508] Invalid ASM disks.

    Dear Gurus please help for troubleshoot the Invalid asm disk error on solaris Oracle Grid 11.2.0.3.0 Solaris10 with EMC Powerpath Partition -bash-3.2$ ./runInstaller -silent -responseFile /aaa/Oracle11g_SunSPARC_64bit/grid/response/grid_install.rsp S