RE: set_sql

[prev] [thread] [next] [Date index for 2005/06/14]

From: Ian.Goldstein
Subject: RE: set_sql
Date: 20:29 on 14 Jun 2005
Yes it was... Because of the has_a relationship, I was returned an =
object rather than the key.  I further complicated by performing p $fnk =
in the debugger which displayed an integer, but it was really an object.

I can't thank you enough for the quick response.  There seem to be a lot =
of un-documented features of class-dbi. =20

I am now trying to figure out how to speed up queries as they seem very =
slow compared to straight DBI.

Thanks again.



-- Ian



-----Original Message-----
From: yoorobot@xxxxx.xxx [mailto:yoorobot@xxxxx.xxx]
Sent: Tuesday, June 14, 2005 9:00 AM
To: Goldstein, Ian
Cc: cdbi-talk@xxxxxx.xxxxx.xxx
Subject: Re: set_sql


hmm,
looks like you may not be passing what you think into your handle.  =20
=3D>"Can't bind a reference (EQ::machine=3DHASH(0xcb3d14))"

On Jun 14, 2005, at 6:55 AM, ian.goldstein@xxx.xxx wrote:

> Good Morning.
>
> First let me say thanks to all the contributors for Class::DBI, =20
> very cool product.
> My question is on set_sql.  I have a sql statement for a class that =20
> works with a single place holder, but if I introduce a second place =20
> holder, I get an error:
>
> Can't bind a reference (EQ::machine=3DHASH(0xcb3d14)) at /home/=20
> goldstia/lib/DBIx/ContextualFetch.pm line 51.
>  at /home/goldstia/lib/DBIx/ContextualFetch.pm line 51
>         DBIx::ContextualFetch::st::_untaint_execute=20
> ('DBIx::ContextualFetch::st=3DHASH(0xde74f4)', 'EQ::machine=3DHASH=20
> (0xcb3d14)', 67) called at /home/goldstia/lib/DBIx/=20
> ContextualFetch.pm line 31
>         DBIx::ContextualFetch::st::execute=20
> ('DBIx::ContextualFetch::st=3DHASH(0xde74f4)', 'EQ::machine=3DHASH=20
> (0xcb3d14)', 67) called at /home/goldstia/tmp/PRISM/PRISM.pm line 88
>         EQ::machine_file::machine_file_latest('EQ::machine_file', =20
> 'EQ::machine=3DHASH(0xcb3d14)', 67) called at ./get_hostsbyproj line =
21
>
> =
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=20
> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
>
> The class itself looks like this  ( it is the second placeholder =20
> that causes the error message f=3D=3D file_name_key =3D ?
>
> package EQ::machine_file;
> use base "EQ::prismDB";
> EQ::machine_file->table('machine_file');
> EQ::machine_file->columns(All=3D> qw/machine_key file_content_key =20
> file_name_key version ctime userid groupid fmode/);
> EQ::machine_file->columns(Primary=3D> qw/machine_key file_name_key =20
> version/);
> EQ::machine_file->has_a('machine_key' =3D> 'EQ::machine');
> EQ::machine_file->has_a('file_name_key' =3D> 'EQ::file_name');
> EQ::machine_file->has_a('file_content_key' =3D> 'EQ::file_content');
> EQ::machine_file->has_a('ctime' =3D> 'Time::Piece',
>                    inflate =3D> sub { Time::Piece->strptime(shift, "%=20
> m:%d:%Y:%H:%M:%S")},
>                    deflate =3D> 'ymd');
> #
> #  Creates a nice method to extract data from a view that has an =20
> object type of machine_file
> #
> __PACKAGE__->set_sql(machinefilelatest =3D>
>         qq( SELECT *
>               from machine_file_latest
>               where machine_key =3D ? and file_name_key =3D ?));
>
> sub machine_file_latest {
>         my $class =3D shift;
>         my $machine_key =3D shift;
>         my $file_name_key =3D shift;
>         my $sth =3D $class->sql_machinefilelatest;
>            $sth->execute($machine_key,$file_name_key);
>         return $class->sth_to_objects($sth);
> }
>
>
> The calling program looks like this:
>
> my $fobj =3D EQ::file_name->search('name'=3D>"/etc/hosts")->next;
> $fnk =3D $fobj->file_name_key;
>
> $mfo =3D EQ::machine_file->machine_file_latest($a->machine_key ,$fnk);
>
> Any thoughts or suggestions would be greatly appreciated.
>
> -- Ian
>
>
>


Visit our website at http://www.ubs.com

This message contains confidential information and is intended only 
for the individual named.  If you are not the named addressee you 
should not disseminate, distribute or copy this e-mail.  Please 
notify the sender immediately by e-mail if you have received this 
e-mail by mistake and delete this e-mail from your system.

E-mail transmission cannot be guaranteed to be secure or error-free 
as information could be intercepted, corrupted, lost, destroyed, 
arrive late or incomplete, or contain viruses.  The sender therefore 
does not accept liability for any errors or omissions in the contents 
of this message which arise as a result of e-mail transmission.  If 
verification is required please request a hard-copy version.  This 
message is provided for informational purposes and should not be 
construed as a solicitation or offer to buy or sell any securities or 
related financial instruments.

set_sql
ian.goldstein 11:55 on 14 Jun 2005

Re: set_sql
yoorobot 13:00 on 14 Jun 2005

Re: set_sql
sriha 15:46 on 14 Jun 2005

Re: set_sql
Tony Bowden 16:07 on 14 Jun 2005

RE: set_sql
Ian.Goldstein 20:29 on 14 Jun 2005

Generated at 16:36 on 28 Jul 2005 by mariachi v0.52