[SQL] MD5 sums of large objects

2007-04-08 Thread Dirk Jagdmann
Hello all together, I have a database containing lots of large objects. Now I'd like to compare large objects in my database and I thought of having a function which creates a hashsum (MD5, SHA-1 or whatever) of my large object, so I can use that in queries: create function lo_md5(id oid) return

Re: [SQL] MD5 sums of large objects

2007-04-08 Thread Michael Fuhr
On Sun, Apr 08, 2007 at 07:03:17PM +0200, Dirk Jagdmann wrote: > I have a database containing lots of large objects. Now I'd like to > compare large objects in my database and I thought of having a > function which creates a hashsum (MD5, SHA-1 or whatever) of my large > object, so I can use that i

[SQL] Question on pgpsql function

2007-04-08 Thread Karthikeyan Sundaram
Hi Everybody, I am using Postgres 8.1.0 and I have a requirement. I have a table create table weekly_tbl (id int, week_flag bit(7) not null default '111'); I want to create a function like this create function week_func (int) returns weekly_tbl as $$ select id, s

Re: [SQL] Question on pgpsql function

2007-04-08 Thread Adrian Klaver
On Sunday 08 April 2007 12:47 pm, Karthikeyan Sundaram wrote: > Hi Everybody, > >I am using Postgres 8.1.0 and I have a requirement. > > I have a table > > create table weekly_tbl (id int, week_flag bit(7) not null default > '111'); > > I want to create a function like this > > create fu

Re: [SQL] [ADMIN] Question on pgpsql function

2007-04-08 Thread Tom Lane
Karthikeyan Sundaram <[EMAIL PROTECTED]> writes: > I am getting an error message > ERROR: function substr(bit, integer, integer) does not existHINT: No func= > tion matches the given name and argument types. You may need to add explici= > t type casts.CONTEXT: SQL function "week_func" I think

Re: [SQL] MD5 sums of large objects

2007-04-08 Thread Dirk Jagdmann
Hello Michael, this works like charm. Although I did fix the argument for lo_lseek: CREATE OR REPLACE FUNCTION md5(id oid) RETURNS text as $$ DECLARE fdinteger; size integer; hashval text; INV_READ constant integer := 262144; -- 0x4 from libpq-fs.h SEEK_SET constant int

Re: [SQL] MD5 sums of large objects

2007-04-08 Thread Michael Fuhr
On Mon, Apr 09, 2007 at 02:07:16AM +0200, Dirk Jagdmann wrote: > this works like charm. Although I did fix the argument for lo_lseek: Oops; thanks for fixing that. > INV_READ constant integer := 262144; -- 0x4 from libpq-fs.h You could also use a hex constant (the cast to integer is necess

[SQL] Another question in functions

2007-04-08 Thread Karthikeyan Sundaram
Hi team, I have a requirement like this. create table valid_lovs (code_id int not null,lov_value int not null ,description varchar(256),status bit(1) not null default '1',constraint lov_pk primary key (code_id,lov_value)); insert into valid_lovs (code_id,lov_value,description) values (1

[SQL] new idea

2007-04-08 Thread sql4-en.narod.ru
Let me know your opinion about next way of processing and extracting data. This would very comfortable for delivery xml-data into any program, for example into browser. Has this idea future ? What are you think ? 1. For exaple, you create SET: create table a ( id num primary key; data