PL SQL資料型別

2022-07-23 16:51:30 字數 1468 閱讀 9893

create or replace procedure pr_mytest is

v_test number(8);--變數

v_char varchar2(10);

c_changl constant number (12,3):= 3.14;--常量

v_bm t_hq_ryxx.bumbm%type;

type ty_ry is record --定義了一種記錄型別

(v_xingm t_hq_ryxx.xingm%type,

v_xingb t_hq_ryxx.xingb%type,

v_gongz t_hq_ryxx.gongz%type

);v_ry ty_ry; --宣告這種記錄型別的變數

v_ryrow t_hq_ryxx%rowtype;--把錶的所有字段定義為記錄型別

type ty_xs is record

(v_sno t_hq_student.sno%type,

v_sname t_hq_student.sname%type,

v_class t_hq_student.class%type

);v_xs ty_xs;

v_xsrow t_hq_student%rowtype;

begin

v_char := '你好';

select xingm,xingb,gongz into v_ry from t_hq_ryxx where rownum =1;

dbms_output.put_line(v_ry.v_xingm ||' '|| v_ry.v_xingb ||' '|| v_ry.v_gongz);

select * into v_ryrow from t_hq_ryxx where rownum =1;

dbms_output.put_line(v_ryrow.xingm ||' '|| v_ryrow.xingb ||' '|| v_ryrow.gongz);

select bumbm into v_bm from t_hq_ryxx where rownum < 2;

dbms_output.put_line(v_char ||',測試儲存過程,記錄條數為:' ||v_bm);

select sno,sname,class into v_xs from t_hq_student where rownum =1;

dbms_output.put_line(v_xs.v_sno || ' ' || v_xs.v_sname || ' ' || v_xs.v_class );

select * into v_xsrow from t_hq_student where rownum = 1;

dbms_output.put_line(v_xsrow.sno || ' '|| v_xsrow.sname || ' ' || v_xsrow.sbirthday || ' ' || v_xsrow.class);

end pr_mytest;

PL SQL資料型別(三)

pl sql資料型別主要包括標量資料型別和復合資料型別。標量資料型別比較簡單,不在詳細說明。復合資料型別主要包括pl sql記錄 pl sql表 索引表 巢狀表和變長陣列 varray 下邊詳細描述。pl sql記錄 pl sql記錄類似於高階語言中的結構,可以儲存多個字段值,類似於表中的一行資料。...

PL SQL 變數與常用資料型別

以oracle8i為例,可以使用的基礎資料型別有 型別子類 說 明 範 圍 oracle限制 char character string rowid nchar 定長字串 民族語言字符集 0 32767 可選,確省 1 varchar2 varchar,string nvarchar2 可變字串 民...

PL SQL 三 復合資料型別

一 復合資料型別 存放多個字段,建立後可以多次使用 二 分類 記錄 表 巢狀表 陣列 三 簡介 1 記錄 儲存一組多個欄位的相關資料項,是字段的集合,主要用於從表中取出查詢到的的行資料 特殊的記錄 rowtype 宣告的表量對應資料庫表或檢視中列的集合,獲取的是單條資訊 優點 對應資料庫中列的數量和...