Hi Akshay,
That's probably because the INSERT and SELECT queries have specific bind parameters and/or custom result set handling. As opposed to the CREATE and DROP queries which only have a simple query string input and a success/fail result.
Because different tables potentially have different inputs/outputs requirements you may need to handle queries for different tables with different calls into the API and depending on your design you might create separate functions to handle those queries. You could also use string manipulation to inline the values into the query string itself to unify all query logic to a single function, but that's general not recommended because of security issues and it also prevents your application from taking advantage of prepared statements.
Currently, there isn't a single, generic function that handles different input types in the API, yet. I have thought about creating an interface in the driver that uses variadic arguments. That would simplify basic queries to a single API call. Here's what I was thinking.
Declaration:
CassFuture cass_session_execute_args(CassSession* session, const char* query, const char* types, ...);
"types" is a string where each character represents the type of a variadic argument at the corresponding position.
Type Mapping:
'i' is int32
'l' is int64
's' is CassString
'b' is CassBytes
'u' is CassUuid
...
Example Usage:
CassUuid uuid;
CassFuture* future
= cass_session_execute_args(session, "SELECT * from table1 WHERE column1 = ? AND column2 = ?", "ui", uuid, 1234);
Variadic arguments have problems though. If the "types" string doesn't match the actual type of the parameter it can cause memory corruption. There are ways to verify the parameters at compile time, but they are generally not portable. There's a story in JIRA to add such an interface:
https://datastax-oss.atlassian.net/browse/CPP-105.
Mike