[Lab Session 5]   [Exercise 5]   [Course Information]   [COMP2400/6240 Home]
Coloured Line

Exercise 5

Solution Notes

Coloured Line

qparm.sql

-- cae Sept 2006
-- COMP2400

-- (using one parameter)

-- Given a year, list all the albums released that year

ttitle "All the albums released in &1"

select Album_Id, Title, Label
from album
where Year = &1
order by Title;

Running  qparm.sql

SQL> @ qparm
Enter value for 1: 1972
Enter value for 1: 1972
old   3: where Year = &1
new   3: where Year = 1972

Wed Sep 20                                                             page    1
                        All the albums released in 1972

  ALBUM_ID TITLE                                    LABEL
---------- ---------------------------------------- ---------------
         3 Exile on Main Street                     Rolling Stone

SQL> @ qparm 1974
old   3: where Year = &1
new   3: where Year = 1974

Wed Sep 20                                                             page    1
                        All the albums released in 1974

  ALBUM_ID TITLE                                    LABEL
---------- ---------------------------------------- ---------------
        27 Band on the Run                          Apple
         1 Its Only Rock'n'Roll                     Rolling Stone
        22 Planet Waves                             Asylum

SQL> @ qparm
old   3: where Year = &1
new   3: where Year = 1974

Wed Sep 20                                                             page    1
                        All the albums released in 1974

  ALBUM_ID TITLE                                    LABEL
---------- ---------------------------------------- ---------------
        27 Band on the Run                          Apple
         1 Its Only Rock'n'Roll                     Rolling Stone
        22 Planet Waves                             Asylum

SQL> undefine 1
SQL> @ qparm
Enter value for 1: 1968
Enter value for 1: 1968
old   3: where Year = &1
new   3: where Year = 1968

Wed Sep 20                                                             page    1
                        All the albums released in 1968

  ALBUM_ID TITLE                                    LABEL
---------- ---------------------------------------- ---------------
         4 White                                    Apple

SQL> @ qparm 1977
old   3: where Year = &1
new   3: where Year = 1977

Wed Sep 20                                                             page    1
                        All the albums released in 1977

  ALBUM_ID TITLE                                    LABEL
---------- ---------------------------------------- ---------------
        17 Heroes                                   RCA

SQL>

[Top]

Coloured Line

Carol Edmondson   <carol@cs.anu.edu.au>
URL: http://computer/student/comp2400.2006/assessment/ca/exercises/ex5/SolnNotes.shtml
Last modified: Saturday, 30-Sep-2006 20:51:42 EST