How the two function return values

Dear all,

Please explain, how the two values of function return?

give a simple example.

OK, a few examples...

First example, using a type of structured on the database object:

SQL > create or replace type tMyValues as an object (yr number, number, number of dy mn)
2.

Type of creation.

SQL > create or replace function getMyValues return tMyValues is
2 number of y: = extraction (year sysdate);
number of 3 m: = extraction (sysdate months);
number of 4 d: = extract (day of sysdate);
5. start
6 return new tMyValues(y,m,d);
7 end;
8.

The function is created.

SQL > set serverout on

SQL > declare
2 myValues tMyValues;
3. start
4 myValues: = getMyValues();
5 dbms_output.put_line (' year: ' | myValues.yr);
6 dbms_output.put_line (' month: ' | myValues.mn);
7 dbms_output.put_line (' date: ' | myValues.dy);
8 end;
9.
Year: 2015
Month: 4
Day: 1

PL/SQL procedure successfully completed.

Second example, using an associative array within PL/SQL:

SQL > set serverout on
SQL > declare
2 type tMyValues is table of the index number to varchar2 (10);
3 myValues tMyValues;
4
5 function getMyValues return tMyValues is
6 retValues tMyValues;
7. start
8 retValues ('Year'): = extraction (year sysdate);
9 retValues ('Month'): = extraction (sysdate months);
10 retValues ('Day'): = extract (day of sysdate);
11 return retValues;
12 end;
13. begin
14 myValues: = getMyValues();
15 dbms_output.put_line (' year: ' | myValues ('Year'));
16 dbms_output.put_line (' month: ' | myValues ('Month'));
17 dbms_output.put_line (' date: ' | myValues ('Day'));
18 end;
19.
Year: 2015
Month: 4
Day: 1

PL/SQL procedure successfully completed.

For the pipeline functions, see the example I wrote on the link provided by ReemaPuri (answer No. 3) that I don't need to re - write what I did before.

Tags: Database

Similar Questions

  • What is READ the array returned by the DAQmx meter? How can I know the two functions DAQmx READ data stream in the same WHILE loop?

    I have a question about the order of execution.  In the WHILE loop, I have two things to measure, period and tension using the DAQmx READ functions for voltage and the meter.  In the end, I want to collect these data as points almost simultaneously as possible, as a pair and then send them together to another piece of code (not shown here) which them will result in some sort of command for an engine.  It would be run, and then I want to perceive the tension and the period at a time later and do the same thing.

    (1.) I'm a little confused on what the meter of the READ function is back because it's a table.  What is a picture of?  I thought that it was up to the value of the individual periods between rising edges.  The output of the counter 1 DBL d's a table. How many elements in this table, and what determines the size of this table?  Are the elements of the array the individual delays between the edges?  How many values are stored in the array by executing?   We take the AVERAGE of the last 15 items, but do not know if we are throwing some of the data or what.  How to understand the composition of this painting?  How can I change the composition of this painting?  Is it possible to measure only one period at a time, for example the time between TWO edges?

    2.) Will this WHILE loop execute as it gathers tension and a "period table ' (remains to be understood by me) by TIME running in a loop?  In particular, we want that the value of the tension associated with the value of the AVERAGE of the period "array", so we can use two data items to create orders of next control every time that the two values are reported.  The structure for the delivery of vi will be attached data in pairs like this?  I understand that one of the READING functions run not before the other function of READING in the WHILE loop.  I want that the period "means" and "strain (Volt) collected at the same pace. This vi will he?

    Thank you

    Dave

    Hi David,

    I suggest including the DAQmx Start Task function. If it does not start before the loop, it starts the loop and work very well, but it is not as fast and efficient. In the model of task status, task wiill go to run the checked each iteration of the loop and then back the time checked running when it restarts.

    The status of the task model: http://zone.ni.com/reference/en-XX/help/370466V-01/mxcncpts/taskstatemodel/

    Kind regards

    Jason D

    Technical sales engineer

    National Instruments

  • How can I add return values

    Hi, I have the folowing method I need two return values
            public   String[]    getChildRoles() {
                
                   
                return   this.getUserTypes()  + this.getUsernew();
    
              
            }

    Variable index wrong here:

    String t = (String)this.getUserTypesSurvey()[count];
    
  • Before then, the shift functions return type?

    I can not stress which is the return type of these functions? numeric value or Member?

    And if they come back that a member would be this fomula be valid (I have to take the average of March and June):
    avgppl = @avgrange ("HRsummary"-> "territory", @list (@currmbr ("YearTotal"), @shift (@currmbr ("YearTotal"),-3)))

    Thanks in advance!

    Hello

    All the mentioned functions (Prior, Next, and shift) returns the values and non-members.

    Concerning
    -SM

  • ExtendScript function return values

    As far as I know, it is only possible to perform functions an Extension of CS ExtendScript. I see no (direct) to obtain the return value of a function of ExtendScript.

    CSXSInterface.getInstance () .evalScript () does not return any useful information. Am I missing something, or should I make a feature request?

    Substances

    Hey, substances,

    Try:

    function test1() {}

    Alert ("Hello");

    return "42blah blah blah."

    }

    You must serialize the object into an Xml STRING to return, and it must be in the format above (for an object in the property data of the SyncRequestResult). You can't return an object directly. It will not automatically put in the above xml format.

    You can also send back an arbitrary block of XML.

    Bob

  • error with function returning values 'multiple '.

    Hello

    I am trying to write a function to return values "multiple".

    However, he returned the following error when compiling

    Errors of compilation for the sch1.myfn FUNCTION

    Error: PLS-00382: expression is of the wrong type
    Online: 19
    Text: RETURN V_res;

    Error: PL/SQL: statement ignored
    Online: 19
    Text: RETURN V_res;


    question:

    is 1 - necessary to always declare an array? as he's going to return only a single record with multiple columns





    Create or REPLACE the TYPE as result_t table;

    CREATE or REPLACE TYPE result_t as object
    (comments of the user varchar2 (100), varchar2 (4000));



    FUNCTION to CREATE or REPLACE myfn (IN_ID IN VARCHAR2, IN_BEGIN IN DATE) result IS
    type V_res_t is RECORD (user varchar2 (100) comments varchar2 (4000));
    V_res V_res_t;
    BEGIN
    Select a.user, a.comment
    in V_res.user, V_res.comments
    from View1,.
    (select distinct id,
    begin_time,
    Max (Time) on max_time (order by times desc) of view2 b
    where id = IN_LOTID
    and begin_time = IN_BEGIN) b
    where a.id = b.id
    and a.begin_time = b.begin_time
    and a.time = max_time
    and a.id = IN_ID
    and a.begin_time = IN_BEGIN;

    RETURN V_res; -> This is the line that the system keep complaining
    END;

    Note: ignore pls if the results returned is correct, but I expect to always return one row

    pls advise

    TKS & rgds

    Forget your 'result' of tabular type of.

    SQL> CREATE OR REPLACE TYPE result_t as object
      2  (user# varchar2(100), comments varchar2(4000));
      3  /
    
    Type created.
    
    SQL>
    SQL> CREATE OR REPLACE FUNCTION myfn (IN_ID IN VARCHAR2, IN_BEGIN IN DATE) RETURN result_t IS
      2  user# varchar2(100);
      3  comments varchar2(4000);
      4  BEGIN
      5  RETURN result_t(user#,comments);
      6  END;
      7  /
    
    Function created.
    
    SQL>
    

    Nicolas.

  • I found a pad that belongs to someone, so I know how the owner to return the unit

    found an ipad that belongs to someone, then how do I know that the owner to return the unit

    Take it to your local police station.   Receive a delivery receipt.   Advertise your find in the location that you found.

  • How to make FUNCTION returns several columns and several outputs line

    Hi all

    Kindly share your idea; Thanks in advance;

    I have the demo of the Table.

    DEMO table:

    name identity
    1 to 10
    1-a11
    1-a12
    2-b10
    2-b11
    3 ccc

    and the function is like:

    create or replace function (number of p1) return varchar2 as
    number of vid;
    VNAME varchar2 (20);
    Start
    SELECT id, name in vid, vname from demo where id = p1;
    return v1;
    end;
    /

    This function returns the output for the id = 3;

    BUT,

    I need output like (input 1)

    VNAME vid
    1 to 10
    1-a11
    1-a12

    A function returns a single data type.

    This type of data can be a type of atomic data (varchar2, number etc.) or it may be a type of data object to save, or even a type of collection data.

    Where will you use this feature? In PL/SQL or SQL?

    If you are wanting to use it in SQL, need you a pipeline for example function

    SQL> CREATE OR REPLACE TYPE myemp AS OBJECT
      2  ( empno    number,
      3    ename    varchar2(10),
      4    job      varchar2(10),
      5    mgr      number,
      6    hiredate date,
      7    sal      number,
      8    comm     number,
      9    deptno   number
     10  )
     11  /
    
    Type created.
    
    SQL> CREATE OR REPLACE TYPE myrectable AS TABLE OF myemp
      2  /
    
    Type created.
    
    SQL> CREATE OR REPLACE FUNCTION pipedata(p_min_row number, p_max_row number) RETURN myrectable PIPELINED IS
      2    v_obj myemp := myemp(NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL);
      3  BEGIN
      4    FOR e IN (select *
      5              from (
      6                    select e.*
      7                          ,rownum rn
      8                    from (select * from emp order by empno) e
      9                   )
     10              where rn between p_min_row and p_max_row)
     11    LOOP
     12      v_obj.empno    := e.empno;
     13      v_obj.ename    := e.ename;
     14      v_obj.job      := e.job;
     15      v_obj.mgr      := e.mgr;
     16      v_obj.hiredate := e.hiredate;
     17      v_obj.sal      := e.sal;
     18      v_obj.comm     := e.comm;
     19      v_obj.deptno   := e.deptno;
     20      PIPE ROW (v_obj);
     21    END LOOP;
     22    RETURN;
     23  END;
     24  /
    
    Function created.
    
    SQL> select * from table(pipedata(1,5));
    
         EMPNO ENAME      JOB               MGR HIREDATE                    SAL       COMM     DEPTNO
    ---------- ---------- ---------- ---------- -------------------- ---------- ---------- ----------
          7369 SMITH      CLERK            7902 17-DEC-1980 00:00:00        800                    20
          7499 ALLEN      SALESMAN         7698 20-FEB-1981 00:00:00       1600        300         30
          7521 WARD       SALESMAN         7698 22-FEB-1981 00:00:00       1250        500         30
          7566 JONES      MANAGER          7839 02-APR-1981 00:00:00       2975                    20
          7654 MARTIN     SALESMAN         7698 28-SEP-1981 00:00:00       1250       1400         30
    
    SQL> select * from table(pipedata(6,10));
    
         EMPNO ENAME      JOB               MGR HIREDATE                    SAL       COMM     DEPTNO
    ---------- ---------- ---------- ---------- -------------------- ---------- ---------- ----------
          7698 BLAKE      MANAGER          7839 01-MAY-1981 00:00:00       2850                    30
          7782 CLARK      MANAGER          7839 09-JUN-1981 00:00:00       2450                    10
          7788 SCOTT      ANALYST          7566 19-APR-1987 00:00:00       3000                    20
          7839 KING       PRESIDENT             17-NOV-1981 00:00:00       5000                    10
          7844 TURNER     SALESMAN         7698 08-SEP-1981 00:00:00       1500          0         30
    
    SQL> select * from table(pipedata(11,15));
    
         EMPNO ENAME      JOB               MGR HIREDATE                    SAL       COMM     DEPTNO
    ---------- ---------- ---------- ---------- -------------------- ---------- ---------- ----------
          7876 ADAMS      CLERK            7788 23-MAY-1987 00:00:00       1100                    20
          7900 JAMES      CLERK            7698 03-DEC-1981 00:00:00        950                    30
          7902 FORD       ANALYST          7566 03-DEC-1981 00:00:00       3000                    20
          7934 MILLER     CLERK            7782 23-JAN-1982 00:00:00       1300                    10
    
    SQL>
    

    If you use it in PL/SQL and then just filling a data type of collection and return that will make. Although you should question why you want to pass large amounts of data around like that first.

    Explain your purpose and what you intend to do and we can recommend the best way.

    {message: id = 9360002}

  • How the get function is available or not on the loaded swf file

    I have 100 swf file in one of my projects. And there is a common feature in some of the SWFs. All these files are loadded in the file main.swf. Here's my Question, "If have the common function is the swf file that is loaded, int how to trigger this funciton of the main.swf.

    Quite simply,.

                if(movieclip.test){
                    movieclip.test();
                }
    

    ('movieclip' is the loaded SWF file and "test()" is the function)

  • Dial the stored function return array

    Hi all

    I have a function as follows:
    create or replace TYPE string_table IS the TABLE OF VARCHAR2 (2000);
    create or replace TYPE ARRAYTYPE is VARRAY (20) OF VARCHAR2 (30);
    create or replace FUNCTION getEmpArray (s varchar2, varchar2, st string_table t) RETURN ARRAYTYPE AS
    ARRAYTYPE l_data: = ARRAYTYPE();
    BEGIN
    l_data.extend; l_data (l_data. (Count): = s; l_data.extend; l_data (l_data. (Count): = t; l_data.extend; l_data (l_data. (Count): = St (1); L_data RETURN;
    END;

    I want to call this function from StoredFunctionCall
    Code:
    Fun StoredFunctionCall = new StoredFunctionCall();
    fun.setProcedureName ("getEmpArray".toUpperCase ());

    Object [] arr = new Object() {"aa", "Valentine", "bbb"};

    ArrayDescriptor = arrDescriptor
    ArrayDescriptor.createDescriptor ("string_table".toUpperCase (),
    connection);
    ARRAY arrayToPass = new ARRAY (arrDescriptor, arr);

    fun.addUnamedArgumentValue ("a");
    fun.addUnamedArgumentValue ("b");
    fun.addUnamedArgumentValue (arrayToPass);

    fun.setResult ("FUNCTION_RESULT"); to get result by this name

    List of vector < DatabaseRecord > = session.executeSelectingCall (fun);

    But the Exception
    PLS-00382: expression is of the wrong type
    ORA-06550: line 1, column 7:
    PL/SQL: Statement ignored

    Error code: 6550
    Call: START? : = GETEMPARRAY (?,?,?); END;
    link = > [= > FUNCTION_RESULT, a, b, oracle.sql.ARRAY@21fbc01]


    Please help me

    Published by: fbg on 26/04/2010 21:52

    A few questions,

    1 JDBC does not support the type of TABLE PLSQL, you must use a type VARRAY, or wrap the TABLE function call in a function that takes a VARRAY.
    TopLink also has support for PLSQL types in his PLSQLStoredProcedureCall class, but no support is currently available for StoredFunctions.
    You can pass the VARRAY type for the argument of the TABLE.

    2. your function returns a VARRAY, so you must set the type in the result of StoredFunctionCall.
    We are currently the API to set a table for the result type, so you must directly access first parameter of the call or use a StoredProcedureCall (and convert your function of a procedure).

    You can also investigate a cursor of returning from a procedure stored instead of the varray.

    You can also directly access the JDBC connection and make the call using JDBC code.

    Feel free to connect these issues EclipseLink.

    ---
    James: www.eclipselink.org

  • There will be a conflict between the two functional modules of a 2010 Biztalk adapter pack?

    Hello

    We already use a free version of SAP Business Suite (32-bit adapter) to suck SAP data.
    We are now upgrading all SSIS packages with the 64-bit Biztalk adapt pack 2010 and have few questions about it. It works successfully.
    Question 1:
    In my direct SAP, I installed the function module and my old 32-bit adapter works. As part of the migration to the new 64-bit adapter, I give myself with new functional module in SAP that I put in the SAP test area. To migrate all my packages, I have to start to move from one card to the other, and both must function in the SAP LIVE system module. If this is the case, will there be conflicts over the 2 functional modules working for 2 different cards (32 & 64 bit)? If my transition period is 4 weeks, these modules can still work?
    Question 2:
    If this works it cause any impact in the production SAP system at all? I don't want daily data extraction to cause an impact at all.
    Please advice. I'm unable to find any relevant article on this.
    Thank you
    Mani
    Original title: biztalk adapt pack 2010

    Hi Vincent,.

    I would have you post your query in the MSDN forums, because it is addressed to an audience of it professionals.

    Your request would be more out there.

    Check out the link-

    http://social.msdn.Microsoft.com/forums/en-us/sqlintegrationservices/threads/

    Get back to us if you have questions about Windows in the future. We will be happy to help you.

    Thank you.

  • multiple function return values

    Hello

    create tablepermission role_

    (

    role_id NUMBER not null,

    permission_id NUMBER not null

    );

    insert into role_permission (ROLE_ID, PERMISSION_ID)

    values (16: 1);

    insert into role_permission (ROLE_ID, PERMISSION_ID)

    values (17: 1);

    Insert role_permission (ROLE_ID, PERMISSION_ID)

    values (18: 1);

    insert into role_permission (ROLE_ID, PERMISSION_ID)

    values (17: 2);

    insert into role_permission(ROLE_ID, PERMISSION_ID)

    values (18, 2);

    insert into role_permission(ROLE_ID, PERMISSION_ID)

    values (15: 1);

    insert into role_permission(ROLE_ID, PERMISSION_ID)

    values (20, 1);

    commit;

    need to create the function for a select statement to integrate it within a query.

    create or replace function return_role (i number) return?

    is

    Start

    Select role_id of

    in?

    (select role_id, max (y.permission_id)

    of role_permission y

    Role_id group

    After max (y.permission_id) = 1)

    end return_role;



    my request should be like this:

    updated roles

    set = 1 ID

    where role_id in (select return_role (1) double)

    Please your help.

    the solution should be without creating an object type in the database.

    Thanks in advance

    Naama



    Example to demonstrate with a pipeline function (although I wouldn't recommend this way)...

    SQL > create table role_permission
    () 2
    3 role_id NUMBER not null,
    4 permission_id NUMBER not null
    5  );

    Table created.

    SQL > insert into role_permission (ROLE_ID, PERMISSION_ID) values (16: 1);

    1 line of creation.

    SQL > insert into role_permission (ROLE_ID, PERMISSION_ID) values (17: 1).

    1 line of creation.

    SQL > insert into role_permission (ROLE_ID, PERMISSION_ID) values (18: 1);

    1 line of creation.

    SQL > insert into role_permission (ROLE_ID, PERMISSION_ID) values (17: 2);

    1 line of creation.

    SQL > insert into role_permission (ROLE_ID, PERMISSION_ID) values (18, 2);

    1 line of creation.

    SQL > insert into role_permission (ROLE_ID, PERMISSION_ID) values (15: 1);

    1 line of creation.

    SQL > insert into role_permission (ROLE_ID, PERMISSION_ID) values (20, 1);

    1 line of creation.

    SQL > commit;

    Validation complete.

    SQL > create type t_roles in the table of the number;
    2.

    Type of creation.

    SQL > create or replace function return_role (i number) t_roles return pipeline as
    2 role of the cursor is
    3. Select role_id
    role_permission 4 y
    Group of 5 by role_id
    6. having max (y.permission_id) = 1;
    7. start
    8 r to the role
    9 loop
    hose 10 row (r.role_id);
    11 end of loop;
    12 end return_role;
    13.

    The function is created.

    SQL > create table roles (number role_id, identification number)
    2.

    Table created.

    SQL > insert into roles (role_id, id) values (15.0);

    1 line of creation.

    SQL > insert into roles (role_id, id) values (16.0);

    1 line of creation.

    SQL > insert into roles (role_id, id) values (17.0);

    1 line of creation.

    SQL > insert into roles (role_id, id) values (18.0);

    1 line of creation.

    SQL > insert into roles (role_id, id) values (19.0);

    1 line of creation.

    SQL > insert into roles (role_id, id) values (20.0);

    1 line of creation.

    SQL > commit;

    Validation complete.

    SQL > update roles
    2 = 1 set ID
    3 where in (select column_value role_id
    table 4 (return_role (1))
    5                    )
    6.

    3 lines to date.

    SQL > select * from roles
    2.
    ROLE_ID-ID
    ---------- ----------
    15 1
    16 1
    17 0
    18 0
    19 0
    20 1

    6 selected lines.

  • In an Adobe form I need the value of Field3 to display the higher of the two fields, Field1 value or Field2 (compare the value of Field1 and Field2 and display the highest amount in field3) can someone please tell me the script to run this simple comparis

    I have 2 fields that are calculated fields and I need display the higher value of the 2 fields in a third field

    The field names must be in double - quotes. And if you change the value of any field, now, you will see error messages in the console.

  • Determine how the CFC function was called?

    I have a CFC that can use CFLOCATION under certain conditions. The problem is this function can be called remotely and it will crumble if CFLOCATION is used. Is there a way I can say within the service if it was called remotely or locally?

    Oh what I needed thank you.

  • How to set the return value of the method to the /outputText inputText field

    Hello

    How to set output return value method of a /outputText adf inputText field

    Concerning

    sevanan

    Well put method's return value to a managed bean variable.

    Create a variable in the bean and set the return value to this variable.

    the inputText and outputTextValue to this managedBean.variable value

    That's all...

    and add partial trigger for inputText programmaticly

Maybe you are looking for