DSQL API Limitations for Database Creation
Go Up to DSQL API Limitations
To create a new database in an API application:
- 1. Detach from any currently attached databases with
isc_detach_database
(). Detaching from a database automatically sets its database handle toNULL
. - 2. Build the
CREATE DATABASE
statement to process. - 3. Execute the statement with
isc_dsql_execute_immediate()
orisc_dsql_exec_immed2
().
For example, the following statements disconnect from any currently attached databases, and create a new database. Any existing database handles are set to NULL, so that they can be used to connect to the new database in future DSQL statements.
char *str = "CREATE DATABASE \"new_emp.ib\""; . . . isc_detach_database(status_vector, &db1); isc_dsql_execute_immediate(status_vector, &db1, &trans, 0, str, 1, NULL);