View Single Post

   
  #4 (permalink)  
Old 04-09-2008, 01:21 PM
Richard Huxton
 
Posts: n/a
Default Re: plpgsql and arrays

Artis Caune wrote:
> Thanks a lot!
> Normal upper/lower loop works fine:
>
>
> CREATE OR REPLACE FUNCTION add_user( VARCHAR(128)[] ) RETURNS SMALLINT


I'd rename the function "add_users()"

> AS $$
> DECLARE
> v_uid SMALLINT;
> v_low SMALLINT;
> v_upp SMALLINT;
> empty BOOLEAN := TRUE;
> BEGIN
> SELECT INTO v_low array_lower($1,1);
> SELECT INTO v_upp array_upper($1,1);


You can also write this:
v_low := array_lower($1,1);

--
Richard Huxton
Archonet Ltd

---------------------------(end of broadcast)---------------------------
TIP 9: In versions below 8.0, the planner will ignore your desire to
choose an index scan if your joining column's datatypes do not
match

Reply With Quote