Database Reference
In-Depth Information
of specifying the number 1, you replace it with a variable called CDNUM.
Variables are identified by a preceding ampersand, & or && symbol, so
you must add that as well. The final query should look as follows:
SELECT M.TITLE, A.NAME, S.TITLE
FROM MUSICCD M JOIN CDTRACK T ON (M.MUSICCD_ID=T.MUSICCD_ID)
JOIN SONG S ON (T.SONG_ID=S.SONG_ID)
JOIN ARTIST A ON (S.ARTIST_ID=A.ARTIST_ID)
WHERE M.MUSICCD_ID = &CDNUM
ORDER BY 1,2,3
/
Once again, exiting the editor returns the query to SQL*Plus. A forward
slash will execute the query. SQL*Plus prompts you to enter a value for the
variable. Figure 8.11 shows how this looks.
Figure 8.11
SQL*Plus Can
Prompt for
Variable Values.
Typing the number 1 and pressing Enter forces SQL*Plus to replace the
variable with a number 1 and execute the query. Figure 8.12 shows the
result.
Figure 8.12
SQL*Plus Variable
Substitution.
Search WWH ::




Custom Search