Value returned by the function

SQL * more: Release 10.2.0.1.0 - Production on Sun 17 may at 11:41:10 2009

Copyright (c) 1982, 2005, Oracle. All rights reserved.


Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - 64 bit Production
With partitioning, OLAP and Data Mining options

SQL > create table testdata
() 2
facid number 3.
4 data varchar2 (10));

Table created.

SQL > insert into testdata (facid, data) values ('10 ', 'Data');

1 line of creation.

SQL > insert into testdata (facid, data) values ('20', 'Qdata');

1 line of creation.

SQL > select * from testdata;

FACID DATA
---------- ----------
10 data
20 Qdata


SQL > create or replace function testdata_fn (v_facid number)
2 back tank
3 is
4
number of tempid 5;
6
7. start
8
9. Select facid in tempid testdata where facid = v_facid;
10
11. IF tempid is null then
12 DBMS_OUTPUT. PUT_LINE ('TEMPID' | tempid);
13 back 'n';
14 on the other
15 return "Y";
16 end if;
17
18 end testdata_fn;
19.

The function is created.



SQL > select distinct testdata_fn (10) of testdata.

TESTDATA_FN (10)
--------------------------------------------------------------------------------
THERE

SQL > SELECT distinct testdata_fn (38) FROM testdata;

TESTDATA_FN (38)
--------------------------------------------------------------------------------


SQL >


I was expecting a "n" If there is no corresponding data.

Is this possible in a single query? I will join this query for an existing query.

Please give your comments.

you need an exception for this handler:

 ....
 exception when no_data_found then
  return 'N'
 end testdata_fn;

Tags: Database

Similar Questions

  • The value returned by the function to load is not of type digital errors after migration to Coldfusion 11

    I'm currently testing our website with CF11. He is currently working with CF8 however after the migration to a new server running CF11 I met the following error.

    The value returned by the function of load is not numeric.

    The error occurred in

    D:/applications/CFusion/CustomTags/NEC/COM/objects/address.cfc: line 263
    Called from D:/apps/CFusion/CustomTags/NEC/com/objects/contact. CFC: line 331

    Called from D:/applications/CFusion/CustomTags/NEC/COM/objects/user.cfc: line 510

    Called from D:/applications/CFusion/CustomTags/NEC/COM/objects/user.cfc: line 1675

    Called from D:/website/NECPhase2/action. Validate.cfm: line 54

    261: < cfif isNumeric (get.idCountry) >

    262: < cfset rc = this.objCountry.setID (get.idCountry) >

    263: < cfset rc = this.objCountry.load () >

    264: < / cfif >

    265: < cfset this.sPostcode = get.sPostcode >

    Were there any changes between CF8 and CF11 which can cause this error?

    Does anyone have any ideas?

    The problem is in the charge function.  There is a real return at the end of the function.  The returntype of the function is set to digital.  True is not digital, it will trigger an error.

  • The value returned by the function is not of type query

    I couldn't understand why I got this error.  I put the default var query.  Help, please.  If qLocal files then fine back, but when the archives qLocal is empty throw errors.  I set a default value.

    < name cffunction = "getName" access = "public" returnType = out of the "query" = "false".
    Hint = "this method returns a query." >
    < cfargument name = "id_fk" required = "no" default = "0" >
    < cfargument name = "id2_fk" required = "no" default = "0" >

    < cfset var qQuery = "" > "".

    < name cfquery = "qLocal" datasource = "#db #" >
    SELECT *.
    FROM tbl
    WHERE id = < cfqueryPARAM value = "#id_fk #" CFSQLType = "CF_SQL_INTEGER" > AND id2 = < cfqueryPARAM value = "#id_fk2 #" CFSQLType = "CF_SQL_INTEGER" >
    < / cfquery >


    < cfif qLocal.recordcount >
    < cfquery name = "qQuery" datasource = "db" >

    SELECT *.

    FOR tbl2

    WHERE tbl2id = < cfqueryPARAM value = "#qLocal.id #" CFSQLType = "CF_SQL_INTEGER" >

    < / cfquery >

    < / cfif >

    < cfreturn qQuery >
    < / cffunction >

    The query named qQuery only runs if the qLocal returned entries. You initialized qQuery as a variable, which is not a query object. If you initialize qQuery as a query object using the QueryNew (columnlist) that should work.

  • 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>
    
  • How to navigate to the next page based on the value returned by the method call inside the action attribute of the command key.

    How to navigate to the next page based on the value returned by the method call inside the action attribute of the command key.

    I use JDeveloper 12.1.2.0.0

    < af:button id = "tt_b2".

    rendered = "#{attrs.nextRendered} '"

    partialSubmit = 'true '.

    action = "#{attrs.backingBean.nextAction} '"

    Text = "next".

    Disabled = "#{attrs.nextDisabled}" / >

    private static final String NEXT_NAVIGATION_ACTION = "controllerContext.currentViewPort.taskFlowContext.trainModel.getNext";

    public String nextAction() {}

    If (validate()) {}

    updateModel();

    Return NEXT_NAVIGATION_ACTION;

    }

    Returns a null value.

    }

    Use case is made for model train, which is being implemented based on this blog: http://javacollectibles.blogspot.co.UK/2014/10/ADF-train-template.html

    We define a generic action following in the model, but the action must be called under certain conditions, based on the question of whether all validation controls had been passed on no.

    You can do this in two ways:

    1 returnValue = (String) ADFUtils.invokeEL("#{controllerContext.currentViewPort.taskFlowContext.trainModel.getNext}");

    return returnValue;

    2.

    public String getNextTrainStop() {}

    String nextStopAction = null;

    ControllerContext controllerContext = ControllerContext.getInstance ();

    ViewPortContext currentViewPortCtx = controllerContext.getCurrentViewPort ();

    TaskFlowContext taskFlowCtx = currentViewPortCtx.getTaskFlowContext ();

    TaskFlowTrainModel taskFlowTrainModel = taskFlowCtx.getTaskFlowTrainModel ();

    TaskFlowTrainStopModel currentStop = taskFlowTrainModel.getCurrentStop ();

    Terminus of TaskFlowTrainStopModel = taskFlowTrainModel.getNextStop (currentStop);

    nextStopAction = nextStop.getOutcome ();

    _logger.fine ("train, next stop:"+ nextStopAction ");

    Return nextStopAction;

    }

  • getting NaN for a value returned by a function

    Hello, I am writing for the reason given above. I'm trying to get two values of a function gives me the hypotnuse of a triangle, like this:

    var hyp1:Number = getHypotenuseLength(theRotation,a);

    var hyp2:Number = getHypotenuseLength ((90-theRotation), b);

    Here's the function:

    public void getHypotenuseLength(theRotation:Number,_segment:Number):Number {}

    var radians = deg2rad (theRotation);

    Return segment/Math.cos (radians);

    }

    values, the 'theRotation', 'a' and 'b', all referred to a certain number, but "hype1" and "hype2" return NaN. If anyone has an idea why please let me know. The function is correct I would say.

    You must use the function trace to see what values are being processed in the getHypotenuseLength function.

  • How to locate the values returned by the data adapter

    I have a need to internationalise/locate a string which our data adapter returns to the web client to fill out things like the table of inventory for our type of object.

    In other words, I would need to make the location in my Java code on the service side.

    But what I do not know how to do is how do I know what locale, the answer must be returned for.  I don't get the locale information in the query for the data.

    Looks like I found my answer: I can get information from the UserSession returned by the UserSessionService.

    One thing I discovered, is that the user must connect to the web client with the regional settings in place.  If you change the value of & local once the user is connected, the new value takes effect.  You will need to sign out and then sign back in.

  • Value returned by the script JSFL in Javascript

    Hello all, please I need your help, I have a file called loader.js, and this is my code:

    var csi=new CSInterface(); 

    function evalScript(script, callback) {

    new CSInterface().evalScript(script, callback);

    }

    var docName = evalScript('fl.getDocumentDOM().name');

    alert(jsfl);

    I want the code to display the name of a document to a flash file, and I put it on a javascript file (to create an extension of html5 to Flash CC). Unfortunately, the variable docName showing always undefined . But if I change the code to be like this:

    var docName = evalScript('fl.trace(fl.getDocumentDOM().name);');

    The code above can make the variable docName showing my 'document name' inside in the flash IDE output panel. How can I get the name of the document and put it on the variable docName (if it's possible, I don't want to load any external jsfl file). Thanks for your help and sorry for my bad English,

    "recall" must be based, so you can write as below:

    (function () {
      'use strict';
      var csInterface = new CSInterface();
      function init() {
      $("#button").click(function () {
      csInterface.evalScript('function getNm(){return fl.getDocumentDOM().name;}getNm();', function(payload){
      alert("My documents name : "+ payload);
      });
      });
      }
      init();
    }());
    

    First arg of callback as JSFL function return value (string).

  • Can I share a value returned by a function of report?

    I have two functions of report:

    1 counts all occurrences of courses that correspond to a given school year.

    2. get a total number of courses

    I also need to count occurrences of courses that do not correspond to a given school year. How can I subtract the value of the first report of second report function?

    Is there a better way to do it?

    As always, try to do as much as you can on the side of the data base.

    For example, in Microsoft SQL Server, you could do the following:

    SELECT

    schoolID, courseID, additionalFields,

    CASE WHEN CourseYear = school year THEN 1 0 OTHERWISE END AS CourseYearMatch,

    CASE WHEN CourseYear <> CourseYearMismatch AS END school year THEN 1 ELSE 0

    TABLENAME

    Then, in the report designer, you can use simple calculated fields to adding these two fields to create the desired counties.

    See you soon

    Eddie

  • Store of value returned by the procedure in the shell variable

    Hi gurus,

    I am trying to store THE return value of the procedure parameter in the variable shell like below;

    RET_VAL = "sqlplus $DB_USER / $DB_PASS < < EOT |" egrep. > $SCRIPT.tmp
    Set linesize 2500 pagesize 0 echo off road feedback off verify off
    Line of VARIABLE VARCHAR2 (4000)
    exec UPCStreamDiffNodeVersions($MStreamName,$oldVersion,$newVersion,:line);
    print the line;
    EOT'

    echo $RET_VAL

    I can print what is in the variable line, but can not enter in the $RET_VAL. Please suggest.

    Concerning
    Fox

    Solomon Yakobson says:

    EdStevens wrote:
    This not only would get the return code of execution of sqlplus itself

    NOP, he returned to any output (no return code) produced by SQL * Plus the term:

    create or replace
    procedure in_out(
    v_in varchar2,
    v_out out varchar2
    )
    is
    begin
    v_out := v_in;
    end;
    /
    

    prompt > export IN = EdStevens
    prompt > RET_VAL ='sqlplus-s /.<>
    Set feedback off
    Go head
    Line of VARIABLE VARCHAR2 (4000)
    exec in_out('$IN',:line);
    print the line;
    EXPRESSIONS OF FOLKLORE"
    prompt > echo $RET_VAL
    EdStevens
    Guest >

    SY.

    I was wrong. And after thinking it an another half minute... Well, of course!
    ;-)

  • Unexpected 'cpuCount' value returned by the command "LIST CELL DETAIL" cellcli EI

    Hello

    After execution of cellcli EI 'LIST CELL DETAIL' command to a server of the cell, I noticed that the output of the 'cpuCount' attribute was 24/24.

    In most of the Exadata environments I've worked with, the output is only 1 number, for example: 16

    Just the curiosity, what is the sense of value 24/24 for the attribute 'cpuCount'?

    I believe that this reflects the total number of CPU cores that are active on the host vs. the total number of cores of CPU on the host computer.  When you run the ability to demand (or as an eighth rack), the number indicates a fraction.  For example, a compute node X 5-2 contains 36 physical processor cores, but there only 18 cores enabled.  In this case, the attribute coreCount on the compute node would show 18/36.

    I see this on my rack X 4-2 running the version of the 12.1.2.1.2 image, while my X 3-2 12.1.2.1.1 still running rack displays the number using the old method, so it seems that it may have been introduced with this version.

    [root@enkx4db01 ~] # dbmcli EI list dbserver detail | grep-e "name | coreCount | makeModel | releaseVersion.

    name: enkx4db01

    coreCount: 24/24

    makeModel: Oracle SUN SERVER Corporation X 4-2

    releaseVersion: 12.1.2.1.2.150617.1

    [root@enkx3db01 ~] # dbmcli EI list dbserver detail | grep-e "name | coreCount | makeModel | releaseVersion.

    name: enkx3db01

    coreCount: 16

    makeModel: Oracle Corporation SUN FIRE X 4170 M3

    releaseVersion: 12.1.2.1.1.150316.2

  • Case string returned from the function

    Is it possible to run cases return the string somehow?

    For example:


    BOX WHEN 1.2.2011 > CURRENT_DATE THEN any OTHER 'OFF' END 'ON '.


    .. If I do like above, I get the error message: ORA-00932

    -case when date'' 2011-02-01 > timestampadd(sql_tsi_day,0,current_date) then 'works' end 'off' else

    the above worked for me

    M.

  • Why the different values for an analytic function of the same group/game

    I have the suite of table I'll be using.

    Select * from table1;

    REC_ID | STATUS | DATE_FROM | DATE_TO

    1. C | 7 January 2015 |

    2. H | December 3, 2014. 6 January 2015

    3. H | October 3, 2014. December 2, 2014

    4. H | May 30, 2014. October 2, 2014

    5. H | May 29, 2014 | May 29, 2014

    6. H | April 16, 2014 | May 28, 2014

    7. H | Tuesday, April 25, 2007 April 15, 2014

    INSERT statement if you need.

    TOGETHER TO DEFINE

    CREATE THE TABLE1 TABLE:

    (

    NUMBER OF REC_ID,

    VARCHAR2 (1 BYTE) STATUS NOT NULL,.

    DATE_FROM DATE NOT NULL,

    DATE OF DATE_TO

    );

    Insert into TABLE1

    (REC_ID, STATUS, DATE_FROM)

    Values

    (1, 'C', TO_DATE (7 JANUARY 2015 00:00:00 ',' DD/MM/YYYY HH24:MI:SS'));))

    Insert into TABLE1

    (REC_ID, STATUS, DATE_FROM, DATE_TO)

    Values

    (2, 'H', TO_DATE (3 DECEMBER 2014 00:00:00 ',' DD/MM/YYYY HH24:MI:SS'), TO_DATE (6 JANUARY 2015 00:00:00 ',' DD/MM/YYYY HH24:MI:SS'));))

    Insert into TABLE1

    (REC_ID, STATUS, DATE_FROM, DATE_TO)

    Values

    (3, 'H', TO_DATE (3 OCTOBER 2014 00:00:00 ',' DD/MM/YYYY HH24:MI:SS'), TO_DATE (2 DECEMBER 2014 00:00:00 ',' DD/MM/YYYY HH24:MI:SS'));))

    Insert into TABLE1

    (REC_ID, STATUS, DATE_FROM, DATE_TO)

    Values

    (4, 'H', TO_DATE (MAY 30, 2014 00:00:00 ',' DD/MM/YYYY HH24:MI:SS'), TO_DATE (2 OCTOBER 2014 00:00:00 ',' DD/MM/YYYY HH24:MI:SS'));))

    Insert into TABLE1

    (REC_ID, STATUS, DATE_FROM, DATE_TO)

    Values

    (5, 'H', TO_DATE (29 MAY 2014 00:00:00 ',' DD/MM/YYYY HH24:MI:SS'), TO_DATE (29 MAY 2014 00:00:00 ',' DD/MM/YYYY HH24:MI:SS'));))

    Insert into TABLE1

    (REC_ID, STATUS, DATE_FROM, DATE_TO)

    Values

    (6, 'H', TO_DATE (APRIL 16, 2014 00:00:00 ',' DD/MM/YYYY HH24:MI:SS'), TO_DATE (28 MAY 2014 00:00:00 ',' DD/MM/YYYY HH24:MI:SS'));))

    Insert into TABLE1

    (REC_ID, STATUS, DATE_FROM, DATE_TO)

    Values

    (7, 'H', TO_DATE (APRIL 25, 2007 00:00:00 ',' DD/MM/YYYY HH24:MI:SS'), TO_DATE (APRIL 15, 2014 00:00:00 ',' DD/MM/YYYY HH24:MI:SS'));))

    COMMIT;

    I will exercise more analytical query...

    Select rec_id date_from, date_to, status,

    min (date_from) over (partition by order of status by date_from desc) min_dt_from_grp,

    ROW_NUMBER() over (partition by order of status by date_from desc) rownumberdesc,

    ROW_NUMBER() over (partition by order of status by ASC date_from) rownumberasc

    FROM table1;

    the query result

    REC_ID | DATE_FROM | DATE_TO | STATUS | MIN_DT_FROM_GRP | ROWNUMBERDESC | ROWNUMBERASC

    1. 7 January 2015 | C | 7 January 2015 | 1. 1

    2. December 3, 2014. 6 January 2015 | H | December 3, 2014. 1. 6

    3. October 3, 2014. December 2, 2014 | H | October 3, 2014. 2. 5

    4. May 30, 2014. October 2, 2014 | H | May 30, 2014. 3. 4

    5. May 29, 2014 | May 29, 2014 | H | May 29, 2014 | 4. 3

    6. April 16, 2014 | May 28, 2014. H | April 16, 2014 | 5. 2

    7. Tuesday, April 25, 2007 April 15, 2014. H | Tuesday, April 25, 2007 6. 1

    If you look at the output above, it dates back in the min_dt_from_grp column.

    MY question is if the analytical function calculates for a particular/set group, which is by statute and for what min (date_from) partition is 25-apr-2007 for the GROUP H (Status column), then why I have different values returned by the query above in the min_dt_from_grp column.

    Hello

    Because you have specified an ORDER BY clause for the analytical function. In doing so, you calculate the rows on a window. Since you have not specified a windowing clause, the default applies:

    RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW

  • Made Oracle 6i LOV with ref cursor returned by a function of database

    Hi all

    I want to dynamically create a LOV in oracle forms 6i using the value of ref cursor returned by the function of database.

    is this possible?

    Using loop, I could able to display the values returned by the ref cursor, but how can I assign these values in the LOV?

    You will need to loop through your REF Cursor and assign each value to a group of registration of forms and then assign the Group Record to your LOV.  Take a look at the built-ins CREATE_GROUP, ADD_GROUP_COLUMN and ADD_GROUP_ROW in the help system of forms for more information about how to use these built-ins and examples of how to use them.

    Craig...

  • RETURN type of function table

    Hello

    I read conflicting information about the return type that has a table function must or may use.

    First, I am a student of a book that says:

    Function in pipeline returns the data types:

    The main constraint for the pipeline functions, it is the return type must be a collection type autonomous which can be used in SQL - i.e. a VARRAY or table nested.

    and then in the next sentence...

    More precisely a pipeline function can return the following:

    A stand-alone nested table or VARRAY, defined at the schema level.

    A nested table or VARRAY that has been declared in a package type.

    This seems to go against the first quoted sentence.

    Now, before reading the above text I had done just my own test to see if a packed type would work because I thought I had read somewhere that it would not, and he does not (the test code and this output is at the end of this question). When I arrived in the text above, after my test, so I was naturally confused.

    So, I'm going to PL/SQL reference that says:

    RETURN data type

    The data type of the value returned by a function table in pipeline must be a type collection defined either at the level of schema or within a package (therefore, it cannot be a type of associative array).

    I tried to call a function that returns a collection of VARRAY type packaged in both SQL and PL/SQL (of course below is SQL all in any case) and no work.

    Now I'm wondering what is a TABLE function must use a schema type and a function table in pipeline can use a packaged type?  I see that I created and called a function table but examples of Oracle see the creation and use of a function table in pipeline.

    Edit: I should add that I read the following sentence in the SF book on p609 in * table functions: "this type of nested table must be defined as an element of level diagram, because the SQL engine must be able to resolve a reference to a collection of this kind."

    So that it begins to resemble table functions should return a schema type and pipelined table functions, perhaps because that they don't in fact return a collection, rather they return (RowSource) content, can use the schema types or types of packages. Is this correct?

    Can someone clarify this for me please?

    Thank you in advance,

    J

    CREATE OR REPLACE PACKAGE PKGP28M

    VAT-type is varray (5) number;

    END;

    /

    DISPLAY ERRORS

    create or replace type VAT is varray (5) number;

    /

    display errors

    create or replace function tabfunc1 return pkgp28m.vat as

    numtab pkgp28m.vat:=pkgp28m.vat();

    Start

    numtab.extend (5);

    because loop me in 1.5

    numtab (i): = trunc (dbms_random. Value (1.5));

    end loop;

    Return numtab;

    end;

    /

    display errors

    create or replace function tabfunc2 as return VAT

    numtab vat:=vat().

    Start

    numtab.extend (5);

    because loop me in 1.5

    numtab (i): = trunc (dbms_random. Value (1.5));

    end loop;

    Return numtab;

    end;

    /

    display errors

    exec dbms_output.put_line (' call tabfunc1 (returns the packaged type) :');)

    Select * from table (tabfunc1)

    /

    exec dbms_output.put_line (' call tabfunc2 (returns the type of schema) :');)

    Select * from table (tabfunc2)

    /

    declare

    RC sys_refcursor;

    number of v;

    Start

    dbms_output.put_line (' in anonymous block1 - open rc to select in the table (tabfunc1) (returns the packaged type) :');)

    Open rc to select table column_value (tabfunc1);

    loop

    extract the rc in v;

    When the output rc % notfound;

    dbms_output.put_line (' > ' | to_char (v));

    end loop;

    close the rc;

    end;

    /

    declare

    RC sys_refcursor;

    number of v;

    Start

    dbms_output.put_line (' in anonymous block2 - open rc to select in the table (tabfunc2) (returns the type of schema) :');)

    Open rc to select table column_value (tabfunc2);

    loop

    extract the rc in v;

    When the output rc % notfound;

    dbms_output.put_line (' > ' | to_char (v));

    end loop;

    close the rc;

    end;

    /

    Scott@ORCL > @C:\Users\J\Documents\SQL\test29.sql

    Package created.

    No errors.

    Type of creation.

    No errors.

    The function is created.

    No errors.

    The function is created.

    No errors.

    the call of tabfunc1 (returns the packaged type):

    PL/SQL procedure successfully completed.

    Select * from table (tabfunc1)

    *

    ERROR on line 1:

    ORA-00902: invalid data type

    the call of tabfunc2 (returns the type of schema):

    PL/SQL procedure successfully completed.

    COLUMN_VALUE

    ------------

    1

    4

    1

    1

    3

    In anonymous block1 - open rc to select in the table (tabfunc1) (returns the packaged type):

    declare

    *

    ERROR on line 1:

    ORA-00902: invalid data type

    ORA-06512: at line 6

    In anonymous block2 - open rc to select in the table (tabfunc2) (returns the type of schema):

    > 1

    > 2

    > 4

    > 2

    > 3

    PL/SQL procedure successfully completed.

    Post edited by: Jason_942375

    But the compilation of the PIPELINED WILL CREATE the schematic function types automatically. And the TABLE function, applied to the PIPELINED function, use these types of hidden patterns.

Maybe you are looking for