1. Get rid of all advertisements and get unlimited access to documents by upgrading to Premium Membership. Upgrade to Premium Now and also get a Premium Badge!

Need help in plsql query

Discussion in 'SQL PL/SQL' started by khan444, Nov 4, 2017.

  1. khan444

    khan444 Starter

    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    10
    Location:
    Hyderabad
    Write Plsql Anonymous Block with Exception Handling to print your Name ten times???
     
  2. zargon

    zargon Community Moderator Forum Guru

    Messages:
    2,531
    Likes Received:
    360
    Trophy Points:
    1,430
    Location:
    Aurora, CO
    Ask your instructor for assistance.
     
  3. krasnoslobodtsev_si

    krasnoslobodtsev_si Forum Genius

    Messages:
    733
    Likes Received:
    143
    Trophy Points:
    830
    Location:
    Russian Federation
    In the documentation on the Oracle everything is well described.

    Write your example. If there are errors, then we can help.
    if we write a script for you, you will not benefit from it.
     
    Last edited: Nov 4, 2017
  4. khan444

    khan444 Starter

    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    10
    Location:
    Hyderabad
    DECLARE
    VNAME VARCHAR2(20);
    CURSOR C1 is
    Select 'Abcd' into VNAME from dual;
    Begin
    For I in 1..20
    Loop
    Dbms_output.put_line('Name is '||VNAME);
    End loop;
    Exception When others then
    Dbms_output.put_line(Sqlerrm)End;



    Will this works????
     
  5. zargon

    zargon Community Moderator Forum Guru

    Messages:
    2,531
    Likes Received:
    360
    Trophy Points:
    1,430
    Location:
    Aurora, CO
    No, it won't since you haven't opened the cursor you declared. I think you are making this harder than it needs to be. You do not need a cursor or a variable. Try again with the loop and a simple string. From Begin to End should work with a text string and no declare section:

    Begin
    For I in 1..20
    Loop
    Dbms_output.put_line('Name is Bubba');
    End loop;
    Exception
    When others then
    Dbms_output.put_line(Sqlerrm)
    End;
    /