본문 바로가기

분류 전체보기

(657)
016 - [Oracle PL/SQL] Collections - Index by tables(Associative arrays) # 숫자 인덱스 declare type tab_no is table of varchar2(20) index by pls_integer; v_tab_no tab_no; begin v_tab_no(1):='aaa'; v_tab_no(6):='bbb'; v_tab_no(4):='ccc'; dbms_output.put_line(v_tab_no(1)); dbms_output.put_line(v_tab_no(6)); dbms_output.put_line(v_tab_no(4)); end; ------------------------- aaa bbb ccc # 문자열 인덱스 declare type tab_no is table of number index by varchar2(20); v_tab_no tab_no; be..
015 - [Oracle PL/SQL] Records - Nested Records Nested Records define 및 접근방법 drop table emp_tel; create table emp_tel (emp_id number primary key, full_name varchar2(20), mob1 varchar2(20), mob2 varchar2(20), landline varchar2(20) ) insert into emp_tel values (1,'London','+971505914999','+97125914777','+971508105499'); select * from emp_tel; /* EMP_ID FULL_NAME MOB1 MOB2 LANDLINE ---------- -------------------- -------------------- -----------..
014 - [Oracle PL/SQL] Records - %rowtype select * from DEPARTMENTS where department_id=10; /* ------------------------------------------------------------ DEPARTMENT_ID DEPARTMENT_NAME MANAGER_ID LOCATION_ID ------------- ------------------------------ ---------- ----------- 10 Administration 200 1700 */ # 테이블을 데이터는 제외하고 구조를 복사 create table copy_DEPARTMENTS as select * from DEPARTMENTS where 1=2; # 새로운 테이블에는 데이터가 없는것을 확인 select * from ..
013 - [Oracle PL/SQL] Records - %type What is a PL/SQL Record A PL/SQL record is a composite data structure that is a group of related data stored in fields. Each field in the PL/SQL record has its own name and data type. Declaring a PL/SQL Record 1- programmer-defined records. 2- table-based record. %Rowtype 3- cursor-based record. ( will be covered later ) # 아래 2가지 표현 방식은 동일한 방식이다. DECLARE TYPE t_EMP IS RECORD ( V_EMP_id employees..
012 - [Oracle PL/SQL] Continue Statement # i want to print under the number the Symbol :) only for 1,2,3,4,5 # there are many methods --method 1 declare v_sym varchar2(100); begin for i in 1..10 loop if i between 1 and 5 then v_sym:=i||chr(10)||':)'; else v_sym:=i; end if; dbms_output.put_line (v_sym); end loop; end; --------------------------------------- --method 2 begin for i in 1..10 loop dbms_output.put_line (i); continue when i>5..
011 - [Oracle PL/SQL] Nested Loops and Labels 이중 for 문에 대해서 알아보겠습니다. 일반적인 프로그래밍에서 사용하는 이중 for문과 유사합니다. declare v_star varchar2(100); begin for i in 1..5 loop for j in 1..i loop v_star:=v_star||'*'; end loop; dbms_output.put_line(v_star); v_star:=null; end loop; end; -------------------------------- * ** *** **** ***** # 위의 for문 샘플에서 이름을 지정한 샘플입니다. declare v_star varchar2(100); begin for i in 1..5 loop for j in 1..i loop v_star:=v_star||'*';..
010 - [Oracle PL/SQL] For Loop # basic for loop begin for i in 1..3 loop dbms_output.put_line('welcome '||i); end loop; end; ------------------------ begin for i in 1..1 loop dbms_output.put_line('welcome '||i); end loop; end; -------------------- begin for i in 3..5 loop dbms_output.put_line('welcome '||i); end loop; end; -------------------- welcome 1 welcome 2 welcome 3 welcome 1 welcome 3 welcome 4 welcome 5 # 감소하는 for 문 ..
009 - [Oracle PL/SQL] While Loop declare v_counter number:=1; begin while v_counter