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 7694133
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T21:14:58+00:00 2026-05-31T21:14:58+00:00

This is the program I wrote: set serveroutput on; declare b empl.name1%type; r varchar;

  • 0

This is the program I wrote:

set serveroutput on;
declare
  b empl.name1%type;
  r varchar;   --can i change this to r empl.designation%type; ?
begin
  r:=&designation;                      --getting input for the designation
  dbms_output.put_line('hello');            --random output to check for errors
  select name1 into b from empl where designation=r;   --i want all the names from the table
  dbms_output.put_line('name'||b);                   --employee where designation is as entered
  dbms_output.put_line(' closed');                 --by user,should i loop this statement?
end;

When I enter designation as ‘a’ (which is entered in the table already) I get an error
identifier 'a' is not declared. What does that mean?
Does the select statement take one row at a time? So if I loop it will I get all the rows? Or should i use a cursor?
Why does SQL Developer not accept %rowtype?

I changed my program to this:

set serveroutput on;
declare
  cursor cempl is select name1,designation from empl;
  b empl.name1%type;
  des empl.designation%type;
  r empl.designation%type;
begin
  r:='meow';
  dbms_output.put_line('hello');
  open cempl;
  if cempl%ISOPEN then
    loop
      fetch cempl into b,des;
      if des=r then
        dbms_output.put_line('name'||b);
      end if;
      exit when cempl%notfound;
    end loop;
    close cempl;
    dbms_output.put_line(' closed');
  end if;
end;

Whenever I get an input like r:=&r and imagine I enter ‘a’ it says
identifier ‘a’ must be declared, but its a value in the table! Why should it be declared, but if its given in the program like above it doesn’t give an error. Instead it repeats the last row twice!

  • 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-05-31T21:14:59+00:00Added an answer on May 31, 2026 at 9:14 pm

    There are a few questions to answer here:

    • ‘Identifier not found’ errors: &designation is a SQL*Plus substitution variable. When you enter a value for &designation, SQL*Plus replaces &designation with the text of what you entered. So, if you enter the vaue a, the line

      r:=&designation;
      

      becomes

      r:=a;
      

      The error arises because Oracle doesn’t know of anything called a. You haven’t declared a variable called a, and there isn’t a procedure or function or anything else it could find with the name a. If you want the end result to be r:='a';, you would need to write r:='&designation';

    • SELECT ... INTO ... only works if the query returns exactly one row. If no rows are returned, you will get a no data found error, and if more than one row is returned, you will get a too many rows error. You should only use SELECT ... INTO ... if you know there will only be one result. If there may be more than one result, you should use a cursor.

    • ‘Why does SQL Developer not accept %rowtype‘? It should do – could you come up with an example that causes a problem for you?

    • In your second example, you’re getting the last row repeated because you’re not exiting the loop immediately after the cursor fails to find any more rows. You should move the exit when line to immediately below the fetch line.

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

Sidebar

Related Questions

I wrote a program to solve a complicated problem. This program is just a
Below is the program that I wrote. /******************************************************************************* * This program reads EOF from
I wrote this small C++ program and built it(Release) #include<iostream> int main(){ std::cout<<Hello World;
I'm trying to understand concurrency in Go. In particular, I wrote this thread-unsafe program:
I wrote this function to communicate with an external program. Such program takes input
I wrote a basic Hippity Hop program in C, Python, and OCaml. Granted, this
How does this program access other processes memory? How can it write into the
I have this simple little batch file program that I wrote but it fails
I wrote this code app = Tk() app.title('Myapp') app.geometry('260x100+50+50') labelText =StringVar() labelText.set('Insert the version
I am having a little problem. I wrote a program that extracts a set

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.