Casting table PL/SQL for the type of existing table and back ref cursor

Hello



I have the problem of casting a pl/sql table for the type of an existing table and turning the ref cursor to the application. Casting a ref cursor back and number of pl/sql table works well.



Declarant

< strong > TYPE type_table_name IS TABLE OF THE package_name.table_name%ROWTYPE; < facilities >

within the stored procedure, fill in a table of this type temp_table_name and returning the ref cursor help

< strong > results OPEN to SELECT * FROM TABLE (CAST (temp_table_name AS type_table_name)); < facilities >

generates an error. type_table_name is unknown in this distribution. According to me, this happens because of the declaration of the type locally.



Statement type_table_name inside the package specification does not work neither. Incredible, cast to the said dbms_sql.number_table to specify ref cursor back and dbms_sql package works very well!



< strong > CREATE TYPE type_table_name IS TABLE OF THE package_name.table_name%ROWTYPE; < facilities > deals without any error but creates an invalid type complain a reference to package_name.table_name



I don't want to declare every column in the table in type_table_name, because any change the table_name table would result in an inconsistent type_table_name.



Thanks in advance!

Edited by: user6014545 the 20.10.2008 01:04

In any case you are right that there is a problem around anchorage (or maintaining) types of objects persistent to match the table structures, they may represent.

In the case you describe, you might be better off just open the refcursor immediately the using one of the techniques described in the http://www.williamrobertson.net/documents/comma-separated.html to manage the delimited list.

In the more general case where the line of treatment is necessary, you may make the pipeline functions.

Oracle Database 10g Express Edition Release 10.2.0.1.0 - Production

SQL> CREATE TABLE table_name
  2  AS
  3     SELECT ename column_name
  4     FROM   emps;

Table created.

SQL> CREATE OR REPLACE PACKAGE package_name
  2  AS
  3     TYPE type_name IS TABLE OF table_name%ROWTYPE;
  4
  5     FUNCTION function_name_pipelined (
  6        parameter_name IN VARCHAR2)
  7        RETURN type_name PIPELINED;
  8
  9     FUNCTION function_name_refcursor (
 10        parameter_name IN VARCHAR2)
 11        RETURN sys_refcursor;
 12  END package_name;
 13  /

Package created.

SQL> CREATE OR REPLACE PACKAGE BODY package_name
  2  AS
  3     FUNCTION function_name_pipelined (
  4        parameter_name IN VARCHAR2)
  5        RETURN type_name PIPELINED
  6     IS
  7     BEGIN
  8        FOR record_name IN (
  9           SELECT table_alias.*
 10           FROM   table_name table_alias
 11           WHERE  table_alias.column_name LIKE parameter_name) LOOP
 12
 13           PIPE ROW (record_name);
 14        END LOOP;
 15
 16        RETURN;
 17     END function_name_pipelined;
 18
 19     FUNCTION function_name_refcursor (
 20        parameter_name IN VARCHAR2)
 21        RETURN sys_refcursor
 22     IS
 23        variable_name sys_refcursor;
 24     BEGIN
 25        OPEN variable_name FOR
 26           SELECT table_alias.*
 27           FROM   TABLE (package_name.function_name_pipelined (
 28                     parameter_name)) table_alias;
 29
 30        RETURN variable_name;
 31     END function_name_refcursor;
 32  END package_name;
 33  /

Package body created.

SQL> VARIABLE variable_name REFCURSOR;
SQL> SET AUTOPRINT ON;
SQL> BEGIN
  2     :variable_name := package_name.function_name_refcursor ('%A%');
  3  END;
  4  /

PL/SQL procedure successfully completed.

COLUMN_NAME
-----------
ALLEN
WARD
MARTIN
BLAKE
CLARK
ADAMS
JAMES

7 rows selected.

SQL> ALTER TABLE table_name ADD (new_column_name VARCHAR2 (1) DEFAULT 'X');

Table altered.

SQL> BEGIN
  2     :variable_name := package_name.function_name_refcursor ('%A%');
  3  END;
  4  /

PL/SQL procedure successfully completed.

COLUMN_NAME NEW_COLUMN_NAME
----------- ---------------
ALLEN       X
WARD        X
MARTIN      X
BLAKE       X
CLARK       X
ADAMS       X
JAMES       X

7 rows selected.

SQL>

Tags: Database

Similar Questions

  • Where lives the logic for the types of flow control step?

    For most types of step, the behavior of the type of the step is determined entirely by the configuration of the stage - that is to say, the properties that can be configured in the window type, such as the properties of the step, steps, etc..  But as far as I know, the behavior of the control flow step types (for example, hop, back at the beginning of a block of loop after a late stage) does not seem to be defined by a lower level, flag, attribute or any other configuration item - it seems to be something inherent to the motor TestStand.

    If this is the case, how the TestStand engine knows to provide the functionality for a particular flow control step type?  It runs the appropriate logic based on the name of the step type?  I suspect that this may be the case, because if I create new types of step in copying the types of step ForEach and end without any changes other than to specify the new name for the beginning of the block and end step types, new types of step repeat not the loops as expected.

    Can someone clear this up for me?  Types of flow control step break the model completely define the features by changing the type of step, or I am simply not find relevant configuration items?  I tried to create a new type of end step that allows an expression pre, but it broke my step ForEach (new) type loopback functionality.  Is it possible to do what I want?

    You are right that the engine processes specially the flow control measures. He looks at the name of step type. If you want the same behavior execution, you must keep the original name of type step as a prefix on your step type name, such as NI_Flow_End_CustomizedByMe.

    Also, check out the http://forums.ni.com/t5/NI-TestStand/copy-of-NI-Flow-End-does-not-work/m-p/290170/highlight/true#M88...

    There is the source code that is similar to what the engine makes the steps of flow control. That was the actual code before it moved into the engine. It might be a bit outdated now. I found this on my machine in C:\Program Files (x 86) \National Instruments\TestStand 2010\Components\StepTypes\FlowControl\

  • Security filters for the Types of Plan of ASO in 11.1.2.3


    All,

    My understanding of security filters for the Types of Plan of ASO in 11.1.2.3, is that they are not as robust as Types of Plan of traditional BSO are. Is this true? If so, can I restrict access to users who are assigned to the ASO Plan Type to display only and read/write on the private accounts and entities (for example)?

    Thanks in advance.

    The limitation that you refer is a bit confusing.  In summary, the planning will not create Essbase security filters on a data base of the ASO.  However, this does NOT mean that you will not have security on the Type of Plan of ASO.  Instead, it depends on which tool you are using to access the Type of Plan of ASO.

    If you want to connect to the ASO Plan type planning or tool (e.g., EN) with a connection to planning, you'll be fine.  The planning gets its security filters Essbase security information.  It gets its information from the relational repository security.  So the planning and the EN (with a connection to planning) are supported.  Security works as you would expect, even for the Type of Plan of ASO.

    If you want to connect on the type of Plan of ASO with something that requires a * Essbase * (not planning) connection, it only is not supported out-of-the-box, because planning will not create filters on the ASO cube (at least not yet in this version).  However, there is nothing that prevents you from creating filters on your own.  I usually manage all of my safety in an Excel/VBA model that allows me to export/import the Essbase security planning and.  This allows me to apply specific to Essbase filters after a refresh (by importing the custom filters via MaxL).

    So the question is... what tool you will use to access the Type of Plan of ASO?  If you use a connection of planning, you're good.  If you use a connection of Essbase, should be a personalized approach.

    Hope this helps,

    -Jake

  • Value to be entered when filling out the metadata for the type of Version in Plannin

    Hello
    I extracted the dimension of the version of my plan.
    Now I need to push planning 11. I reversed the planning 7 dimension by using the dimension of the version to push the value.

    After the excerpt, the type of version is UDA as 'Standard bottom-up, Public '. I divided the chain into 2 columns in the version type and others such as the UDA.
    I traced the type column version to the source to version type (in planning) to the target.

    The performance of the interface, it generated the following error log:

    Final Version, Version, never share, Public, Standard Bottom Up, ~, cannot load the dimension member, error message is: java.lang.IllegalArgumentException: invalid value for the Version Type field: Standard Bottom Up.
    REV 1, Version, never share, Release 1, Public, Standard Bottom Up, ~, cannot load the dimension member, error message is: java.lang.IllegalArgumentException: invalid value for the Version Type field: Standard Bottom Up

    What value must be entered for the type of version?

    Furthermore, if there is no doc/pdf that provide details on the different values that can appear in the dimensions of planning, please share.

    Thanks in advance

    Published by: user8628169 on January 18, 2010 16:40

    Hello

    The value should be 'Bottom Up' or 'Target', have a read here for properties

    Ok?

    See you soon

    John
    http://John-Goodwin.blogspot.com/

  • Is there a manual for the user of Windows XP and how can I get a?

    Is there a manual for the user of Windows XP and how can I get a?

    Hello

    See how you go with this...

    http://download.Microsoft.com/download/1/6/6/16674679-1e6e-4304-A5A0-49eeaa31e639/RevGuide.PDF

    Concerning

    GT4U

  • It takes up to 4 minutes for the player switch between library and Rip, and vice versa.

    I run Media Player 11 on my XP machine with spare 120G on the C: memory and 3G - recently, it takes up to 4 minutes for the player switch between library and Rip, and vice versa. I have re-installed twice but no change. No new software has been installed before this time.

    Hello Absno69,

    Thank you for your message.  You mentioned that there were no new software installed before that happens.  Were there any hardware changes or updates?  If this isn't the case, we will perform a system restore to a point that you know that your system is working effectively.  Click HERE for the system restore instructions.
    Please let us know if it did or did not help to solve your problem.
    See you soon

    Engineer Jason Microsoft Support answers visit our Microsoft answers feedback Forum and let us know what you think.

  • How to install a local help for the tools of cmd.exe and command line on Windows 7?

    Hello

    for many applications, the command line (cmd.exe) is a good choice to get results with minimum effort. The shell has continuously been improved over the years, at least until Windows XP.

    All the command line tools have a short help screen (using the /? option). When you need more information, you use Windows system for example from the Explorer Help. It is very good.

    Now, Windows XP Help content was installed on site, and the operating system. In Windows 7, my computer wants to go to the Microsoft web site on the internet and there is no local help available. The operating system seems to be incomplete. This makes the help system unusable on a computer without internet access or when the server is not accessible.

    So my question is: is it possible to install a local copy of help for the tools of cmd.exe and command line under Windows 7 or do we have to go back to Windows XP?

    Thank you

    Martin

    Download it directly from Microsoft - Windows Command Reference

  • DVD how much we need for the files backup with backup and restore program?

    Hello how are you?
    DVD how much we need for the files backup with backup and restore program? Y at - it large differences in the time and space between write backups on DVD and external hard drive?

    I do not understand your question.  Asked how the space has been used on your C: drive and you answered 60 GB.  Now you say your PARTITION C: is 60 GB with only 20 GB used?  I really don't understand what you're so confused.  It's simple arithmetic grade 3rd.  What is space you USED on the C: drive, that multiply by 0.7 to obtain the amount of space will be used on your backup disk after compression.  Divide this number by 4.7 and round.  That's how many DVDs you'll need if you insist on the use of DVDs for backup.  Then

    (1) If you are using 60 GB, the answer is (60 x.7) / 4.7 = 8.936.  I rounded up to 9 and added 1 just to be sure.

    (2) If you use only 20 GB, the answer is (20 x.7) / 4.7 = 2.97 rounded up to 3.  Add 1 and get 4.

    If you use only 20 GB, I am very surprised, because almost any important installation of Windows 7 is going to take more than 20 GB.

    All of this assumes that you do NOT use the Windows backup and restore program, but one that I recommended.  When I used the windows one, the results were several times the space that I used on my C: partition.

    Good luck.

  • I would like to have the best possible experience for the games on my laptop and I want to download everything that is necessary for the performance of the games.

    I bought a new laptop which has Windows 8. I heard that Windows 8 is new, it only is not automatically provided some 'things' - forgive me for my lack of knowledge in technology. I intend to play games on my new laptop, but according to my knowledge, Windows 8 does not support things like Visual C++ and Directx 9. I am very uncertain about this subject, however. If anyone understands this as am I mean, can you please correct and/or explain more on this topic? I would like to have the best possible experience for the games on my laptop and I want to download everything that is necessary for the performance of the games.

    Original title: what's missing in Windows 8?

    Jack

    We were all new at one point, so don't worry what you know.  Win 8 is compatible with all previous OS.  It supports C++, and depends on your video card supports DIrectX 9, 10 and 11.

    The only thing that doesn't come with win 8 (and since you bought it, it may already be installed) is windows media player.

    What exactly are you trying to do, or can you give us more information for we can help you better?

  • I signed up for the 10 free stock images, and when I try to download them, save them to the desktop isn't an option.  What should I do?  I need to get rid of the tattoo.

    I signed up for the 10 free stock images, and when I try to download them, save them to the desktop isn't an option.  What should I do?  I need to get rid of the tattoo.

    Follow the n steps these screenshots: I downloaded my 10 free images and they all have the Adobe watermark on them, so I can't use them. Why do they have a watermark on them?

  • How to make a stationary State (or equivalent) for the form to change color and reveal some hidden above text...? is there a widget I could use?

    How to make a stationary State (or equivalent) for the form to change color and reveal some hidden above text...? is there a widget I could use?

    There are many solutions. A more simple: put the text and the items colored in the back and put the 'shape' on it. Configuration of the 'shape' become transparent in a stationary state.

  • Hi - I signed up for the Adobe Creative cloud monthyly and don't know where to find?  I bought the product, but is not a file to download? What I have to do to get it on my laptop &gt; how to find this &gt; thanks :)

    I signed up for the Adobe Creative cloud monthyly and don't know where to find?  I bought the product, but is not a file to download? What I have to do to get it on my laptop > how to find this > thanks

    Install the desktop cc app from here, https://creative.adobe.com/products/creative-cloud

    Check your account indicates the subscriptions that you expect (and that the adobe, used in the next step id is correct) by logging in here and checking the status of your subscription, https://www.adobe.com/account.html

    then, if it's current, disconnect and then back to your client application using the adobe with the link above in cc id: http://helpx.adobe.com/creative-cloud/kb/sign-in-out-creative-cloud-desktop-app.html

    Use your desktop app to install your programs of cc.

  • I paid for the pack of adobe PDF and I in some weird screen which shows the different products to buy. I just want to use the pdf pack to do what I need. any suggestions?

    I paid for the pack of adobe PDF and I in some weird screen which shows the different products to buy. I just want to use the pdf pack to do what I need. any suggestions?

    Hi jerrir58650452,

    You can access your service pack pdf by using the following link: https://cloud.acrobat.com

    Kind regards
    Rahul

  • Need the difference between strong Ref Cursor and weak Ref Cursor examples

    Oracle 9.2

    It would be great if someone can help understand the differences between
    1 Strong Ref Cursors(return type)
    and
    2. weak Ref Cursor (no return type)

    What I read is weak ref Cursor as sys_refcursor is better to use the ref Cursor, because in the case of slider strong Ref object type that will be returned must be declared in advance. It dosent make sense to me?

    I start with the examples would be appreciate for advice

    Strong Ref Cursor

    create the package str_pack
    is
    type sref_type is ref cursor return emp % rowtype;
    SVAR sref_type;
    end str_pack;

    Create procedure st_proc (eid in number, c1 on str_pack.sref_type)
    is
    Start
    Open c1 to select empno, ename, sal from emp where empno = eid;
    end;

    declare
    str_pack.sref_type C1;
    type rec is RECORD (eid, ename varchar2 number (20), number of sal);
    SheikYerbouti rec;
    Start
    st_proc(10,C1);
    loop
    When exit c1% notfound;
    Fetch c1 into SheikYerbouti.
    end loop;
    Close c1;
    end;


    There could be errors in the above example but its basically to get a better understanding.

    For weak Ref Cursor

    procedure of the child

    Create procedure child_proc (in number, c1 on sys_refcursor eid)
    is
    Start
    Open c1 to select empno, ename, sal from emp where empno = eid;
    end;

    parent process

    Create procedure parent_proc (recnum varchar2)
    is
    p_retcur sys_refcursor;
    emp_row emp % rowtype;
    Start
    child_proc (eid, p_retcur);
    loop
    extract the p_retcur in emp_row;
    dbms_output.put_line(emp_row.empno ||) e '|| emp_row. Ename | "wins". emp_row. SAL);
    end loop;
    end parent_proc;

    Concerning
    @

    Hello

    the fundamental difference is to do with the compiling and linking of runtime type that occurs.

    The he should explain a lot more detail than I could ever!
    http://asktom.Oracle.com/pls/asktom/f?p=100:11:0:P11_QUESTION_ID:1640161160708

    P;

  • SQL Developer 3.0 EA 1 Advanced support for the type of data in the unit tests

    Hello

    According to SQL Developer 3.0 EA 1 New Feature List (http://www.oracle.com/technetwork/developer-tools/sql-developer/rel3-featurelist-ea1-166831.html#ut)
    the EA 1 version 3.0 supported advanced data types in the unit tests. This means support the ANYDATA and RECORD types? I installed version 3.0 of EA 1 to CentOS linux, but it seems that those advanced types are not supported yet. When I try to add a unit test for a function that returns the record type, I get quick error: "the return of PL/SQL RECORD type is not supported. Cannot test (function_name) because 1 arguments have not supported for types". Also if I try to unit test procedure which parameter is of type ANYDATA, I get quick error: "the type UNDEFINED P_DATA argument is not supported. Cannot test (procedure_name) because 1 arguments have not supported for types". Are those advanced data types supported in SQL Developer 3.0 FINAL version?

    Thank you
    Miikka L

    Edited by: user12844253 the 27.10.2010 16:31

    Hi Mikka,

    Only simple PL/SQL records are currently supported i.e. those containing no optional or repeating components and where all components are themselves supported. This restriction is in place, due to the fact that we are using JDBC as a parameter mechanism which does not directly support the passage the PL/SQL record type.

    ANYTYPE and ANYDATA are currently not supported because they have a dynamic value type and must be set programmatically. In the future, it would be possible to support these via the dynamic value and and validation features.

    This will remain for the final version.

    Kind regards
    Richard

Maybe you are looking for

  • updated at 14.0 and not more can access firefox on my mac OSX - help!

    Firefox asked me to update to 3.6 to 14.0, so I did. At the end of the process, I was told that '14.0 is not compatible with your OS x system. I have since not been able to access Firefox and lost all my favorites and other info. In addition, my comp

  • Personal cloud IX2 - download a folder

    Hi all Yesterday, I connect my personal Cloud 2bay IX2 nas. Everything works ok, I can view the files, go review the files and download a single file, just a question: How can I download multiple files or a folder to my personal cloud?

  • Integrated vs. discrete graphics-&gt; processors

    Hello world I am looking to buy a new computer workstation E30, and I am a little uncertain on which I should choose between integrated and discrete graphics. I understand it, in effect, what the differences are and I would go with discrete graphics,

  • Does not start in safe mode.

    Does not start in safe mode.  "System Tools" jumped to the top and I couldn't get our of it.  Shut down the system to turn everything off.  When I try to reboot in safe mode, I get to the scren that ask for your system press operating enter and get a

  • What is the problem and how can I solve this problem?

    I can't update my laptop I did the microsoft fix and I was told that my firewall is not on site have seen firewall I windows vista security requesting for me to pay how to make my computer back to normal windows firewall? I meet a lot of problems bec