Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options

Re: Calling SQL with embedded quotes

by grep (Monsignor)
on May 21, 2002 at 08:43 UTC ( #168066=note: print w/replies, xml ) Need Help??

in reply to Calling SQL with embedded quotes

If at all possible I would switch to DBI instead of sybperl. DBI is the standard for perl database access and gives you a (mostly) consistant interface to whatever database you want to access wether it be Sybase or PostGreSQL or MySQL.

DBI and DBD::Sybase give you some nice methods for dealing with your quoting problem like placeholders and binding

But back to your original question, in the sybperl docs it explains you have both the 'dbsafestr' method and placeholders available with the 'ct_dyn_prepare' method. My personal preference is for placeholders since they make for efficient queries if reused.

Of course you can always go to the monastary's mpeppler's page and read about both.

These are not the monks you are looking for, move along

Replies are listed 'Best First'.
Re: Re: Calling SQL with embedded quotes
by c-era (Curate) on May 21, 2002 at 12:40 UTC
    I have to second use DBI instead. Also, you should get in the habit of using placeholders and binding, as they can make a huge difference on performance.

    Where I'm working now, most of our old code didn't use placeholders and binding. Now that we are literally doing 1000X more transactions then when the program was written, we are feeling the pain. We've gone back and started to change all of our old code, and it has made a huge difference. Not only are we able to keep up now, but the program now responds noticeably faster then it did before. I see using placeholders and binding like using strict and warnings, you may not think you need to use them, but if you don't use them, it will come back to haunt you.

    PS We use an Oracle database.

    PPS We are doing this to both our perl and java code, and both languages are benifiting from using placeholders.

      Note that while usually usage of placeholders is standart way to deal with such problems and it is highly recomended with most databases in case of Sybase implementation of placeholders have a number of different problems. It is covered in POD documentation for DBD::Sybase in chapter 'Using ? Placeholders & bind parameters to $sth->execute'.

      Ilya Martynov (

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://168066]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (4)
As of 2022-05-24 14:49 GMT
Find Nodes?
    Voting Booth?
    Do you prefer to work remotely?

    Results (83 votes). Check out past polls.