Looking for a good explanation of select function in perl dbi

Looking for a good explanation of select function in perl dbi

am 18.09.2007 05:29:51 von mohnkern

------=_Part_14312_13511528.1190086191354
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

Well, I've figured out how to put data into a sqlite database. I can
extract data from the command line, however, for the life of me, I just
can't find any good documentation on using Select.

What I'm trying to do:

SELECT name, size FROM filelist where uid=

This works from the command line:

sqlite3 data.dbl "SELECT name, uid from filelist where UID=\"1000\""

I'd like to pop this into an array, where I could manipulate it, where each
element of the array would contain name,size.

Are there any good web pages on using the SELECT function? I took a look
at:

http://souptonuts.sourceforge.net/readme_sqlite_tutorial.htm l

But it kind of lost me.

Scott Mohnkern

------=_Part_14312_13511528.1190086191354--

Re: Looking for a good explanation of select function in perl dbi

am 18.09.2007 09:55:23 von Martin.Evans

Scott Mohnkern wrote:
> Well, I've figured out how to put data into a sqlite database. I can
> extract data from the command line, however, for the life of me, I just
> can't find any good documentation on using Select.
>
> What I'm trying to do:
>
> SELECT name, size FROM filelist where uid=
>
> This works from the command line:
>
> sqlite3 data.dbl "SELECT name, uid from filelist where UID=\"1000\""
>
> I'd like to pop this into an array, where I could manipulate it, where each
> element of the array would contain name,size.

Read about DBI's selectall_arrayref in the pod as it returns a ref to an
array of arrays as you want. Alternatively, do the fetching yourself
with fetchrow_arrayref.

Use bound parameters in your select SQL:
SELECT name, uid from filelist where UID=?
- see DBI's bind_param.

> Are there any good web pages on using the SELECT function? I took a look
> at:
>
> http://souptonuts.sourceforge.net/readme_sqlite_tutorial.htm l
>
> But it kind of lost me.
>
> Scott Mohnkern
>

I'm not sure if you want help on use of select in SQL or obtaining
result sets created by select in your Perl. The following link (if you
scroll down past the ODBC stuff) does the latter:

http://www.easysoft.com/developer/languages/perl/dbd_odbc_tu torial_part_2.html

There are literally loads of SQL tutorials on the web including the
w3schools one at http://www.w3schools.com/sql/default.asp. You may have
to refer back to sqllite to check what syntax it supports - I don't use
sqllite so I don't know.


Martin
--
Martin J. Evans
Easysoft Limited
http://www.easysoft.com