Variable ____oracle can be defined in an Oracle cursor

Source: Internet
Author: User
Tags oracle cursor

2008/03/07
Skate

A variable can be defined in a cursor, and the following is an example of the procedure of my Update column order

Create or replace
PROCEDURE TEST as
--v_id varchar2;
--V_num number;
--v_x number;
I number (10,0): = 1;

v_id VARCHAR2 (32);
V_num number (10,0);
V_x number (10,0);


Cursor Cur_ids is
Select Id,sum from (
Select count (ID) sum,id from m_category_t where ordernumber = 0 GROUP by ID)
where Sum >1;

Cursor CUR_IDS1 is
Select CategoryID from m_category_t where id=v_id;

Begin
Open cur_ids;
Loop
Fetch cur_ids into V_id,v_num;
Exit when Cur_ids%notfound;

Open cur_ids1;
Loop
Fetch CUR_IDS1 into v_x;
Exit when Cur_ids1%notfound;

Update m_category_t set ordernumber=i where categoryid=v_x;
i:=i+1;
End Loop;
Close cur_ids1;
I:=1;
End Loop;
Close Cur_ids;
End TEST;


--End--

Related Article

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.