Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

the compliting of SQL

Posted on 2009-05-18
4
Medium Priority
?
346 Views
Last Modified: 2013-11-12
If you compile C++code that depends on some sort of SQL library, how does SQL change under the hood?  Is all code changed into some form of optimal abstract data types to store the info?

Looking for a general answer as well as good resource that talks about this - thanks!
0
Comment
Question by:figmit
  • 2
4 Comments
 
LVL 40

Accepted Solution

by:
mrjoltcola earned 1600 total points
ID: 24421918
The question is a bit vague, can you qualify "some sort of SQL library", otherwise it is hard to answer specifically.

A "SQL library" could range from hardcoded SQL as in const character strings that cannot be changed (easily) at runtime, to a data file of stored SQL queries that _could_ be modified at runtime.

C++ uses a database specific library to both bind the SQL statement to a set of parameters as well as execute the SQL against the database, so at runtime you can generate dynamic SQL statements, as long as they are legal and the bind variables are of the correct type for parameters in the statement.

Since you use the term "abstract data types", I assume you mean how is inline SQL handled. Typically it is stored the same way as other constant character strings in a C++ program, as string data. It is not parsed at compile time, per se, except to pre-process from embedded SQL syntax to low level API syntax, but it is still stored as a SQL string.





0
 
LVL 40

Assisted Solution

by:mrjoltcola
mrjoltcola earned 1600 total points
ID: 24422009
The only compiling I am aware of, except in the case of Microsoft's new LINQ, is the pre-processing of embedded SQL syntax; this is sort of a standard that lets you mix SQL with the host language (C, C++, etc.) by saying:

char name[100]; // C++ variable

EXEC SQL SELECT NAME INTO :name FROM CUSTOMER;


The pre-processor will convert this to low-level C++ code

Statement * statement = connection->createStatement("SELECT NAME INTO :1 FROM CUSTOMER");
statement->setString(1, name);
ResultSet * result = statement->executeQuery();

As you can see it really doesn't compile the SQL but just translates to expliciti API usage.
0
 
LVL 3

Assisted Solution

by:Akumas
Akumas earned 400 total points
ID: 24557495
generally, SQL lib such as OCI or sybase DBLibrary always map DB data type to basic c data type, like char*, long, int
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Instead of error trapping or hard-coding for non-updateable fields when using QODBC, let VBA automatically disable them when forms open. This way, users can view but not change the data. Part 1 explained how to use schema tables to do this. Part 2 h…
How much do you know about the future of data centers? If you're like 50% of organizations, then it's probably not enough. Read on to get up to speed on this emerging field.
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.
Suggested Courses

916 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question