Inserting a bitarray value through storedprocedure - Mailing list pgsql-general

From Deepa K
Subject Inserting a bitarray value through storedprocedure
Date
Msg-id 3E7AFB64.F7B07671@midascomm.com
Whole thread Raw
List 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.


pgsql-general by date:

Previous
From: Joshua Moore-Oliva
Date:
Subject: Re: rules problem
Next
From: Georgi Chorbadzhiyski
Date:
Subject: Re: rules problem