Macro substitution in Postgres

From: "Louise Cofield" <lcofield(at)box-works(dot)com>
To: <pgsql-novice(at)postgresql(dot)org>
Subject: Macro substitution in Postgres
Date: 2003-09-10 20:28:48
Message-ID: 000d01c377da$2438bd60$7801a8c0@Louise
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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! :-)

Browse pgsql-novice by date

  From Date Subject
Next Message Bryan Irvine 2003-09-10 20:29:41 Re: phone number list
Previous Message Bruno Wolff III 2003-09-10 20:28:10 Re: phone number list