3

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
4
  • I have added info on the errors to my initial post Commented Nov 29, 2012 at 12:17
  • 1
    Does it have to be PL/SQL-Developer? Could you use SQL*PLUS instead? Commented Nov 29, 2012 at 12:21
  • 1
    DEFINE is really the sort of thing that is used as part of a code deployment or installation, and those should always be executed through SQL*Plus. Commented Nov 29, 2012 at 12:30
  • No there aren`t any constraints on development environment. I asked about PL/SQL-Devaloper because I work with it at home and on our practice at the university we use SQLplus Commented Nov 29, 2012 at 12:32

3 Answers 3

9

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).

Sign up to request clarification or add additional context in comments.

Comments

0

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;

Comments

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.