With the help of the collection within sql

I have a function that returns a list of numbers. for example:
CREATE TYPE integer_table_type AS TABLE OF INTEGER;

CREATE OR REPLACE FUNCTION test_fnc
   RETURN integer_table_type
AS
   return_var   integer_table_type;
BEGIN
   SELECT   *
     BULK   COLLECT
     INTO   return_var
     FROM   (SELECT   1 FROM DUAL
             UNION
             SELECT   2 FROM DUAL
             UNION
             SELECT   3 FROM DUAL);

   RETURN return_var;
END test_fnc;
/
I would use this function in a sql statement, without aid of a subquery, for example:
WITH t1 AS (SELECT   1 f1 FROM DUAL
            UNION
            SELECT   2 FROM DUAL
            UNION
            SELECT   3 FROM DUAL
            UNION
            SELECT   4 FROM DUAL
            UNION
            SELECT   5 FROM DUAL
            UNION
            SELECT   6 FROM DUAL)
SELECT   *
  FROM   t1
 WHERE   f1 IN (test_fnc);
but I can't get it's running by using a subquery for example:
WITH t1 AS (SELECT   1 f1 FROM DUAL
            UNION
            SELECT   2 FROM DUAL
            UNION
            SELECT   3 FROM DUAL
            UNION
            SELECT   4 FROM DUAL
            UNION
            SELECT   5 FROM DUAL
            UNION
            SELECT   6 FROM DUAL)
SELECT   *
  FROM   t1
 WHERE   f1 IN (SELECT   * FROM table (test_fnc));
Is this possible without having to return to the function in a subquery? Thank you.

Oracle Database 11g Enterprise Edition Release 11.1.0.6.0 - Production

Try

select *
  from t1
 where f1 member of test_fnc

Tags: Database

Similar Questions

  • What is the most trouble free Mac OS to use with the collection master CS6? (not CC)

    What is the most trouble free Mac OS to use with the collection master CS6? (not CC)

    Unless 10.10 has features you really need, a restore is logical. It's a pain, but if you can't do the job, this is what is needed.

    Roll back MacOS is outside these forums, but I don't know that apple Support you can get to the right help. That's all I can say.

    Gene

  • Clear the cache in connection with the collection

    Hello

    I create a report by using the .one problem collection has to happen when I hide any column in the report.
    Enter the value in the report and press Add button line to add the new line to insert the new record, and the previous value is to clear the cache.

    How can I remove this problem.

    and another question

    could you send me a link or sample report where the collection is used with multiple cascading select list more then select three list.



    Thank you
    Maury

    Maury,

    Have you written a PL/SQL process that updates the data in the collection, whenever any button is clicked? A collection is not updated by the SUBMIT button or add a LINE unless you write the code to make - table normal function tabular forms can use the MRU deals, but it can not be used when you use a collection, so you must write code to update the collection every time that the page is sent.

    I sent a link to an application that uses three LOVs cascading - as I said in my other thread, this is not based on a collection, but the LOV is nothing to do with the collections. In addition, even if it is based on 3 lists, you can extend that to 4, or more, lists easily enough as it is still used for each list after the first principle.

    Andy

  • Need help with the creation of SQL table

    Hi all

    I created a table, a month back. Now, I need to create another table in the same structure.
    Is there a way for dat I can get the script from the table I created earlier and use the same to create another.
    Or y at - it another way, so that we can create a table with the same structure of the existing table.

    Help, please.

    Kind regards
    Mohan

    Discover the function [DBMS_METADATA. GET_DDL | http://download.Oracle.com/docs/CD/B19306_01/AppDev.102/b14258/d_metada.htm#i1019414].

    Example:

    SQL> SET LONG 5000
    SQL> SELECT DBMS_METADATA.GET_DDL('TABLE','EMP','SCOTT') FROM DUAL;
    
    DBMS_METADATA.GET_DDL('TABLE','EMP','SCOTT')
    --------------------------------------------------------------------------------
    
      CREATE TABLE "SCOTT"."EMP"
       (    "EMPNO" NUMBER(4,0),
            "ENAME" VARCHAR2(10),
            "JOB" VARCHAR2(9),
            "MGR" NUMBER(4,0),
            "HIREDATE" DATE,
            "SAL" NUMBER(7,2),
            "COMM" NUMBER(7,2),
            "DEPTNO" NUMBER(2,0),
             CONSTRAINT "PK_EMP" PRIMARY KEY ("EMPNO")
      USING INDEX PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS
      STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
      PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT)
      TABLESPACE "USERS"  ENABLE,
             CONSTRAINT "FK_DEPTNO" FOREIGN KEY ("DEPTNO")
              REFERENCES "SCOTT"."DEPT" ("DEPTNO") ENABLE
       ) PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255 NOCOMPRESS LOGGING
      STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
      PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT)
      TABLESPACE "USERS"
    

    Published by: Centinul on January 11, 2010 08:01

  • Need help with the installation of SQL 2005 for my VC 2.5

    Someone can tell me where I can find the instructions for the installation of SQL 2005 and create the DB and connect via ODBC?

    IM assuming that I will first install SQL and then install VC 2.5, correct?

    Hi, take a look at page 21...

    http://www.VMware.com/PDF/vi3_35/esx_3/R35/vi3_35_25_quickstart.PDF

    Dave

  • call the collection of sql

    Hello guys,.

    I just wonder can I get the SQL collection via PL/SQL. However, I can't call from pure SQL. In other words,.
    create or replace type plch_number is table of number;
    
    create or replace package den 
    is
    
      my_arr plch_number := plch_number();
      procedure doldur(a pls_integer);
      function func2 return plch_number;
    
    end;
    
    create or replace
    package body den 
    is
    
    procedure doldur(a pls_integer)
    is
    begin
      my_arr.extend(a);
      for i in 1..a
      loop
        my_arr(i) := i;
      end loop;
    end;
    
    
    function func2 return plch_number 
    is
    begin
      return my_arr;
    end;
    
    end;
    I can run the following code without any errors.
    set serveroutput on;
    declare
      a integer;
    begin
      den.doldur(10);
      select count(*) into a from table(den.my_arr);
      dbms_output.put_line(a);
    end;
    
    
    ------------------------------------------
    anonymous block completed
    10
    However, when run the code sql. Although it is almost the same code that I have run PL/SQL block, it gives an error, ORA-06553: PLS-221.
    select * from table(den.my_arr);
    ORA-06553: PLS-221
    In addition, I can call the function from the package through SQL without any error. But why I can't invoke collections directly from SQL, why?
    select * from table(den.func2);
    Thank you.

    970992 wrote:
    OK, but I just want to know, why? I mean, is there a technical explanation?

    Unfortunately, in ORACLE SQL & PL/SQL keep two separate motors. All SQL allows you to call is UDF (user-defined functions). You can't call procedures in SQL and you cannot reference package variables. Everything works and even this is not always possible - for example, you cannot call a UDF with OUT or IN OUT. You cannot call function PL/SQL defined parameter and return value types.

    SY.

  • Problem with the process running sql

    I created a pricess that deletes a file off of the table apex_application_files

    When I run the following statement:
    delete apex_application_files whose name like "resume.pdf" it works without problem

    When I run the following statement:
    delete apex_application_files whose name like ': P4_PDF_DISPLAY' he does not. what I have to do.

    I changed the: p4_pdf_display to be a single item displayed on the page
    With the help of the P4_PDF_DISPLAY can view the file in a query sql and beable to view the file to download, but am unable to delete
    Help!

    Hello
    >
    I created a pricess that deletes a file off of the table apex_application_files

    When I run the following statement:
    delete apex_application_files whose name like "resume.pdf" it works without problem

    When I run the following statement:
    delete apex_application_files whose name like ': P4_PDF_DISPLAY' he does not. what I have to do.

    I changed the: p4_pdf_display to be a single item displayed on the page
    With the help of the P4_PDF_DISPLAY can view the file in a query sql and beable to view the file to download, but am unable to delete
    >

    What is this point of P4_PDF_DISPLAY? It is the name of the file, as it is supposed to be in your delete statement? Or, view the article PDF?
    Verify session state to display the value of the element. You see the name in it?

    See you soon,.

  • Problem with the Collection

    I have problems of filling of a collection.
    I created my collection on page load of the Page 7 for help
    BEGIN
    
    apex_collection.create_or_truncate_collection
      (p_collection_name => 'PEOPLE');
    
    END;
    The user then clicks on the "Copy" button that brings them to the Page 13.
    That's where I'm trying to complete my collection, by clicking on the link add to the report of the population.
    for x in (select * from gus_people_2 where id = :P13_ID)
    loop
      apex_collection.add_member(p_collection_name => 'PEOPLE', 
        p_c001 => x.id,
        p_c002 => x.rank,
        p_c003 => x.first_name,
        p_c004 => x.surname,
        p_c005 => x.dob,
        p_c006 => x.job,
        p_c007 => x.disp_seq);
    end loop;
    Once added, the Member of the collection should appear in the report of the full Collection.
    select c001, c002, c003, c004, c005, c006, c007, 'Remove' remove
    from apex_collections
    where collection_name = 'PEOPLE'
    I use Apex 4.1 on the Oracle website

    http://Apex.Oracle.com/pls/Apex/f?p=4550:1:0:

    Workspace: GUSCRIGHTON
    Username: ANGUS. [email protected]
    Password: terminator

    Application name: EXCEL_UPDATE_TEST

    Same username and password as described above.

    It's probably something really obvious, but I can't place it today.

    Any help appreciated.

    Gus

    Hi gUS,.
    Now, run your page, it will work.
    Thank you
    Loga

    Add the collection process
    Ask = exp1
    'ADD' - removed single quotes

    Remove the collection process

    Ask = exp1

    DEL - I gave this string.
    You will add later with link or a button.

    Published by: Logaa on May 18, 2012 06:04

  • problem with the collection and refcursor

    I have the 'ServerDisconnect2' function below. It should return as 'ref_cursor' on the parameter that is a data container of deleted rows slider, Java developers insist on using this type of data/collection. I don't know how to code to return the values of ID removed as 'ref_cursor '. See commented "open pDeleteList" - sentence, it is commented as does not compile.
    CREATE OR REPLACE PACKAGE oe_ctx AS
      TYPE gIntegerTable IS TABLE OF INTEGER INDEX BY BINARY_INTEGER;
      TYPE cursor_type IS REF CURSOR;
    ....
    
      PROCEDURE ServerDisconnect2(pCasinoCode NUMERIC, pCasinoServerCode NUMERIC, pChannelServerCode CurrentLogins.ChannelServerCode%TYPE, pDeleteList OUT cursor_type) 
      IS
        vDeleteList oe_ctx.gIntegerTable;
      BEGIN
        DELETE FROM
        (
           SELECT cl.* FROM CurrentLogins cl, Accounts a
           WHERE cl.CasinoCode = pCasinoCode
           AND cl.CasinoServerCode = pCasinoServerCode
           AND cl.ChannelServerCode = pChannelServerCode
           AND cl.Code = a.code
           AND a.Type = 'lplayer'
           ORDER BY a.code
        ) RETURNING Code
          BULK COLLECT INTO vDeleteList;
          
    /*    OPEN pDeleteList FOR
          SELECT * FROM TABLE(vDeleteList);*/
          
        COMMIT;
      END ServerDisconnect2;
    Is it possible to convert the variable 'vDeleteList' in ref_cursor?
    So my only solution would be to open the ref_cursor BEFORE delete-clause with the same query delete clause has. But I'm afraid that then after opening the instant cursor after a milliseconds the deletion clause removes different lines and the procedure would be data incorrect in pDeleteList.

    Published by: CharlesRoos on August 26, 2010 06:10

    You need a collection of sql (created with CREATE TYPE...):

    I'll use the predefined collection sys.odcivarchar2list demonstation purposes:

    SQL> var cur refcursor
    
    SQL> declare
       ret_coll       sys.odcivarchar2list;
    begin
       delete from emp
         returning ename
              bulk collect into ret_coll;
    
       open :cur for select * from table (ret_coll);
    end;
    /
    PL/SQL procedure successfully completed.
    
    SQL> print
    
    COLUMN_VALUE
    -----------------------------------------------------------------------------------------------------------------------------
    SMITH
    ALLEN
    WARD
    JONES
    MARTIN
    BLAKE
    CLARK
    SCOTT
    KING
    TURNER
    ADAMS
    JAMES
    FORD
    MILLER                                                                                                                       
    
    14 rows selected.
    
  • Installer for the simultaneous program defined with the parameters - Script SQL

    I wrote a very simple sql script and I want to save it as a simultaneous Oracle program. I have included a parameter field in the sql script to allow the entry of a value to determine the number of days prior to the script. The script runs correctly in SQL * Plus, but when I try to record it as a competitor Oracle program I get the following errors below:
    This works in SQL* PLUS
    
    SELECT emp_id, amount
    FROM tblSalaries
    WHERE hire_date > SYSDATE-&Days;
    
    Enter value for Days: 7
    old    3: hire_date > SYSDATE-&Days
    new  3: hire_date > SYSDATE-7
    
    And it provides my results....
    Although when I save this as a simultaneous program and set the configuration setting and run the simultaneous program and enter the number in the parameter field, work ends with an ERROR with the following:
                                                                                                             
    Enter value for Days: EXEC FND_CONC_STAT.COLLECT;
    hire_date > SYSDATE-EXEC FND_CONC_STAT.COLLECT; and
                                        *
    ERROR at line 3:
    ORA-00933: SQL command not properly ended 
    If I put single quotes around '& days', in line 3, I get a different error:
    ERROR at line 3:
    ORA-01722: invalid number 
    Do you know what could be the problem?
    Thanks for the review!

    You can try one of these approaches-

    1. replace '& days' in your script with "& 1"- or-".

    2. Add the following to your script at the beginning

    Days := &1;
    

    PL see the developer's Guide Application for your specific version http://www.oracle.com/technology/documentation/applications.html EBS

    HTH
    Srini

  • Problem with the collection xmltype column - tags endangered

    Hello

    Apex 4.0, I have a traditional relationship with this query:
    SELECT c.collection_name,
           c.seq_id,
           c.c001,
           c.c002,
           c.xmltype001.getclobval() xmltype001
    FROM   apex_collections c
    The xmltype001 column is set to display text (special escape characters). What I see on the page of this something column is:
    <env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/">
     <env:Header/>
     <env:Body>
     <m:tag1 xmlns:m="http://cosservices/COSServices.wsdl">
     <result xmlns:typ="http://cosservices/COSServices.wsdl/types/">
     <typ:tag2>
     <typ:subdepartmentCode>AUTO</typ:subdepartmentCode>
     <typ:subdepartmentName>Automotive</typ:subdepartmentName>
     <typ:itemNumber>0000610</typ:itemNumber>
    ...
    This column is filled by calling a web service using this package Apex web service utility, and this is the content for this column. However, when I export to CSV, what I see in the text file is the following:
      
      
        
          
            
              
              AUTO
              Automotive
         0000610
    ...
    In case you missed it: all tags have disappeared and that the actual data remained. If I change the type of column to Column Standard in the report, the same thing is happening on the page.

    My findings to date are:
    -Tags are present in the column, as it is sort of the column display in text type is smart enough to display the data correctly.
    -It seems that this has something to do with the character encoding, but I don't know how to fix it. I tried to use the convert() function but no luck.

    Any ideas?

    Thank you
    Luis

    Hi Luis,.

    It is not something as simple that the attribute "Strip HTML" report, is it?
    (ie - change no.)

    Scott

  • Procedure with the collection as a parameter-help needed

    I have records like below:

    Add time of Rol
    ---------------
    A1 08:20
    A2 08:25
    A2 A1 08:29
    A2 A1 08:32
    A3 08:45
    A3 08:46
    A3 08:50

    I have a scenario where I have to calculate the average_time based on a scenario.
    The formulas that we have to calculate the average is:
    (min (next_address) - max (previous_address)) * 0.55
    that is, for example, form 5, (08:45 - 08:32) * 0.55.
    Here in my procedure I am passing the TDA and Rol as input parameters collection.
    How can I go and calculate the value of average_time is now.

    I tried with
    For I in Add.count
    loop
    v_avg_time: = (Add(I+1) - Add (I)) * 0.55;
    end loop;

    When I want to test this, I am not knowing how to pass values to the procedure.
    Please tell me how to run the procedure and how to get the results.

    Thanks in advance

    Concerning
    Rambeau

    Try like this.

    SQL> create or replace type my_num as table of number
      2  /
    
    Type created.
    
    SQL> create or replace procedure my_proc (pNum my_num)
      2  as
      3     lsum number;
      4     lavg number;
      5  begin
      6     select sum(column_value), avg(column_value)
      7       into lsum, lavg
      8       from table(cast(pNum as my_num));
      9
     10     dbms_output.put_line('SUM: ' ||lSum);
     11     dbms_output.put_line('AVG: ' ||lAvg);
     12  end;
     13  /
    
    Procedure created.
    
    SQL> declare
      2     lNum my_num := my_num(1,2,3,4,5,6,7,8,9,10);
      3  begin
      4     my_proc(lNum);
      5  end;
      6  /
    SUM: 55
    AVG: 5.5
    
    PL/SQL procedure successfully completed.
    

    Thank you
    knani.

  • Why has Adobe decided to do cloud subscription and not continue with the Collections?

    I know that it is hard to predict the future and trends. And I know wanted offer convenience, but it's an inconvenience when you do not offer a time offer without continually having to pay for a product. Yes. Adobe is an exceptional product. But you could potentially lose a good customer because continually have to pay for a product year after year without ever owning. People prefer to invest a lump sum, then ending up paying more in the long term. I just wanted to know why not continue with CS 7, 8, 9. Or if you want clouds. Let a time buy and be able to have available for use without the CD.

    You can always buy cs6 (Creative Cloud now includes the features of Creative Suite Master Collection and Design Premium)and a handful of other adobe programs.

  • Can a report prepared with the free hand SQL(Sql Query) using a DB link

    Hi all

    To be developed a report based on query in OBIEE dashboards

    Select the query - 1
    UNION
    Select the request - 2

    First select source of the schema of a database and second query came from the other.

    Is it possible to develop the report using the free hand THAT SQL based on a link to DB?
    Y at - it feature to use the database link (link DB)?


    I thank in advance

    SMA

    What you ask, it's the live database query capabilities:
    http://gerardnico.com/wiki/dat/OBIEE/presentation_service/obiee_direct_database_request

    But you can also use the repository's federated query capabilities to model a star schema with two star of two different sources of data schema.

    See you soon
    Nico

  • Rotate the text with the character within the text block style

    I would like to apply a paragraph or character style to a certain character in a text frame. I would need to rotate 90 degrees in the framework, separate from the other text. Is this possible?

    Insert the text block in the block of text as an anchor and rotation you need.

Maybe you are looking for