Home > database >  Comrades, what use cases for example, a what circumstances use for 2???
Comrades, what use cases for example, a what circumstances use for 2???

Time:10-10

CodePudding user response:

For x in (select cols
The from XXXXX x
Inner join yyyyyyy y on x.i d=y.x id
Inner join ZZZZZ z on x.i d=z.x id
Where x.n ame in (select the name from aaaa where age & gt; 1000 and FFF & gt; 30000 or (CD & gt; 1000 and tt!=1000))
And the exists (select * from BBBB b where x.i dx=1000 and b.i d=7.0.x.x xid)
The and...
The and... )
Loop
//todo
End loop


If change to this, looked at the loop body is more relaxed some

Cursor cur is
Select the cols
The from XXXXX x
Inner join yyyyyyy y on x.i d=y.x id
Inner join ZZZZZ z on x.i d=z.x id
Where x.n ame in (select the name from aaaa where age & gt; 1000 and FFF & gt; 30000 or (CD & gt; 1000 and tt!=1000))
And the exists (select * from BBBB b where x.i dx=1000 and b.i d=7.0.x.x xid)
The and...
The and... ;

The open cur;

For rec in cur loop
//todo
end loop;

The close cur;

CodePudding user response:

The same, only is a display definition cursor, another implicit definition,

CodePudding user response:

reference 1st floor selling fruit net reply:
for x in (select cols
The from XXXXX x
Inner join yyyyyyy y on x.i d=y.x id
Inner join ZZZZZ z on x.i d=z.x id
Where x.n ame in (select the name from aaaa where age & gt; 1000 and FFF & gt; 30000 or (CD & gt; 1000 and tt!=1000))
And the exists (select * from BBBB b where x.i dx=1000 and b.i d=7.0.x.x xid)
The and...
The and... )
Loop
//todo
End loop


If change to this, looked at the loop body is more relaxed some

Cursor cur is
Select the cols
The from XXXXX x
Inner join yyyyyyy y on x.i d=y.x id
Inner join ZZZZZ z on x.i d=z.x id
Where x.n ame in (select the name from aaaa where age & gt; 1000 and FFF & gt; 30000 or (CD & gt; 1000 and tt!=1000))
And the exists (select * from BBBB b where x.i dx=1000 and b.i d=7.0.x.x xid)
The and...
The and... ;

The open cur;

For rec in cur loop
//todo
end loop;

The close cur;

Thank you, smile [smoking] smoke [laughs]

CodePudding user response:

refer to the second floor lhdz_bj response:
both the same, is just a display definition cursor, another implicit definition,

But he ask under what circumstances a, what circumstance with ah,,,

CodePudding user response:

zhang programmers reference 4 floor response:
Quote: refer to the second floor lhdz_bj response:

The same, only is a display definition cursor, another implicit definition,

But he ask under what circumstances a, what circumstance with ah,,,


Writing a slight difference, no difference function, applicable scenario,
The first is more concise,

CodePudding user response:

If you say, it is the first kind of SQL (SELECT statement) for the cursor easier, the second is more suitable for the cursor SQL SELECT statement more complex scenarios,