On Thu, Nov 21, 2002 at 06:38:11PM -0500, Ronald J Kimball wrote: > On Thu, Nov 21, 2002 at 03:12:47PM -0800, Daniel Olson wrote: > > I have a Perl script acting as a CGI processor with many values being passed, > > and the values can possibly be empty. This seems to cause problems. I have a > > prepare statement with 19 columns with 17 columns of variable data. I'm trying > > to set up the execute statement properly so it handles arguments that are > > defined as well as those that aren't. If all the arguments have values, it all > > works swimmingly. The code looks like this: > > > > $sth = $dbh->prepare("insert into ul_info >(ul_id,ul_len,ul_wid,ul_dep,ul_tun,ul_sin,ul_und,ul_und_fr,ul_und_to,ul_edge,ul_stat,ul_skin,ul_drain_typ,ul_drain_amt,ul_drain_col,ul_drain_od,ul_stage,timestamp,clinician) > > values (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,sysdate,'')"); > > >$sth->execute($UlID,$formdata->param('Len'),$formdata->param('Wid'),$formdata->param('Dep'),$formdata->param('Tun'),$formdata->param('Sin'),$formdata->param('Und'),$formdata->param('UStart'),$formdata->param('UEnd'),$formdata->param('DEdge'),$formdata->param('DEval'),$formdata->param('DSkin'),$formdata->param('DType'),$formdata->param('DAmt'),$formdata->param('DColor'),$formdata->param('DOdor'),$newstage) > || die "Can't perform execute: $DBI::errstr";
Ron has already described what is happening and why, so, as a potential solution, I would suggest $sth->execute( $UlID, ( map { scalar $formdata->param($_) } qw(Len Wid Dep Tun Sin Und UStart UEnd DEdge DEval DSkin DType DAmt DColor DOdor)), $newstage ) || die "Can't perform execute: $DBI::errstr"; Graham.