perl - Forward Slash issue with DBI -


i'm new using dbi sql queries in perl script. issue i'm having pertains data in fields have forward slash. i'm wanting use variables input clause, doing dbi intends forward slash do: stop query. tried numerous different work arounds binds, quotes, etc. none worked, possible? data in consistent. line $sql variable trouble is.

#!/usr/bin/perl  # modules use dbi; use dbd::oracle; use strict; use warnings;  # connection info $platform = "oracle"; $database = "mydb"; $user = "user"; $pw = "pass";  # data source $ds = "dbi:oracle:$database";  $dbh = dbi->connect($ds, $user, $pw);  # $dbh = dbi->connect();        $xcod = $dbh->quote('cba'); $a = $dbh->quote('abc'); $b = $dbh->quote('123'); # tried  $pid = $dbh->quote('$a/$b'); $sql = "select p_id mytable p_id=$a/$b , xcod=$xcod"; $sth = $dbh->prepare($sql); $sth->execute();   $outfile = 'superunique.txt'; open outfile, '>', $outfile or die "unable open $outfile: $!";  while(my @re = $sth->fetchrow_array) { print outfile @re,"\n"; }  close outfile;  $sth->finish(); $dbh->disconnect(); 

i don't see folks use variable interpolation in sql queries. try using placeholders:

 [ snip ]  $p_id = "$a/$b"  $sql = "select p_id mytable p_id = ? , xcod = ?";  $sth = $dbh->prepare($sql);  $sth->execute($p_id, $xcod);   [ snip ] 

Comments

Popular posts from this blog

c# - Better 64-bit byte array hash -

webrtc - Which ICE candidate am I using and why? -

php - Zend Framework / Skeleton-Application / Composer install issue -