-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path%TYPE ATTRIBUTE,Delimiters and Commenting.sql
More file actions
87 lines (84 loc) · 2.35 KB
/
%TYPE ATTRIBUTE,Delimiters and Commenting.sql
File metadata and controls
87 lines (84 loc) · 2.35 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
--Using %Type Attribute (Code Samples)
---------------------%TYPE ATTRIBUTE---------------------
desc employees;
declare
V_TYPE employees.JOB_ID%TYPE;
V_TYPE2 V_TYPE%TYPE;
V_TYPE3 employees.JOB_ID%TYPE ;
begin
v_type := 'IT_PROG';
v_type2 := 'SA_MAN';
v_type3 := NULL;
dbms_output.put_line(v_type);
dbms_output.put_line(v_type2);
dbms_output.put_line('HELLO' || v_type3);
end;
---------------------------------------------------------
--PL/SQL Delimiters and Commenting (Code Samples)
------------------DELIMITERS AND COMMENTING------------------
DECLARE
V_TEXT VARCHAR2(10):= 'PL/SQL';
BEGIN
--This is a single line comment
/* This is a
multi line
comment */
--DBMS_OUTPUT.PUT_LINE(V_TEXT || ' is a good language');
null;
END;
-------------------------------------------------------------
------------------------VARIABLE SCOPE--------------------------
begin <<outer>>
DECLARE
--v_outer VARCHAR2(50) := 'Outer Variable!';
v_text VARCHAR2(20) := 'Out-text';
BEGIN
DECLARE
v_text VARCHAR2(20) := 'In-text';
v_inner VARCHAR2(30) := 'Inner Variable';
BEGIN
--dbms_output.put_line('inside -> ' || v_outer);
--dbms_output.put_line('inside -> ' || v_inner);
dbms_output.put_line('inner -> ' || v_text);
dbms_output.put_line('outer -> ' || outer.v_text);
END;
--dbms_output.put_line('inside -> ' || v_inner);
--dbms_output.put_line(v_outer);
dbms_output.put_line(v_text);
END;
END outer;
----------------------------------------------------------------
--------------------------BIND VARIABLES--------------------------
set serveroutput on;
set autoprint on;
/
variable var_text varchar2(30);
/
variable var_number NUMBER;
/
variable var_date DATE;
/
declare
v_text varchar2(30);
begin
:var_text := 'Hello SQL';
:var_number := 20;
v_text := :var_text;
--dbms_output.put_line(v_text);
--dbms_output.put_line(:var_text);
end;
/
print var_text;
/
variable var_sql number;
/
begin
:var_sql := 100;
end;
/
select * from employees where employee_id = :var_sql;
/*------------------------BIND VARIABLES--------------------------
NOTE: When you run a bind variable creation and SELECT statement
together, SQL Developer may return an error but when you execute
them separately, there will be no problem.
----------------------------------------------------------------*/