Pro. Regarding Arrays. - Mailing list pgsql-general

From Pankaj Soni
Subject Pro. Regarding Arrays.
Date
Msg-id F22YILoygXLsxpTljBO0000061b@hotmail.com
Whole thread Raw
List pgsql-general
Hello All,

I am Working on pgsqls user defined arrays.
if i am using arrays as l-value then '[]' doesnt give any error
but if i am trying to assign some value to any element of the array
then it gives error.
the function i am using as follows...


CREATE TYPE int_array_t (
   INPUT = array_in,
   OUTPUT = array_out,
   INTERNALLENGTH = VARIABLE,
   ELEMENT = int4
);


create function test_int_array()
returns int4 as

'declare
   array_input       int_array_t;
   count             int4;


begin
-- Initialize
   count := 0;
   array_input := ''{1, 2, 3}'';

   while array_input[count + 1] IS NOT NULL
   loop
      count := count + 1;
      count := array_input[count];
   end loop;

   return count;
end;'
/*
  if i use array_input[Count]:=Count; then it gives compilation error

NOTICE:  plpgsql: ERROR during compile of test_int_array near line 15
ERROR:  parse error at or near "["
*/

Please guide me
Thanks
Pankaj

language 'plpgsql';



_________________________________________________________________________
Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com.

Share information about yourself, create your own public profile at
http://profiles.msn.com.


pgsql-general by date:

Previous
From: Tom Lane
Date:
Subject: Re: Transaction, Rollback and Database Corruption question,
Next
From: Tom Lane
Date:
Subject: Re: [HACKERS] Enum type emulation: problem with opaque type in PL/pgSQL functions