psql/perl oddity
talexb-SBdzbUvMQDunS0EtXVNi6w at public.gmane.org
talexb-SBdzbUvMQDunS0EtXVNi6w at public.gmane.org
Wed Aug 18 20:49:26 UTC 2004
On Wed, 18 Aug 2004, Madison Kelly wrote:
[..]
> Perfect! Notice that 'assign_up_to' has a value? Well, when I try to
> do the same thing in perl like this it is always returns '0':
>
>
Normally I would set a query string to hold the query, then print and
prepare the same string. Less chance of thumb-fingeredness.
> print " |- DBI: SELECT mntdir, freecap, maxcap, usedcap, assign_up_to,
> assigned_space, fs FROM dev WHERE uuid='$uuid';\n";
> $DBreq=$DB->prepare("SELECT mntdir, freecap, maxcap, usedcap,
> assign_up_to, assigned_space, fs FROM dev WHERE uuid='$uuid'") || die
> $DBI::errstr;
Yikes. Here you're using Perl interpolation to put the UUID into the
query. Better to use a placeholder (?) instead, and pass the real $uuid
into the execute method.
> $null=$DBreq->execute();
> @part_info=$DBreq->fetchrow_array();
> print " | |- DEBUG: mntdir: [$part_info[0]], freecap: [$part_info[1]],
> maxcap: [$part_info[2]], usedcap: [$part_info[3]], assign_up_to:
> [$part_info[4]], assigned_space: [$part_info[5]], fs: [$part_info[6]]\n";
Well, when all else fails, add
$DBReq->trace(2,'/var/tmp/DBI-August18.log')
into your code, resetting trace to zero afterwards, and see what DBI
thinks is going on. My guess is that you've got a bad field name in there,
even though what you've quoted doesn't show anything.
Alex
--
The Toronto Linux Users Group. Meetings: http://tlug.ss.org
TLUG requests: Linux topics, No HTML, wrap text below 80 columns
How to UNSUBSCRIBE: http://tlug.ss.org/subscribe.shtml
More information about the Legacy
mailing list