I’m using DBD::mysql, and I want to insert a record into clients table (id, address, and phone-number of a client):
Expand|Select|Wrap|Line Numbers
- my $str= “?,?,?,,,”;
- my @args1=('Zalman','Zalmanovich',12121,'New York');
- $q=$dbh->prepare("INSERT INTO $table VALUES($str)")
- or die "Couldn't prepare statement: " . $dbh->errstr;
- $q->execute($args1[0],$args1[1],$args1[2],…)
- or die "Couldn't execute statement: " . $q->errstr;
If I want to change the number of arguments sent to execute(), I must change the source code inside execute() brackets.
I would like to be able to change it on run-time with something like:
Expand|Select|Wrap|Line Numbers
- $q->execute(f(@args1))
- or die "Couldn't execute statement: " . $q->errstr;
This may add invaluable flexibility to my program, because my program works with different kinds of clients tables, but how to do it ????.
thanks for your advices