Oracle midstream Standard, array usage

Source: Internet
Author: User

1) SELECT * from Cnbs_security_role_menu for update;


2) Oracle Midstream use: http://www.cnblogs.com/sc-xx/archive/2011/12/03/2275084.html

Declare

--type definition

Cursor C_job is

Select Combine_no,plan_code,flag from Rate_combine where plan_code= ' C01 ' and rownum <10;

--Define a cursor variable

C_row C_job%rowtype;

Begin

Open c_job;

Loop

--Fetch a row of data to C_row

Fetch c_job into C_row;

--to interpret if the value is extracted and exit without taking a value

--Take the value C_job%notfound is False

--No value C_job%notfound is true

Exit when C_job%notfound;

Dbms_output.put_line (c_row.combine_no| | ' -' | | c_row.plan_code| | ' -' | | C_row.flag);

End Loop;

--Close cursor

Close C_job;

End



3) If you use a fixed-length array, and you do not need an external definition, you can define the following

Declare

Type AR is Varray (all) of VARCHAR2 (12); --Declaring an array type

RT Ar:=ar (' DD ', ' FF ', ' SS '); --Declares the array type variable RT and assigns the initial value

I integer:=1;

Begin

For I in 1..rt.count loop

--RT (i): =i;

Dbms_output.put_line (' count= ' | | RT (i));

End Loop;

End


4) If the length of the array we want to use is not predictable, we can do this as follows:

Declare

TYPE Numtab is TABLE of VARCHAR2 (a) INDEX by Binary_integer; Defines an array type;

Arr Numtab; Declare a variable using this type;

I integer:=1;

Begin

For I in 1..100 loop

Arr (i): =i;//assigning values to variables

Dbms_output.put_line (' arr[' | | i| | '] = ' | | Arr (i));

End Loop;

Dbms_output.put_line (' count= ' | | Arr.count);

End;


5)---The use of cursors with parameters;

Declare

CURSOR stock_cur (symbol_in VARCHAR2) is

SELECT * from RATE_COMBINE_NR nr WHERE nr.combine_no=symbol_in;

Stock_info Stock_cur%rowtype;

Begin

OPEN stock_cur (' G600000001 '); --Open the cursor;

Loop

FETCH stock_cur into Stock_info; --Take a value from the cursor

Exit when Stock_cur%notfound;

Dbms_output.put_line (stock_info.combine_no| | ' -' | | Stock_info.department_code);

End Loop;

Close stock_cur; --Close cursor

End


This article is from the "Small Li Guangzhi Blog" blog, please be sure to keep this source http://6817977.blog.51cto.com/6807977/1597129

Oracle midstream Standard, array usage

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.