Use DBI placeholders. It's as easy as the following:
... $dbh->{AutoCommit} = 0; # disable auto-commit my $sth_insert_login = $dbh->prepare(<<'SQL'); insert into logintbl( username, password) values(?, ?) SQL my $sth_insert_student = $dbh->prepare(<<'SQL'); insert into studenttbl( fname,lname,grade,DOB,email,tel_no,membertype,username) values (?, ?, ?, ?, ?, ?, ?, ?) SQL #$dbh->do ("insert into logintbl(username, password) values('jones2100 +','password')"); $sth_insert_login->execute('jones2100', 'password'); #$dbh->do ("insert into studenttbl(fname,lname,grade,DOB,email,tel_no, +membertype,username) VALUES ('jamie','batty','7thkyu','1988/07/21','b +attydave@hotmail.com','01234523454','monthly pay','jones2010')"); $sth_insert_student->execute('jamie','batty','7thkyu','1988/07/21','ba +ttydave@hotmail.com','01234523454','monthly pay','jones2010'); $dbh->commit();
In reply to Re^2: perl to write to more than one table in a database at the same time (or call anotherscript to do one)
by Corion
in thread perl to write to more than one table in a database at the same time (or call anotherscript to do one)
by bogglemaster89
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |