Oracle
 sql >> Teknologi Basis Data >  >> RDS >> Oracle

Apakah mungkin untuk meneruskan objek ke prosedur paket PL SQL sebagai parameter?

CREATE OR REPLACE TYPE t_parsed_name as object (
name_prefix varchar2(50),
name_first varchar2(50),
name_middle varchar2(50),
name_last varchar2(100),
name_suffix varchar2(50)
);

CREATE OR REPLACE TYPE T_PARSED_NAME_ARY as table of t_parsed_name;

create or replace procedure test_parsed_names(i_parsed_name_ary in t_parsed_name_ary) as
    idx pls_integer;
begin
    idx := i_parsed_name_ary.first;
    loop
        exit when idx is null;
        dbms_output.put_line('First name: ' || i_parsed_name_ary(idx).name_first || ', Last name: ' || i_parsed_name_ary(idx).name_last);
        idx := i_parsed_name_ary.next(idx);
    end loop;
end;

----------------------------------------
-- example using above procedure
declare
    l_parsed_name t_parsed_name;
    l_parsed_name_ary t_parsed_name_ary;
begin
  l_parsed_name_ary := t_parsed_name_ary();
  l_parsed_name_ary.extend(3);

  -- create some parsed names and add to array
  l_parsed_name := t_parsed_name('Mr','Joe','T','Blow','Jr');
  l_parsed_name_ary(1) := l_parsed_name;
  l_parsed_name := t_parsed_name('Mrs','Jane','','Doe','');
  l_parsed_name_ary(2) := l_parsed_name;
  l_parsed_name := t_parsed_name('','Betty','','Boop','');
  l_parsed_name_ary(3) := l_parsed_name;

  -- test the array (call procedure with object type array parameter)
  test_parsed_names(l_parsed_name_ary);
end;


  1. Database
  2.   
  3. Mysql
  4.   
  5. Oracle
  6.   
  7. Sqlserver
  8.   
  9. PostgreSQL
  10.   
  11. Access
  12.   
  13. SQLite
  14.   
  15. MariaDB
  1. Apa cara terbaik untuk menegakkan hubungan 'subset' dengan batasan integritas

  2. Cara mengaktifkan jejak di aplikasi oracle r12

  3. ORA-28000:akun sering error

  4. SYS_EXTRACT_UTC() Fungsi di Oracle

  5. Tidak dapat masuk ke database sebagai SYS dengan Oracle SQL Developer