using 'for each' record in a table

General

using 'for each' record in a table

Hi,

I've been failing in executing a complicated select which joins two large tables. When tried to execute it for a specific record of the first table, it runs perfectly and fast. I tried to collect statistics and use all other, known to me, optimizing methods, with no success.

Is there a way, as part of a regular query (if not, then as part of a stored procedure) to use a 'for each' logic?
If I could run through each row on the first table, and for each execute the query, my problem would be solved.

thanks,

Ido.

Tags (1)
1 REPLY
Junior Contributor

Re: using 'for each' record in a table

The only 'for each' in SQL is a cursor, which is usually considered as evil.

To get help you have to post more info:
What means 'failing'?
What's your actual query plus DDL and explain

Dieter