Anyone who puts a small gloss on a fundamental technology, calls it proprietary, and then tries to keep others from building on it, is a thief -- Tim O'Reilly

Lab #9 - Databases and DBI

  1. Create a table within a new database using the DBD::SQLite driver, using the same structure as for the sample customer table given in the lectures. You could use the code from the lecture as a starting point.

  2. Use the SQL INSERT statement to add some data to your table. Examine the SQLite database using the sqlite3 command line utility, in order to verify that it worked. Run some generic SQL queries (eg. SELECT, UPDATE, DELETE) against the table and verify that they work as expected.

  3. Create another Perl program that retrieves all data from the customer table, sorting it by surname. Print the records out as text - perhaps you could format them using tabs or even fixed width formatting.

  4. The previous program doesn't look anything a CGI. Add the standard Perl code to turn it into a CGI. You may also want to change your output so that it uses XHTML/CSS to format the output (eg. use a HTML table to layout the data). Make sure you use "use CGI::Carp qw(fatalsToBrowser);" so that you can see any errors in your browser.

  5. See if you can create a FORM to collect information which your CGI will use to structure its query - eg. ask for a customer ID, surname, firstname and order value, then insert this data into the table. Try some different forms/queries.

Copyright © 2000-2007 Phil Scott
Copyright © 2008-2009 Joel Sing