pg.ddx.io  pgsql-php@postgresql.org mailing list archive  
help / color / mirror / Atom feed
how to get the field types of a(n empty) table?
3+ messages / 2 participants
[nested] [flat]

* how to get the field types of a(n empty) table?
@ 2001-10-20 17:59 knut.suebert@web.de
  2001-10-22 15:59 ` Re: how to get the field types of a(n empty) table? Papp Gyozo <pgerzson@freestart.hu>
  0 siblings, 1 reply; 3+ messages in thread

From: knut.suebert@web.de @ 2001-10-20 17:59 UTC (permalink / raw)
  To: pgsql-php

Hello,

is there a possibility to get the field types of an empty table?

I made a class for editing tables in a html form. The data is inserted
or updated by something like

  "update $table set $row='$DATA'::$ftype[$row] where oid=$oid"

The type of the fields is gotten by a "select $rows from $table limit
1" -- but this is only possible, if there is at least one row inside a
table (for an "insert", "update" is no problem, of course).

It should be possible by reading something out of the postgres' system
tables, but I didn't found it.

Thank in advance,
Knut Sübert



^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: how to get the field types of a(n empty) table?
  2001-10-20 17:59 how to get the field types of a(n empty) table? knut.suebert@web.de
@ 2001-10-22 15:59 ` Papp Gyozo <pgerzson@freestart.hu>
  2001-10-26 17:28   ` Re: how to get the field types of a(n empty) table? knut.suebert@web.de
  0 siblings, 1 reply; 3+ messages in thread

From: Papp Gyozo @ 2001-10-22 15:59 UTC (permalink / raw)
  To: pgsql-php; knut.suebert@web.de

If you runs psql with -E option, then psql reveals the SQL equivalent of its
magical metacommands starting with a backslash ie.: \dv \d and so on.
Use those queries to get the columns' types!

<manual src="app-psql.html">
-E, --echo-hidden
Echoes the actual queries generated by \d and other backslash commands. You
can use this if you wish to include similar functionality into your own
programs. This is equivalent to setting the variable ECHO_HIDDEN from within
psql.
</manual>

----- Original Message -----
From: <knut.suebert@web.de>
To: <pgsql-php@postgresql.org>
Sent: Saturday, October 20, 2001 7:59 PM
Subject: [PHP] how to get the field types of a(n empty) table?


Hello,

is there a possibility to get the field types of an empty table?

I made a class for editing tables in a html form. The data is inserted
or updated by something like

  "update $table set $row='$DATA'::$ftype[$row] where oid=$oid"

The type of the fields is gotten by a "select $rows from $table limit
1" -- but this is only possible, if there is at least one row inside a
table (for an "insert", "update" is no problem, of course).

It should be possible by reading something out of the postgres' system
tables, but I didn't found it.

Thank in advance,
Knut Sübert

---------------------------(end of broadcast)---------------------------
TIP 1: subscribe and unsubscribe commands go to majordomo@postgresql.org





^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: how to get the field types of a(n empty) table?
  2001-10-20 17:59 how to get the field types of a(n empty) table? knut.suebert@web.de
  2001-10-22 15:59 ` Re: how to get the field types of a(n empty) table? Papp Gyozo <pgerzson@freestart.hu>
@ 2001-10-26 17:28   ` knut.suebert@web.de
  0 siblings, 0 replies; 3+ messages in thread

From: knut.suebert@web.de @ 2001-10-26 17:28 UTC (permalink / raw)
  To: pgsql-php

Papp Gyozo schrieb:
> If you runs psql with -E option, then psql reveals the SQL equivalent of its
> magical metacommands starting with a backslash ie.: \dv \d and so on.
> Use those queries to get the columns' types!

That doesn't work from php (at least with the settings here) -- but
turning on the debug mode and reading the syslog put me on the way to 

	SELECT a.attname, format_type(a.atttypid, a.atttypmod)
	FROM pg_class c, pg_attribute a
	WHERE c.relname = 'tabname'
	AND a.attnum > 0 AND a.attrelid = c.oid
	ORDER BY a.attnum

Thanks,
Knut Sübert



^ permalink  raw  reply  [nested|flat] 3+ messages in thread


end of thread, other threads:[~2001-10-26 17:28 UTC | newest]

Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2001-10-20 17:59 how to get the field types of a(n empty) table? knut.suebert@web.de
2001-10-22 15:59 ` Papp Gyozo <pgerzson@freestart.hu>
2001-10-26 17:28   ` knut.suebert@web.de

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox