Skip to Content
0
Former Member
May 06, 2008 at 08:08 PM

Effective Single Query...

33 Views

Hi All,

I have a need to combine multiple queries into single and declare it as cursor. This would minimize the complexities in defing cursor for a BI Extractor. These queries are on the same table but with deifferent selection condition. COuld anyone combine and give a single query and how it can be done?

1. SELECT PERNR USRID FROM PA0105 WHERE SUBTY = '0001'.

2. SELECT PLANS FROM PA0001 WHERE PERNR = PERNR from Step 1.

3. SELECT SOBID FROM HRP1001 WHERE OTYPE = 'S' AND

PLVAR = '01' AND

RSIGN = 'A' AND

RELAT = '003' AND

SCLAS = 'O' AND

OBJID = PLANS from step 2.

4. SELECT SOBID FROM HRP1001 WHERE OTYPE = 'S' AND

PLVAR = '01' AND

RSIGN = 'A' AND

RELAT = '003' AND

SCLAS = 'O' AND

ONJID = SOBID from step 3.

5. SELECT SOBID FROM HRP1001 WHERE OTYPE = 'O' AND

PLVAR = '01' AND

RSIGN = 'B' AND

RELAT = '012' AND

SCLAS = 'S' AND

OBJID = SOBID from Step 4.

Thanks in advance.

Alex.