pg.ddx.io pgsql-sql@postgresql.org mailing list archive
help / color / mirror / Atom feedHow access to array component
5+ messages / 3 participants
[nested] [flat]
* How access to array component
@ 2003-07-18 14:52 Cristian Cappo <ccappo@cnc.una.py>
0 siblings, 2 replies; 5+ messages in thread
From: Cristian Cappo @ 2003-07-18 14:52 UTC (permalink / raw)
To: pgsql-sql
Hello
How access to especific array component
of an function with return type _varchar
declaration of my function:
>>> create or replace __function( int2, int2 ) returns _varchar ....
now use the function in SQL and access to the element 1...
>>> select __function(10::int2, 20::int2)[1]
^^^ parsing error.
Thanks.
Cristian Cappo
-------------
^ permalink raw reply [nested|flat] 5+ messages in thread
* Re: How access to array component
@ 2003-07-20 03:04 Joe Conway <mail@joeconway.com>
parent: Cristian Cappo <ccappo@cnc.una.py>
1 sibling, 0 replies; 5+ messages in thread
From: Joe Conway @ 2003-07-20 03:04 UTC (permalink / raw)
To: Cristian Cappo <ccappo@cnc.una.py>; +Cc: pgsql-sql
Cristian Cappo wrote:
> >>> select __function(10::int2, 20::int2)[1]
> ^^^ parsing error.
>
Try:
create or replace function foo(int2, int2 ) returns _varchar as '
select ''{1,2}''::_varchar
' language 'sql';
regression=# select (foo(10::int2, 20::int2))[1];
foo
-----
1
(1 row)
HTH,
Joe
^ permalink raw reply [nested|flat] 5+ messages in thread
* Re: How access to array component
@ 2003-07-21 19:17 Cristian Cappo A. <ccappo@cnc.una.py>
parent: Cristian Cappo <ccappo@cnc.una.py>
1 sibling, 2 replies; 5+ messages in thread
From: Cristian Cappo A. @ 2003-07-21 19:17 UTC (permalink / raw)
To: Joe Conway <mail@joeconway.com>; +Cc: pgsql-sql
Joe
Tried, but...
>> select (foo(10::int2,20::int2))[1];
>> ERROR: parser: parse error at or near "[" at character 32
I'm using the version 7.3.3
Thanks..
---
> Cristian Cappo wrote:
> > >>> select __function(10::int2, 20::int2)[1]
> > ^^^ parsing error.
> >
>
> Try:
>
> create or replace function foo(int2, int2 ) returns _varchar as '
> select ''{1,2}''::_varchar
> ' language 'sql';
>
> regression=# select (foo(10::int2, 20::int2))[1];
> foo
> -----
> 1
> (1 row)
>
> HTH,
>
> Joe
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 2: you can get off all lists at once with the unregister command
> (send "unregister YourEmailAddressHere" to majordomo@postgresql.org)
------------------------------------
Cristian Cappo Araujo
Desarrollo de Proyectos - Direccion Tecnica
Centro Nacional de Computación
Universidad Nacional de Asunción
email: ccappo@cnc.una.py
tel. : 595-021-585550
fax : 595-021-585619
^ permalink raw reply [nested|flat] 5+ messages in thread
* Re: How access to array component
@ 2003-07-22 05:09 Joe Conway <mail@joeconway.com>
parent: Cristian Cappo A. <ccappo@cnc.una.py>
1 sibling, 0 replies; 5+ messages in thread
From: Joe Conway @ 2003-07-22 05:09 UTC (permalink / raw)
To: Cristian Cappo A. <ccappo@cnc.una.py>; +Cc: pgsql-sql
Cristian Cappo A. wrote:
> Tried, but...
> >> select (foo(10::int2,20::int2))[1];
> >> ERROR: parser: parse error at or near "[" at character 32
>
> I'm using the version 7.3.3
Sorry, it works on 7.4devel, so I thought it might on 7.3 as well. In
any case, this works on 7.3.3:
test=# select f1[1] from (select foo(10::int2, 20::int2) as f1) as ss;
f1
----
1
(1 row)
HTH,
Joe
^ permalink raw reply [nested|flat] 5+ messages in thread
* Re: How access to array component
@ 2003-07-22 14:19 Cristian Cappo A. <ccappo@cnc.una.py>
parent: Cristian Cappo A. <ccappo@cnc.una.py>
1 sibling, 0 replies; 5+ messages in thread
From: Cristian Cappo A. @ 2003-07-22 14:19 UTC (permalink / raw)
To: Joe Conway <mail@joeconway.com>; +Cc: pgsql-sql
Thanks Joe..
------
On 21 Jul 2003 at 22:09, Joe Conway wrote:
> Cristian Cappo A. wrote:
> > Tried, but...
> > >> select (foo(10::int2,20::int2))[1];
> > >> ERROR: parser: parse error at or near "[" at character 32
> >
> > I'm using the version 7.3.3
>
> Sorry, it works on 7.4devel, so I thought it might on 7.3 as well. In
> any case, this works on 7.3.3:
>
> test=# select f1[1] from (select foo(10::int2, 20::int2) as f1) as ss;
> f1
> ----
> 1
> (1 row)
>
> HTH,
>
> Joe
------------------------------------
Cristian Cappo Araujo
Desarrollo de Proyectos - Direccion Tecnica
Centro Nacional de Computación
Universidad Nacional de Asunción
email: ccappo@cnc.una.py
tel. : 595-021-585550
fax : 595-021-585619
^ permalink raw reply [nested|flat] 5+ messages in thread
end of thread, other threads:[~2003-07-22 14:19 UTC | newest]
Thread overview: 5+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2003-07-18 14:52 How access to array component Cristian Cappo <ccappo@cnc.una.py>
2003-07-20 03:04 ` Joe Conway <mail@joeconway.com>
2003-07-21 19:17 ` Cristian Cappo A. <ccappo@cnc.una.py>
2003-07-22 05:09 ` Joe Conway <mail@joeconway.com>
2003-07-22 14:19 ` Cristian Cappo A. <ccappo@cnc.una.py>
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