Re: [GENERAL] bytea question

2009-09-28 Thread Stephan Szabo
On Mon, 28 Sep 2009, Maximilian Tyrtania wrote: > testdb=# create table byteatest(blob bytea); > CREATE TABLE > testdb=# insert into byteatest (blob) values (E'\\007'); > INSERT 0 1 > testdb=# insert into byteatest (blob) values (E'\\008'); > ERROR: invalid input syntax for type bytea > LINE 1: i

[GENERAL] bytea question

2009-09-28 Thread Maximilian Tyrtania
PG 8.4.0 running on Mac OS 10.6.1 Could anyone tell me why the bytea datatypes seems to like some bytes better than others? testdb=# create table byteatest(blob bytea); CREATE TABLE testdb=# insert into byteatest (blob) values (E'\\007'); INSERT 0 1 testdb=# insert into byteatest (blob) values (E

Re: [GENERAL] Bytea question with \208

2007-08-17 Thread Lew
Decibel! wrote: On Thu, Aug 09, 2007 at 04:16:15PM -0400, Woody Woodring wrote: My bad, the table I was looking (8.7) at had the first column as the decimal representation and I did notice that the numbers changed as they moved right. Is there a way for bytea to take a hex number, or do I need

Re: [GENERAL] Bytea question with \208

2007-08-09 Thread Decibel!
or do I need to convert the > bit stream to octal numbers? to_hex()? > -Original Message- > From: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED] On Behalf Of Tom Lane > Sent: Thursday, August 09, 2007 2:14 PM > To: Woody Woodring > Cc: pgsql-general@postgresql.org > Sub

Re: [GENERAL] Bytea question with \208

2007-08-09 Thread Woody Woodring
-Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Tom Lane Sent: Thursday, August 09, 2007 2:14 PM To: Woody Woodring Cc: pgsql-general@postgresql.org Subject: Re: [GENERAL] Bytea question with \208 "Woody Woodring" <[EMAIL PROTECTED]> writes:

Re: [GENERAL] Bytea question with \208

2007-08-09 Thread Tom Lane
"Woody Woodring" <[EMAIL PROTECTED]> writes: > Could someone explain why \208 is not a valid syntax for bytea? Aren't those escapes octal? regards, tom lane ---(end of broadcast)--- TIP 5: don't forget to increase your free

[GENERAL] Bytea question with \208

2007-08-09 Thread Woody Woodring
Could someone explain why \208 is not a valid syntax for bytea? I am getting the following: test=> select E'\\207'::bytea; bytea --- \207 (1 row) test=> select E'\\208'::bytea; ERROR: invalid input syntax for type bytea test=> select E'\\209'::bytea; ERROR: invalid input syntax for type

Re: [GENERAL] bytea question

2000-08-15 Thread mjp
Oops! You have to write a function for it. Here is a sample quick C function: typedef struct { int len; char data[1]; } string; string *byteatostr(bytea *arg) { char buf[1024]; int ln,i; string *res; ln = VARSIZE(arg) - VARHDRSZ; memmove(buf, VARDAT

Re: [GENERAL] bytea question

2000-08-15 Thread mjp
Oops! You have to write a function for it. Here is a sample quick C function: typedef struct { int len; char data[1]; } string; string *byteatostr(bytea *arg) { char buf[1024]; int ln,i; string *res; ln = VARSIZE(arg) - VARHDRSZ; memmove(buf, VARDATA

Re: [GENERAL] bytea question

2000-08-15 Thread Stephan Szabo
Well, I don't think you're going to be able to without resorting to something other than straight sql (a c function would probably work). You can get the value of a particular byte using get_byte(bytea,int) but I can't think of a good way outside of some sort of function to turn that into a split

Re: [GENERAL] bytea question

2000-08-15 Thread mikeo
thanks anyway but that doesn't work. i should've mentioned that i'd already tried that in SQL. my apologies. tig4=# \d x Table "x" Attribute | Type | Modifier ---+---+-- tgargs| bytea | tig4=# select substr(tgargs,1,5) from x; ERROR: Function 'substr(by

Re: [GENERAL] bytea question

2000-08-15 Thread mjp
Try substr(text,int4) or substr(text, int4, int4) For example, % select substr('hi there',4,3); substr the (1 row) Morey Parang ORNL On Tue, Aug 15, 2000 at 03:34:27PM -0400, mikeo wrote: > hi all, >in the pg_trigger table the tgargs column is defined > as type "BYTEA". i ca

[GENERAL] bytea question

2000-08-15 Thread mikeo
hi all, in the pg_trigger table the tgargs column is defined as type "BYTEA". i can split this up in perl, once retrieved, but can't figure out how to "substring" it in sql. is there an SQL way to select pieces of a column of this type? any help is appreciated, mikeo