pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
setof or array as input parameter to postgresql 8.2 functions
8+ messages / 4 participants
[nested] [flat]

* setof or array as input parameter to postgresql 8.2 functions
@ 2007-06-13 11:57 Jyoti Seth <jyotiseth2001@gmail.com>
  2007-06-13 12:55 ` Re: [SQL] setof or array as input parameter to postgresql 8.2 functions Pavel Stehule <pavel.stehule@gmail.com>
  2007-06-13 13:09 ` Re: setof or array as input parameter to postgresql 8.2 functions Albe Laurenz <all@adv.magwien.gv.at>
  0 siblings, 2 replies; 8+ messages in thread

From: Jyoti Seth @ 2007-06-13 11:57 UTC (permalink / raw)
  To: pgsql-general@postgresql.org; pgsql-sql

Hi,

 

I have to pass a set of values and arrays in postgresql 8.2 functions. But I
am not getting any help on that. Please let me know if any one has idea.

 

Thanks,

Jyoti 

^ permalink  raw  reply  [nested|flat] 8+ messages in thread

* Re: [SQL] setof or array as input parameter to postgresql 8.2 functions
  2007-06-13 11:57 setof or array as input parameter to postgresql 8.2 functions Jyoti Seth <jyotiseth2001@gmail.com>
@ 2007-06-13 12:55 ` Pavel Stehule <pavel.stehule@gmail.com>
  2007-06-14 05:47   ` Re: [SQL] setof or array as input parameter to postgresql 8.2 functions Jyoti Seth <jyotiseth2001@gmail.com>
  1 sibling, 1 reply; 8+ messages in thread

From: Pavel Stehule @ 2007-06-13 12:55 UTC (permalink / raw)
  To: Jyoti Seth <jyotiseth2001@gmail.com>; +Cc: pgsql-general@postgresql.org; pgsql-sql

Hello

maybe:

create function foo(varchar[][]) returns void as $$ begin end$$
language plpgsql;

postgres=# select foo(array[array[1,2], array[2,2]]::varchar[][]);
 foo
-----

(1 row)

Regards
Pavel Stehule

2007/6/13, Jyoti Seth <jyotiseth2001@gmail.com>:
>
>
>
>
> Hi,
>
>
>
> I have to pass a set of values and arrays in postgresql 8.2 functions. But I
> am not getting any help on that. Please let me know if any one has idea.
>
>
>
> Thanks,
>
> Jyoti



^ permalink  raw  reply  [nested|flat] 8+ messages in thread

* Re: [SQL] setof or array as input parameter to postgresql 8.2 functions
  2007-06-13 11:57 setof or array as input parameter to postgresql 8.2 functions Jyoti Seth <jyotiseth2001@gmail.com>
  2007-06-13 12:55 ` Re: [SQL] setof or array as input parameter to postgresql 8.2 functions Pavel Stehule <pavel.stehule@gmail.com>
@ 2007-06-14 05:47   ` Jyoti Seth <jyotiseth2001@gmail.com>
  2007-06-14 05:57     ` Re: [SQL] setof or array as input parameter to postgresql 8.2 functions Pavel Stehule <pavel.stehule@gmail.com>
  0 siblings, 1 reply; 8+ messages in thread

From: Jyoti Seth @ 2007-06-14 05:47 UTC (permalink / raw)
  To: 'Pavel Stehule' <pavel.stehule@gmail.com>; +Cc: pgsql-general@postgresql.org; pgsql-sql

Thanks for the solution. With this I am able to pass arrays and
multidimensional arrays in postgresql functions. 

One of my problem is still left I want to pass set of values with different
datatypes.For eg:
I want to pass following values to the function:
1 ajay 1000.12 
2 rita 2300.24
3 leena 1230.78
4 jaya 3432.45

As the values have different data types I have to create three different
arrays. Is there any way with which I can pass this as a single setof
values. 

Thanks,
Jyoti


-----Original Message-----
From: Pavel Stehule [mailto:pavel.stehule@gmail.com] 
Sent: Wednesday, June 13, 2007 6:25 PM
To: Jyoti Seth
Cc: pgsql-general@postgresql.org; pgsql-sql@postgresql.org
Subject: Re: [SQL] setof or array as input parameter to postgresql 8.2
functions

Hello

maybe:

create function foo(varchar[][]) returns void as $$ begin end$$
language plpgsql;

postgres=# select foo(array[array[1,2], array[2,2]]::varchar[][]);
 foo
-----

(1 row)

Regards
Pavel Stehule

2007/6/13, Jyoti Seth <jyotiseth2001@gmail.com>:
>
>
>
>
> Hi,
>
>
>
> I have to pass a set of values and arrays in postgresql 8.2 functions. But
I
> am not getting any help on that. Please let me know if any one has idea.
>
>
>
> Thanks,
>
> Jyoti




^ permalink  raw  reply  [nested|flat] 8+ messages in thread

* Re: [SQL] setof or array as input parameter to postgresql 8.2 functions
  2007-06-13 11:57 setof or array as input parameter to postgresql 8.2 functions Jyoti Seth <jyotiseth2001@gmail.com>
  2007-06-13 12:55 ` Re: [SQL] setof or array as input parameter to postgresql 8.2 functions Pavel Stehule <pavel.stehule@gmail.com>
  2007-06-14 05:47   ` Re: [SQL] setof or array as input parameter to postgresql 8.2 functions Jyoti Seth <jyotiseth2001@gmail.com>
@ 2007-06-14 05:57     ` Pavel Stehule <pavel.stehule@gmail.com>
  2007-06-14 06:04       ` Re: [SQL] setof or array as input parameter to postgresql 8.2 functions Jyoti Seth <jyotiseth2001@gmail.com>
  0 siblings, 1 reply; 8+ messages in thread

From: Pavel Stehule @ 2007-06-14 05:57 UTC (permalink / raw)
  To: Jyoti Seth <jyotiseth2001@gmail.com>; +Cc: pgsql-general@postgresql.org; pgsql-sql

2007/6/14, Jyoti Seth <jyotiseth2001@gmail.com>:
> Thanks for the solution. With this I am able to pass arrays and
> multidimensional arrays in postgresql functions.
>
> One of my problem is still left I want to pass set of values with different
> datatypes.For eg:
> I want to pass following values to the function:
> 1 ajay 1000.12
> 2 rita 2300.24
> 3 leena 1230.78
> 4 jaya 3432.45
>
> As the values have different data types I have to create three different
> arrays. Is there any way with which I can pass this as a single setof
> values.
>
>

You have to wait for 8.3 where arrays on composite types are
supported. Currently in one our application we use array of arrays
where different types are too, and we cast it to text.

Regards
Pavel



^ permalink  raw  reply  [nested|flat] 8+ messages in thread

* Re: [SQL] setof or array as input parameter to postgresql 8.2 functions
  2007-06-13 11:57 setof or array as input parameter to postgresql 8.2 functions Jyoti Seth <jyotiseth2001@gmail.com>
  2007-06-13 12:55 ` Re: [SQL] setof or array as input parameter to postgresql 8.2 functions Pavel Stehule <pavel.stehule@gmail.com>
  2007-06-14 05:47   ` Re: [SQL] setof or array as input parameter to postgresql 8.2 functions Jyoti Seth <jyotiseth2001@gmail.com>
  2007-06-14 05:57     ` Re: [SQL] setof or array as input parameter to postgresql 8.2 functions Pavel Stehule <pavel.stehule@gmail.com>
@ 2007-06-14 06:04       ` Jyoti Seth <jyotiseth2001@gmail.com>
  2007-06-14 07:03         ` Re: [SQL] setof or array as input parameter to postgresql 8.2 functions Manso Gomez, Ramon <rmgomez@indra.es>
  0 siblings, 1 reply; 8+ messages in thread

From: Jyoti Seth @ 2007-06-14 06:04 UTC (permalink / raw)
  To: 'Pavel Stehule' <pavel.stehule@gmail.com>; +Cc: pgsql-general@postgresql.org; pgsql-sql

Thanks a lot.

Regards,
Jyoti

-----Original Message-----
From: Pavel Stehule [mailto:pavel.stehule@gmail.com] 
Sent: Thursday, June 14, 2007 11:27 AM
To: Jyoti Seth
Cc: pgsql-general@postgresql.org; pgsql-sql@postgresql.org
Subject: Re: [SQL] setof or array as input parameter to postgresql 8.2
functions

2007/6/14, Jyoti Seth <jyotiseth2001@gmail.com>:
> Thanks for the solution. With this I am able to pass arrays and
> multidimensional arrays in postgresql functions.
>
> One of my problem is still left I want to pass set of values with
different
> datatypes.For eg:
> I want to pass following values to the function:
> 1 ajay 1000.12
> 2 rita 2300.24
> 3 leena 1230.78
> 4 jaya 3432.45
>
> As the values have different data types I have to create three different
> arrays. Is there any way with which I can pass this as a single setof
> values.
>
>

You have to wait for 8.3 where arrays on composite types are
supported. Currently in one our application we use array of arrays
where different types are too, and we cast it to text.

Regards
Pavel




^ permalink  raw  reply  [nested|flat] 8+ messages in thread

* Re: [SQL] setof or array as input parameter to postgresql 8.2 functions
  2007-06-13 11:57 setof or array as input parameter to postgresql 8.2 functions Jyoti Seth <jyotiseth2001@gmail.com>
  2007-06-13 12:55 ` Re: [SQL] setof or array as input parameter to postgresql 8.2 functions Pavel Stehule <pavel.stehule@gmail.com>
  2007-06-14 05:47   ` Re: [SQL] setof or array as input parameter to postgresql 8.2 functions Jyoti Seth <jyotiseth2001@gmail.com>
  2007-06-14 05:57     ` Re: [SQL] setof or array as input parameter to postgresql 8.2 functions Pavel Stehule <pavel.stehule@gmail.com>
  2007-06-14 06:04       ` Re: [SQL] setof or array as input parameter to postgresql 8.2 functions Jyoti Seth <jyotiseth2001@gmail.com>
@ 2007-06-14 07:03         ` Manso Gomez, Ramon <rmgomez@indra.es>
  2007-06-14 07:41           ` Re: [SQL] setof or array as input parameter to postgresql 8.2 functions Pavel Stehule <pavel.stehule@gmail.com>
  0 siblings, 1 reply; 8+ messages in thread

From: Manso Gomez, Ramon @ 2007-06-14 07:03 UTC (permalink / raw)
  To: pgsql-general@postgresql.org; pgsql-sql

 How can delete my suscription to this forums?

-----Mensaje original-----
De: pgsql-sql-owner@postgresql.org
[mailto:pgsql-sql-owner@postgresql.org] En nombre de Jyoti Seth
Enviado el: jueves, 14 de junio de 2007 8:04
Para: 'Pavel Stehule'
CC: pgsql-general@postgresql.org; pgsql-sql@postgresql.org
Asunto: Re: [SQL] setof or array as input parameter to postgresql 8.2
functions

Thanks a lot.

Regards,
Jyoti

-----Original Message-----
From: Pavel Stehule [mailto:pavel.stehule@gmail.com]
Sent: Thursday, June 14, 2007 11:27 AM
To: Jyoti Seth
Cc: pgsql-general@postgresql.org; pgsql-sql@postgresql.org
Subject: Re: [SQL] setof or array as input parameter to postgresql 8.2
functions

2007/6/14, Jyoti Seth <jyotiseth2001@gmail.com>:
> Thanks for the solution. With this I am able to pass arrays and 
> multidimensional arrays in postgresql functions.
>
> One of my problem is still left I want to pass set of values with
different
> datatypes.For eg:
> I want to pass following values to the function:
> 1 ajay 1000.12
> 2 rita 2300.24
> 3 leena 1230.78
> 4 jaya 3432.45
>
> As the values have different data types I have to create three 
> different arrays. Is there any way with which I can pass this as a 
> single setof values.
>
>

You have to wait for 8.3 where arrays on composite types are supported.
Currently in one our application we use array of arrays where different
types are too, and we cast it to text.

Regards
Pavel


---------------------------(end of broadcast)---------------------------
TIP 4: Have you searched our list archives?

               http://archives.postgresql.org



^ permalink  raw  reply  [nested|flat] 8+ messages in thread

* Re: [SQL] setof or array as input parameter to postgresql 8.2 functions
  2007-06-13 11:57 setof or array as input parameter to postgresql 8.2 functions Jyoti Seth <jyotiseth2001@gmail.com>
  2007-06-13 12:55 ` Re: [SQL] setof or array as input parameter to postgresql 8.2 functions Pavel Stehule <pavel.stehule@gmail.com>
  2007-06-14 05:47   ` Re: [SQL] setof or array as input parameter to postgresql 8.2 functions Jyoti Seth <jyotiseth2001@gmail.com>
  2007-06-14 05:57     ` Re: [SQL] setof or array as input parameter to postgresql 8.2 functions Pavel Stehule <pavel.stehule@gmail.com>
  2007-06-14 06:04       ` Re: [SQL] setof or array as input parameter to postgresql 8.2 functions Jyoti Seth <jyotiseth2001@gmail.com>
  2007-06-14 07:03         ` Re: [SQL] setof or array as input parameter to postgresql 8.2 functions Manso Gomez, Ramon <rmgomez@indra.es>
@ 2007-06-14 07:41           ` Pavel Stehule <pavel.stehule@gmail.com>
  0 siblings, 0 replies; 8+ messages in thread

From: Pavel Stehule @ 2007-06-14 07:41 UTC (permalink / raw)
  To: Manso Gomez, Ramon <rmgomez@indra.es>; +Cc: pgsql-general@postgresql.org; pgsql-sql

visit http://www.postgresql.org/community/lists/subscribe

2007/6/14, Manso Gomez, Ramon <rmgomez@indra.es>:
>  How can delete my suscription to this forums?
>
> -----Mensaje original-----
> De: pgsql-sql-owner@postgresql.org
> [mailto:pgsql-sql-owner@postgresql.org] En nombre de Jyoti Seth
> Enviado el: jueves, 14 de junio de 2007 8:04
> Para: 'Pavel Stehule'
> CC: pgsql-general@postgresql.org; pgsql-sql@postgresql.org
> Asunto: Re: [SQL] setof or array as input parameter to postgresql 8.2
> functions
>
> Thanks a lot.
>
> Regards,
> Jyoti
>
> -----Original Message-----
> From: Pavel Stehule [mailto:pavel.stehule@gmail.com]
> Sent: Thursday, June 14, 2007 11:27 AM
> To: Jyoti Seth
> Cc: pgsql-general@postgresql.org; pgsql-sql@postgresql.org
> Subject: Re: [SQL] setof or array as input parameter to postgresql 8.2
> functions
>
> 2007/6/14, Jyoti Seth <jyotiseth2001@gmail.com>:
> > Thanks for the solution. With this I am able to pass arrays and
> > multidimensional arrays in postgresql functions.
> >
> > One of my problem is still left I want to pass set of values with
> different
> > datatypes.For eg:
> > I want to pass following values to the function:
> > 1 ajay 1000.12
> > 2 rita 2300.24
> > 3 leena 1230.78
> > 4 jaya 3432.45
> >
> > As the values have different data types I have to create three
> > different arrays. Is there any way with which I can pass this as a
> > single setof values.
> >
> >
>
> You have to wait for 8.3 where arrays on composite types are supported.
> Currently in one our application we use array of arrays where different
> types are too, and we cast it to text.
>
> Regards
> Pavel
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 4: Have you searched our list archives?
>
>                http://archives.postgresql.org
>
> ---------------------------(end of broadcast)---------------------------
> TIP 4: Have you searched our list archives?
>
>                http://archives.postgresql.org
>



^ permalink  raw  reply  [nested|flat] 8+ messages in thread

* Re: setof or array as input parameter to postgresql 8.2 functions
  2007-06-13 11:57 setof or array as input parameter to postgresql 8.2 functions Jyoti Seth <jyotiseth2001@gmail.com>
@ 2007-06-13 13:09 ` Albe Laurenz <all@adv.magwien.gv.at>
  1 sibling, 0 replies; 8+ messages in thread

From: Albe Laurenz @ 2007-06-13 13:09 UTC (permalink / raw)
  To: Jyoti Seth *EXTERN* <jyotiseth2001@gmail.com>; pgsql-general@postgresql.org; pgsql-sql

> I have to pass a set of values and arrays in postgresql 8.2 
> functions. But I am not getting any help on that. Please let 
> me know if any one has idea.

Something like this?

CREATE OR REPLACE FUNCTION sample(avalue integer, anarray text[])
   RETURNS void LANGUAGE plpgsql STRICT AS
$$DECLARE
   i integer;
BEGIN
   -- I can access the value
   i := avalue;
   -- I can access the array
   i := anarray[2];
END;$$;

Called like

SELECT sample(3, ARRAY[1, 2, 3]);

Yours,
Laurenz Albe



^ permalink  raw  reply  [nested|flat] 8+ messages in thread


end of thread, other threads:[~2007-06-14 07:41 UTC | newest]

Thread overview: 8+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2007-06-13 11:57 setof or array as input parameter to postgresql 8.2 functions Jyoti Seth <jyotiseth2001@gmail.com>
2007-06-13 12:55 ` Pavel Stehule <pavel.stehule@gmail.com>
2007-06-14 05:47   ` Jyoti Seth <jyotiseth2001@gmail.com>
2007-06-14 05:57     ` Pavel Stehule <pavel.stehule@gmail.com>
2007-06-14 06:04       ` Jyoti Seth <jyotiseth2001@gmail.com>
2007-06-14 07:03         ` Manso Gomez, Ramon <rmgomez@indra.es>
2007-06-14 07:41           ` Pavel Stehule <pavel.stehule@gmail.com>
2007-06-13 13:09 ` Albe Laurenz <all@adv.magwien.gv.at>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox