set_sql question

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

From: Ian.Goldstein
Subject: set_sql question
Date: 11:48 on 14 Jun 2005
------_=_NextPart_001_01C570D7.0B4A02AE
Content-Type: text/plain;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

Good Morning.
=20
First let me say thanks to all the contributors for Class::DBI, very =
cool product.
My question is on set_sql.  I have a sql statement for a class that =
works with a single place holder, but if I introduce a second place =
holder, I get an error:
=20
Can't bind a reference (EQ::machine=3DHASH(0xcb3d14)) at =
/home/goldstia/lib/DBIx/ContextualFetch.pm line 51.
 at /home/goldstia/lib/DBIx/ContextualFetch.pm line 51
        =
DBIx::ContextualFetch::st::_untaint_execute('DBIx::ContextualFetch::st=3D=
HASH(0xde74f4)', 'EQ::machine=3DHASH(0xcb3d14)', 67) called at =
/home/goldstia/lib/DBIx/ContextualFetch.pm line 31
        =
DBIx::ContextualFetch::st::execute('DBIx::ContextualFetch::st=3DHASH(0xde=
74f4)', 'EQ::machine=3DHASH(0xcb3d14)', 67) called at =
/home/goldstia/tmp/PRISM/PRISM.pm line 88
        EQ::machine_file::machine_file_latest('EQ::machine_file', =
'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=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
=20
The class itself looks like this  ( it is the second placeholder that =
causes the error message f=3D=3D file_name_key =3D ?
=20
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 =
file_name_key version ctime userid groupid fmode/);
EQ::machine_file->columns(Primary=3D> qw/machine_key file_name_key =
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, =
"%m:%d:%Y:%H:%M:%S")},
                   deflate =3D> 'ymd');
#
#  Creates a nice method to extract data from a view that has an 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 ?));
=20
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);
}

=20
The calling program looks like this:
=20
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);
=20
Any thoughts or suggestions would be greatly appreciated.
=20

-- Ian

=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
Ian Goldstein
System Administrator


=20


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.

------_=_NextPart_001_01C570D7.0B4A02AE
Content-Type: multipart/mixed; boundary="retimiled-emim-detsen-mijooneldraneldeen"

--retimiled-emim-detsen-mijooneldraneldeen
Content-Type: text/html;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META HTTP-EQUIV=3D"Content-Type" CONTENT=3D"text/html; =
charset=3Diso-8859-1">


<META content=3D"MSHTML 6.00.2800.1499" name=3DGENERATOR></HEAD>
<BODY>
<DIV><FONT face=3DArial size=3D2><SPAN class=3D378254111-14062005>Good=20
Morning.</SPAN></FONT></DIV>
<DIV><FONT face=3DArial size=3D2><SPAN=20
class=3D378254111-14062005></SPAN></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2><SPAN class=3D378254111-14062005>First =
let me say=20
thanks to all the contributors for Class::DBI, very cool=20
product.</SPAN></FONT></DIV>
<DIV><FONT face=3DArial size=3D2><SPAN class=3D378254111-14062005>My =
question is on=20
set_sql.&nbsp; I have a sql statement for a class that works with a =
single place=20
holder, but if I introduce a second place holder, I get an=20
error:</SPAN></FONT></DIV>
<DIV><FONT face=3DArial size=3D2><SPAN=20
class=3D378254111-14062005></SPAN></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2><SPAN class=3D378254111-14062005>Can't =
bind a=20
reference (EQ::machine=3DHASH(0xcb3d14)) at=20
/home/goldstia/lib/DBIx/ContextualFetch.pm line 51.<BR>&nbsp;at=20
/home/goldstia/lib/DBIx/ContextualFetch.pm line=20
51<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
DBIx::ContextualFetch::st::_untaint_execute('DBIx::ContextualFetch::st=3D=
HASH(0xde74f4)',=20
'EQ::machine=3DHASH(0xcb3d14)', 67) called at=20
/home/goldstia/lib/DBIx/ContextualFetch.pm line=20
31<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
DBIx::ContextualFetch::st::execute('DBIx::ContextualFetch::st=3DHASH(0xde=
74f4)',=20
'EQ::machine=3DHASH(0xcb3d14)', 67) called at =
/home/goldstia/tmp/PRISM/PRISM.pm=20
line 88<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
EQ::machine_file::machine_file_latest('EQ::machine_file',=20
'EQ::machine=3DHASH(0xcb3d14)', 67) called at ./get_hostsbyproj line=20
21<BR></SPAN></FONT></DIV>
<DIV><FONT face=3DArial size=3D2><SPAN=20
class=3D378254111-14062005>=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=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D</SPAN></FONT></DIV>
<DIV><FONT face=3DArial size=3D2><SPAN=20
class=3D378254111-14062005></SPAN></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2><SPAN class=3D378254111-14062005>The =
class itself=20
looks like this&nbsp; ( it is the second placeholder that causes the =
error=20
message f=3D=3D file_name_key =3D ?</SPAN></FONT></DIV>
<DIV><FONT face=3DArial size=3D2><SPAN=20
class=3D378254111-14062005></SPAN></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2><SPAN =
class=3D378254111-14062005>package=20
EQ::machine_file;<BR>use base=20
"EQ::prismDB";<BR>EQ::machine_file-&gt;table('machine_file');<BR>EQ::mach=
ine_file-&gt;columns(All=3D&gt;=20
qw/machine_key file_content_key file_name_key version ctime userid =
groupid=20
fmode/);<BR>EQ::machine_file-&gt;columns(Primary=3D&gt; qw/machine_key=20
file_name_key version/);<BR>EQ::machine_file-&gt;has_a('machine_key' =
=3D&gt;=20
'EQ::machine');<BR>EQ::machine_file-&gt;has_a('file_name_key' =3D&gt;=20
'EQ::file_name');<BR>EQ::machine_file-&gt;has_a('file_content_key' =
=3D&gt;=20
'EQ::file_content');<BR>EQ::machine_file-&gt;has_a('ctime' =3D&gt;=20
'Time::Piece',<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&=
nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
inflate =3D&gt; sub { Time::Piece-&gt;strptime(shift,=20
"%m:%d:%Y:%H:%M:%S")},<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp=
;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
deflate =3D&gt; 'ymd');<BR>#<BR>#&nbsp; Creates a nice method to extract =
data from=20
a view that has an object type of=20
machine_file<BR>#<BR>__PACKAGE__-&gt;set_sql(machinefilelatest=20
=3D&gt;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; qq( SELECT=20
*<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n=
bsp;&nbsp;=20
from=20
machine_file_latest<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n=
bsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
where machine_key =3D ? and <FONT color=3D#ff0000>file_name_key =3D=20
?</FONT>));</SPAN></FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2><SPAN class=3D378254111-14062005>sub=20
machine_file_latest {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; my =
$class =3D=20
shift;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; my $machine_key =3D =

shift;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; my $file_name_key =
=3D=20
shift;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; my $sth =3D=20
$class-&gt;sql_machinefilelatest;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=
&nbsp;&nbsp;&nbsp;&nbsp;=20
$sth-&gt;execute($machine_key,$file_name_key);<BR>&nbsp;&nbsp;&nbsp;&nbsp=
;&nbsp;&nbsp;&nbsp;=20
return $class-&gt;sth_to_objects($sth);<BR>}<BR></SPAN></FONT></DIV>
<DIV><FONT face=3DArial size=3D2><SPAN=20
class=3D378254111-14062005></SPAN></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2><SPAN class=3D378254111-14062005>The =
calling program=20
looks like this:</SPAN></FONT></DIV>
<DIV><FONT face=3DArial size=3D2><SPAN=20
class=3D378254111-14062005></SPAN></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2><SPAN class=3D378254111-14062005>my =
$fobj =3D=20
EQ::file_name-&gt;search('name'=3D&gt;"/etc/hosts")-&gt;next;<BR>$fnk =
=3D=20
$fobj-&gt;file_name_key;<BR></DIV></SPAN></FONT>
<DIV><FONT face=3DArial size=3D2><SPAN class=3D378254111-14062005>$mfo =
=3D=20
EQ::machine_file-&gt;machine_file_latest($a-&gt;machine_key=20
,$fnk);</SPAN></FONT></DIV>
<DIV><FONT face=3DArial size=3D2><SPAN=20
class=3D378254111-14062005></SPAN></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2><SPAN class=3D378254111-14062005>Any =
thoughts or=20
suggestions would be greatly appreciated.</SPAN></FONT></DIV>
<DIV><FONT face=3DArial size=3D2><SPAN=20
class=3D378254111-14062005></SPAN></FONT>&nbsp;</DIV>
<P><FONT size=3D2>-- =
Ian<BR><BR>=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
<BR>Ian Goldstein<BR>System=20
Administrator<BR></FONT></P>
<DIV><FONT size=3D2></FONT>&nbsp;</DIV></BODY></HTML>

--retimiled-emim-detsen-mijooneldraneldeen
Content-Type: text/plain; charset=us-ascii; name="disclaim.txt"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
Content-Description: Legal Disclaimer


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.

--retimiled-emim-detsen-mijooneldraneldeen--

------_=_NextPart_001_01C570D7.0B4A02AE--

set_sql question
Ian.Goldstein 11:48 on 14 Jun 2005

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