Recently saw a lot of things, also practiced some, I found this thing seems to be a bit into the bottleneck of the feeling, this bottleneck, I think is because the time is too short,
There are not enough exercises, and there are a lot of things that have been done at random. And recently in learning Python, some things are a little confusing, I decided to new
Go through the book and learn every example.
PL/SQL blocks are anonymous or named, and are actually named for those processes, functions, packages, triggers, object types, and so on. The first example in the book is this one.
Insert.sql
CREATE OR REPLACE PROCEDURE get_happy (emp_id_in in number) AUTHID Current_useris l_hiredate DATE; BEGIN l_hiredate: = SYSDATE-2; INSERT into employees (employee_id, hire_date) VALUES (emp_id_in, l_hiredate); EXCEPTION when Dup_val_on_index and then Dbms_output. Put_Line (' cannot insert. '); end;/
The example in the book is actually a bit of a pit, I look like the data in the table when the database is installed, and then I press it to write, using the HR account login,
The creation of the problem, and later found that it is not at all, and that the error Dup_val_on_index, his book is also wrong.
Here is an anonymous block
Date.sql
DECLARE l_date date; BEGIN l_date: = SYSDATE-5; Dbms_output. Put_Line (l_date); end;/
I still don't know how to call that process, although I tried it before, but I didn't remember it.
I'm going to try to write a call on my own, I write a process for printing time, and then call it in an anonymous block.
Get_date.sql
CREATE OR REPLACE PROCEDURE get_date (num_in in number) AUTHID Current_useris l_date date; BEGIN l_date: = sysdate-num_in; Dbms_output. Put_Line (l_date); end;/
Then anonymous blocks are called
Date.sql
BEGIN Get_date (10); end;/
The implementation of the call, the successful output, if your display is successful but no output, it should be not open the output that function.
I am using Sqlplus to run these. sql files, @ xxx.sql
and enter set serverout on in Sqlplus; Use this command to turn on the output function.
Oracle PL/SQL Programming Fifth Edition, chapter III Language Basics