PLSQL defines record records and plsqlrecord records

Source: Internet
Author: User

PLSQL defines record records and plsqlrecord records

1. Basic use of PLSQL

Note: 1. Three paragraphs declare

Begin

Exception

End;

2. Declaration: emp. ename % type; is the same as the attribute of the field.

3. begin: select stores variables with query automatic.

4. Condition Statement:

(1) if then

Statement;

End if;

(2) When then

Statement;

 

Declare

V_ename emp. ename % type;

E_meet_scott exception;

Begin

Select enameinto v_enamefrom empwwhere emp. empno = 7788;

Dbms_output.put_line ('Who? | V_ename ');

If v_ename = 'Scott 'then

Raise e_meet_scott;

Endif;

Exception

When e_meet_scottthen

Dbms_output.put_line ('aaaa, scott @@@@@');

End;

2. Record

2.1 custom records:

Note: 1. Custom struct:

Declare struct name is record (

Field 1,

Field 2 );

Instantiate the struct;

2. ''|'' connection string.

Declare

Type emp_basic_recordisrecord (

Empno emp. empno % type,

Empname emp. ename % type,

Empjob emp. job % type

);

Emp_basic_info emp_basic_record;

Begin

Select empno, ename, jobinto emp_basic_infofrom emp

Where e-mapreduce = 7788;

Dbms_output.put_line ('name: '| emp_basic_info.empname );

End;

2.2 rowtype record

Note: 1. Use rowtype to create a record. The field name of the record is the same as that of the original field.

2. Create multiple rowtypes to process different records at the same time.

Declare

Emp_detail_info emp % rowtype;

Begin

Select empno, ename, jobinto emp_detail_info.empno

, Emp_detail_info.ename, emp_detail_info.jobfrom emp

Where e-mapreduce = 7788;

Dbms_output.put_line ('name' | emp_detail_info.ename );

 


In PLSQL, define a RECORD type variable r1 table1 % rowtype. How to put a RECORD in Table 1 into r1 and get

Select table1.clo1, table1.clo2, table1.clo3 into r1.clo1, r1.clo2, r1.clo3 from table1
The r1 variable is a record type. The structure of r1 is exactly the same as that of Table 1. The record type can only accept one piece of data at a time. You can add a restriction when you run it again, ensure that only one record is found. This is probably the case.

How to use record in an assembly record

When there are few data items to be processed and each data item can be expressed in a few binary digits, you can use record to define these data items and put them in one or two bytes.
For example, student record name: 4, sex: 1
The name width is 4 binary bits, the sex is 1, and the total width is less than or equal to 8. The assembler will use 1 byte to indicate the record. If the total width exceeds 8 but is smaller than or equal to 16, it is expressed in two bytes.

If you want to find the specific value of a field, the shift value operation and the shielding operation are used.

For example, define the data segment:
Data segment
S record a: 4, B: 1
S1 s <3, 1>
S2 s <10, 0>
Data ends
The memory is allocated as follows:
Ds: 0 07 -- Here 07 is the value of s1
Ds: 1 14 -- here 14 is the s2 value.

Mov bl, s1; get s1
Mov al, mask a; shielding operation. In al, the shielding code of field a is stored, that is, each of the fields is 1, and all others are 0, that is, 1EH.
The value of field a of and bl, al; s1 is stored in bl, but it is not 3, because it has a bit of field B on the right. So we need to perform the shift operation.
Mov cl, a; a field's position in the record, that is, the number of digits to be moved.
Shr bl, cl; the value in bl is the value of field a in s1 -- 3

You can use the following program to analyze and debug the connection after compilation.
Assume cs: code, ds: data
Data segment
S record a: 4, B: 1
S1 s <3, 1>
S2 s <10, 0>
Data ends
Code segment
Start: mov ax, data
Mov ds, ax
Mov al, mask
Mov bl, s1
And bl, al
Mov cl,
Shr bl, cl
Mov ax, 4c00h
Int 21 h
Code ends
End start

We recommend that you take a look at the relevant content in the assembly language teaching material.

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.