handling with variable

handling with variable

am 04.09.2006 16:55:46 von Ruprecht Helms

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi,

how can I work with variables within a perl-script using DBI.
I want to read content of tablefields into variables to compute with it.
The result of the computing should be written into another field of
another table.

A little scriplet would be nice.

Regards,
Ruprecht
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2 (GNU/Linux)
Comment: Using GnuPG with SUSE - http://enigmail.mozdev.org

iD8DBQFE/D5yOAckbBgiIFcRAhEBAJsHhtJ40n2iafcrGq/Oxu31tD+sowCe IeuO
wG1LN7ZuIZcK9vN7orYVHnE=
=ZHde
-----END PGP SIGNATURE-----

--
MySQL Perl Mailing List
For list archives: http://lists.mysql.com/perl
To unsubscribe: http://lists.mysql.com/perl?unsub=gcdmp-msql-mysql-modules@m .gmane.org

RE: handling with variable

am 04.09.2006 18:50:00 von Martin.Evans

Not actually tested but the basic principle is:

my $dbh = DBI->connect(...);
my $sth = $dbh->prepare(q/select col1, col2 from table where col3=1/);
my ($col1, $col2);
$sth->bind_col(1, \$col1);
$sth->bind_col(2, \$col2);
$sth->fetch;
my $result = $col1 + $col2;
$sth = $dbh->prepare(q/insert into table2 values(?)/);
$sth->execute($result);

Martin
--
Martin J. Evans
Easysoft Ltd, UK
http://www.easysoft.com


On 04-Sep-2006 Ruprecht Helms wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Hi,
>
> how can I work with variables within a perl-script using DBI.
> I want to read content of tablefields into variables to compute with it.
> The result of the computing should be written into another field of
> another table.
>
> A little scriplet would be nice.
>
> Regards,
> Ruprecht
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.2 (GNU/Linux)
> Comment: Using GnuPG with SUSE - http://enigmail.mozdev.org
>
> iD8DBQFE/D5yOAckbBgiIFcRAhEBAJsHhtJ40n2iafcrGq/Oxu31tD+sowCe IeuO
> wG1LN7ZuIZcK9vN7orYVHnE=
> =ZHde
> -----END PGP SIGNATURE-----
>
> --
> MySQL Perl Mailing List
> For list archives: http://lists.mysql.com/perl
> To unsubscribe:
> http://lists.mysql.com/perl?unsub=martin.evans@easysoft.com

--
MySQL Perl Mailing List
For list archives: http://lists.mysql.com/perl
To unsubscribe: http://lists.mysql.com/perl?unsub=gcdmp-msql-mysql-modules@m .gmane.org