A View to Share

From: <btober(at)seaworthysys(dot)com>
To: <pgsql-general(at)postgresql(dot)org>
Subject: A View to Share
Date: 2003-06-18 20:29:25
Message-ID: 65143.216.238.112.88.1055968165.squirrel@$HOSTNAME
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

This is an a view I have found somewhat useful in helping partially
automate definition of functions during database design and testing:

CREATE VIEW public.function_elements AS
SELECT
pg_catalog.pg_class.relname,
pg_attribute.attname,
typname,
pg_attribute.attnum,
cast('l_'||pg_attribute.attname as varchar) as local_variable_name,
cast('l_'||pg_attribute.attname||' ALIAS FOR $'||btrim(TO_CHAR(attnum,
'999;')) as varchar) as local_alias_declaration,
cast(pg_attribute.attname||' = l_'||pg_attribute.attname as varchar) as
equality_expression
FROM pg_attribute LEFT JOIN pg_type ON pg_type.oid =
pg_attribute.atttypid, pg_catalog.pg_class
WHERE pg_catalog.pg_attribute.attrelid = pg_class.oid
AND pg_catalog.pg_attribute.attstattarget <> 0
ORDER BY
pg_catalog.pg_class.relname,
pg_catalog.pg_attribute.attnum

~Berend Tober

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Bob Powell 2003-06-18 20:32:57 How indexes are updated
Previous Message Paul Thomas 2003-06-18 20:18:36 Re: Allowing user to connect to a database?