Avatar of carlpaddick
carlpaddick

asked on 

Quotes for SQL statements

Guys, wonder if you could help me.

I'm working on an mfc/sdk  app that supports data access/entry via ODBC database drivers.  Now I know that each ODBC vendor has a list of delimiters required for SQL querying and I wonder if anyone can come up with the answers to whether SINGLE or DOUBLE quotes are required for the 'insert' and 'delete' statements and also the 'where' clause.

I need to know answers for the following databases:

MS Access
MS SQL Server
DBase
Foxpro & Visual Foxpro
Paradox
Oracle (Oracle's driver and Microsofts)
DB2
Informix
Ingres

and any others that I have forgotten to mention.
System Programming

Avatar of undefined
Last Comment
carlpaddick
Avatar of sri_darr
sri_darr

Since this is an MFC application using MS-ODBC to get to the back-end, you'd be OK to use the single quote for all the strings to be passed in the Insert/ Update statements. I hope I got your question right. Ex:
INSERT INTO Items ( ItemCode, ItemName, Price) VALUES (112, 'Soap', 2.54)
should work regardless of the database. That's what the ODBC is for. But incase you have to send the single quote itself to the backend, ( like "David's Book" to be updated in one of the fields ) then it's a bit different. You should probably write a wrapper class around ODBC APIs and handle the single quote separately.
But for all normal insert/ updates the single quote will work.
Avatar of carlpaddick
carlpaddick

ASKER

sri_darr,

I could be wrong here, but are single quotes ok for Access databases?  Don't these require double quotes(")?
Avatar of sri_darr
sri_darr

Carl,

Absolutely. Single quotes work fine for Access DB too. U shd hv no problem.
ASKER CERTIFIED SOLUTION
Avatar of Carel
Carel

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Avatar of carlpaddick
carlpaddick

ASKER

Carel,

This is the sort of thing I'm looking for.
However, I've looked all over the place for an example but can't find one for SQLGetTypeInfo that uses LITERAL_PREFIX and LITERAL_SUFFIX parameters.  Do you have a working example that I could use as reference please?
Avatar of Carel
Carel

I will have an example in Win32 style that does what you want. I will have to look it up though tomorrow. Basically the API gets called and produces a result set. The literal prefix and suffix columns are two columns of that result set. Then what remains is a fetch. You might encounter a problem though since not all db support them. What we do and what works best is we define our own table of literal pre- and suffix as well as other characteristics for the different databases that we support. We do so in an end-user accessible way but provide preconfigured stuff. We can easily extend it if we come acros a new database.
Avatar of carlpaddick
carlpaddick

ASKER

Comment accepted as answer
Avatar of carlpaddick
carlpaddick

ASKER

Carel,

Ok I've found a working example of SQLGetTypeInfo and it seems to do the job.

Because you have come up with the answer, please have the points.

Thank you.
System Programming
System Programming

Kernel and system programming is the process of creating the software necessary for a computer or device to function and operate other programs. Some operating systems (such as Microsoft Windows) are proprietary, but others, such as the various Linux distributions, are open source.

41K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo