How to return an array from a function package

It is a package, that give the type of table.

But it does not work.

create or replace package account_group is

TYPE string_array IS the TABLE OF varchar2.

function get_acc_by_vat_number (in_string varchar2) return string_array;

end account_group;

create or replace package body is account_group

function get_acc_by_vat_number (in_string varchar2) return string_array is

acc_array string_array;

i the number;

cursor c1 is

(Select to_char (d.account_number) wiz_customer_descrip account_number d, wiz_customer_hp_life l

where commercial_flag = 'Y '.

and l.franchise_code! = 'F29'

and d.account_number = l.account_number

and id_3 = in_string - vat_number

- and ssn ='08-09-002272' - company_reg_num

UNION

Select to_char (d.account_number) wiz_customer_descrip account_number d, wiz_customer_hp_life l

where commercial_flag = 'Y '.

and l.franchise_code = 'F29'

and d.account_number = l.account_number

and id_3 = in_string - vat_number

- and ssn ='08-09-002272' - company_reg_num

and there are

(select 1 from WIZ_CUSTOMER_HP_OCCURRENCE p

WHERE product_category_code in ('MID', "MVO")

and p.account_number = l.account_number

and p.service_address_id = l.service_address_id));

Start

I: = 0;

for the news loop c1

i: = i + 1;

acc_array (i): = cur.account_number;

end loop;

Return acc_array;

end;

end account_group;

Use the functions in pipeline, which give to the appellant, while the dataset is the treatment.

create or replace package account_group is

TYPE string_array IS the TABLE OF varchar2.

function get_acc_by_vat_number (in_string varchar2) return string_array in pipeline;

end account_group;

create or replace package body is account_group

function get_acc_by_vat_number(in_string varchar2) return pipeline string_array is

acc_array string_array;

i the number;

cursor c1 is

(Select to_char (d.account_number) wiz_customer_descrip account_number d, wiz_customer_hp_life l

where commercial_flag = 'Y '.

and l.franchise_code! = 'F29'

and d.account_number = l.account_number

and id_3 = in_string - vat_number

- and ssn ='08-09-002272' - company_reg_num

UNION

Select to_char (d.account_number) wiz_customer_descrip account_number d, wiz_customer_hp_life l

where commercial_flag = 'Y '.

and l.franchise_code = 'F29'

and d.account_number = l.account_number

and id_3 = in_string - vat_number

- and ssn ='08-09-002272' - company_reg_num

and there are

(select 1 from WIZ_CUSTOMER_HP_OCCURRENCE p

WHERE product_category_code in ('MID', "MVO")

and p.account_number = l.account_number

and p.service_address_id = l.service_address_id));

Start

I: = 0;

for the news loop c1

pipe row (c.account_number);

end loop;

return;

end;

end account_group;

Tags: Database

Similar Questions

  • How to return multiple variables from a function

    Hello

    As seen below, I tried more then return a variable to a function, but I think I have a syntax problem...

    function hesapla3 (parameter1, parameter 2): (number & & Boolean) / / PROBLEM IS HERE, I have NEED of TWO VARIABLES to RETURN
    {
    var yenideger2:Number = new Number();
    var bol2:Boolean = new Boolean();
    yenideger2 = parameter1 + parameter 2;
    if(yenideger2>80) {bol2 = false ;}
    Return yenideger2;
    return bol2;
    trace (yenideger2);
    trace (bol2);
    }

    You can do it this way.

    You can combine the 2 to 1 as a var

    var tekdeger:String=yenideger2.toString()+"-"+bol2.toString();

    Return tekdeger;

    and then you can split and mount the value returned into variables that you want...

  • How to return two values of a function?

    Hi all
    I have a function which returns a varchar2 value. This value is used in the SQL of a ref cursor

    Now I want this function returns two values. I tried to use varray, but could not accomplish the task.

    Can you tell me how can I find the two values from a function? and how this function can be called in a SQL query?

    Thank you very much

    The query should look like:

    SELECT v.col.name AS name
         , v.col.flag AS flag
    FROM   ( SELECT kk_test_kk(t.somecolumn,t.someothercolumn,42) AS col
             FROM   sometable t ) v;
    

    Note that you need to prefix with the name of view inline ('v' in the example) and the expression of the function ('col' in the example).

  • How to return a message of a function

    Hi gurus,
    I wrote the function on my database related to the return of the specific table voucherdate
    I want to return one message if other that this condition means that if vouchers No. is not there or if there is no null vouchertype is provided.

    my function is
    -------------------
    create or replace fn_get_voucherdate (v_vouchertype in varchar2, v_compcode in numbers)
    date of return
    as
    date of v_voucherdate;
    Start
    If v_vouchertype = "B - P" then
    Select max (voucherdate) from v_voucherdate
    from sometables where vouchertype = v_vouchertype and companycode = v_compcode;

    Return v_voucherdate;

    elsif v_vouchertype = "C - P" then
    Select max (voucherdate) from v_voucherdate
    from someothertables where vouchertype = v_vouchertype and companycode = v_compcode;

    Return v_voucherdate;

    elsif v_vouchertype = "C - R" then
    Select max (voucherdate) from v_voucherdate
    from someothertables where vouchertype = v_vouchertype and companycode = v_compcode;

    Return v_voucherdate;

    elsif v_vouchertype = s-P' then
    Select max (voucherdate) from v_voucherdate
    from someothertables where vouchertype = v_vouchertype and companycode = v_compcode;

    Return v_voucherdate;
    on the other
    return a message here;
    end if;

    but the message by not returning function showing no matter what return value error

    Please guide me how display a message to the user.

    Please answer...

    but the message by not returning function showing no matter what return value error

    as it is coded your function returns a DATE data type
    It cannot return any "message".

  • Return multiple values from a function in a SELECT statement

    I hope I've provided enough information here. If not, let me know what I'm missing.

    I create a view that will combine the information from several tables. Most are pretty simple, but there are a couple of columns in the view that I need to get by running a function within a package. Even if this is quite simple (I have a function named action_date in a package called rp, for example, that I can use to return the date that I need through SOME rp.action_date (sequence_number).

    Here is the question: I really need to return several bits of information of the same record (not only action_date, but also action_office, action_value, etc.)-a join of the tables will work not here, as I will explain below. I can, of course, perform a function separate for each statement, but this is obviously inefficient. Within the select statement of the view, however, I don't know how each of the values that I need to get back.

    For example, right now, I have:

    Table 1:
    sequence_number NUMBER (10),
    name varchar (30),
    ...

    Table2:
    Table1_seq NUMBER (10),
    action_seq NUMBER (10),
    action_date DATE,
    action_office VARCHAR (3),
    action_value VARCHAR (60),
    ...

    I can't just simply join Table1 and Table2 because I have to perform processing in order to determine the rows returned matching, I really need to select. If the package opens a cursor and treats each line until it finds the one I need.

    The following works but is ineffective since all calls to the package returns the columns of the same record. I don't know how to put all the values that I need in the SELECT statement.
    CREATE VIEW all_this_stuff AS
    SELECT sequence_number, name,
    RP.action_date (sequence_number) action_date,
    RP.action_office (sequence_number) action_office,
    RP.action_value (sequence_number) action_value
    FROM table1

    Is there a way to return multiple values in my SELECT statement or I'm going about this all wrong?

    Any suggestions?

    Thank you very much!

    Hello

    What you want is a Query of Top - N , what you can do using the ROW_NUMBER analytic function in a subquery, like this:

    WITH     got_rnum     AS
    (
         SELECT     action_seq, action_dt, action_office, action_type, action_value
         ,     ROW_NUMBER () OVER ( ORDER BY  action_date
                                   ,            action_seq
                             ,            action_serial
                           ) AS rnum
         FROM     table2
         WHERE     action_code     = 'AB'
         AND     action_office     LIKE 'E'     -- Is this right?
    )
    SELECT     action_seq, action_dt, action_office, action_type, action_value
    FROM     got_rnum
    WHERE     rnum     = 1
    ;
    

    As written, this returns a single line (at most).
    I suspect you'll actually get a rank for each group , where a group is defined by a value in a table in which you join.
    In this case, add a PARTITION BY clause to the ROW_NUMBER function.
    If post you a small example of data (CREATE TABLE and INSERT statements), I could show you exactly how.
    As I don't have your tables, I'll show you the use of the tables in the scott schema.
    This is a view containing data in the scott.dept table and also to scott.emp, but only for the highest employee in each Department (in other words, the employee whose oldest hire date). If there be a tie for the first hire date, while the candidate with the lowest empno is selected.

    CREATE OR REPLACE VIEW     senior_emp
    AS
    WITH     got_rnum     AS
    (
         SELECT     d.deptno
         ,     d.dname
         ,     e.empno
         ,     e.ename
         ,     e.hiredate
         ,     ROW_NUMBER () OVER ( PARTITION BY  d.deptno
                                   ORDER BY          e.hiredate
                             ,                e.empno
                           ) AS rnum
         FROM     scott.dept     d
         JOIN     scott.emp     e     ON     d.deptno     = e.deptno
    )
    SELECT     deptno
    ,     dname
    ,     empno
    ,     ename
    ,     hiredate
    FROM     got_rnum
    WHERE     rnum     = 1
    ;
    
    SELECT     *
    FROM     senior_emp
    ;
    

    Output:

    .    DEPTNO DNAME               EMPNO ENAME      HIREDATE
    ---------- -------------- ---------- ---------- ---------
            10 ACCOUNTING           7782 CLARK      09-JUN-81
            20 RESEARCH             7369 SMITH      17-DEC-80
            30 SALES                7499 ALLEN      20-FEB-81
    

    Moreover, one of the conditions to the query you posted has been

    action_office     LIKE 'E'
    

    which equals

    action_office     = 'E'
    

    (AS is always equivalent to = if the string that follows AS does not contain the winning cards.)
    Did you mean say that or did you mean something like this:

    action_office     LIKE 'E%'
    

    Instead?

  • How to return a value from stored procedure.

    Hello

    I have an insert in which insert a username through generated sequence number.

    I need this generated sequence number stored procedure return.

    Kindly help me to achieve this goal.

    It might be useful if there is a code sample for the same thing.

    Thank you
    Ahmed Shareefuddin

    Something like this:

    create or replace procedure xproc (num out number) is
    begin
     insert into mytab values (myseq.nextval);
     select myseq.currval into num from dual;
    end;
    /
    

    Max
    http://oracleitalia.WordPress.com

  • Hello, could someone show me how to return an object from horizontal to vertical?

    I read all the blogs, but can not turn my object

    Thank you.

    See if that helps... ?

  • Return an array of strings of call library function node

    Hello

    I'm having a few problems getting the following work.

    I have a camera from a manufacturer that came with its own .dll and header files. I'm calling the LabVIEW .dll file (2011). In total, there are about 50 functions, and there is a rest that I can't go to work (probably because I understand enough about the topic to interface with an external code).

    The description of .dll is delivered with the following text:

    #define length

    #define MAX_CONFIGURATIONS

    Prototype: int ConfigListGet (char (& sConfigurations) [MAX_CONFIGURATIONS] [length]);

    and the header file with:

    extern "C" __declspec (dllexport) int RepRateConfigurationListGet (char (& sConfigurations) [MAX_CONFIGURATIONS] [length]);

    The function should return an array of strings to the list of configurations.

    The problem I have is that I can not understand how to return the array of strings for the node of the library function call to LabVIEW. I looked a little on the web and the examples in LabVIEW and I can't find anything specific to return an array of strings in this way, so if anyone can point me in the right direction I would really appreciate it.

    Also, if I click with the right button on the node library function call and click on "File Create.c", I would be able to create the prototype of function even that above? I tried this but no luck. Was the closest I came:

    int32_t RepRateConfigurationListGet (char sConfigurations [], uint8_t MAX_CONFIGURATIONS, uint8_t MAX_LEN);

    Thank you very much in advance for any help!

    D

    Hello!

    I tried once using an array of U8, converting it to a string and then split into an array.

    Here is my old piece of code (the split part can be cleaner ;=))

    Kind regards

    Marco

  • From a function table: invalid data type error

    Hello

    I'm a ORA-00902: invalid data type error when I try to call the function from a select statement below. Here, I am leaving an array from a function.
    create or replace package pkg10
    as
    
    type tabletype1 is table of table1%rowtype
    index by binary_integer;
    
    function func1 return tabletype1;
    
    end pkg10;
    create or replace package body pkg10
    as
    
    function func1 return tabletype1 
    is
        v_tab1 tabletype1;
        idx integer;
    begin 
    
        idx := 1;
        
        for i in (select * from table1)
        loop
            v_tab1(idx).name1 := i.name1;
            v_tab1(idx).key := i.key;
            idx := idx+1;
            
        end loop;
    
    return v_tab1; 
    
    end func1; 
    
    end pkg10;
    select * from table(pkg10.func1);
    Please point out to me where I'm wrong.

    Thank you

    Sathya Vamsi says:
    Hello

    I'm a ORA-00902: invalid data type error when I try to call the function from a select statement below. Here, I am leaving an array from a function.

    create or replace package pkg10
    as
    
    type tabletype1 is table of table1%rowtype
    index by binary_integer;
    
    function func1 return tabletype1;
    
    end pkg10;
    
    create or replace package body pkg10
    as
    
    function func1 return tabletype1
    is
    v_tab1 tabletype1;
    idx integer;
    begin 
    
    idx := 1;
    
    for i in (select * from table1)
    loop
    v_tab1(idx).name1 := i.name1;
    v_tab1(idx).key := i.key;
    idx := idx+1;
    
    end loop;
    
    return v_tab1; 
    
    end func1; 
    
    end pkg10;
    
    select * from table(pkg10.func1);
    

    Please point out to me where I'm wrong.

    Thank you

    you try to use a data type of PL/SQL as part of an SQL statement. is NOT authorized.

  • A varray of returning from a function

    Hello

    I would like to return a set of values of a function as:
    select my_function(6) from dual
    should return multiple values:
    1 2 3 4 5 7 8 9

    right now, my function works only by returning a value from the array:
    create or replace
    FUNCTION sls_forf(
          depassement IN number,position in integer)
        RETURN number
      IS
        type res is varray(9) of number;
        sls res:=res();
        depa number;
      BEGIN
        depa:=depassement*100;
        sls.extend(9);
        CASE
        WHEN depa<60 THEN
          sls(1):=0.13+0.03*(depa-20);
          sls(2):=0.13+0.06*(depa-20);
          sls(3):=0.13+0.075*(depa-20);
          sls(4):=0.27+0.03*(depa-20);
          sls(5):=0.27+0.06*(depa-20);
          sls(6):=0.27+0.075*(depa-20);
          sls(7):=0.34+0.03*(depa-20);
          sls(8):=0.34+0.06*(depa-20);
          sls(9):=0.34+0.075*(depa-20);
        when depa between 60 and 149 then
          sls(5):=2.69+0.08*(depa-60);
        when depa>=150 then
          sls(5):=9.91+0.1*(depa-150);
        END CASE;
        
        RETURN sls(position);
        END sls_forf;
    It is possible.
    Ideally, it would be cool to be able to take the function itself in the form of table as my_funtion() gives me the o set while values than my_function (3) don't give me the 3rd value...

    Something like that?

    SQL> select rtrim(
      2           extract(
      3             xmlagg(xmlelement("a",level||'='||nvl(to_char(sls_forf(0.7,level)),'null')||', '))
      4             ,'//text()'),' ,') myvalues
      5  from dual
      6  connect by level <=9;
    
    MYVALUES
    ----------------------------------------------------------------------------------------------------
    1=null, 2=null, 3=null, 4=null, 5=3.49, 6=null, 7=null, 8=null, 9=null
    

    Max
    http://oracleitalia.WordPress.com

  • Select from 2 dimensions collection returned by a pipeline-table-function

    With the help of 10 gr 2

    A pipeline function returns a collection of an object oriented sub-collection:


    TYPE TXT_ARRAYTYPE IS TABLE OF THE VARCHAR2 (2000);

    type txt2dtable_objtype as object)
    txt2dtable txt_arraytype;

    type txt2dtable_arraytype as the txt2dtable_objtype table;


    FUNCTION getTxtList (start_date IN DATE) RETURN PIPELINED txt2dtable_arraytype
    ....



    How can I select from the function for each element varchar2 grouped by line number (the top-level collection) txt2dtable_arraytype?

    Example:

    Text of RowNum
    1 Hello
    1 World
    2 my
    2 name
    2 is
    2 Nuerni!
    3 How
    ....


    A select statement can be used for an external, OIC - / JDBC / follow App would be great!

    Any ideas?

    Kind regards
    Nuerni

    Something like this:

    SQL>create type txt_arraytype is table of varchar2(2000)
      2  /
    
    Type created.
    
    SQL>create type txt2dtable_objtype as object ( txt2dtable txt_arraytype )
      2  /
    
    Type created.
    
    SQL>create type txt2dtable_arraytype as table of txt2dtable_objtype
      2  /
    
    Type created.
    
    SQL>create or replace FUNCTION getTxtList (start_date in date)
      2  return txt2dtable_arraytype pipelined
      3  is
      4  begin
      5    pipe row( txt2dtable_objtype( TXT_ARRAYTYPE( 'Hello', 'World' ) ) );
      6    pipe row( txt2dtable_objtype( TXT_ARRAYTYPE( 'My', 'name', 'is', 'Anton' ) ) );
      7    pipe row( txt2dtable_objtype( TXT_ARRAYTYPE( 'And', 'this', 'is', 'an', 'example' ) ) );
      8    return;
      9  end;
     10  /
    
    Function created.
    
    SQL>
    SQL>select rn, y.column_value
      2  from ( select rownum rn
      3              , object_value
      4         from table( getTxtList( sysdate ) )
      5       ) x
      6     , table( x.object_value.txt2dtable ) y
      7  /
    
            RN COLUMN_VALUE
    ---------- -----------------------------------------------------------------------------------------
             1 Hello
             1 World
             2 My
             2 name
             2 is
             2 Anton
             3 And
             3 this
             3 is
             3 an
             3 example
    
    11 rows selected.
    
    SQL>
    

    Anton

  • How to return to the earlier version of El Capitan (from 10.11.3 at 10.11.1) with Time Machine? My HP LaserJet M475dw MFP printer worked fine with previous versions, but fails miserably to recognize the device on the same Wi - fi network now?

    How to return to the earlier version of El Capitan (from 10.11.3 at 10.11.1) with Time Machine? My HP LaserJet M475dw MFP printer worked fine with previous versions, but fails miserably to recognize the device on the same Wi - fi network now with 10.11.3.  I would like to restore the previous version of the operating system without losing any data created in various applications since the 10.11.1.  Fortunately, I had only to use Time Machine is rare over the years, I do not know if you have to return the entire drive to the chosen date or it can somehow just go back to a previous state of OS.  Any suggestions, much appreciated.

    OS X El Capitan: revert to a previous version of OS X

  • How to return from Vista to XP Pro?

    How to return from Vista to XP Pro?

    If this is the case, contact the manufacturer of your computer:

    Can I downgrade my OEM version of Windows Vista business to Windows XP Professional?

    Yes. Right of demotion OEM desktop operating systems PC apply to Windows Vista business and Windows Vista Edition full, as stated in the terms of the license. Please note, downgrade versions OEM Windows Vista business and Windows Vista Ultimate are limited to Windows XP Professional (including Windows XP Edition Tablet PC and Windows XP x 64 edition). End users can use the following media for their downgrade: Volume Licensing media (provided that the end-user has a Volume License Agreement), trade retail (FPP) or System Builder hologram CD (provided that the software is acquired in accordance with the Microsoft OEM System Builder License). Use of degraded operating system is governed by the Windows Vista Business license terms, and the end user cannot use the downgrade and professional Windows Vista operating system. There is no right of demotion for Windows Vista Home Basic or Windows Vista Edition Home Premium.

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    Otherwise:

    Come on first, site of the manufacturer of your computer, check to see if your model computer has XP drivers available for it...

    If the XP drivers are not available for your model, forget the idea.

    If Yes, download and save to a CD or Flash drive.

    Then buy a disc XP and license.

    Save all your data because it will be lost during the installation of XP.

    Then follow the steps below to do a clean install.

    http://www.winsupersite.com/showcase/windowsxp_sg_clean.asp

    Once installed, reload ALL your other programs of original media, or download again.

    Reload all drivers and utilities for your motherboard.

    See you soon.

    Mick Murphy - Microsoft partner

  • How to return data from PHP form MySQL

    I need to return data from a database MySQL, based on a simple form in a PHP page. The user will enter a zip code in a form and click a button to get all the records in a MySQL database that match the zip code entered by the user. I have configured MySQL database and I can return all records from a PHP page. What I have to do now is create the form and the code PHP to call the MySQL database. Can someone help me with how to do it?

    slpuyear wrote:
    > My apologies for the confusion. Can I get back all the data in the dataset,
    > However, I create a form to query the dataset object. I can do a simple
    > HTML form, but do not know how the action of the form to query my dataset
    > and return a subset of all data.

    Press F1 to open help for Dreamweaver. Go to develop Applications quickly
    > Construction of the ColdFusion Applications rapidly > building search and results
    pages (ColdFusion, ASP, JSP, PHP).

    --
    Adobe Community Expert David Powers
    Author, "Foundation PHP for Dreamweaver 8" (friends of ED)
    Author, "PHP Solutions" (friends of ED)
    http://foundationphp.com/

  • How to insert the VI she draws from the function palette?

    Hi all

    I create a project to compile a bunch of screws as lvlib and export only some libraries as public. I wonder how to export public screws in the function palette? I try [tools]-> [Advanced]-> [modify a Palette set], I create a new Palette, but when I insert VI by selecting the lvlib, it does not matter the exported VI. I wonder if there is some way I can import the public a lvlib VI in the function palette. Thank you.

    dragondriver wrote:

    Hi all

    I create a project to compile a bunch of screws as lvlib and export only some libraries as public. I wonder how to export public screws in the function palette? I try [tools]-> [Advanced]-> [modify a Palette set], I create a new Palette, but when I insert VI by selecting the lvlib, it does not matter the exported VI. I wonder if there is some way I can import the public a lvlib VI in the function palette. Thank you.

    After trying for hours, I finally find the solutions.

Maybe you are looking for

  • Notification of the following communities

    Hello I want to be notified of the discussion on the communities of AW. I selected 'Suit', but I did not notice. What I am doing wrong? Thank you

  • I can not add making conta email Gmail e nem os synchronise to

    BOM dia Proceed as Estou tentando add minha conta email Gmail e os is, ao selecionar a conta Google appears a mensagem abaixo: Conexao Insegura Falha ao verificar o certificado do servidor. ISTO pode ser por causa da sua configuracao of rede or seus

  • How to delete hard drive partitions

    Can someone help to give me advice on how to remove my hard drive on my Satellite 2520 partitions? Partitions only appeared after using the system now recovery disk, I have c:d:e: disc where as before didn't the c: folder. This caused me problems whe

  • BIOS and HP Envy 17-3070NR

    During the installation of the new BIOS to correct the problem with the dynamic switchable graphics switchable and Windows 8 I deleted all my video driver software and was able to use my gragics ATI 6790 card that I really appreciate, but I noticed a

  • UCS-E140S-M1/K9 ESXi Upgrade Path?

    We have these (UCS-E140S-M1/K9) USCe modules installed in our routers ISR 3945. They come delivered installed with a custom Image ESXi profile, or you can download VMware. ESXi-5.0.0-623860-custom-Cisco-2.0.1.6.iso We can upgrade these modules UCSe t