spin_eight
spin_eight

Reputation: 4025

using define statement in PL/SQL developer

This is one of the tasks from my homework assignement:

DEFINE countryid = CA
DECLARE 
country_record countries%ROWTYPE;
BEGIN
  SELECT *
  INTO country_record
  FROM countries
  WHERE country_id = '&countryid';
END;

According to the task requirements countryid should be declared using define statement and should be given default value CA, then select should be performed based on value entered by the user.
When I run script i get 4 errors, when I comment out DEFINE countryid = CA scripts executes successfuly.
My question: is define statement availiable in PL/SQL Developer?
If it is, what I am doing wrong and could you suggest a proper usage?

edit: I get the following errors:

ORA-06550 row 3 column 8
PLS-00201 identificator 'COUNTRY_RECORD' have to be declared
ORA-06550 row 4 column 3
PL/SQL ORA-00904: invalid identificator
ORA-06550 row 2 column 3
PL/SQL SQL statement ignored

Upvotes: 3

Views: 24561

Answers (3)

mlulis
mlulis

Reputation: 1

DEFINE countryid = CA
DECLARE 
country_record countries%ROWTYPE;
BEGIN
  SELECT *
  INTO country_record
  FROM countries
  WHERE country_id = :countryid;
END;

Upvotes: 0

Isha
Isha

Reputation: 31

in PLSQL Developer, you can use this code, But use the Command Window.

DEFINE countryid = 'CA' DECLARE country_record countries%ROWTYPE; BEGIN SELECT * INTO country_record FROM countries WHERE country_id = '&countryid'; END;

Upvotes: 0

DazzaL
DazzaL

Reputation: 21973

DEFINE is a SQLPLUS thing, and as such isn't supported in PLSQL Developer apart from in the COMMAND window. for the sql / test window, just remove it (it will see the & and give you a popup for you to define it that way).

Upvotes: 9

Related Questions