pg.ddx.io pgsql-sql@postgresql.org mailing list archive
help / color / mirror / Atom feedSQL equivalent to nested loop
4+ messages / 3 participants
[nested] [flat]
* SQL equivalent to nested loop
@ 2005-06-06 16:52 Markus Bertheau ☭ <twanger@bluetwanger.de>
0 siblings, 0 replies; 4+ messages in thread
From: Markus Bertheau ☭ @ 2005-06-06 16:52 UTC (permalink / raw)
To: pgsql-sql
Hi,
I basically need the SQL equivalent of the following pseudo code:
BEGIN
FOR v IN SELECT * FROM f(4, 'foo') LOOP
FOR w IN SELECT * FROM f(v.id, 'bar') LOOP
RETURN NEXT W
END LOOP;
END LOOP;
RETURN;
Is that possible in SQL?
Markus
--
Markus Bertheau ☭ <twanger@bluetwanger.de>
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: SQL equivalent to nested loop
@ 2005-06-06 18:08 KÖPFERL Robert <robert.koepferl@sonorys.at>
2005-06-06 23:16 ` Re: SQL equivalent to nested loop Markus Bertheau <twanger@bluetwanger.de>
0 siblings, 1 reply; 4+ messages in thread
From: KÖPFERL Robert @ 2005-06-06 18:08 UTC (permalink / raw)
To: 'Markus Bertheau ?' <twanger@bluetwanger.de>; pgsql-sql
This is basicly a Join, a cross table
i.e.
select b.w from table a, table b where ...
|-----Original Message-----
|From: twanger@bluetwanger.de [mailto:twanger@bluetwanger.de]
|Sent: Montag, 06. Juni 2005 18:53
|To: pgsql-sql@postgresql.org
|Subject: [SQL] SQL equivalent to nested loop
|
|
|Hi,
|
|I basically need the SQL equivalent of the following pseudo code:
|
|BEGIN
|FOR v IN SELECT * FROM f(4, 'foo') LOOP
| FOR w IN SELECT * FROM f(v.id, 'bar') LOOP
| RETURN NEXT W
| END LOOP;
|END LOOP;
|RETURN;
|
|Is that possible in SQL?
|
|Markus
|
|--
|Markus Bertheau ☭ <twanger@bluetwanger.de>
|
|
|---------------------------(end of
|broadcast)---------------------------
|TIP 7: don't forget to increase your free space map settings
|
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: SQL equivalent to nested loop
2005-06-06 18:08 Re: SQL equivalent to nested loop KÖPFERL Robert <robert.koepferl@sonorys.at>
@ 2005-06-06 23:16 ` Markus Bertheau <twanger@bluetwanger.de>
0 siblings, 0 replies; 4+ messages in thread
From: Markus Bertheau @ 2005-06-06 23:16 UTC (permalink / raw)
To: KÖPFERL Robert <robert.koepferl@sonorys.at>; +Cc: pgsql-sql
Dnia 06-06-2005, pon o godzinie 20:08 +0200, KÖPFERL Robert napisał(a):
> This is basicly a Join, a cross table
>
> i.e.
>
> select b.w from table a, table b where ...
You'd hope that. The problem is that you don't have the tables and
afterwards specify the join condition, but in specifying the tables
(=calling the function) you have the join condition already. I can't
figure out the right syntax. What are you proposing?
SELECT * from f(4, 'foo') as b, f(b.int, 'bar')?
oocms=# select * from object_get_list_of_reference_property(311,
'Themen') as b, object_get_list_of_reference_property(b.object_id,
'Objekte');
ERROR: ?????????????? ????????? ??
FROM ?? ????? ????????? ?? ?????? ????????? ?? ??? ?? ?????? ???????
I can't get an english error message atm :/, but that doesn't work.
Markus
--
Markus Bertheau <twanger@bluetwanger.de>
Attachments:
signature.asc (application/pgp-signature, 188B) download
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: SQL equivalent to nested loop
@ 2005-06-07 08:58 KÖPFERL Robert <robert.koepferl@sonorys.at>
0 siblings, 0 replies; 4+ messages in thread
From: KÖPFERL Robert @ 2005-06-07 08:58 UTC (permalink / raw)
To: pgsql-sql
Instead of tablenames just use functions (tablefunctions)
like my example
select a."Id", a."Code" from "GetLanguages"() a, "GetLanguages"() b
"2","en"
"2","en"
"1","de"
"1","de"
|-----Original Message-----
|From: Markus Bertheau [mailto:twanger@bluetwanger.de]
|Sent: Dienstag, 07. Juni 2005 01:17
|To: KÖPFERL Robert
|Cc: pgsql-sql@postgresql.org
|Subject: RE: [SQL] SQL equivalent to nested loop
|
|
|Dnia 06-06-2005, pon o godzinie 20:08 +0200, KÖPFERL Robert napisał(a):
|> This is basicly a Join, a cross table
|>
|> i.e.
|>
|> select b.w from table a, table b where ...
|
|You'd hope that. The problem is that you don't have the tables and
|afterwards specify the join condition, but in specifying the tables
|(=calling the function) you have the join condition already. I can't
|figure out the right syntax. What are you proposing?
|
|SELECT * from f(4, 'foo') as b, f(b.int, 'bar')?
|
|oocms=# select * from object_get_list_of_reference_property(311,
|'Themen') as b, object_get_list_of_reference_property(b.object_id,
|'Objekte');
|ERROR: ?????????????? ????????? ??
|FROM ?? ????? ????????? ?? ?????? ????????? ?? ??? ?? ?????? ???????
|
|I can't get an english error message atm :/, but that doesn't work.
|
|Markus
|
|--
|Markus Bertheau <twanger@bluetwanger.de>
|
^ permalink raw reply [nested|flat] 4+ messages in thread
end of thread, other threads:[~2005-06-07 08:58 UTC | newest]
Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2005-06-06 16:52 SQL equivalent to nested loop Markus Bertheau ☭ <twanger@bluetwanger.de>
2005-06-06 18:08 Re: SQL equivalent to nested loop KÖPFERL Robert <robert.koepferl@sonorys.at>
2005-06-06 23:16 ` Markus Bertheau <twanger@bluetwanger.de>
2005-06-07 08:58 Re: SQL equivalent to nested loop KÖPFERL Robert <robert.koepferl@sonorys.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