Re: [SQL] distinguishing identical columns after joins
In times like these, I usually write a query using information_schema.columns to generate the column list: SELECT ordinal_position, 1 AS table_instance, 'a.' || column_name || ' AS ' || column_name || '_a,' FROMINFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 'your_table_here' UNION ALL SELECT ordinal_position, 2 AS table_instance, 'b.' || column_name || ' AS ' || column_name || '_b,' FROMINFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 'your_table_here' ORDER BY table_instance, ordinal_position; Or something along those lines, and copy-and-paste the results into the query. It's quicker than typing them all out once you hit a certain number of columns, and certainly less typo-prone. It's not the shortcut you were thinking of but it works. On 3/1/2011 5:13 PM, S G wrote: Rob, what you wrote certainly does work. But suppose you had to do that for a join with 50 columns in each table, and you really needed to see all those columns show up in the final result set, and furthermore, you needed to be able to identify each one uniquely in the final result set. Explicit renaming works, but it's tedious. Call me lazy. I'm hoping a column-renaming shortcut exists that works with the "SELECT *" concept. -- Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-sql
Re: [SQL] statement-level trigger sample out there?
I am curious (coming from a MS SQL Server background, I just started playing with PostgreSQL recently). What type of situation would warrant a statement-level trigger that can't access the old and new values? Without that access, isn't the only information you get is the fact that an operation occurred on the table? Or am I missing something? -- Stephen Pavel Stehule wrote: Hello You cannot to access to values in statement trigger. Postgres doesn't support it. Regards Pavel Stehule On 29/11/2007, Christian Kindler <[EMAIL PROTECTED]> wrote: Hi Can anyone provide me a simple example of a statement-level trigger? Problem is I do not know how to access the old.*, new.* values. Thanks Chris -- GMX FreeMail: 1 GB Postfach, 5 E-Mail-Adressen, 10 Free SMS. Alle Infos und kostenlose Anmeldung: http://www.gmx.net/de/go/freemail ---(end of broadcast)--- TIP 1: if posting/reading through Usenet, please send an appropriate subscribe-nomail command to [EMAIL PROTECTED] so that your message can get through to the mailing list cleanly ---(end of broadcast)--- TIP 1: if posting/reading through Usenet, please send an appropriate subscribe-nomail command to [EMAIL PROTECTED] so that your message can get through to the mailing list cleanly ---(end of broadcast)--- TIP 7: You can help support the PostgreSQL project by donating at http://www.postgresql.org/about/donate