Inserting a bitarray value through storedprocedure

From: Deepa K <kdeepa(at)midascomm(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Inserting a bitarray value through storedprocedure
Date: 2003-03-21 11:45:40
Message-ID: 3E7AFB64.F7B07671@midascomm.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hi all,
I need to insert a bit array value into a table through
storedprocedure. The bit array value need to be formed dyanamically,
since its very big value.
I tried in the following manner.

create function testProc(text,text,integer) returns integer as '

DECLARE
verNum alias for $1;
profileName alias for $2;
appNum alias for $3;
count int := 0;
privilegeRow diuflatnumprivileges%rowtype;
flatNumArr text;
APPLICATIONS_INSERTED int2 := 0;

begin
select into privilegeRow * from diuflatnumprivileges where
diuprofilename = profileName and diuversionnumber = verNum;

if not found then
flatNumArr = ''\\\'{'';
while count < 4000
loop
if count != 3999 then
flatNumArr = flatNumArr||''0,'';
else
flatNumArr = flatNumArr||''0'';
end if;
count := count + 1;
end loop;
flatNumArr = flatNumArr||''}\\\''';
insert into diuflatnumprivileges values (verNum,
profileName,flatNumArr,flatNumArr);
end if;
return APPLICATIONS_INSERTED;
end;
' language 'plpgsql';

When I try to select the above storedprocedure, I am getting the
following error

testdb=# select testproc('ver1','profile1',1);
ERROR: Attribute 'diureadprivileges' is of type '_bit' but expression
is of type 'text'
You will need to rewrite or cast the expression

How to insert a dyanamically created value as bit array through stored
procedure. And also when I try to print the value (flatNumArr) using
raise notice, the backend closed abrubtly. What could be the possible
reason for this. Can any one help me.

Very urgent.

regards,
Deepa K.

Browse pgsql-general by date

  From Date Subject
Next Message James Gregory 2003-03-21 11:53:15 Re: Very stupid backup I made
Previous Message Michal Adamczak 2003-03-21 11:28:24 constraint function, newbie