A View to Share - Mailing list pgsql-general

From
Subject A View to Share
Date
Msg-id 65143.216.238.112.88.1055968165.squirrel@$HOSTNAME
Whole thread Raw
List 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




pgsql-general by date:

Previous
From: Paul Thomas
Date:
Subject: Re: Allowing user to connect to a database?
Next
From: "Bob Powell"
Date:
Subject: How indexes are updated