On Tue, Mar 18, 2003 at 02:05:33PM +0200, Ville Jungman wrote:
>
> It's easier if you can call sql-commands just in the same way that you do
> with sql-prompt. For example
>
> @result=$self->kanta("select $a from table where name='$prod'");
>
> is much simpler than same query with placeholders. That's why I like to do
> it with sub like this.
It's not really that much easier, if the sub kanta is written to
handle lists, like so:
@result=$self->kanta("select $a from table where name=?",$prod);
Then:
sub kanta {
my $self=shift;
my $sql=shift;
my @values=@_;
# [do stuff]
my $sth=prepare($sql);
$sth->execute(@values);
# [do stuff with $sth to return the result
return @result;
}
It's still easy to use kanta--it even allows you not to use
placeholders, but allows you to migrate to it if you wish.
--keith
--
kkeller@speakeasy.net
public key: http://wombat.san-francisco.ca.us/kkeller/kkeller.asc
alt.os.linux.slackware FAQ: http://wombat.san-francisco.ca.us/cgi-bin/fom