Pl/SQL programming data types in Oracle

Source: Internet
Author: User
Pl programming data types: 1. scalar 2. composite 3. reference 4.lob( largeobject )--------------

Pl programming data types: 1. scalar 2. composite 3. reference 4.lob( large object )--------------

Pl programming data types:
1. scalar)
2. composite)
3. reference)
4. lob (large object)
----------------------------------------------------------
Case of defining scalar
1. Define a variable-length string
V_ename varchar2 (10)
2. Define a decimal range-9999.99 to 9999.99
V_sal number (6, 2)
3. Define a decimal number and assign a value of 5.4: = to pl/SQL.
V_sal2 number (6, 2): = 5.4
4. Define a date type data
V_hiredate date;
5. Define a Boolean variable. The value cannot be blank. The initial value is false.
V_valid boolean not null default false;
----------------------------------------------------------

Compound variable
Variable used to store multiple values
1. pl/SQL records
2. pl/SQL table
3. nested tables
4. varray

----------------------------------------------------------

Reference variable
Divided into: cursor variable and object variable

Case 1
Use pl/SQL to write a block. You can enter the Department number and display all

Declare
-- Define a cursor type
Type chenchuang_emp_cursor is ref cursor;
-- Define a cursor variable
Test_cursor chenchuang_emp_cursor
-- Define variables
V_ename emp. name % type
V_sal emp. sal % type
Begin
-- Execute
-- Combines test_cursor with a select statement
Open testr_cursor for select ename, sal from emp where

Deptno = & no;
-- Cyclically retrieve
Loop
Fetch test_cursor into v_ename, v_sal;
-- Judge whether testr_cursor is null
Exit when testr_cursor % notfound;
Dbms_output.put_line ('name' | v_name | 'wage '| v_sal );
End loop;

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.