Solved

the compliting of SQL

Posted on 2009-05-18
4
330 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 400 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 400 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 100 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

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

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

Suggested Solutions

Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

895 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now