how to traverse a bytea value in pl/pgsql
От | Jules Alberts |
---|---|
Тема | how to traverse a bytea value in pl/pgsql |
Дата | |
Msg-id | 200212180930.gBI9UYbH025680@artemis.cuci.nl обсуждение исходный текст |
Ответы |
Re: how to traverse a bytea value in pl/pgsql
Re: how to traverse a bytea value in pl/pgsql |
Список | pgsql-novice |
Hello everyone, I'm working on a function that will give me the table + column another table + column is referenced to. The function looks like this: --------------------------------------------------------- create function getreftable(text, text) returns text as ' declare TABL alias for $1; COLM alias for $2; rs RECORD; begin for rs in select tgnargs, tgargs from pg_trigger join pg_class on tgrelid=pg_class.oid where tgisconstraint = true and relname = TABL loop -- check out tgargs end loop; return ''FIXME''; end; ' language 'plpgsql' --------------------------------------------------------- The selection works fine, but now I have to find a way to traverse tgargs. It's of the datatype "bytea" (which sounds C-ish, but I'm not a C programmer) and has a value like: <unnamed>\000cust\000land\000UNSPECIFIED\000land\000code I'm looking for something like this (in a sort of semi-code): SEPERATOR := ''\000''; FOR (i := 1; i <= rs.tgnargs; i++) { raise notice ''%'', byteaslice(rs.tgargs, SEPERATOR, i); } I experimented with functions like byteacat(), strpos(), substr() etc., but none does what I want. Can anybody tell me how to do this? Thanks a lot IA!
В списке pgsql-novice по дате отправления: