Skip to Main Content
Oracle PL/SQL Programming: A Developer's Workbook
book

Oracle PL/SQL Programming: A Developer's Workbook

by Steven Feuerstein, Andrew Odewahn
May 2000
Intermediate to advanced content levelIntermediate to advanced
594 pages
11h 32m
English
O'Reilly Media, Inc.
Content preview from Oracle PL/SQL Programming: A Developer's Workbook

Chapter 1. Declaring Variables and Naming Elements

Beginner

Q:

1-1.

The following variables are valid or invalid for these reasons:

  1. Valid. my_variable2 starts with a letter, is less than 31 characters in length, and contains only letters, digits, and $, #, or _.

  2. Invalid. my-variable2 may not contain a dash.

  3. Invalid. my^variable contains an illegal character, ^.

  4. Valid. MyVariable starts with a letter, is less than 31 characters in length, and contains only letters, digits, and $, #, or _.

  5. Invalid. my_variable_for_many_many_of_usages contains more than 30 characters.

  6. Invalid. 123myvariable cannot start with a number.

  7. Valid. “123myvariable” is surrounded by double quotes. If you surround an identifier with double quotes (very different from two consecutive single quotes), then all rules about identifiers are suspended except for the maximum length of 30 characters.

Q:

1-2.

Oddly enough, (a) compiles, while (b) fails with the following error message:

PLS-00371: at most one declaration for 'LASTDATE' is permitted

PL/SQL is a case-insensitive language (except for the contents of literal strings). Therefore, in both cases you are trying to declare two variables with the same name, which is not allowed. It turns out, however, that the compiler will not reject the duplicate declarations unless you actually try to use one of the variables!

Q:

1-3.

Here is an example that demonstrates these two formats and shows that the same value is assigned:

DECLARE myDate DATE := SYSDATE; yourDate DATE DEFAULT SYSDATE; BEGIN ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Oracle Database 12c PL/SQL Programming

Oracle Database 12c PL/SQL Programming

Michael McLaughlin
Oracle PL/SQL for DBAs

Oracle PL/SQL for DBAs

Arup Nanda, Steven Feuerstein
Oracle PL/SQL For Dummies

Oracle PL/SQL For Dummies

Michael Rosenblum, Paul Dorsey

Publisher Resources

ISBN: 9781449324070Supplemental ContentErrata Page