Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7714655
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T02:11:09+00:00 2026-06-01T02:11:09+00:00

I want to grab a particular column value a.id and store it into a

  • 0

I want to grab a particular column value a.id and store it into a variable v_id. Then use this value to pass into a stored procedure.

DECLARE v_id a.id%TYPE;
BEGIN
SELECT id  into v_id from a where a.name='test' and rownum <2 order by id desc;
Print v_id;
doSomething(v_id);
END;
/

I’m getting this error in Oracle SQL Developer:

Error report: ORA-06550: line 3, column 7: PLS-00103: Encountered the
symbol “V_ID” when expecting one of the following:

:= . ( @ % ; The symbol “:=” was substituted for “V_ID” to
continue.
06550. 00000 – “line %s, column %s:\n%s”
*Cause: Usually a PL/SQL compilation error.
*Action:

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T02:11:10+00:00Added an answer on June 1, 2026 at 2:11 am

    If you want to use rownum and order by you have to put the order by in a sub-query. There is no other way to guarantee that you get the correct value.

    It’s also good practice to deal with the possibility that there may not be an id that matches your query. I’ve added an additional begin... end; block to deal with this.

    declare
       v_id a.id%type;
    begin
    
       begin
          select id into v_id 
            from ( select id
                     from a 
                     where name = 'test' 
                     order by id desc )
           where rownum < 2 
                 ;
        exception when no_data_found then
          v_id := null;
        end;
    
       dbms_output.put_line(v_id);
       doSomething(v_id);
    
    end;
    /
    

    As @raukh noted (whilst I was writing this!) the problem is print, which should be dbms_output.put_line()

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Not sure if this is possible. I want to grab the latest X stories
I want to grab a list of all the files under a particular directory.
I have this URL: http://itutormaths.hub/home/hub/6/hello/world and I want grab only hello and world. How
I want to grab the most recent entry from a table. If I was
I want to grab from a db a record with name='John Doe'. I'd like
I want to grab records from a table based on the day of the
I have a flash applet that I want to grab a remote XML file
I have an id: div id =untitled-region-5 I want to grab that id and
I'm working with various XML inputs and outputs and simply want to grab the
using simplexml to parse a feed, but I want to grab the date of

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.