[Gllug] Perl DBI question

Andy Farnsworth farnsaw at stonedoor.com
Tue Oct 3 17:17:04 UTC 2006


Adrian McMenamin wrote:
> Maybe more appropriate for a perl list...
>
> Given a database of N records where N > 0 but size of N is otherwise
> unkown, is it possible to pick a random record from the database?
>
> I cannot find any examples on google...
>
> Alternatively, any simple way (ie other than selecting every record and
> counting them) of determining N?
>
> Thanks
>
>   
Adrian,
  If you look in the Perl Cookbook you will find this exact problem 
except it refers to lines in a file.  You can use one of the methods put 
forth here or just look there for one.  Adminitedly, when the number of 
rows in the table get very large then the solution in the cookbook is 
fairly slow.

Andy
-- 
Gllug mailing list  -  Gllug at gllug.org.uk
http://lists.gllug.org.uk/mailman/listinfo/gllug




More information about the GLLUG mailing list