How to declare a cursor with stored proc?

Hi All,
Can we declare a cursor with stored proc?
For Example -
CREATE PROCEDURE DDL_proc() LANGUAGE SQLSCRIPT AS
    CURSOR c_cursor1 (v_isbn VARCHAR(20)) FOR CALL SYS.GET_OBJECT_DEFINITION(<SCHEMA_NAME>, <TABLE_NAME>).;
     BEGIN
          FOR cur_row as c_cursor1 DO
          END FOR;
     END;
Could you please have a look on the same?
Thank you,
Vijeesh

Oracle PL/SQL also has a select into statement which is described in the same manual the link takes you to part of.
select column_list
into variable_list
from table(s)
where conditions
The PL/SQL Users Guide is something you are going to want to have gone over cover to cover before you start converting because so that you make the best choices for how to rewrite the code: select into, explicit cursor, implicit cursor, for loop, simple loop, while loop, collections,bulk load, etc ....
HTH -- Mark D Powell --

Similar Messages

  • How to use REF cursor with toplink

    Hi,
    I have a stored proc has a out variable which is a REF CURSOR.
    How to read my cursor with toplink?

    I have got it. Here is the solution.
              UnitOfWork uow= dbSession.acquireUnitOfWork();
              StoredProcedureCall call = new StoredProcedureCall();
              call.setProcedureName("smart.getCompanyStruct");
              call.addNamedArgument("xnrid");
              call.useNamedCursorOutputAsResultSet("cpy");
              DataReadQuery query = new DataReadQuery();
              query.setCall(call);
              Vector parameters = new Vector();
              query.addArgument("xnrid");
              parameters.add(new Long(5009L));
              Vector obj = (Vector) uow.executeQuery(query, parameters);     
    Vector contains result ser of the cursor
    Gurcan

  • How to declare and work with select-option in screen painter?

    hello there,
    can anybody plz suggest me ,how to declare and work with select-option in screen painter?
    neon

    Hi Blue,
    Please check these threads which will help you a lot..
    module pool programming " to add selection-option on screen"
    Re: Select option in Dialog program screen
    Re: SELECT-OPTIONS in Screen
    Good luck
    Narin

  • How to display a cursor with sand glass ?

    I would like to know how to display a cursor with sand glass I am performing a long operation ?
    Thanks in advance.

    As long as you are using anything that extends Component...
    this.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
    doLongOperation();
    this.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));Hope this helps,
    Radish21
    PS the API is ALWAYS your friend
    http://java.sun.com/j2se/1.4.1/docs/api/
    http://java.sun.com/j2se/1.4.1/docs/api/java/awt/Cursor.html

  • How to use NTILE in a stored proc.?

    My module works in SQL*Plus but not in a stored proc. Have tried dynamic SQL to no avail.
    Has anyone been successful (in 8.1.7)? If so, how did you overcome the problem?

    Thanks, Rich.
    Here is my similar effort:
    create or replace procedure New_CSD_Hist(p_yr IN number,
                                            p_qtr IN number,
                                            p_market IN varchar2)
    is
         TYPE CSD_cur_type is REF CURSOR;
         CSD_cur           CSD_cur_type;
         more_data           BOOLEAN:=TRUE;
    begin
    OPEN CDS_cur FOR
    SELECT client,
              (ntile(3) over(order by sum(csd_spend) DESC)) as csd
    from      csd_hist
    where      csd = '0' and
              csd_spend > 0 and
              market = p_market and
              yr = p_yr and
              qtr = p_qtr
    group by client;
    HERE is another effort, trying to follow an example from Pipelines:
    lv_stmnt :=
    'declare '||
    'lv_yr varchar2(4) := :1; '||
    'lv_qtr varchar2(1) := :2; '||
    'lv_market varchar2(16) := :3; '||
    'begin '||
    'insert into clientspend select client,'||
    'ntile(3) over (order by sum(csd_spend) DESC) as csd '||
    'from csd_hist where csd = ''0'' and csd_spend > 0 and '||
    'market = :3 and yr = :1 and qtr = :2 '||
    'group by client; end;';
    execute immediate lv_stmnt using p_yr,p_qtr,p_market;
    commit;
    Again,
    Thanks for your comments and suggestions.,
    Dick Berry

  • ** How to use TO_DATE function in Stored Proc. for JDBC in ABAP-XSL mapping

    Hi friends,
    I use ABAP-XSL mapping to insert records in Oracle table. My Sender is File and receiver is JDBC. We use Oracle 10g database. All fields in table are VARCHAR2 except one field; this is having type 'DATE'.
    I use Stored procedure to update the records in table. I have converted my string into date using the Oracle TO_DATE function. But, when I use this format, it throws an error in the Receiver CC. (But, the message is processed successfully in SXMB_MONI).
    The input format I formed like below:
    <X_EMP_START_DT hasQuot="No" isInput="1" type="DATE">
    Value in Payload is like below.
    <X_EMP_START_DT hasQuot="No" isInput="1" type="DATE">TO_DATE('18-11-1991','DD-MM-YYYY')</X_EMP_START_DT>
    Error in CC comes as below:
    Error processing request in sax parser: Error when executing statement for table/stored proc. 'SP_EMP_DETAILS' (structure 'STATEMENT'): java.lang.NumberFormatException: For input string: "TO_DATE('18"
    Friends, I have tried, but unable to find the correct solution to insert.
    Kindly help me to solve this issue.
    Kind Regards,
    Jegathees P.
    (But, the same is working fine if we use direct method in ABAP-XSL ie. not thru Stored Procedure)

    Hi Sinha,
    Thanks for your reply.
    I used the syntax
    <xsl:call-template name="date:format-date">
       <xsl:with-param name="date-time" select="string" />
       <xsl:with-param name="pattern" select="string" />
    </xsl:call-template>
    in my Abap XSL.  But, its not working correctly. The problem is 'href' function to import "date.xsl" in my XSLT is not able to do that. The system throws an error. Moreover, it is not able to write the command 'extension-element-prefixes' in my <xsl:stylesheet namespace>
    May be I am not able to understand how to use this.
    Anyway, I solved this problem by handling date conversion inside Oracle Stored Procedure. Now, its working fine.
    Thank you.

  • How to set variable values in Stored Procs

    Hi all,
    please excuse my newbie questions - I've spent too long using SQL Server......
    Anyway,
    I'm playing with SP basics and was wondering how I can set a variable value in a stored proc, ideally getting a value from a table or some select .
    for instance...........
    CREATE OR REPLACE PROCEDURE RPT_SP_ANT_TESTING
    P1 IN NUMBER,
    P2 IN VARCHAR2
    IS
    TmpNum NUMBER;
    TmpStr VARCHAR2(255);
    BEGIN
    --How do set these?
    SET TMPNUM := SELECT Count( * ) FROM ALL_TABLES;
    SET TMPSTR := P2 + '_APPENDED';
    INSERT INTO TEST_TABLE
    ( STRINGFIELD, NUMBERFIELD )
    VALUES
    ( TmpStr, TMPNUM )
    END;
    Regards
    DC

    Some ways are...
    setting directly
    x := 1;
    setting from a select use INTO clause
    select 1 into x from dual
    setting from a select into a collection type use BULK COLLECT INTO
    select name bulk collect into lName from your_table.
    It would be better if you read the document.
    Thanks,
    Karthick.

  • How to declare class variable with generic parameters?

    I've got a class that declares a type parameter T. I know how to declare a static method, but this doesn't work for a static variable:
    public class Test< T >
        * Map of String to instances of T.
        * error: '(' expected (pointing to =)
        * <identifier> expected (pointing to () )
       private final static < T > Map< String, T > MAP = new HashMap< String, T >();
        * Get instance of type T associated with the given key.
       public final static < T > T getType( String key )
          return MAP.get( key );
    }Edited by: 845859 on Mar 20, 2011 11:46 AM

    jveritas wrote:
    I'm trying to create a generic polymorphic Factory class that contains boilerplate code.
    I don't want to have to rewrite the registration code every time I have a different return type and parameter.I haven't seen a case yet where that is reasonable.
    If you have hundreds of factories then something is wrong with your code, design and architecture.
    If you have a factory which requires large number of a varying input types (producing different types) then something is probably wrong with your code and design.
    A reasonable factory usage is one where you have say 20 classes to be created and you need to add a new class every 3 months. Along with additional functionality represented by the class itself and perhaps variances in usage. Thus adding about 3 lines of code to one class is trivial. Conversely if you have hundreds of classes to be created by the factory and you are adding them daily then it is likely that
    1. Something is wrong with the architecture which requires a new class every day.
    2. You should be using a dynamic mechanism for creation rather than static because you can't roll out a static update that often.
    More than that the idiom that leads to factory creation is different for each factory. A factory that creates a database connection is substantially different than the one used in dynamic rules logic processing. A generic version will not be suitable for both.
    Actualy the only case I know of where such a factory might be seem to be a 'good' idea is where someone has gotten it into their head that every class should be represented by an interface and every class created by a factory (its own factory.) And of course that is flawed.

  • How to compare the table, constraint, stored proc, view between 2 schema ?

    Hi All,
    We have two schema : app_test & app_prod :
    app_test is where user run acceptance test, and where we make correction etc
    app_prod is where user prepare data for going live/production.
    Now we need to make sure that :
    table structure
    stored proc
    view
    function
    sequence
    constraint ...
    Is the SAME between the two schema : Is there any script that can automate the process ?
    Thank you very much,
    xtanto

    You may use TOAD, OEM, and use "ALL_" views to compare.
    And also, take a look into the duplicate thread on this forums.
    How to compare two oracle database schemas
    You can also check in the google for any free tools for this !!
    Regards,
    Sabdar Syed.

  • How to move the cursor with keyboard

    Is there a way to move the cursor with the keyboard? My right forearm is hurting prob because of extended use of the mouse.

    While in the 'Finder' click on 'Help' in the upper menu bar....enter 'Mouse Keys' and then select 'Controlling the pointer with the numeric keypad'....only problem I can see is the MacBook doesn't have a numeric keypad...so you would need an full size external keyboard....tried it on my iMac and it works OK...

  • How to SEND PAGE from Oracle stored proc

    I've searched all Oracle docs and internet. Need to be able to
    send a msg to a pager via SMS (or some other method) from a
    stored proc. Saw some mention of Oracle Paging Server but not
    much doc on implementing. Please feel free to post here or
    mailto:[email protected]

    if you need to send sms message you need to have wapgateway and
    wml background

  • How pass ext characters to a stored proc by odbc when enable sqlserver syntax is on??

    how pass french characters or extended characters to a stored procedure by odbc
    error: ORA-01756: quoted string not properly terminated
    une chaine entre apostrophhes ne se termine pas correctement
    oracle Retrieving extended characters thru ODBC
    PL/SQL procedure parameters
    hi, i hope you can help to me.
    I have a problem with french and german characters.
    i have a little stored procedure than return what i'm passing to him.
    see these example: (the second one work fine on plsql)
    first exemple:
    1) i created a new odbc dsn
    2) i'm going into sqlserver migration tab to choose
    Enable Exac Syntax.
    3) i'm open Winsql (this is a odbc tools)
    http://www.indus-soft.com/winsql/
    4) i'm write
    exec ksp_test 0,'HiLLO ORACLE'
    i receive this error:
    Error: ORA-01756: quoted string not properly terminated
    (State:S1000, Native Code: 6DC)
    I trying to changed too the NLS_LANG in the registry
    like FRENCH_CANADA.WE8ISO8859P1
    French_France.WE8ISO8859P1
    but without any success..
    i got the same problem with
    oracle 9 database with utf8 characters set.
    oracle 8.1.7 with iso8859p1 characters set.
    i trying all latest odbc driver from oracle website.
    second exemple:
    SQL> variable mytest refcursor;
    SQL> exec ksp_test (0,'HiLLO ORACLE',:MYTEST);
    PL/SQL procedure successfully completed.
    SQL> PRINT MYTEST;
    Your Database Value
    HiLLO ORACLE
    CREATE OR REPLACE PACKAGE KSP_PLSQLRSETPKG
    AS
    TYPE RCT1 IS REF CURSOR;
    END;
    CREATE OR REPLACE PROCEDURE KSP_TEST (
    PATCH INT DEFAULT 0,
    PONC VARCHAR2,
    RC1 IN OUT KSP_PLSQLRSETPkg.RCT1
    AS
    BEGIN
    OPEN RC1 FOR
    SELECT PONC "Your Database Value" FROM DUAL;
    FROM DUAL;
    RETURN ;
    END;
    i'm trying also different nls setting but no good result.
    AMERICAN_AMERICA.US7ASCII
    AMERICAN_AMERICA.WE8MSWIN1252
    FRENCH_CANADA.WE8DEC
    FRENCH_CANADA.UTF8
    FRENCH_CANADA.WE8MSWIN1252
    FRENCH_FRANCE.WE8DEC
    FRENCH_FRANCE.UTF8
    FRENCH_FRANCE.WE8MSWIN1252
    is working well on sqlplus but not by odbc..
    also..
    i'm declare a variable and
    i set
    v_variable := 'id'
    and the procedure return the good syntax...
    i think is a odbc driver problem....
    the driver don't want to accept a extended characters set by a parameters coming from the procedure.
    can you confirm to me ..this is a major bug for the driver..
    my procedure is very basic to make a little test.
    did you try my procedure to be sure you have the same problem?
    i try with a oracle instance utf8,WE8MSWIN1252 and
    i got always the same problem.
    if i write insert into test values ('di');
    everything is fine...but when i call the procedure...
    the procedure don't want to accept any german..french or any extended characters...
    our application is working by odbc driver.
    i'm pretty sure is a bug in the driver ...the bug is coming only when i select "ENABLE EXEC SYNTAX" IN THE DSN (SQLSERVER MIGRATION SECTION) ... i try with Shema Database and Owner and Empty and i got
    always the same problem
    exec KSP_TEST 0,'TiEST'
    ------------------------>>>>>>>NOT WORKING.
    BUT IF I WRITE
    CALL KSP_TEST (0,'TiEST')
    ------------------------->>>>IS WORKING
    if i select enable exec or i unselect enable exec...
    the CALL KSP_TEST...... is always working properly.
    BETWEEN THESE SYNTAX THE NLS_LANG IS NEVER CHANGED....
    IS WORKING.....THE NLS_LANG IS GOOD.......because i make a little modification in procedure to be sure the INSERT IS inside the database CORRECTLY.
    CREATE OR REPLACE PROCEDURE KSP_TEST
    PATCH INT,
    PONC VARCHAR2
    AS
    v_test varchar2(100);
    BEGIN
    v_test := 'test';
    INSERT INTO YYY VALUES (PONC);
    END;

    If  "just using Crystal Reports XI R2" means using Crystal Report Viewer and do not want to see the prompt, please follow the below steps.
    1. Select the report you want to see
    2. Select "Process" tab
    3. Select Parameters menu under the process tab.
    4. You would see two date parameters there.
    Select the [Empty] value for each parameter and fill out the value you want.
    Hope this would help.

  • Help with Stored Procs.

    Hello All,
    Orcl Version:
    Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - 64bit Production
    PL/SQL Release 11.2.0.2.0 - Production
    "CORE     11.2.0.2.0     Production"
    TNS for Linux: Version 11.2.0.2.0 - Production
    NLSRTL Version 11.2.0.2.0 - Production
    I have a scenario, where I've to run the procedures from a package multiple times with different input parameter(key) primary key of one of the tables used inside the proc.
    For ex,
    pkg1
    proc1(Key);
    proc2(Key);
    proc3(Key);
    proc30(Key);
    Engine(Main code) runs these procs multiple times with different params. Sometimes a proc runs more than 4000 times with different param value(key). I have 2 questions.
    1. A proc when run for the first time, it is compiled and for the next time it will be in compiled form. I'm not sure how it works for the second run. Is the query in the proc cached and helps improve the performance?
    2. Are there any ways to improve the performance?
    Like, I'm hitting the base tables everytime a proc is run. Is there any advantage of creating MV's or something like that?
    Thanks
    Shank.

    Hi, Shank,
    SamFisher wrote:
    Orcl Version:
    Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - 64bit Production ...
    Thanks for including that!
    I have a scenario, where I've to run the procedures from a package multiple times with different input parameter(key) primary key of one of the tables used inside the proc.
    For ex,
    pkg1
    proc1(Key);
    proc2(Key);
    proc3(Key);
    proc30(Key);
    Engine(Main code) runs these procs multiple times with different params. Sometimes a proc runs more than 4000 times with different param value(key). I have 2 questions.
    1. A proc when run for the first time, it is compiled and for the next time it will be in compiled form. Not usually. A stored procedure is compiled when it is created, that is, when you run the CREATE OR REPLACE PROCEDURE (or CREATE OR REPLACE PACKAGE) command.
    It may be automatically re-compiled when you call it the first time. For example, if procedure A calls some other procedure B, and B has been re-compiled since A was created, then A will be re-compiled when you run it the first time.
    I'm not sure how it works for the second run. Is the query in the proc cached and helps improve the performance? Performance may be a little faster after the first call, because the procedure, and the objects it references (such as table blocks) may already be cached in memory.
    2. Are there any ways to improve the performance?
    Like, I'm hitting the base tables everytime a proc is run. Is there any advantage of creating MV's or something like that? If the package body contains a BEGIN section, then that section is run the first time the package is used , but not again in the same session. You can use that section to initialize package variables (or SYS_CONTEXT variables, or global temporary tables) so you don't have to re-compute them every time you call the package.
    For example, I have a package called pk_mail. The package body looks like this:
    CREATE OR REPLACE PACKAGE BODY     pk_mail
    AS
    mail_host_name     VARCHAR2 (30);
    PROCEDURE   add_recipient    -- First procedure
    END  send_to_all;            -- Last procedure
    -- The following is run the first time the package is used in a given session:
    BEGIN
         SELECT     txt
         INTO     mail_host_name
         FROM     constant_tbl
         WHERE     ent_name     = 'MAIL_HOST_NAME'
         AND     status_txt     = 'ACTIVE'
         AND     ROWNUM     = 1;
    EXCEPTION
         WHEN     NO_DATA_FOUND
         THEN
              mail_host_name := 'itd-smtp-out.foo.bar.com;             -- Default value
    END     pk_mail;
    /The package variable mail_host_name, which is used in various procedures in the package, is set the first time the package is used. After the first call, the code that gives it a value is not run again.
    Edited by: Frank Kulash on Jul 6, 2012 1:21 PM
    Added pk_mail example.

  • How to wake-up a Java Stored Proc at Oracle Server Startup

    Hi,
    I am writing a Java Stored Procedure responsible to
    execute periodically (daily for example) a command (the
    command and its arguments are prepared by the Java stored
    procedure and they are date and time sensitive).
    My questions are:
    1. Is there any way that my Java stored procedure is
    initially NOTIFIED (woke-up) when the Oracle server is
    started ? I noticed that there is a built-in Java stored procedure in Oracle DB declared as:
    "PROCEDURE notify_at_startup( user_schema VARCHAR2, classname VARCHAR2) ;"
    Can this be used in any way for my purpose ? If yes, how ?
    2. I can do the PERIODIC scheduling of execution of the
    command using standard (SUN) java timer/Thread
    primitives. Are there any Oracle Java classes/methods
    which can be used instead for this scheduling ?
    Thanks for any help/suggestions.
    Arminius

    I would look at two things.
    1) Create a database level trigger that fires at server start up.
    2) Define an Oracle Job that runs every xx minutes and restarts itself.
    Chet West

  • How to zoom my cursor with document zoom:

    when I click the stamp tool and select a stamp,the cursor change into a stamp, and the stamp cursor could zoom in with the pdf
    document zoom in. I have achieved the stamp cursor using windows API :
    AVCursor cursor =(AVCursor)LoadImage(gHINSTANCE,"c:\\stamp.cur",IMAGE_CURSOR,170,170,LR_LOADFROMFILE);
    but my stamp cursor can not zoom with the pdf document zoom. How to achieve this?
    Thanks in advance for any help!

    lrosenth, Thanks for your reply!
    when I received the notification of AVPageViewDidChange
    How can I get the Scaling rate?

Maybe you are looking for

  • No Applicable data in the report

    HI - I got no applicable data in the result area,.. So i searched for the previous posts... In that speacified ,.. if we remove the previous  Erroneous requests made in the infopack / DTP  ,..the problem solved.... No i would like to know where can i

  • Grainy Output When Outputting h.264 into QuickTime File in Premiere Elements 12

    I have a video project that I need to output into a QuickTime file. I would like to use the h.254 codec in the file, because that would make it the most versatile for all of the places I will be using the video. However, when I use Share > Computer >

  • 'Plugin Check' wrong?

    Firefox 4 on Windows XP I've used the Firefox 'Plugin Check' page and it tells me that my Adobe Acrobat plugin is outdated, even though I've updated twice via the 'update' button on that page. I've also been reminded about it twice direct from Adobe

  • Attn - The correct way to connect to the repository

    From iFS Product Management. Many people appear to be having trouble connecting to the repository and are using the wrong API calls to do. The recommended API calls changed between beta and production. For the production release here is the correct w

  • Email links not recognized

    My iPad no longer recognizes links in email.  This is true for both Hotmail and Gmail.  Is this a settings problem?