QuestionQ166

VerifiedRetrieving data using the SQL SELECT statement

You want to create a query that prompts for two column names and the WHERE condition every time it runs in a session, but prompts for the table name only the first time it runs.

The variables used by the query are never undefined during the session.

Which query can be used?

Explanation

In SQL*Plus, a value supplied for a single-ampersand substitution variable is not stored, so it is prompted for again on each execution. A double-ampersand reference stores the supplied value for the session, so the table name is requested only the first time. The column names and condition must be unquoted so their substituted values are interpreted as SQL identifiers and syntax rather than string literals.

Learn more

Community Discussion

No comments yet. Be the first to start the discussion!