Обсуждение: field defaults

Поиск
Список
Период
Сортировка

field defaults

От
Peter Childs
Дата:
I need a method of getting the column defaults out of my database. 
I would like to use them to fill in a screen so the user can then edit 
them before they insert the record.Looking at how psql does this it does not seam very easy. I think a view of the
releventsystem table should help. 
 
any ideas?

Peter Childs



Re: field defaults

От
"A.Bhuvaneswaran"
Дата:
>     I need a method of getting the column defaults out of my database. 
> I would like to use them to fill in a screen so the user can then edit 
> them before they insert the record.
>     Looking at how psql does this it does not seam very easy. 
>     I think a view of the relevent system table should help. 

pg_attrdef.adsrc must help you.

regards,
bhuvaneswaran



Re: field defaults

От
Peter Eisentraut
Дата:
Peter Childs writes:

>     I need a method of getting the column defaults out of my database.
> I would like to use them to fill in a screen so the user can then edit
> them before they insert the record.
>     Looking at how psql does this it does not seam very easy.
>     I think a view of the relevent system table should help.

Well, the default expressions are stored in the system table pg_attrdef,
but note that they are expressions.  Even if you could evaluate those
expressions yourself the results won't be the same as letting the database
evaluate them, because the data that the default expressions refer to
might have changed between the time you've read them and the time you're
inserting the data.

If you insist on this user interface you described, maybe it's better to
save your defaults somewhere else.

-- 
Peter Eisentraut   peter_e@gmx.net