Summary

This chapter deals with the basics of getting data from the database to your Perl programs. Recall that there are a number of different ways to get the data from the database: (fetch, fetchrow_arrayref, fetchrow_array, fetchall_arrayref, and fetchrow_hashref).

Don't forget that fetch and fetchrow_arrayref do the exact same thing. For brevity's sake, you may want to use only the fetch method.

Keep in mind that if you make a call to the fetchall_arrayref function, you should not use it if you are dealing with a large amount of data. Also, remember that it returns only the data remaining since the last fetch-type call.

Try these example programs, and try to change them so that you can get different data and see how it all works. Try things like changing the SELECT * statements so you get only specific fields. Or change the code so that the output from the programs is much nicer. Don't be afraid to change the code and to experiment; you won't break the computer!

Although being able to get data from the database is nice, we are ready to move to the next level-manipulating the data in the database. The next section shows you how to add records, delete records, and update existing records. Add this to your growing arsenal of Perl-database knowledge, and you'll soon be writing powerful, data-driven applications!



Perl Database Programming
Perl Database Programming
ISBN: 0764549561
EAN: 2147483647
Year: 2001
Pages: 175

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net