my $sth = $dbh -> prepare("insert into table1 (col1, col2, col2) values (?, ?, ?)"); #### # do we need an insert or an update? my $row_checker = $dbh -> prepare("select count(col1) from table1 where col1 = ? and col2 = ? and col3 = ?"); my $inserter = $dbh -> prepare("insert into table1 (col1, col2, col2) values (?, ?, ?)");my $upda ter = $dbh -> parepare("update table1 set col1 = ?, col2 = ?, col3 = ? where col1 = ? and col2 = ? and col3 = ?"); #### my $row_checker = "select count(col1) from table1 where col1 = ? and col2 = ? and col3 = ?"; $row_checker = $dbh -> prepare($row_checker); # or ... my $updater = $dbh -> prepare(qq{ update table1 set col1 = ?, col2 = ?, col3 = ? where col1 = ? and col2 = ? and col3 = ? }); #### my $rowRef = $dbh -> selectrow_arrayref("select col1 from table1 where col1 = col2 and col2 != '$ someval'"); my @row = @{ $rowRef }; #or ... my $tuple = shift @{ $rowRef }; #or ... my $tuple = @{ $rowRef }[0]; #### my ($tuple) = map { @{ $_ } } $dbh -> selectall_arrayref("select col1 from table1 where col1 = co l2 and col2 != '$someval'"); #### if ($tuple) { # succeeded... #### my $next_col1 = "select distinct(col1) from table1"; $next_col1 = $dbh -> prepare($next_col1); $next_col1 -> execute(); my @col1s = map { @{ $_ } } @{ $next_col1 -> fetchall_arrayref() }; foreach my $col1 (@col1s) { ...