SQL (Structured Query Language) Question:
Download Questions PDF

How can variables be passed to a SQL routine?

Answer:

Level: Low
Expected answer: By use of the & symbol. For passing in variables the numbers 1-8 can be used (&1, &2,...,&8) to pass the values after the command into the SQLPLUS session. To be prompted for a specific variable, place the ampersanded variable in the code itself:
"select * from dba_tables where owner=&owner_name;" . Use of double ampersands tells SQLPLUS to resubstitute the value for each subsequent use of the variable, a single ampersand will cause a reprompt for the value unless an ACCEPT statement is used to get the value from the user.

Download SQL Interview Questions And Answers PDF

Previous QuestionNext Question
What description of a data source is required for ODBC?You want to include a carriage return/linefeed in your output from a SQL script, how can you do this?