migration package to the procedure, how to use THE params

Hi all
We just roll back packages in the stand alone procedures and I starat have problems with syntax and OUT defintion, for example our body of package/East:
create or replace
PACKAGE          PACK_RYBA_INVENT AS 
  TYPE CURSOR_INFO IS REF CURSOR;
  -- FUNCTION DECLARATIONS
  PROCEDURE p_RYBA_GetALL (in_custom IN NUMBER, out_cursorINFO OUT CURSOR_INFO);
END PACK_RYBA_INVENT;

-- body
create or replace
PACKAGE BODY                   PACK_RYBA_INVENT AS
  PROCEDURE p_RYBA_GetALL (in_custom IN NUMBER, out_cursorINFO OUT CURSOR_INFO) AS
    BEGIN
      OPEN out_cursorINFO FOR
      SELECT id_comp, id_name, cust_profile   FROM tc_INFO
      WHERE id_comp = in_custom;
    END p_RYBA_GetALL;
END PACK_RYBA_INVENT;
It is sweet to cursor declataion, specify us its type in code 'run '.
I'm still new to Oracle, and I have the problem with the compilation of my inside, do not know how to correctly, report Cursro or should I let its declation in Packge and referencing it from there? How better to give this slider out all statements within the procedure, what Miss me? and I want to use the 'Cursor OPEN FOR' approach if possible.
create or replace  Procedure  p_RYBA_GetALL (in_custom IN NUMBER,  out_cursorINFO OUT CURSOR_INFO) AS
 TYPE CT IS REF CURSOR RETURN tc_INFO.id_comp%TYPE, tc_INFO.id_name%TYPE , tc_INFO.cust_profile%TYPE;
 CURSOR_INFO CT;
   BEGIN
      OPEN out_cursorINFO FOR
      SELECT id_comp, id_name, cust_profile   FROM tc_INFO
      WHERE id_comp = in_custom;
    END ;
TX
TR

Published by: trento on September 21, 2010 14:25

sys_refcursor is available on 9i, here is the sample code that I tried...

create or replace procedure getAllHierarchies (oc_sysrc out sys_refcursor)
IS
BEGIN
 OPEN oc_sysrc FOR SELECT * FROM tstproduct;
EXCEPTION WHEN OTHERS THEN
   RAISE_APPLICATION_ERROR(-20002,SQLERRM);
END getAllHierarchies;

Then the procedure is called in this way...

DECLARE
  refCursorValue SYS_REFCURSOR;
  myRecord tstproduct%ROWTYPE;
BEGIN
  getAllHierarchies(refCursorValue);

  LOOP
    FETCH refCursorValue INTO myRecord;
    EXIT WHEN refCursorValue%NOTFOUND;
    dbms_output.put_line(TO_CHAR(myRecord.product_id)||' '||myRecord.product_description);
  END LOOP;
EXCEPTION WHEN OTHERS THEN
  dbms_output.put_line(TO_CHAR(SQLCODE)||' '||SQLERRM);
END;

Tags: Database

Similar Questions

  • How to use the pl/sql procedure

    Hi all,

    How to use pl/sql packages and especially in what situations we are pl/sql, which is the cause of the procedure. Please explain with precision using small example.

    Thanks and greetings

    RAM

    I could tell this at a very high level.

    PL/SQL's procedural extension to SQL. SQL (structured query language) has no procedural capacity. They are executed as a stand-alone statement. When you want to generate a process flow with several SQL statement that you need to have a procedural language that could accommodate your SQL. PL/SQL is something similar to Java and Dot Net in this aspect. Said that PL/SQL is Oracle DB. This has some advantages. The most important thing is that when you have your SQL in PL/SQL oracle maintains its reliance on the object. Any database oracle related so you want to build, then you can consider to PL/SQL as the best way to use process flows.

    PL/SQL provides various methods such as the PROCEDURE, FUNCTION and the PACKAGE. The only thing that race stands is in its ability to modularize your code. So, using the package you can create process workflows that is modular and easy to understand.

  • Find out all the package and procedure names linked using an array of specifc

    I have 25 packages
    Each package contains 30-35 procedures
    I need to find all packages and procedures
    Each procedure handles the Tables from 5 to 20 according to the need of business rule.
    I need the entire package and related procedure names where a specific Table name is
    (DBA_SOURCE is not objective).
    Quick response appreciated.
    Thank you and best regards,

    It is difficult to help you if you do not want to read what is suggested. The utldtree.sql script will do what you want. Read the first part of the script and it will tell you what it does and how it works:

    >
    REM $Header: utldtree.sql, v 1.2 1992/10/26 16:24:44 $ RKOOI Stab
    REM
    REM Copyright (c) 1991 by Oracle Corporation
    REM NAME
    REM deptree.sql - Show objects recursively depends on given object
    REM DESCRIPTION
    REM This procedure, temp and table will allow you to see all
    Objects REM (recursively) depends on the given object.
    REM Note: you will see the objects for which you have permission.
    Examples of rem:
    REM run deptree_fill ('procedure', 'scott', 'billing');
    REM select * from deptree by seq #;
    REM
    REM Execute deptree_fill ('table', 'scott', 'emp');
    REM select * from deptree by seq #;
    REM
    REM run deptree_fill ("package body ', 'scott', 'accts_payable'");
    REM select * from deptree by seq #;
    REM
    Way prettier REM to display this information only
    REM select * from deptree by seq #;
    REM is
    REM select * from ideptree;
    REM This shows the relationship of dependence via indentation. View
    REM that no order by clause is necessary with ideptree.
    REM RETURNS

    >

    Did you notice the part that says? :

    >
    REM Execute deptree_fill ('table', 'scott', 'emp');
    REM select * from deptree by seq #;

    >
    If you supply a table name, it will display the objects that depend on this table just as you said you want.
    Please try this script.

  • How to use a function inside the package?

    Hello

    You will need to convert weight unit of kilogram kips when filling out the weight values into a temporary table. In our database, schema there is a function called convert_units is available.
    How could I use this feature in my package? My package is also resides in the same database schema.

    Here, I pasted the function.
         convert_units
       (
         in_base_unit_id       NUMBER,
         in_conversion_unit_id NUMBER,
         in_value              NUMBER
       ) RETURN NUMBER AS
    CURSOR unit_cur IS
      SELECT *
      FROM units_conversion
      WHERE base_unit_id = in_base_unit_id
        AND conversion_unit_id = in_conversion_unit_id;
    unit_rec unit_cur%ROWTYPE;
    BEGIN
      OPEN unit_cur;
      FETCH unit_cur INTO unit_rec;
      IF unit_cur%NOTFOUND THEN
        unit_rec := NULL;
      END IF;
      CLOSE unit_cur;
      RETURN (in_value+unit_rec.pre_adjust_add)*(unit_rec.rate);
    END convert_units;

    Hello

    It seems that the first two arguments of this function are ID in the units_conversion table. If you know this id = 1234 means kilograms, 9876 means kips, then you can do things like:

    wt_kips := convert_units (1234, 9876, wt_kilograms);
    

    or

    INSERT INTO tmp_table ( ..., weight_val,                               ...)
           VALUES           ( ..., convert_units (1234, 9876, wt_kilograms), ...);
    

    I can't just look at the code which could be any valid ID. I'm not even sure of the order of the arguments. I hope you have instructions on how to use the function.

    If the function is in a package named pk_xyz (a different package to the one in which you call it), add the name of the package, like this

    wt_kips := pk_xyz.convert_units (1234, 9876, wt_kilograms);
    
  • After replacing the motherboard of PC how can use the license package, is the same hard drive.

    Mr President, our pc is repaired & change the motherboard and now how to use the product under license of photoshop

    It could be cleaner if you uninstall the products in question, using the CS cleanup tool and then contact Adobe technical support via chat and ask to reset your activations before install and activate the software again.

    Adobe Creative Suite cleanup tool

    helps resolve installation for CS3 thru CS6 and creative cloud problems

    http://www.Adobe.com/support/contact/cscleanertool.html

    To the link below, click on the still need help? the option in the blue box below and choose the option to chat...

    Make sure that you are logged on the Adobe site, having cookies enabled, clearing your cookie cache.  If it fails to connect, try to use another browser.

    Serial number and activation support (non - CC) chat

    https://helpx.Adobe.com/contact.html?step=PHSP-PHXS_downloading-installing-setting-up_lice nsing-activation_stillNeedHelp

    Before you uninstall, you can see if you can extract the serial number in case you don't have it at hand.

    If it's a Windows machine, and then try running Belarc Advisor

    http://www.Belarc.com/free_download.html

    For a Mac, you can try:

    https://Mac-product-key-Finder.com/

  • How to use the DBMS_ROWID package

    Hello

    I am not able to use this DBMS_ROWID package, I ran this script in my schema dbmsrwid.sql

    When I use this sql I get the following error:

    SQL > select DBMS_ROWID. ROWID_BLOCK_NUMBER (ROWID)
    2 FROM emp3
    3 where id = 1;
    Select DBMS_ROWID. ROWID_BLOCK_NUMBER (ROWID)
    *
    ERROR on line 1:
    ORA-04067: not executed, the package body "KAM. DBMS_ROWID' does not exist
    ORA-06508: PL/SQL: called program unit is not found: "KAM. DBMS_ROWID.
    ORA-06512: at line 1

    and also when I try to use below that I get the same above erro

    SQL > DBMS_ROWID. () ROWID_BLOCK_NUMBER

    If I connect with scott so I am able to do it as below:

    SQL > select DBMS_ROWID. ROWID_BLOCK_NUMBER (ROWID)
    2 FROM emp
    3. WHERE ename = 'KING '.

    DBMS_ROWID. ROWID_BLOCK_NUMBER (ROWID)
    ------------------------------------
    30
    Thank you and best regards,
    Kam

    Did you run dbmsrwid.sql in the KAM schema? Because it seems that the DBMS_ROWID package has been created it there.

    I suggest you drop the package in the KAM schema version, unless there is a specific reason that you need (very, very unlikely that you do).

    DROP PACKAGE kam.dbms_rowid
    

    If you do this, the SELECT statement that has worked in the SCOTT schema should also work in the KAM schema.

    SQL > SYS. DBMS_ROWID. () ROWID_BLOCK_NUMBER
    SP2-0734: unknown command starts 'SYS. DBMS_R... "- rest of line is ignored.

    You cannot call a function like this just to the SQL * quicker. You need to put it in a SELECT statement. If you add the SYS prefix to the query that you previously had, it should work as well. But if you do not file the package, you will always have an invalid version of DBMS_ROWID in the KAM schema.

    Justin

  • How to use transfer windows for xp to xp. When I plug usb computers are delivered to the top with the same screen and when I try to use the transfer to the new computer, it just said information gathering and sits for hours

    How to use transfer windows for xp to xp.  When I plug usb computers are delivered to the top with the same screen and when I try to use the transfer to the new computer, it just said information gathering and sits for hours

    Hello, welcome.

    The process is automatic and the maximum transfer rate should be about 20 GB/HR. If the process crashes during that long of a time, it's probably because of something internal rather something you're doing wrong.
    For reference purposes, I included this link. It goes into the details of the migration from XP to Vista (and the basic steps you follow). The instructions are for migrating to Vista via the network, but you can easily follow the steps and choose a different option for your specific installation.
    For both machines, I recommend you to prepare for the transfer using the following procedure:
    1. click on START > run
    2 type "msconfig" (without the quotes) and press enter
    3. go to the "Startup" tab and uncheck all the entries displayed
    4. click on 'Apply' at the bottom right
    DO NOT RESTART YOUR COMPUTER AGAIN
    5. click on START > run
    6. Type "cmd" (without the quotes). Right-click on the result at the top of the menu START and select 'run as administrator '.
    7. type chkdsk /r and press enter
    8 allow the system to attempt disassembly of the volume
    9. allow the system to plan restarting
    10. restart your computer
    11 let checkdisk analyze the file system on your hard drive
    12. Once completed, perform the same steps on the other machine
    13. Once completed, repeat the transfer

    Let us know what happens
    Thank you!

    Ryan Thieman
    Microsoft Answers Support Engineer
    Visit our Microsoft answers feedback Forum and let us know what you think.

  • How to use procedures in a variable of ODI ODI

    Hello
    I have the condition

    Select c1 from the table where c1 > #ODIVAR1 and use of the output of this query in a variable to define the workflow package

    If output = 0 workflow package goes xxx
    on the other
    flow goes like YYY.

    Then please suggest how to use an ODI variable to capture the putput procedures and use it in the package for this stream.

    Thank you
    Naveen.

    Hello

    In the workflow of the package type of the variable as a Variable to be evaluated , if the step is ok go for a flow...
    otherwise, go to another stream in the Advanced tab.

    Thank you
    Ananth

  • Call objects (packages-Pl/SQL procedures) DB of the ADF

    Hello

    1. How can we call DB procedures/Packages using ADF?

    2 are there scenarios describing when to use what Layout? & Also any introduction of layouts in the ADF.

    Thank you.

    Hello

    You can expose your PL/SQL package in the form of web services as well and use it on your layout. Check this blog entry on the call of PL/SQL of the ADF, it may be useful
    http://baigsorcl.blogspot.com/2010/05/calling-PLSQL-procedure-and-function-in.html

    This presentation would help understand layouts http://blogs.oracle.com/shay/2010/05/adf_faces_layouts_demo_-ahid.html
    also, you can refer to the guide of the web user interface.

  • extract the package and the procedure name in the code

    In my treatment of exceptions, I need to register the name of package and procedure I have the exception. How can I get these two names without manually coding the names?

    Thanks to anticipiation

    A better option is to get the package name and the line number

    An even better option is to use the pl/scope (when you are in 11g (not sure about 10g)):

    SQL> alter session set plscope_settings='identifiers:all'
    /
    Session altered.
    
    SQL> set serverout on
    
    SQL> create or replace package pkg
    as
       procedure p1;
    
       procedure p2;
    end pkg;
    /
    Package created.
    
    SQL> create or replace package body pkg
    as
       procedure get_scope (obj varchar2, line int)
       as
       begin
          for c in (select rpad (lpad (' ', 2 * (level - 1)) || name, 20, '.') || ' ' || rpad (type, 20) || rpad (usage, 20) identifier_usage_contexts
                    from user_identifiers t
                    where level != 1
                    start with line = get_scope.line and object_name = obj
                    connect by usage_id = prior usage_context_id)
          loop
             dbms_output.put_line (c.identifier_usage_contexts);
          end loop;
       end get_scope;
    
       procedure p1
       as
       begin
          null;
       end p1;
    
       procedure p2
       as
       begin
          get_scope ($$plsql_unit, $$plsql_line);
       end p2;
    end pkg;
    /
    Package body created.
    
    SQL> exec pkg.p2
    
      P2................ PROCEDURE           DEFINITION
        PKG............. PACKAGE             DEFINITION
        PKG............. PACKAGE             DECLARATION
    PL/SQL procedure successfully completed.
    
  • Tables created in a stored procedure cannot be used with dynamic SQL? The impact?

    There is a thread on the forum which explains how to create tables within a stored procedure (How to create a table in a stored procedure , however, it does create a table as such, but not how to use it (insert, select, update, etc.) the table in the stored procedure.) Looking around and in the light of the tests, it seems that you need to use dynamic SQL statements to execute ddl in a stored procedure in Oracle DB. In addition, it also seems that you cannot use dynamic SQL statements for reuse (insert, select, update, etc.) the table that was created in the stored procedure? Is this really the case?

    If this is the case, I am afraid that if tables cannot be 'created and used"in a stored procedure using the dynamic SQL, as is the case with most of the servers of DB dynamic SQL is not a part of the implementation plan and, therefore, is quite expensive (slow). This is the case with Oracle, and if yes what is the performance impact? (Apparently, with Informix, yield loss is about 3 - 4 times, MS SQL - 4 - 5 times and so on).

    In summary, tables created within a stored procedure cannot be 'used' with dynamic SQL, and if so, what is the impact of performance as such?

    Thank you and best regards,
    Amedeo.

    Published by: AGF on March 17, 2009 10:51

    AGF says:
    Hi, Frank.

    Thank you for your response. I understand that the dynamic SQL is required in this context.

    Unfortunately, I am yet to discover "that seeks to" using temporary tables inside stored procedures. I'm helping a migration from MySQL to Oracle DB, and this was one of the dilemmas encountered. I'll post what is the attempt, when more.

    In Oracle, we use [global temporary Tables | http://www.psoug.org/reference/OLD/gtt.html?PHPSESSID=67b3adaeaf970906c5e037b23ed380c2] aka TWG these tables need only be created once everything like a normal table, but they act differently when they are used. The data inserted in TWG will be visible at the session that inserted data, allowing you to use the table for their own temporary needs while not collide with them of all sessions. The data of the TWG will be automatically deleted (if not deleted programmatically) when a) a commit is issued or b) the session ends according to the parameter that is used during the creation of the TWG. There is no real need in Oracle to create tables dynamically in code.

    I noticed that many people say that the "Creation of the tables within a stored procedure" is not a good idea, but nobody seems necessarily explain why? Think you could elaborate a little bit? Would be appreciated.

    The main reason is that when you come to compile PL/SQL code on the database, all explicit references to tables in the code must correspond to an existing table, otherwise a djab error will occur. This is necessary so that Oracle can validate the columns that are referenced, the data types of those columns etc.. These compilation controls are an important element to ensure that the compiled code is as error free as possible (there is no accounting for the logic of programmers though ;)).

    If you start to create tables dynamically in your PL/SQL code, so any time you want to reference this table you must ensure that you write your SQL queries dynamically too. Once you start doing this, then Oracle will not be able to validate your SQL syntax, check the types of data or SQL logic. This makes your code more difficult to write and harder to debug, because inevitably it contains errors. It also means that for example if you want to write a simple query to get that one out in a variable value (which would take a single line of SQL with static tables), you end up writing a dynamic slider all for her. Very heavy and very messy. You also get the situation in which, if you create tables dynamically in the code, you are also likely to drop tables dynamically in code. If it is a fixed table name, then in an environment multi-user, you get in a mess well when different user sessions are trying to determine if the table exists already or is the last one to use so they can drop etc. What headache! If you create tables with table names, then variable Dynamics not only make you a lot end up creating (and falling) of objects on the database, which can cause an overload on the update of the data dictionary, but how can ensure you that you clean the tables, if your code has an exception any. Indeed, you'll find yourself with redundant tables lying around on your database, may contain sensitive data that should be removed.

    With the TWG, you have none of these issues.

    Also, what is the impact on the performance of the dynamic SQL statements in Oracle? I read some contrasting opinions, some indicating that it is not a lot of difference between static SQL and SQL dynamic in more recent versions of Oracle DB (Re: why dynamic sql is slower than static sql is this true?)

    When the query runs on the database, there will be no difference in performance because it is just a request for enforcement in the SQL engine. Performance problems may occur if your dynamic query is not binding variable in the query correctly (because this would cause difficult analysis of the query rather than sweet), and also the extra time, to dynamically write the query running.

    Another risk of dynamic query is SQL injection which may result in a security risk on the database.

    Good programming will have little need for the tables of dynamically created dynamically or SQL.

  • How to use PowerPhotos to perform a migration of Aperture for photo

    We are running Yosemite and openness. We have about 10 Aperture libraries, some libraries have about 6000 images.

    We have the Photos app on our Mac but don't use it yet.   What workflow we should follow to upgrade to El Capitan and migrate from Aperture for the Photos using PowerPhotos.

    I have been informed that we should first upgrade to El Capitan.   But I don't know how to use PowerPhotos to help us in this migration.

    I read on the PowerPhotos site below.

    "If you have a lot of existing iPhoto or libraries to open that you want to migrate Photos, PowerPhotos will help automate your migration if you do not have to spend time to care for children of this long process."

    It's a good question for FatCat (authors of PowerPhotos) support or study Chapter 7 of their manual - https://www.fatcatsoftware.com/powerphotos/Help/table%20of%20contents.html

    LN

  • How to use the recovery CD?

    Hello

    Ive lost the instructions to tell me how to use the recovery CD. I forgot, I need to press to access the disks when I reboot!

    Can anyone help please?
    St. Clare

    Hi clear, before using the recovery CD make you that all important data has been saved to the floppy or USB key because the procedure will erase the entire hard drive. The method for booting from a cΘdΘrom may vary according to the model number of your laptop, but it's something like hold the 'B' button for the Toshiba Startup logo. If this fails you can try to change the boot sequence or use the Toshiba from Windows or the BIOS configuration tool (ESC then F1 when prompted from a cold start) make CD-ROM the first device startup in the list.

    Richard S.

  • How to use the product with laptop Portege R150 recovery CD?

    How to use the recovery CD product with laptop Portege R150 of Formate and reinstall the operating system?

    Mobile recovery procedure Asian does not for me but may not be very different as on mobile phones produced in Europe or the United States.

    Start your laptop and press F12 to display the boot options
    Place the recovery disc into the optical disc drive
    In the start menu, choose the CD/DVD drive and press ENTER
    The procedure of the facilities is expected to begin
    Follow the menu on the screen

    I do not know what will be shown at this stage, but it is not complicated to install the original recovery image. If you have any other questions please let me know what happens when upgraders begins. What options are displayed?

  • Satellite M100 - how to use the restore CD?

    Hello

    I have a Toshiba satellite m100...
    Due to a virus problem, I had my laptop set in shape by a local technician...
    It has installed a pirated version of windows xp, even if I had given him the recovery dvd. I had the memory upgraded to 1 GB also...

    Now, I would like to know how to use my recovery DVD for the original windows xp? The user manual mentions express media player recovery cd.
    I n t have it... What should I do... plse help... as you can see, I am a complete newbie at this... so would appreciate that you would give me the answer in detail... Thanks in advance...

    Hello

    It's really easy buddy.
    You must boot from the Toshiba recovery disc in order to start the recovery procedure.

    But note; the recovery disc formats the entire HARD drive. So if you have important data on your HARD drive and save it first.

    Greetigns

Maybe you are looking for