Skip site navigation (1) Skip section navigation (2)

how to traverse a bytea value in pl/pgsql

From: "Jules Alberts" <jules(dot)alberts(at)arbodienst-limburg(dot)nl>
To: pgsql-novice(at)postgresql(dot)org
Subject: how to traverse a bytea value in pl/pgsql
Date: 2002-12-18 09:30:26
Message-ID: (view raw, whole thread or download thread mbox)
Lists: 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 '
  TABL alias for $1;
  COLM alias for $2;
  rs RECORD;
  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'';
' 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:


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 by date

Next:From: Jules AlbertsDate: 2002-12-18 10:28:52
Subject: Re: how to traverse a bytea value in pl/pgsql
Previous:From: Tommy ErikssonDate: 2002-12-18 08:31:18
Subject: Default transaction isolation level.

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group