Re: [SQL] Desc Commnad in pgsql?

2008-04-20 Thread TJ O'Donnell

I like the table and other info from psql
and find I sometimes need that info in my client programs.
Are there any SQL/plpgsql functions that are analogous
to the psql \dt, \ds, etc. commands?
For example
create function d_table(table_name text) returns setof record
that could be used in SQL commands in client programs?
I am not concerned whether these are compatible with other
RDBMS.

TJ O'Donnell
http://www.gnova.com



If you're looking for ways to "describe" a table, there are two
mechanisms:

  1.  SQL standard (probably SQL:1993) describes an
  "information_schema" which contains tables or views that allow
  querying database metadata in a fairly standard fashion.

  PostgreSQL supports that.

  2.  Probably easier and friendlier, albeit nonportable, is to use
  the psql "\d" command.


> >>

For instance:
\dt will list all tables
\ds will list all sequences
\dv will list all views
and there's a further cast of ~20 variants for various different sorts
of objects.



--
Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-sql


[SQL] Error: could not find pathkey item to sort

2008-04-20 Thread Theerasak Maneeneim

Hi Everyone,

  I had some problem with postgresql 8.3.1. I had got an error 
message, ERROR:  could not find pathkey item to sort, when

I use this query statement:

  SELECT   INTO   wk_fcstrec_dt   DISTINCT  MAX(fcstrec_dt) 
FROM a_cusfcst   
 WHERE

  cscd = '2203'
  ANDcs_partno = '35732SSA'
  ANDdelipnt_no = '001'
  ANDplantcd_no = '003'
  ANDlocatto = trim(both FROM 'SS')
  ANDfcstrec_dt < '20080910'
  ANDlatest_flg = 'N';


  I have not ever seen the error in version 8.1 and 8.2. Now, I 
have already revised my program by removed the word "DISTINCT" but I 
want to know what is cause of this error. Could you please to explain to me?


Thank you very much.

--
Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-sql