catch the collection returned by the function in a SQL statement

I have a select like query: (I need all the values returned by the function in the select list)

Select t1.col1, t2.col2, (by selecting t.a, t.b., t.c in fn (t2.col3) t)
Of
T1, t2
where t1.col1 = t2.col2;



My function is like:

FN (T2.col3) returns an array in format of the object



Here, I was able to select only one value from the table returned by the funcation both. If I select all of the values as above, she gave too much error vales.
Please someone help me in this

user13044793 wrote:
I have a select like query: (I need all the values returned by the function in the select list)

Select t1.col1, t2.col2, (by selecting t.a, t.b., t.c in fn (t2.col3) t)
Of
T1, t2
where t1.col1 = t2.col2;

No specific reason for this? It adds additional complexity to the projection of SQL, and there are additional costs of failover for the motor of PL/SQL (per line) of context. Overall - not your typical approach and one that should have sound justification.

With regard to the basic method - the SQL multiset() function should be used to create a collection. Here is an example of the approach:

SQL> create or replace type TFoo as object(
  2          id      number,
  3          bar     varchar2(5)
  4  );
  5  /

Type created.

SQL>
SQL> create or replace type TFooSet as table of TFoo;
  2  /

Type created.

SQL>
SQL> create or replace function GetSomeFoo( n number ) return TFooSet is
  2          foo     TFooSet;
  3  begin
  4          foo := new TFooSet();
  5          foo.Extend( 5 );
  6
  7          for i in 1..5
  8          loop
  9                  foo(i) := new TFoo( n+i-1, to_char(i-1,'0000') );
 10          end loop;
 11
 12          return( foo );
 13  end;
 14  /

Function created.

SQL>
SQL> select
  2          object_id,
  3          object_name,
  4          cast(
  5                  multiset( select * from table(GetSomeFoo(object_id)) ) as TFooSet
  6          )       as FOO
  7  from       all_objects
  8  where      owner = 'SYS'
  9  and        rownum <= 5;

 OBJECT_ID OBJECT_NAME                    FOO(ID, BAR)
---------- ------------------------------ --------------------------------------------------
     27538 /1000e8d1_LinkedHashMapValueIt TFOOSET(TFOO(27538, ' 0000'), TFOO(27539, ' 0001')
                                          , TFOO(27540, ' 0002'), TFOO(27541, ' 0003'), TFOO
                                          (27542, ' 0004'))

     28544 /1005bd30_LnkdConstant         TFOOSET(TFOO(28544, ' 0000'), TFOO(28545, ' 0001')
                                          , TFOO(28546, ' 0002'), TFOO(28547, ' 0003'), TFOO
                                          (28548, ' 0004'))

     11718 /10076b23_OraCustomDatumClosur TFOOSET(TFOO(11718, ' 0000'), TFOO(11719, ' 0001')
                                          , TFOO(11720, ' 0002'), TFOO(11721, ' 0003'), TFOO
                                          (11722, ' 0004'))

     30094 /100c1606_StandardMidiFileRead TFOOSET(TFOO(30094, ' 0000'), TFOO(30095, ' 0001')
                                          , TFOO(30096, ' 0002'), TFOO(30097, ' 0003'), TFOO
                                          (30098, ' 0004'))

    684122 /1023e902_OraCharsetUTFE       TFOOSET(TFOO(684122, ' 0000'), TFOO(684123, ' 0001
                                          '), TFOO(684124, ' 0002'), TFOO(684125, ' 0003'),
                                          TFOO(684126, ' 0004'))

SQL>
SQL> with dataset as(
  2          select
  3                  object_id,
  4                  object_name,
  5                  cast(
  6                          multiset( select * from table(GetSomeFoo(object_id)) ) as TFooSet
  7                  )                as FOO
  8          from    all_objects
  9          where   owner = 'SYS'
 10          and     rownum <= 5
 11  )
 12  select
 13          d.object_id,
 14          d.object_name,
 15          f.id,
 16          f.bar
 17  from   dataset d,
 18          table(d.foo) f
 19  /

 OBJECT_ID OBJECT_NAME                            ID BAR
---------- ------------------------------ ---------- ---------------
       217 DUAL                                  217  0000
       217 DUAL                                  218  0001
       217 DUAL                                  219  0002
       217 DUAL                                  220  0003
       217 DUAL                                  221  0004
       268 SYSTEM_PRIVILEGE_MAP                  268  0000
       268 SYSTEM_PRIVILEGE_MAP                  269  0001
       268 SYSTEM_PRIVILEGE_MAP                  270  0002
       268 SYSTEM_PRIVILEGE_MAP                  271  0003
       268 SYSTEM_PRIVILEGE_MAP                  272  0004
       271 TABLE_PRIVILEGE_MAP                   271  0000
       271 TABLE_PRIVILEGE_MAP                   272  0001
       271 TABLE_PRIVILEGE_MAP                   273  0002
       271 TABLE_PRIVILEGE_MAP                   274  0003
       271 TABLE_PRIVILEGE_MAP                   275  0004
       274 STMT_AUDIT_OPTION_MAP                 274  0000
       274 STMT_AUDIT_OPTION_MAP                 275  0001
       274 STMT_AUDIT_OPTION_MAP                 276  0002
       274 STMT_AUDIT_OPTION_MAP                 277  0003
       274 STMT_AUDIT_OPTION_MAP                 278  0004
       815 RE$NV_LIST                            815  0000
       815 RE$NV_LIST                            816  0001
       815 RE$NV_LIST                            817  0002
       815 RE$NV_LIST                            818  0003
       815 RE$NV_LIST                            819  0004

25 rows selected.

SQL>

Tags: Database

Similar Questions

  • How to the return type of function from PL/SQL

    Hello

    I need to create a function that returns a list of ID, which is stored in a type T_IDs, something like:

    search function (searchstring in varchar2) return to T_IDs

    I have a little problem with the type within the body of the function using a select statement and filling

    Select the id of the table where the text as searchstring.

    which is to select a list of IDS corresponding to the where clause. Is it possible to use select in or should I go for another mechanism?

    Thanks for all the ideas.

    Bulk Collect works for me...

    SQL> create type t_ids as table of number;
      2  /
    
    Type created.
    
    SQL> ed
    Wrote file afiedt.buf
    
      1  create or replace function get_ids(deptno in number) return t_ids is
      2    ids t_ids;
      3  begin
      4    select empno
      5    bulk collect into ids
      6    from   emp
      7    where  deptno = get_ids.deptno;
      8    return ids;
      9* end;
    SQL> /
    
    Function created.
    
    SQL> select * from table(get_ids(10));
    
    COLUMN_VALUE
    ------------
            7782
            7839
            7934
    

    However, I would rarely use such a data collection, as it fills with PGA in memory and passing a lot of data between SQL and PL/SQL. I must have a just cause and justified in wanting to do things this way.

  • How to "end" to the function definition in SQL like?

    I'm using Oracle 11 g and SQL Plus.

    I'm trying to define a function and return to the SQL command prompt, but it is simply not to leave the function definition.

    SQL > create function dept_count (dept_name varchar (20))
    2 returns whole
    3. start
    4 declare entire d_count;
    5. select count (*) in d_count
    6 the instructor
    7 where instructor.dept_name = dept_name
    8 return d_count;
    9 end
    10;
    11
    12
    13
    14
    15
    16.
    end 17 dept_count;
    18;
    19
    20; <-I expect the SQL > invite here, but it is not.

    What should I do? Help, please. Thank you.

    Try this please

    .
    .
    .
    SQL> end ;
    SQL> /
    
  • Trace is still get generated even after disabling the option of initializing SQL statement - Custom profile

    Hi all

    We have a problem with the profile option "initialize SQL statement - Custom." We put this at the user level. After awhile, we have erased the value of the this user profile option.

    But you can still see the trace files generated are getting updated. We checked this files trc pathname returned at the bottom of the query.

    Select name, value

    the parameter $ v

    WHERE name like 'user_dump_dest;

    Please help us on how to solve this problem. We use Oracle Apps R 12.1.2 version.

    Thanks in advance

    Rambaud

    Find the trace file creation session and kill this session

    HTH
    Srini

  • Cannot display the results to the database during "Update": SQL statement

    Hello

    I get this error trying to update a VO via the UI or BCBrowser.

    Cannot display the results to the database during "Update": SQL statement

    This is a default single front & right THAT VO creates on the object of the entity (Database Table)

    On the same table and with the same credentials of DB, I could update the record.

    Any guess on what went wrong?

    Thanks in advance for any help.

    p.s Jdev 11.1.1.6

    Journal:

    oracle.jbo.DMLException: Houston-26041: could not publish data from database in "Update": SQL statement "START the CAR UPDATED CarEO SET SEL_ITEM =: 1 WHERE TXN_NO =: 2 AND LOGID =: AND SEQNO = 3: 4 POLL DELIVERY_MODE, CERTIFICATION_REQ, SOFT_COPY_IND, SELITEM IN: 5,: 6,: 7,: 8; END; ».

    at oracle.jbo.server.OracleSQLBuilderImpl.doEntityDML(OracleSQLBuilderImpl.java:583)

    at oracle.jbo.server.EntityImpl.doDML(EntityImpl.java:8575)

    at oracle.jbo.server.EntityImpl.postChanges(EntityImpl.java:6816)

    at oracle.jbo.server.DBTransactionImpl.doPostTransactionListeners(DBTransactionImpl.java:3290)

    at oracle.jbo.server.DBTransactionImpl.postChanges(DBTransactionImpl.java:3093)

    at oracle.jbo.server.DBTransactionImpl.commitInternal(DBTransactionImpl.java:2097)

    at oracle.jbo.server.DBTransactionImpl.commit(DBTransactionImpl.java:2378)

    at oracle.adf.model.bc4j.DCJboDataControl.commitTransaction(DCJboDataControl.java:1615)

    at oracle.adf.model.binding.DCDataControl.callCommitTransaction(DCDataControl.java:1417)

    at oracle.jbo.uicli.binding.JUCtrlActionBinding.doIt(JUCtrlActionBinding.java:1437)

    at oracle.adf.model.binding.DCDataControl.invokeOperation(DCDataControl.java:2150)

    at oracle.jbo.uicli.binding.JUCtrlActionBinding.invoke(JUCtrlActionBinding.java:740)

    at oracle.jbo.uicli.jui.JUActionBinding.actionPerformed(JUActionBinding.java:193)

    at oracle.jbo.uicli.controls.JUNavigationBar.doAction(JUNavigationBar.java:412)

    at oracle.jbo.jbotester.NavigationBar.doAction(NavigationBar.java:111)

    to oracle.jbo.uicli.controls.JUNavigationBar$ NavButton.actionPerformed (JUNavigationBar.java:118)

    at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1995)

    in javax.swing.AbstractButton$ Handler.actionPerformed (AbstractButton.java:2318)

    at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:387)

    at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:242)

    at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:236)

    at java.awt.AWTEventMulticaster.mouseReleased(AWTEventMulticaster.java:272)

    at java.awt.Component.processMouseEvent(Component.java:6289)

    at javax.swing.JComponent.processMouseEvent(JComponent.java:3267)

    at java.awt.Component.processEvent(Component.java:6054)

    at java.awt.Container.processEvent(Container.java:2041)

    at java.awt.Component.dispatchEventImpl(Component.java:4652)

    at java.awt.Container.dispatchEventImpl(Container.java:2099)

    at java.awt.Component.dispatchEvent(Component.java:4482)

    at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4577)

    at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4238)

    at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4168)

    at java.awt.Container.dispatchEventImpl(Container.java:2085)

    at java.awt.Window.dispatchEventImpl(Window.java:2478)

    at java.awt.Component.dispatchEvent(Component.java:4482)

    at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:644)

    to java.awt.EventQueue.access$ 000 (EventQueue.java:85)

    in java.awt.EventQueue$ 1.run(EventQueue.java:603)

    in java.awt.EventQueue$ 1.run(EventQueue.java:601)

    at java.security.AccessController.doPrivileged (Native Method)

    in java.security.AccessControlContext$ 1.doIntersectionPrivilege(AccessControlContext.java:87)

    in java.security.AccessControlContext$ 1.doIntersectionPrivilege(AccessControlContext.java:98)

    in java.awt.EventQueue$ 2.run(EventQueue.java:617)

    in java.awt.EventQueue$ 2.run(EventQueue.java:615)

    at java.security.AccessController.doPrivileged (Native Method)

    in java.security.AccessControlContext$ 1.doIntersectionPrivilege(AccessControlContext.java:87)

    at java.awt.EventQueue.dispatchEvent(EventQueue.java:614)

    at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:269)

    at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:184)

    at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:174)

    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:169)

    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:161)

    at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)

    Caused by: java.sql.SQLException: invalid column type

    at oracle.jdbc.driver.OracleCallableStatement.registerOutParameterInternal(OracleCallableStatement.java:150)

    at oracle.jdbc.driver.OracleCallableStatement.registerOutParameter(OracleCallableStatement.java:399)

    at oracle.jdbc.driver.OracleCallableStatement.registerOutParameter(OracleCallableStatement.java:581)

    at oracle.jdbc.driver.OracleCallableStatementWrapper.registerOutParameter(OracleCallableStatementWrapper.java:1765)

    at oracle.jbo.server.OracleSQLBuilderImpl.bindUpdateStatement(OracleSQLBuilderImpl.java:2243)

    at oracle.jbo.server.EntityImpl.bindDMLStatement(EntityImpl.java:10524)

    at oracle.jbo.server.OracleSQLBuilderImpl.doEntityDML(OracleSQLBuilderImpl.java:412)

    ... 52 more

    The problem is solved now.

    new columns added to the database table, after the creation of the entity object. Those changes were not picked up in the entity object.

    I found this difference after object entity with the DB Table comparison.

    And when I added these new columns to EO & VO, I don't get this error more.

    Thanks to all who tried to help

  • In SQL Developer, is it possible to send the results of a sql statement?

    In SQL Developer, is it possible to send the results of a sql statement?

    Right-click on the query results pane, select "Export data" in the context menu, then select "xls".

  • Graph based on the function of PL/SQL returning the sql query

    Hello, is it possible to have a chart based on PL/SQL return SQL function as with the reports.
    If I need to present data that is based on the graph and the graph itself, and the report is based on the function PL/SQL, SQL back then how I do the table if this is not possible? Also, is there a way to specify which columns in the report to use for the chart instead of having to specify the same question again on the list - this seems a bit redundant.

    Ah, OK - one HTML table does not offer the possibility of using the PL/SQL (I don't know why, if)

    However, you can create a collection (using the APEX_COLLECTION. Function CREATE_COLLECTION_FROM_QUERY) from your vSQL of string and then basing the chart on that?

    Andy

  • Impossible to retrieve the return value of function from pl/sql using the DB adapter

    Dear Experts,

    I use the DB adapter in my BPEL process. Using the DB adapter I invoke a PL / SQL function. I am able to send two input parameters for the pl/sql function. But I do not know how to retrieve the return value of the function. Please suggest me.

    Thank you
    Rajesh

    Can you tell how pl/sql function looks like you? you return the value of the function, right?

  • can we write the function in a select statement?

    I have function and there Out parameter, so in this case I can write a select statement to my function to retrieve the value?

    user11195165 wrote:
    I have function and there Out parameter, so in this case I can write a select statement to my function to retrieve the value?

    Never mind that it's bad! for a function to have an OUT parameter. That's not how the functions should be designed and written.

    It's like with a knife like a spoon to eat porridge. Of course, it can work in a way. But why? A knife was never designed to be a spoon - and while it may work of porridge to eat, you'll have a hell of a time trying to use it to eat the soup. So, use the right tool.

    In other words, a function is the wrong tool for the job. Use a procedure.

  • The analysis of a sql statement without executing it

    Hello everyone,

    I would like to know a way of parsing sql statements to validate them, so I would get the error messages in advance without executing them.

    Here we have the difficult task to analyze several sql scripts and send corrections to the development team and thirty third companies before applying them in our production databases. I am ready to create a program web/pl sql, making this difficult task, at least one program to identify errors such as lack of owner of the table, nonexistent tables, syntax errors and so on...

    Any information will be a great help!

    Thanks in advance.

    Hi and welcome to the forum.

    Tip1:
    http://asktom.Oracle.com/pls/asktom/f?p=100:11:0:P11_QUESTION_ID:3648254441315

    Tip2:
    to bookmark this forum (SQL and PL/SQL)
    Bookmark http://tahiti.oracle.com (The Oracle Documentation)
    Bookmark http://asktom.oracle.com

    Tip3:
    On all the sites mentioned, you can do a quick search on key words of your interest and you will get the examples and explanations returned.

  • Using a Bind Variable in the FROM of a SQL statement part?

    Hi all

    I have a problem, I am trying to execute a SQL statement. However, I need the FROM part of the SQL statement in a variable binding. This is because the end user will have to choose between 2 views of database.

    I tried this:
    Select CON_ID from: P23_DB_NAME where CON_LEGACY_ID =: P23_CONLEG_NO

    I had no chance. The error I got was,
    '+ The query cannot be parsed in the generator. If you believe that your request is
    syntactically correct, choose the generic "columns" box below the
    the source of the region without analysis.
    "ORA-00903: invalid table name +".
    What makes sence, but now I'm a little stuck.

    Does anyone have ideas for a workaround?

    Thanks in advance.
    -N.S.N.O.

    The example I gave you is quite simple. You must take some time to study it to see where you need to be very careful what put you where. Now, of course your example does not work becaues you have several errors. It will work for you:

    DECLARE
       x   VARCHAR2 (4000);
    BEGIN
       x := x || 'SELECT CON_ID FROM ';
       x := x || :p23_db_name;
       x := x || ' WHERE CON_LEGACY_ID = ' || :p23_conleg_no;
       RETURN (x);
    END;
    

    Denes Kubicek
    -------------------------------------------------------------------
    http://deneskubicek.blogspot.com/
    http://www.Opal-consulting.de/training
    http://Apex.Oracle.com/pls/OTN/f?p=31517:1
    -------------------------------------------------------------------

  • Zero error of iteration - the treatment of dynamic sql statements in dbms_xmlgen

    Hello

    I have a procedure that creates a dynamic sql v_sql

    cursor v_curr is
    Select *.
    of btctl_msg_log;

    BEGIN
    Select count (*) in the v_cnt of btctl_msg_log;

    IF v_cnt > 0 THEN
    C1 in v_curr
    LOOP
    v_sql: = "' | ' SELECT * from '. C1.msg_rcrd_src_tbl_nm | |' where rowid = ' | " ' ||'' ' || C1.msg_rcrd_src_tbl_id | " ' ||'' ' ||'' ' ;
    Select DBMS_XMLGEN.getXMLtype (v_sql) in the double v_xml;

    gives me an error

    ORA-19202: an error has occurred in the processing of XML
    ORA-24333: zero number of iterations
    ORA-06512: at "SYS." DBMS_XMLGEN", line 288
    ORA-06512: at line 1

    I don't know why is this error happening.
    Any help much appreciated.

    881575 wrote:
    Hello

    I have a procedure that creates a dynamic sql v_sql

    cursor v_curr is
    Select *.
    of btctl_msg_log;

    BEGIN
    Select count (*) in the v_cnt of btctl_msg_log;

    IF v_cnt > 0 THEN
    C1 in v_curr
    LOOP
    v_sql: = "' | ' SELECT * from '. C1.msg_rcrd_src_tbl_nm | |' where rowid = ' | " ' ||'' ' || C1.msg_rcrd_src_tbl_id | " ' ||'' ' ||'' ' ;
    Select DBMS_XMLGEN.getXMLtype (v_sql) in the double v_xml;

    gives me an error

    ORA-19202: an error has occurred in the processing of XML
    ORA-24333: zero number of iterations
    ORA-06512: at "SYS." DBMS_XMLGEN", line 288
    ORA-06512: at line 1

    I don't know why is this error happening.
    Any help much appreciated.

    Standard when boards (ab) use of EXECUTE IMMEDIATE is to compose the SQL statement in a single VARCHAR2 variable
    Then print the variable before passing to EXECUTE IMMEDIATE.
    COPY the statement & PASTE in sqlplus to validate its correctness.

  • Under certain conditions, update a table based on the comparison with a SQL statement

    I have a table (table 1) that has 4 columns:

    UID. THE NEST | VALUE1 | VALUE2

    I have another statement SQL (STMT) that returns the 3 columns of a few other tables:

    UID. THE NEST | VALUE1

    Now this is the condition of the way in which I want to put up-to-date TABLE1:

    First, to compare a pair of UID and PID of STMT with those in TABLE1,

    -1, for any new pair UID and PID not in TABLE1, insert a new line of STMT in TABLE1 set TABLE1. Value2 = 0 (I already did this).

    2, for an existing UID and PID pair in STMT and TABLE1, do:

    a. in TABLE1. Value2 > 0, update TABLE1. VALUE1 = STMT. VALUE1

    b. to TABLE1. Value2 = 0 and if TABLE1. VALUE1! = STMT. Value1, update of TABLE1. VALUE1 = STMT. Value1, otherwise nothing to do.

    I can't seem to come with a solution for condition 2. Any help is appreciated!

    Hello

    Here's one way:

    MERGE INTO  table1  dst
    USING          (
                 SELECT  ...   -- your stmt query goes here
             )   src
    ON         (    src.uid  = dst.uid
             AND      src.pid  = dst.pid
             )
    WHEN MATCHED THEN UPDATE
    SET           dst.value1 = CASE
                                   WHEN   dst.value2 > 0
                        OR     (   dst.value2 = 0
                             AND dst.calue1 != src.value1
                        )
                        THEN   src.value1
                               END
    WHERE   dst.value2 > 0
    OR (    dst.value2 = 0
       AND  dst.calue1 != src.value1
       )
    ;
    

    This assumes that the combination (uid, pid) is unique in stmt. It doesn't have to be unique in table1.

    sb92075 wrote:

    -1, for any new pair UID and PID not in TABLE1, insert a new line of STMT in TABLE1 set TABLE1. Value2 = 0 (I already did this).

    FUSION could also do parts 1 and 2 together, in the same statement.

    2, for an existing UID and PID pair in STMT and TABLE1, do:

    a. in TABLE1. Value2 > 0, update TABLE1. VALUE1 = STMT. VALUE1

    b. to TABLE1. Value2 = 0 and if TABLE1. VALUE1! = STMT. Value1, update of TABLE1. VALUE1 = STMT. Value1, otherwise nothing to do.

    Why are they not simply your needs ' uid and pid that already exist in stmt and table1, if table1.value2 > = 0, then the value table1.value1 = stmt.value1 "? Are you concerned about shooting triggers unnecessarily? It has something to do with null values? The MERGE statement above does exactly what you asked, but, depending on your needs, something simpler and more efficient could do it as well.

    I hope that answers your question.
    If not, post a small example data (CREATE TABLE and only relevant columns, INSERT statements) for all of the tables involved and also publish outcomes from these data.
    If you ask on a DML statement, such as UPDATE, the sample data will be the content of the or the tables before the DML, and the results will be the State of the or the tables changed when it's all over.
    Explain, using specific examples, how you get these results from these data.
    Always tell what version of Oracle you are using.
    See the FAQ forum {message identifier: = 9360002}

    Published by: Frank Kulash, June 6, 2012 14:51

  • regexp_replace to remove the clause of a sql statement

    Select regexp_replace ("select Column1, Column2 in var1, var2 from table1, table2")
    where 1 = 1', '(into|) IN). * \w. (a |) (FROM)', null) double

    Returns

    Select Column1, Column2 table1, table2
    where 1 = 1

    Problem: I'm missing 'of' or 'FROM '.

    Question: How do you fit in before the "from" or "FROM" so that my output is:

    SELECT column1, Column2 from table1, table2
    where 1 = 1

    Summer experiences $' etc, but no dice. Clues?

    or you can try the following:

    select regexp_replace( '
    select column1,
           /*+ into */ column2
    into var1,
         var2
    from table1,
         table2
    where 1=1',
                           'into\s((\s*,\s*)?[a-z0-9_#$]{1,30})*\s*from',
                           'from', 1, 1, 'i')
    from dual;
    

    gives the following output

    select column1,
           /*+ into */ column2
    from table1,
         table2
    where 1=1
    

    Even if you have strange line breaks it works

    select regexp_replace( '
    select column1,
           /*+ into */ column2 into var1,
         var2 from table1,
         table2
    where 1=1',
                           'into\s((\s*,\s*)?[a-z0-9_#$]{1,30})*\s*from',
                           'from', 1, 1, 'i')
    from dual;
    

    gives

    select column1,
           /*+ into */ column2 from table1,
         table2
    where 1=1
    

    and

    select regexp_replace( 'select column1, /*+ into */ column2 into var1, var2 from table1, table2 where 1=1',
                           'into\s((\s*,\s*)?[a-z0-9_#$]{1,30})*\s*from',
                           'from', 1, 1, 'i')
    from dual;
    

    gives

    select column1, /*+ into */ column2 from table1, table2 where 1=1
    
  • Helps with the syntax of dynamic sql statements

    Hi all
    How can I pass the value of the result of my dynamic select statement to a Ref Cursor?
    I try the following statement but does not work, I get this error:
    ORA-00932: inconsistent data types: expected - was - ORA-06512: at
    Procedure getItems(v_first In number, v_second In Number, arg_Cursor IN OUT CUSTOM_REF_CURSOR) is
         sqlString varchar(3000);
         Begin
           sqlString := 'select* from bla where o.arg_1 = :1 and arg_2 = :2'; 
       
           execute immediate sqlString 
           into arg_Cursor
           using v_first, v_second;
       End getItems;
    Any ideas?
    Thank you

    Johnny
    PROCEDURE getitems (v_first IN NUMBER, v_second IN NUMBER, arg_cursor IN OUT sys_refcursor)
    IS
      sqlstring   VARCHAR (3000);
    BEGIN
      sqlstring := 'select* from bla where o.arg_1 = :1 and arg_2 = :2';
    
      OPEN arg_cursor FOR sqlstring USING v_first, v_second;
    END getitems;
    

Maybe you are looking for

  • New retina 21.5 seems slow.

    I just bought an iMac 21.5 with Retina display, and it seems terribly slow for a new machine expensive.  It has the standard 1 TB drive. Does anyone else have a similar opinion? Thank you

  • How to create a formula to ask if something is both greater AND less than a range

    Don't know how to ask the question, but here's what I want to do. In a formula, I need an 'if' statement asking us: IF "cell id" is greater than "$ 100" and less than "$ 200", IF - TRUE, IF - FALSE. I don't see how the question of both the code < and

  • His system problem HP DV7

    The SOUND SYSTEM remains weak and will not strong as speakers will be. The volume of the sounds system is adjustable, but only amplitude of low volume. How can I get the sound system to match the speakers? I tried the mixer and the sound system will

  • a table composed of several paintings of orinted line

    Hi all 5.6.4 can we create an array consisting of several paintings of orinted line? If yes how? Thank you.

  • User profile absent on the start screen.

    Original title: Windows 7 lost profile Nice day I have 2 profiles on my laptop and start I see only one profile since this morning. I did not a startup repair as the hard drive is encrypted and will take at least 8 hours for the decryption. I see all