| |

VerySource

 Forgot password?
 Register
Search
View: 18|Reply: 2

Why can't I use a case when statement when using select in the cursor cursor?

[Copy link]

2

Threads

3

Posts

4

Credits

Newbie

Rank: 1

Credits
4

 China

Post time: 2020-2-18 23:30:02
| Show all posts |Read mode
As the title, for example
select a. *, c.ovt_date,
     b.shf_at1,
     case when b.shf_of1 <b.shf_at1 then trunc (a.rcd_dat) + 1 + (b.shf_of1-trunc (b.shf_of1))
          else b.shf_of1 end
     from att_rcd a, att_supply_ovt_t c, att_shf b
      where rcd_dat = to_date ('20161127', 'yyyymmdd') and. . . . Omitted

The above SQL can have running results, but errors occur when defining the cursor, such as:

cursor test is
   select ....... statement as above

Why did it go wrong?
Reply

Use magic Report

0

Threads

2

Posts

2

Credits

Newbie

Rank: 1

Credits
2

 China

Post time: 2020-4-26 14:00:01
| Show all posts
Oh. You need to execute this dynamically. Such as:

sql = 'select ....'

execute immediate 'sql';
Reply

Use magic Report

0

Threads

1

Posts

2

Credits

Newbie

Rank: 1

Credits
2

 China

Post time: 2020-5-8 17:45:01
| Show all posts
execute immediate 'select ..'
  Learn
Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

Contact us|Archive|Mobile|CopyRight © 2008-2020|verysource.com ( 京ICP备17048824号-1 )

Quick Reply To Top Return to the list