Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re: Calling SQL with embedded quotes

by grep (Monsignor)
on May 21, 2002 at 08:43 UTC ( [id://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.

grep
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 (http://martynov.org/)

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others meditating upon the Monastery: (3)
As of 2024-04-25 09:23 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found