Application Development Guide

Parameter Markers in Perl

To enable you to execute a prepared statement using different input values for specified fields, the Perl DBI module enables you to prepare and execute a statement using parameter markers. To include a parameter marker in an SQL statement, use the question mark (?) character.

The following Perl code creates a statement handle that accepts a parameter marker for the WHERE clause of a SELECT statement. The code then executes the statement twice using the input values 25000 and 35000 to replace the parameter marker.

   my $sth = $dbhandle->prepare( 
      'SELECT firstnme, lastname 
         FROM employee
         WHERE salary > ?'
      );
 
   my $rc = $sth->execute(25000);
   
·
·
·
my $rc = $sth->execute(35000);


[ Top of Page | Previous Page | Next Page ]