PLPGSQL - extra column existence in trigger

Поиск
Список
Период
Сортировка
От Durumdara
Тема PLPGSQL - extra column existence in trigger
Дата
Msg-id CAEcMXhmO-FjavfjRwf6+sbR-FV_RPyG14gR7H5G+yM3u6J=udg@mail.gmail.com
обсуждение исходный текст
Ответы Re: PLPGSQL - extra column existence in trigger  ("David G. Johnston" <david.g.johnston@gmail.com>)
Re: PLPGSQL - extra column existence in trigger  ("Peter J. Holzer" <hjp-pgsql@hjp.at>)
Список pgsql-general
Hello!

We stored the username in a temporary table which was created by the client app.
With this technique we can log these names in triggers too.

Now we extend it with user id and later the comp name.

Because we can update the client applications slowly, some client's tables have these one or two extra fields, some not.

So in the new trigger we can't load them all with:

select username, userid, usercompname 
   into uname, uid, ucomp from tmp_userauth limit 1;

or 

FOR rec IN 
  select * from tmp_userauth limit 1 ...  IF ColumnExists(rec, 'uid') THEN  --- ????     uid = rec.uid

So what is the best way to load the field values from the table?

Is there any way to know which field exists / avoid error or exception?

select username, getvaluewithouterror(userid, -1)...

So is there any syntax to not fall on missing columns?

Thank you!

Best regards,
   dd

В списке pgsql-general по дате отправления:

Предыдущее
От: Guillaume Lelarge
Дата:
Сообщение: Re: pg_dump: VACUUM and REINDEXING
Следующее
От: Hasan Marzooq
Дата:
Сообщение: Re: pg_dump: VACUUM and REINDEXING