Macro substitution in Postgres - Mailing list pgsql-novice

From Louise Cofield
Subject Macro substitution in Postgres
Date
Msg-id 000d01c377da$2438bd60$7801a8c0@Louise
Whole thread Raw
List pgsql-novice

Greetings -

 

I am trying to create a table, using variables and/or array elements for all required elements of a simple create table statement.  For example, m_array[4][1] holds the value "MyTable", m_array[4][2] holds "col1" m_array[4][3] holds "varchar2", and m_array[4][4] holds "2".

 

I want to be able to create the following: 

"CREATE TABLE" || <value of m_array[1]>  "(" || <value of m_array[2]> || "  "

      || <value of m_array[3] || "(" || <value of m_array[4] || "))"

 

Generated, would be:  "create table MyTable(col1 varchar(2))"

 

Making the macro substitution for the "value of " to work syntactically in the statement that has me scratching my head. 

(The array will be read in a C program, using LIBPQ as the interface.)

 

Thanks!   :-)

pgsql-novice by date:

Previous
From: Bruno Wolff III
Date:
Subject: Re: phone number list
Next
From: Stuart Woodward
Date:
Subject: Re: how many records