Oracle,oracle官網

來源:互聯網
上載者:User

Oracle,oracle官網

包頭:

create or replace package ProdureceCursorData is

type  curtype is ref cursor;    
type type_record is record  
(  
  deptno NUMBER(2) ,
  dname  VARCHAR2(14),
  loc    VARCHAR2(13)
); 
PROCEDURE Procedure1(cur out curtype);

end ProdureceCursorData;


包體:

create or replace package body ProdureceCursorData is

PROCEDURE Procedure1(cur out curtype)
as
begin
open  cur for select * from DEPT;
end;

end ProdureceCursorData;


測試:

SQL> select * from DEPT;

DEPTNO DNAME          LOC
------ -------------- -------------
    10 ACCOUNTING     NEW YORK
    20 RESEARCH       DALLAS
    30 SALES          CHICAGO
    40 OPERATIONS     BOSTON

SQL> set serveroutput on
SQL> declare
  2  curoutarg    ProdureceCursorData.curtype;
  3  rec_arg      ProdureceCursorData.type_record;
  4  begin
  5    dbms_output.put_line('------------------------');
  6    ProdureceCursorData.Procedure1(curoutarg);
  7   loop
  8   fetch curoutarg into rec_arg;
  9   exit when curoutarg%notfound;
 10   dbms_output.put_line(rec_arg.deptno||' '||rec_arg.dname||' '||rec_arg.loc);
 11    end loop;
 12  end;
 13  /
------------------------
10 ACCOUNTING NEW YORK
20 RESEARCH DALLAS
30 SALES CHICAGO
40 OPERATIONS BOSTON
PL/SQL procedure successfully completed

記錄一下實踐結果,哈哈哈


oracle 當中,(+)是什?

SELECT
A.id, B.IDD
FROM
A, B
WHERE
A.id(+)=B.IDD
等價於
SELECT
A.id, B.IDD
FROM
A RIGHT OUTER JOIN B ON ( A.id=B.IDD)

SQL> select * from A;

ID VAL
---------- ----------
1 A1
2 A2

SQL> select * from B;

IDD VAL
---------- ----------
1 B1
3 B3

SQL> SELECT
2 A.id, B.IDD
3 FROM
4 A, B
5 WHERE
6 A.id(+)=B.IDD;

ID IDD
---------- ----------
1 1
3

SQL> SELECT
2 A.id, B.IDD
3 FROM
4 A RIGHT OUTER JOIN B ON ( A.id=B.IDD);

ID IDD
---------- ----------
1 1
3

意思是 兩表關聯的時候,
B 表的資料, 全部檢索出來。
A表的資料,則是在B表有相對應的資料的情況下,才檢索出來。
 
oracle 當中,(+)是什?

SELECT
A.id, B.IDD
FROM
A, B
WHERE
A.id(+)=B.IDD
等價於
SELECT
A.id, B.IDD
FROM
A RIGHT OUTER JOIN B ON ( A.id=B.IDD)

SQL> select * from A;

ID VAL
---------- ----------
1 A1
2 A2

SQL> select * from B;

IDD VAL
---------- ----------
1 B1
3 B3

SQL> SELECT
2 A.id, B.IDD
3 FROM
4 A, B
5 WHERE
6 A.id(+)=B.IDD;

ID IDD
---------- ----------
1 1
3

SQL> SELECT
2 A.id, B.IDD
3 FROM
4 A RIGHT OUTER JOIN B ON ( A.id=B.IDD);

ID IDD
---------- ----------
1 1
3

意思是 兩表關聯的時候,
B 表的資料, 全部檢索出來。
A表的資料,則是在B表有相對應的資料的情況下,才檢索出來。
 

相關文章

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.