Functions table of AS2 AS3 migration

The code below is intended to load randomly selected "koan sovereign wealth funds" in a clip on the timeline main root called "koan_loader_mc" by using a loader, called "koan_loader."  The actions in this table are correctly migrated to AS3?  Thanks for your help

create the function that is called at the end of koan_ # .swfs

This code is in the first frame of the root timeline

Array.prototype.shuffle = function() {}

for (var koan.length - 1; ivar = ivar > = 0; ivar-) {}

var p = random (ivar + 1);

var t = this [ivar];

This [ivar] = this [p];

This [p] = t;

}

};

MovieClip (root) .index = 0;

var koan_loader:Loader = new Loader();

koan var: Array = ['swfs/koans/koan_1.swf","swfs/koans/koan_2.swf', 'swfs/koans/koan_3.swf', 'swfs/koans/koan_4.swf', 'swfs/koans/koan_5.swf', 'swfs/koans/koan_6.swf', 'swfs/koans/koan_7.swf', 'swfs/koans/koan_8.swf', 'swfs/koans/koan_9.swf', 'swfs/koans/koan_10.swf', 'swfs/koans/koan_11.swf', 'swfs/koans/koan_12.swf'];

KOAN.shuffle ();

koan_loader. Load (new URLRequest (koan [index]));

MovieClip (root).koan_loader_mc.addChild (koan_loader);

-----------

This is the code in a frame at the end of the koan SWFs:

MovieClip (root) .index ++

If (root.index > _root.koan.length - 1) {}

root.index = 0;

root. KOAN.shuffle ();

}

var koan_loader:Loader = new Loader();

koan_loader. Load (new URLRequest (koan [root.index]);

MovieClip (root).koan_loader_mc.addChild (koan_loader);

loadMovie (_root.koan [root.index]);

function shuffle(a:Array) {}

for (var = ivar. Length-1; Ivar > = 0; Ivar-) {}

var p = random (ivar + 1);

var t = a [ivar];

a [ivar] = a [p];

a [p] = t;

}

};

Tags: Adobe Animate

Similar Questions

  • Conversion function XML AS2 AS3

    Hi guys, how are you?

    Once again I m here to ask for your help.

    I m trying to convert an AS2 AS3 script, but I m not good in AS3 síntax yet. I Don t know how to create this structure. Please, could someone help me?

    xml:
    
    <resources>
    
             <levelTitle1>Iniciante</levelTitle1>
              <levelTitle5>Aprendiz</levelTitle5>
              <levelTitle10>Aspirante</levelTitle10>
              <levelTitle15>Recruta</levelTitle15>
              <levelTitle20>Experiente</levelTitle20>
              <levelTitle30>Profissional</levelTitle30>
              <levelTitle50>Star</levelTitle50>
              <levelTitle70>Ás</levelTitle70>
              <levelTitle90>Campeão</levelTitle90>
              <levelTitle120>Lenda</levelTitle120>
    
    </resources>
    
    
    AS2 Function:
    
    public static function getLanguage(tag:String):String
    {
               if (languageObject[tag].data){
    
    
                        return slanguageObject.resources[tag].data;
               }
                 return "Error";
     }
    

    I can´t find a way to work in as3 without the parameter 'data '.

    I want to call this as2 function, pass "levelTitle30" to the "tag" parameter and return by the return of the function of the content of "levelTitle30" of the xml tag.

    Kind regards

    is your code xml in an external file?

    If so, (for example, resources.xml), you would use:

    var xml

    var urlLoader:URLLoader = new URLLoader();

    urlLoader.addEventListener (Event.COMPLETE, completeF);

    urlLoader.load (new URLRequest ("resources.xml"));

    function completeF(e:Event):void {}

    XML = e.Target.Data;

    }

    public static function getLanguage(tag:String):String{
    if(xml[tag]){
    return xml[tag];

    } else {
    return "Error";
    }
    }

  • To AS2 AS3, need help.

    I learned Flash using AS2 and I try now migrate to AS3, but some of the simplest things have changed.  I know I can't put script directly on movieclips now, but I do not know how to use if the conditions to check for movieclips hit some frames, etc.

    Can someone direct me to the tutorials on the displacement of AS2 AS3 and some of the fundamental behaviors of AS3.

    For example:

    If I had a movieclip I used as a button and I tried jumping a specific image when another movieclip on the stage struck a framework?  With AS2, I could simply put a script on the movieclip itself that says something like:

    onClipEvent (EnterFrame)

    {

    If (this ._currentframe is 10)

    {

    _parent.sampleClip.gotoAndStop (2);

    }

    }

    I don't know how to do simple same navigation like this in AS3 code.

    Thanks for the help.

    There are a lot of tutorials and a few great books too. For tutorials that you probably want just a search on any specific problems that you find. Regarding the example you gave, it is a little different in 3 and also better:

    someMovieClip.addEventListener (Event.ENTER_FRAME, checkFrame);
    function checkFrame(e:Event) {}
    if(someMovieClip.currentFrame == 10) {}
    sampleClip.gotoAndStop (2);
    }
    }

    I say better because you don't need to worry about scope as you did in 2 - checkFrame is not executed in the context of the someMovieClip - sampleClip is available directly, you don't need to 'parent' to access.

  • AS2 AS3 conversion please!

    Hi guys.

    I had a major problem when trying to convert an old AS2 AS3 code.

    It would be great if you guys can help in anyway you can.

    onClipEvent (enterFrame)

    {

    This;

    If (_x > 520)

    {

    setProperty (this, _x,-20);

    } / / end if

    This;

    If (_x <-20)

    {

    setProperty (this, _x, 520);

    } / / end if

    setProperty (this, _x, _x + (1.250000E + 000) Number);

    }

    In the chronology of the object in question, try:

    addEventListener (Event.ENTER_FRAME, moveX);

    function moveX(evt:Event):void {}

    If (x > 520) {}

    x = - 20;

    }

    If (x<>

    x = 520;

    }

    x += 1.25;

    }

  • actions AS2 as3 scripts

    can someone help me to get comparable to as2 as3 actions? as

    1. "Loadmovie" on different levels. Level 0, level 1, etc.

    2 in, click on "loadmovie".

    3 fscommand like, quiet, full screen, enable scale.

    4. on the release to go and play

    5. on the release of play and stop.

    6. play the content to the side of the clip with liberation.

    1 AS3 doesn't have a Level0, level1, etc..  You can use the Loader class to load an external swf,

    2 AS2 doesn't have any such orders - the loader allows you to load an external file.  If you want to have an insider click it then use an event listener for a CLICK MouseEvent.

    3. search Google AS3 fscommand

    4 AS3 uses the same command gotoAndStop that AS2, except that the arguments for scene/frame are reversed to frame/scene - again, happens with a click, use an event listener for a CLICK MouseEvent

    5 AS2 doesn't have any orders to play and stop, they are against orders, nor is AS3.  If you want to say stop, it's the same for both except, once again, the order of the arguments

    6. This would be the same in AS2 where you target the movieclip using the dot notation and tell the play() - once again, using an event listener for a CLICK MouseEvent.

    Explaining the AS3 button Code
    --------------------------

    Assume that you create a button symbol.  Since this is a button, it is already a car animation object that will react to mouse interactions, but only visually at this stage.  The first thing you need to do to make it useful down must assign a unique instance name.  If you drag a copy of it on the stage of the library, and while it is still selected, enter you this unique instance for her name in the Panel properties... say you name "btn1.

    In AS3, to make a button with the code, you must add a listener of events and event handler for it function.  You may need to add a little (for different events, like reversal, deployment, by clicking on it, but for now let's just say you want to be able to click them to get a web page.)  In the scenario that contains this button, a layer of separate actions that you create in a similar framework where this button exists, numbered, you must add the event listener:

    Btn1.addEventListener (MouseEvent.CLICK, btn1Click);

    The name of the unique function for the treatment, the click of this button is specified at the end of the assignment of event listener, so now you just have to write this function:

    function btn1Click(evt:MouseEvent):void {}

    var url: String = "http://www.awebsite.com/awebpage.html";

    var req:URLRequest = new URLRequest (url);

    navigateToURL (req);

    }

    Here's what this is:

    evt:MouseEvent - event listeners get an argument automatically the function should be implemented to receive.  In this case I just this argument a name of variable evt, although I could choose anything.

    : Sub - this defines the class of the value that the function returns.  In this case, the function does not return anything, so "Sub" is used.  If she returned a value, you will see a line that contains "return xyz." in the function (where xyz is not literal, it represents just the variable or the value returned)

    The normal code that opens a web page contains three distinct elements, the url, the application and command to get the page, so I showed in three separate lines.  Many people combine in a single line.

    In AS3, in strict mode, it is necessary to identify the types/classes of variables being created, that's why you see: String,: MouseEvent, etc. display everywhere.

    I know it's probably clear as mud in the explanation, but I hope that it will shed some light on what you're working with.

    Now, to create another button with a single function for it, you could just drag another copy of the library, give it a unique name, say btn2, copy / paste the code from btn1 and replace "btn1" "btn2" in this code copied, adding a new url to the page, this button opens.

  • Replace code as2 as3

    I used a tutorial http://www.Flash-game-design.com/Flash-tutorials/funky-Flash-website-Tutorial-5.html make a menu for my application, I tried following advice on how to change code AS2 AS3, but it simply doesn't.

    menu = ['bulls', 'about', 'alignment', 'plan'];

    current var menu = [0];

    for (var i = 0; i < menu.length; i ++) {}

    var b = menu [i];

    ce.stars._visible [b + '_btn'] = false;

    this .txt [b + '_btn'] = b;

    this [b + '_btn'] .onPress = function() {}

    _root.site [current + "_btn"].stars._visible = false;

    _root.site [this.txt + "_btn"].stars._visible = true;

    current = this.txt;

    _root.site.content.gotoAndStop (this.txt)

    };

    }

    Cette.stars._visible [current + "btn"] = true;

    this.onEnterFrame = function() {}

    this [current + '_btn']. stars.s1._rotation += 1;

    this [current + '_btn']. stars.s2._rotation & = 0.5;

    };

    Thank you

    Glenn

    Hi, I have fixed that and you sent the mail, check the Inbox.

  • Need help with as2 as3 conversion. Please, I beg you.

    Could someone help me to convert as2 as3, please?

    Source code:

    _root.magnet = 500;
    _root.magic = 10;

    and

    onClipEvent (load)
    {
        homex = this._x;
        homey = this._y;
        forcex = 1;
        forcey = 1;
    }
    onClipEvent (enterFrame)
    {
        x0 = this._x;
        y0 = this._y;
        x1 = this._xmouse;
        y1 = this._ymouse;
        distancex = x1 - x0;
        distancey = y1 - y0;
        distance = Math.sqrt(distancex * distancex + distancey * distancey);
        powerx = this._x - distancex / distance * _root.magnet / distance;
        powery = this._y - distancey / distance * _root.magnet / distance;
        forcex = (forcex + (homex - x0) / 2) / _root.magic;
        forcey = (forcey + (homey - y0) / 2) / _root.magic;
        this._x = powerx + forcex;
        this._y = powery + forcey;
    }

    I am a newbie in flash so if anyone can help with this would be great.

    I really need to be done please help me.

    MovieClip(root).magnet = 500;MovieClip(root).magic = 10;
    

    and

    var homex:Number = yourmc.x;var homey:Number = yourmc.y;var forcex:Number = 1;var forcey:Number = 1;
    
    yourmc.addEventListener(Event.ENTER_FRAME, loopF);
    
    function loopF(e:Event){    var x0:Number = e.currentTarget.x;    var y0:Number = e.currentTarget.y;    var x1:Number = e.currentTarget.mouseX;    var y1:Number = e.currentTarget.mouseY;    var distancex:Number = x1 - x0;    var distancey:Number = y1 - y0;    var distance:Number = Math.sqrt(distancex * distancex + distancey * distancey);    var powerx:Number = e.currentTarget.x - distancex / distance * MovieClip(root).magnet/distance;    var powery:Number = e.currentTarget.y - distancey / distance * MovieClip(root).magnet/distance;    forcex = (forcex + (homex - x0) / 2) /MovieClip(root).magic;    forcey = (forcey + (homey - y0) / 2) / MovieClip(root).magic;    e.currentTarget.x = powerx + forcex;    e.currentTarget.y = powery + forcey;}
    
  • AS2 AS3 help.

    Hi guys.

    I had a major problem when trying to convert an old AS2 AS3 code.

    It would be great if you guys can help in anyway you can.

    What I try to do is, load in a clip again and again to create a rain effect, the clip is a drop of falling rain.

    I need for the MovieClip name is also updated every time. For example, Name1, name2, Name3, name4 ect

    AS2 code:

    {onClipEvent (load)}

    _root.d_counter = 1;

    }

    {onClipEvent (enterFrame)}

    If () {}

    _root.attachMovie ("particles", "particle", + _root.d_counter, _root.d_counter, {_x:0, _y:0});})

    _root.d_counter = _root.d_counter + 1;

    }

    }

    =====================================

    My AS3 Code:

    particle.addEventListener (Event.ADDED_TO_STAGE, loaded);
    function loaded(event:Event):void {}
    var _counter:Number = 1;
    }
    particle.addEventListener (Event.ENTER_FRAME, entered);
    function entered(event:Event):void {}
    if (MovieClip (root) .d_counter < 100) {}
    MovieClip (root) .addChild (particle);
    . D_counter (root) of MovieClip is MovieClip (root) .d_counter + 1;.
    }
    }
    =====================================
    My code is close to what I want, but it does not load in multiple instances of the same object.
    Any help would be great.

    use:

    var d_counter:Number = 1;
    particle.addEventListener (Event.ENTER_FRAME, entered);
    function entered(event:Event):void {}
    If (MovieClip (root) .d_counter< 200){="">
    trace ("Yes");
    rain in the var: MovieClip = new Particle();
    Rain.x = Math.Random () * stage.stageWidth;
    MovieClip (root) .addChild (rain);
    . D_counter (root) of MovieClip is MovieClip (root) .d_counter + 1;.
    } else {}
    remove your particles and their ready for gc
    particle.removeEventListener (Event.ENTER_FRAME, entered)
    }
    }
  • function table

    Hi experts


    I want to know how to create a table function that returns the Recordset (empno, ename, sal + comm) of the emp table

    I know that this can be done with simple SQL, but I want to learn to write the table function.

    And how to call this function from another sql table.

    Please help me...

    The sample data is data.

    EMPNO, ENAME, JOB HIREDATE DEPTNO COMM SAL MGR

    7369 SMITH COMMITTED 7902 17 DECEMBER 80 800 100 20

    7499 ALLEN 7698 1600 20 FEBRUARY SALESMAN 81 300 30

    7521 WARD 7698 1250 22 FEBRUARY SALESMAN 81 500 30

    Table function returns a collection of lines (a nested table or varray). You can choose from this collection, as if it were a database table by calling the function table inside of the TABLE clause in a SELECT statement. However, the use of the results of the function table based on table producing the entire collection (and remember, the collection is stored in memory) and then sending it only to the SQL statement. Table function in pipeline using PIPE ROW to route the data to the SQL statement as part of collection is produced. This SQL statement way working on this element table in function transformation pipeline while working to produce the next item in the collection. This improves performance and reduces the memory usage which can be even more important when the function produces collections of great footpring. RTFM in pipeline and functions using parallel Tableanyway.

    SY.

  • Function table in oracle

    Hi all

    I am using Oracle 11g

    I want to know in order to learn

    What is the CURSOR in the function table.

    What is its usefulness

    Can someone explain to me.

    SELECT x.*

    (TABLE (package1.function1)

    CURSOR (SELECT

    t.*

    OF test1 t))) x

    Thank you

    What is the CURSOR in the function table.

    What is its usefulness

    Can someone explain to me.

    SELECT x.*

    (TABLE (package1.function1)

    CURSOR (SELECT

    t.*

    OF test1 t))) x

    This slider is NOT 'in the function table. It is in the call to YOUR function named "packagae1.function1" and the function returns a collection. If it is the result of the collection of YOUR function call which is 'in the function table.

    Your probable function takes a REF CURSOR as a parameter, so the code above uses the CURSOR operator to create a cursor from a subquery.

    Your function then returns a collection and SCOREBOARD operator is used to make this collection available in SQL.

    See FUNCTIONS TABLE in the Oracle documentation. A simple search for 'oracle 11g table function' returns the Oracle doc as the FIRST result listed:

    http://docs.Oracle.com/CD/B28359_01/AppDev.111/b28425/pipe_paral_tbl.htm

    This chapter describes the functions of table

    . . .

    Overview of the functions of table

    Table functions are producing a set of lines (a nested table or a varray) that can be queried as a physical database table. You use a function table as the name of a database table, in the FROM clause of a query.

    A table function can take a set of input lines. A parameter of the input collection can be of a collection type or a REF CURSOR .

    . . .

    Look at the examples 5-13 and 13-6, because they show the code for your EXACT example:

    http://docs.Oracle.com/CD/B28359_01/AppDev.111/b28425/pipe_paral_tbl.htm#CIHEGADE

    . . .

    Example 13-6 How to use a function Table in pipeline with REF CURSOR Arguments

    SELECT * FROM TABLE(StockPivot(CURSOR(SELECT * FROM StockTable)));
    

    In the previous query, the function table in pipeline StockPivot retrieves the lines of the CURSOR subquery SELECT * FROM StockTable , performs the transformation and channels the results to the user in the form of table. The function produces two lines of output for each input line (items in the collection).

    Note that when a CURSOR subquery went from SQL for a REF CURSOR argument of function as in the previous example, the referenced cursor is already open when the function begins to run.

    As the doc example, as in your example, a subquery of CURSOR to create a cursor to be used as a function parameter. Example 13 - 5 has the actual code for the function.

    The documentation is your FRY - don't be afraid to use it.

    If you try to learn something a good question to ask on the forums is: where can I get more information about the functions of the table (or other topic).

    Then, we can direct you to the Oracle documentation that covers this topic.

  • 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.

  • How to model a view based on a function table

    Hello

    I want to model a view in SQL Developer Data Modeler which is based on a function of painting as:

    table (function (a, b))

    When the function is a function table in pipeline. How is that possible?

    DM 3.3.0.734 SQL version

    Best regards

    Joop

    Hello

    In the Properties dialog box of the view that is displayed when you create the view, you can select the Report Builder queries (on the general page) button.

    In the query designer, you can enter the query text in the box above the buttons OK and apply, cancel, for example
    SELECT * FROM TABLE (FUNCTION (a, b))

    David

  • How do I get the output of a function table

    Hi all

    Kindly share your idea.


    I need the outputs of a function table only.

    Database version: oracle 10.1.0.2.0

    login_details:

    login_id branch_code

    admin 1
    Admin1 2
    Test 1
    user 1

    I need output for the query function below.

    Select login_id from login_details where branch_code = '1';

    If I create a function:


    FUNCTION to CREATE or REPLACE fn_get_login (pvBranch varchar2)
    IS BACK SYS_REFCURSOR
    REF_TEST SYS_REFCURSOR;
    BEGIN
    OPEN FOR REF_TEST
    Login_id SELECT FROM login_details WHERE branch_code = pvBranch;
    RETURN REF_TEST;

    END;
    /


    Select * from login_master where login_id in (select fn_get_login('01') from double);


    and get

    ORA-00932: inconsistent data types: expected - got CURSER

    Edited by: 887268 October 8, 2012 12:25

    You cannot use a Ref cursor in a table, because it isn't a result set of data, it's just a pointer to a request for enforcement.

    {: identifier of the thread = 886365}

    A ref cursor must be used if you want to refer the request to an external application.

    Transfer data back to a function is to use a pipeline for example function

    SQL> CREATE OR REPLACE TYPE num_descript AS OBJECT(num number, descript varchar2(30))
      2  /
    
    Type created.
    
    SQL>
    SQL> CREATE OR REPLACE TYPE tbl_num_descript AS TABLE OF num_descript
      2  /
    
    Type created.
    
    SQL>
    SQL>
    SQL> CREATE OR REPLACE PACKAGE reftest AS
      2    FUNCTION pipedata(p_choice number) RETURN tbl_num_descript PIPELINED;
      3  END;
      4  /
    
    Package created.
    
    SQL>
    SQL> CREATE OR REPLACE PACKAGE BODY reftest AS
      2    FUNCTION pipedata(p_choice number) RETURN tbl_num_descript PIPELINED IS
      3      v_obj num_descript := num_descript(NULL,NULL);
      4      v_rc  sys_refcursor;
      5    BEGIN
      6      IF p_choice = 1 THEN
      7        OPEN v_rc FOR SELECT empno as num, ename as descript FROM emp;
      8      ELSIF p_choice = 2 THEN
      9        OPEN v_rc FOR SELECT deptno as num, dname as descript FROM dept;
     10      END IF;
     11      LOOP
     12        FETCH v_rc INTO v_obj.num, v_obj.descript;
     13        EXIT WHEN v_rc%NOTFOUND;
     14        PIPE ROW(v_obj);
     15      END LOOP;
     16      CLOSE v_rc;
     17      RETURN;
     18    END;
     19  END;
     20  /
    
    Package body created.
    
    SQL> select * from table(reftest.pipedata(1));
    
           NUM DESCRIPT
    ---------- ------------------------------
          7369 SMITH
          7499 ALLEN
          7521 WARD
          7566 JONES
          7654 MARTIN
          7698 BLAKE
          7782 CLARK
          7788 SCOTT
          7839 KING
          7844 TURNER
          7876 ADAMS
          7900 JAMES
          7902 FORD
          7934 MILLER
    
    14 rows selected.
    
    SQL> select * from table(reftest.pipedata(2));
    
           NUM DESCRIPT
    ---------- ------------------------------
            10 ACCOUNTING
            20 RESEARCH
            30 SALES
            40 OPERATIONS
    
    SQL>
    

    but of course, it is wise to just use pure SQL that in order to mix the PL/SQL in queries in the form of best performance features.

    Perhaps explain what problem you are trying to solve when trying to use a function, and we can advise you on the best options.

  • How can I call a function table in pipeline via DB link?

    I am using a function table in pipeline defined in a remote DB (DB_A) of my DB in local (DB_B) via a link DB (DB_A_REMOTE).

    The function table in pipeline is defined in a package with all the specifications of type he needs and works very well when she is called locally but when called it remotely fails

    Here is an example configuration in DB_A:
    connect scott/tiger
    create or replace
    package pkg as
      type rec is record (
        dte date
      );
      type rec_set is table of rec;
      
      function dts(p_eff_date date) return rec_set pipelined;
      function dt(p_eff_date date) return date;
    end;
    /
    create or replace
    PACKAGE BODY pkg AS
    
      function dts(p_eff_date date) return rec_set pipelined AS
        r rec;
      BEGIN
        r.dte := p_eff_date;
        pipe row(r);
        r.dte := r.dte+1;
        pipe row(r);
        RETURN;
      END dts;
    
      function dt(p_eff_date date) return date as
      begin
        return p_eff_date;
      end;
    
    END pkg;
    /
    In DB_B, I have the following configuration:
    create database link DB_A_REMOTE connect to Scott identified by tiger using 'DB_A';
    create or replace synonym RPKG for PKG@DB_A_REMOTE;
    In DB_A, I can access the two PKG functions very well
    SQL> select pkg.dt(sysdate) from dual
    DJ.DT(SYSDATE)       
    ----------------------
    21-SEP-2012 11:26:31   
    
    SQL> select * from table(pkg.dts(sysdate))
    DTE                  
    ----------------------
    21-SEP-2012 11:26:31   
    22-SEP-2012 11:26:31   
    23-SEP-2012 11:26:31   
    24-SEP-2012 11:26:31   
    However, in DB_B the I get the following:
    SQL> select rpkg.dt(sysdate) from dual
    RPKG.DT(SYSDATE)     
    ----------------------
    21-SEP-2012 11:29:05   
    
    SQL> select * from table(rpkg.dts(sysdate))
    
    Error starting at line 2 in command:
    select * from table(rpkg.dts(sysdate))
    Error at Command Line:2 Column:20
    Error report:
    SQL Error: ORA-06553: PLS-752: Table function DTS is in an inconsistent state.
    06553. 00000 -  "PLS-%s: %s"
    *Cause:    
    *Action:
    selection rpkg.dt shows I can get to the remote package and run functions in it, but the second line is where my problem.

    Why the function table in an inconsistent state and how can I fix this problem so that it will work in all of the linlk database?

    Published by: Sentinel on September 21, 2012 11:35

    Go! You have posted more than 1,000 times and know that you must provide your Oracle version 4-digit.
    >
    Why the function table in an inconsistent state and how can I fix this problem so that it will work in all of the linlk database?
    >
    You can't - it is not supported.

    See the note under the PIPELINED clause in the declaration section of the definition of the doc of PL/SQL and function
    http://docs.Oracle.com/CD/E11882_01/AppDev.112/e25519/function.htm
    >
    Note:

    You cannot run a function table in pipeline over a database link. The reason is that the return type of a function table in pipeline is a SQL type defined by the user, which can be used in a single database (as explained in the Guide of the Oracle object-relational database developer). Although the return type of a function table in pipeline may appear as a PL/SQL type, the database actually converts this PL/SQL type to a type defined by the corresponding SQL user.
    >
    Your code using PL/SQL types for these types are implicitly converted to the SQL type needed to access the service using SQL. But the SQL types have an OID (object ID) which is not recognized on the other server so that the other server is unable to create the appropriate type.

    If you click on the link provided to the other doc in this note, you will see that even though you can create a type and specify an OID you still won't be able to use it as you wish.
    http://docs.Oracle.com/CD/E11882_01/AppDev.112/e11822/adobjbas.htm#ADOBJ7083
    >
    Restriction on the use of Types defined by the user with a remote database

    Objects or user-defined types (specifically, types declared with a SQL CREATE TYPE statement, as opposed to types declared in a PL/SQL package) are currently only useful in a single database. Oracle database limits the use of a link of database as follows:

    Unable to connect to a remote database for select, insert, or update a type defined by the user or a REF object on a remote table.

    You can use the CREATE TYPE statement with the Optional keyword OID to create an object identifier specified by the user (OID) that allows an object type for use in multiple databases. See the discussion on the attribution of an OID for a type of object in Oracle Database Data Cartridge Developer's Guide.

    You cannot use the links from the database of the PL/SQL code to declare a local variable of a type defined by the remote user.

    You cannot pass an argument value or return of type user defined in a PL/SQL remote procedure call.

  • Question of functions table

    Hello people,

    I just want to know why I can't use indexed tables in the table as return type functions. For example when I write "pls_integer index" at the end of the holder_t code, table function does not work. I would like to know why? What are the differences?

    create or replace
    package my_pack
    is
    type holder_t is table of Hello % rowtype;
    / * When I type this table like this, type holder_t is table of the Hello % rowtype index by pls_integer; table function does not work * /.
    type ref_cur_t is ref cursor
    Hello return % rowtype;
    end;

    create or replace
    function pipeline (SLEEP my_pack.ref_cur_t)
    parallel_enable my_pack.holder_t return pipeline (partition SLEEP by any)
    is
    my_row Hello % rowtype;
    holder hello_o: = hello_o (null, null);
    Start

    loop
    When the exit SLEEP % notfound;
    extract SLEEP them in my_row;
    Holder.a: = my_row.a;
    Holder.b: = my_row.b;
    course of action (my_row);
    end loop;
    Close SLEEP;

    return;

    end;



    Thank you.

    Polat says:
    OK, but what are the differences with the type holder_t is table of Hello % rowtype and type holder_t table with % rowtype index by pls_integer Hello? I mean both of them are table, but if I then use as return type it gives an error, I am trying to understand this?

    Difference is

    type holder_t is table of hello%rowtype index by pls_integer;
    

    Is an associative array. Similar to a hash table. This is only one type of PL/SQL, SQL cannot be used.

    This

    type holder_t is table of hello%rowtype;
    

    Is a nested table, similar to a set (or bag). This can be used in SQL, too.

    Looking at the docs for functions in pipeline, type that see you back:

    The data type of the value returned by a function table in pipeline must be a collection type defined at the schema or within a packet level (therefore, it cannot be a type of associative array).
    The elements of the collection type should be given SQL type, not data types supported only by the PL/SQL (for example PLS_INTEGER and BOOLEAN).

    Looking for all ther son you have on this topic, you should certainly read and try under rest three different collection types offered:
    http://docs.Oracle.com/CD/E11882_01/AppDev.112/e25519/composites.htm#LNPLS00501

    Concerning
    Peter

Maybe you are looking for

  • Time Capsule backup suddenly stopped working

    I used my Air Port Time Capsule since July last year, without a hitch. Then all of a sudden today, he says: 'no back ups for 155 days' (!) and I get this message: "The backup drive is not available. Make sure that the backup disk is connected, or sel

  • Print/copy / fax

    My HP Officejet 6500 a model E710N prints suddenly alone if the text is in color. Black & white print out just a Virgin, even if B & W cartridge is full. Can you help me?

  • Options available for the OS deployment

    Hello. We recently purchased the Dell Poweredge R730xd servers. I can't find the 'Boot from USB' option in the BIOS. Also, I am unable to deploy the operating system using the virtual console because of the absence of iDRAC8 Enterprise license. I tri

  • Where can I find a USB receiver for a keyboard 1011?

    I bought a used Microsoft Wireless Desktop Elite Keyboard (1011) but I need the mouse (1007) and Receiver USB, no idea where I can find one?

  • OSPF in VRF with the same area ID.

    Hi all On a PE MPLS/VPN router, I configured OSPF as the routing PE Protocol / THIS. I configured several OSPF (one for each VRF) process. But if I have several customers who use the same ID in OSPF area on the side, can I set up the same area ID for