Oracle modifiable cursor example

Source: Internet
Author: User

Source code:

Declare
Cursor C1
Is
Select *
From Src_list
For   Update   Of Callednum,
Businessnum,
Startdate,
Starttime,
Duration,
Unitnumber,
Break;

V_callednum
Varchar2 ( 20 );
V_startdate
Char ( 8 );
V_starttime
Char ( 6 );
V_duration
Number ( 10 );
V_unitnumber
Number ( 7 );
V_133
Number ( 8 );
Begin
For R In C1
Loop
Select Called168
Into V_callednum
From ( Select Called168
From Called168
Order   By Dbms_random.value)
Where Rownum =   1 ;

Select   ' 200611 '   | To_char (trunc (dbms_random.value ( 10 , 30 )))
Into V_startdate
From Dual;

Select Lpad (to_char (trunc (dbms_random.value ( 9 , 20 ))), 2 , ' 0 ' )
| Lpad (to_char (trunc (dbms_random.value ( 1 , 59 ))), 2 , ' 0 ' )
| Lpad (to_char (trunc (dbms_random.value ( 1 , 59 ))), 2 , ' 0 ' )
Into V_starttime
From Dual;

Select Trunc (dbms_random.value ( 120 , 480 ))
Into V_duration
From Dual;

Select Ceil (v_duration /   60 )
Into V_unitnumber
From Dual;

V_1:
= V_unitnumber *   200 ;

Update Src_list
Set Callednum = V_callednum,
Businessnum
= V_callednum,
Startdate
= V_startdate,
Starttime
= V_starttime,
Duration
= V_duration,
Unitnumber
= V_unitnumber,
Bytes
= V_133
Where   Current   Of C1;
End Loop;

Commit ;
End ;

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.