Stories
Slash Boxes
Comments
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

jdavidb (1361)

jdavidb
  (email not shown publicly)
http://voiceofjohn.blogspot.com/

J. David Blackstone has a Bachelor of Science in Computer Science and Engineering and nine years of experience at a wireless telecommunications company, where he learned Perl and never looked back. J. David has an advantage in that he works really hard, he has a passion for writing good software, and he knows many of the world's best Perl programmers.

Journal of jdavidb (1361)

Wednesday July 12, 2006
02:18 PM

Oracle gravel of the day: no placeholders in ALTER SESSION

[ #30263 ]

For some reason I cannot use placeholders in an ALTER SESSION statement. This works:

sub set_date_format
{
  my($dbh, $format) = @_;
  my $sql = <<"EOF";
    ALTER SESSION SET NLS_DATE_FORMAT = '$format'
EOF
  my $sth = $dbh->prepare($sql);
  $sth->execute;
}

But this does not:

sub set_date_format
{
  my($dbh, $format) = @_;
  my $sql = <<"EOF";
    ALTER SESSION SET NLS_DATE_FORMAT = ?
EOF
  my $sth = $dbh->prepare($sql);
  $sth->execute($format);
}

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
 Full
 Abbreviated
 Hidden
More | Login | Reply
Loading... please wait.
  • I tried using bind_parms with a numbered parameter and with a named parameter both with and without a data type.

    sub set_date_format_bind
    {
      my($dbh, $format) = @_;
      my $sql = <<"EOF";
        ALTER SESSION SET NLS_DATE_FORMAT = ?
    EOF
      my $sth = $dbh->prepare($sql) or die $DBI::errstr;
      $sth->bind_param(1, $format, SQL_LONGVARCHAR);
      $sth->execute() or die $DBI::errstr;
    }

    sub set_date_format_named_bind
    {
      my($dbh, $format) = @_;
      my $sql = <<"EOF";