Initialising bit values inside stored procedure.

Поиск
Список
Период
Сортировка
От HK
Тема Initialising bit values inside stored procedure.
Дата
Msg-id Pine.LNX.4.33.0303211739210.5295-100000@mallard.midascomm.com
обсуждение исходный текст
Список pgsql-novice
hi all,
    I have a table
    privileges (version text, profile text,
                readbits bit[], writebits bit[]);

The readbits and writebits is 4000 bits long.

The operation i am trying to do is.
(eg) insert into privileges (version, profile) values ('ver100', 'prf100');
For version ver100 and profile prf100 the readbits and writebits must have all
bits set to 0.

So i wrote a stored procedure which will update the bitsets.

create function testproc(text,text) returns int as '
declare
version alias for $1;
profile alias for $2;
flatbits text;
count int := 0;

begin
flatbits = ''\\\'{'';
-- for inserting the '{ in the array
while count < 4000
loop
    flatbits = flatbits||''0,'';
    count := count + 1;
end loop;
flatbits = flatbits||''}\\\''';
-- for closing the bit set }'
end;

insert into privileges(version, profile, flatbits, flatbits);

' language 'plpgsql';


When i try to run this as
testdb=# select testproc('ver100', 'prf100');
ERROR: Attribute 'readbits' is of type '_bit' but expression is of type 'text'
You will need to rewrite or cast the expression

Casting the value to bit in stored procedure also doesnt help.
i used
insert into privileges(version, profile, flatbits::bit[], flatbits::bit[]);

ERROR: Cannot case type 'text' to '_bit'

Can anybody help me in this regard.

TIA.
--
regards,
hari
      __
     / /    __  _  _  _  _ __  __         -o)
    / /__  / / / \\// //_// \\ \\/ /         /\\\\  Making things happen
   /____/ /_/ /_/\\/ /___/  /_/\\_\\        _\\_v-


В списке pgsql-novice по дате отправления:

Предыдущее
От: "A.Bhuvaneswaran"
Дата:
Сообщение: Re: table sequence
Следующее
От: Tom Lane
Дата:
Сообщение: Re: age / timestamp