![]() ![]() LEFT JOIN pg_catalog.pg_attrdef d ON (a.attrelid, a.attnum)ĪND a.attrelid = qualified_name::regclassĪLTER FUNCTION lumn_default (qualified_name text, column_name text) OWNER TO user_bender SELECT d.adsrc AS default_value - A human-readable representation of the default value, already typed as text. I've wrapped it up and figured I'd add it to the archives: CREATE OR REPLACE FUNCTION lumn_default (qualified_name text, column_name text) I saw a mention of wanting to have Erwin Brandstetter's code as a function. I wanted to get the default value for a column and ran into this thread. I'm assuming the names and such come back from the days when letters had to be carved individually and were, consequently, very expensive -) Anyway, that's all a fact of life. I'm spending some time trying to get to grips with the pg_catalog tables. The other thing to watch out for is any TRIGGER AFTER/BEFORE INSERT which will fire even though the INSERT gets rolled back (I think any changes the trigger function makes will get rolled back though.) It likely does not matter so long as it is unique if it is just a table index. One thing to note here is that any SERIAL columns will get incremented. INSERT INTO mytable DEFAULT VALUES RETURNING * So I went back to what I was doing before: BEGIN I bet Erwin can figure out some magical way to EVAL() the returned value and use the a.atttypid column to get the right data type. replace(/.*/, '') which is not robust enough. I could not think of a good way to remove the cast suffix without doing something like. 'I am default'::character varying which did not work when they are being stuffed into web form input values.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |