0

When I'm trying to Execute below code

Execute '`create table employee(Empid Serial Primary key, Empname text, Dob Date)`'

I'm getting error

ERROR: syntax error at or near "'create table employee(Empid Serial
Primary key, Empname text, Dob Date)'" LINE 1: Execute 'create table
employee(Empid Serial Primary key, Emp...
^
********** Error **********

ERROR: syntax error at or near "'create table employee(Empid Serial
Primary key, Empname text, Dob Date)'" SQL state: 42601 Character: 9

Please help me out on this.

Ajay Jain
  • 9
  • 1
  • 2
    Which database are you actually using? – Tim Biegeleisen Jun 02 '16 at 05:46
  • Possible duplicate of [dynamic sql query in postgres](http://stackoverflow.com/questions/12780275/dynamic-sql-query-in-postgres) – Shadow Jun 02 '16 at 06:44
  • well error code is from postgres. and syntax is. better tell where you run `execute`?.. in function?.. as plain `SQL`?.. – Vao Tsun Jun 02 '16 at 07:08
  • Actually im new to postgreSQL, In PgAdmin III have a option "Execute arbitary SQL queries", im trying to execute my code there. Im executing there as plain SQL, not in a function. – Ajay Jain Jun 02 '16 at 07:15
  • You don't need "execute" to run a plain SQL statement. Just run that `create table` (and get rid of those backticks) –  Jun 02 '16 at 07:24
  • yeah that is fine. But I have to create this table dynamically as i dont know how many columns could i add at the time of execution. it depends on the other variable. – Ajay Jain Jun 02 '16 at 08:46

0 Answers0