dbExecQuery#

Purpose#

Executes a SQL statement and creates a query.

Format#

qid = dbExecQuery(db_id, sql_statement[, placeholders])#
Parameters:
  • db_id (scalar) – database connection index number.

  • sql_statement (string) – Contains a valid SQL statement

  • placeholders (string or string array) – Contains bind value(s)

Returns:

qid (scalar) – query id to be used for result retrieval.

Examples#

Example 1#

In the examples below, db_id is a previously created database id.

// Set SQL statement
sql_statement = "SELECT * FROM GDP WHERE COUNTRY = ?";

// Set bind value
placeholders = "USA";

// Execute query
qid = dbExecQuery(db_id, sql_statement, placeholders);

// Results as a matrix
results = dbQueryFetchAllM(qid);

Example 2#

// Set SQL statement
sql_statement = "INSERT INTO PEOPLE(id, fname, lname) VALUES (NULL, ?, ?);";

// Set bind values
placeholders = "Joe"$|"Smith";

// Execute query
qid = dbExecQuery(db_id, sql_statement, placeholders);

Example 3#

// Set SQL statement
sql_statement = "SELECT * FROM PEOPLE p WHERE p.FNAME = ?";

// Set bind value
placeholders = "Joe";

// Execute query
qid = dbExecQuery(db_id, sql_statement, placeholders);

// Results as a string array
results = dbQueryFetchAllSA(qid);

See also

Functions dbCreateQuery(), dbExecQueries()