Thread: ESQL CREATE DATABASE

ESQL CREATE DATABASE

From
"Krejci, Pavel"
Date:
Hello,
 
I am using embedded SQL command for creating the database:
 
EXEC SQL BEGIN DECLARE SECTION;
  char dbase[32];
EXEC SQL END DECLARE SECTION;
...
 
 EXEC SQL CONNECT TO postgres;
  //the create database cannot be run in transaction block
 EXEC SQL SET AUTOCOMMIT TO ON;
 
EXEC SQL CREATE DATABASE :dbase;
I get an error during compile with ecpg (/usr/bin/ecpg -I../../include -c source_file.ec)
ERROR: syntax error at or near ":dbase"
*** Error code 3
When I use literal string like: "EXEC SQL CREATE DATABASE my_dbase;" it is compilable and it works.
 
All other SQL commands work with the variables except for the CREATE DATABASE.
 
I am using the package postgresql-devel-8.1.3-12.
 
 
Any idea?
 
Thank you!
 
Pavel Krejci