2013-06-20 24 views
0

舉例來說,如果我寫:SQL'select'和PL/SQL'select'語句有什麼區別?

  select employee_id,last_name from employees; 

我會在現有的「僱員」表中的所有行。 如果我寫:

  declare 
       id employee_id.employees%type; 
       ln last_name.employees%type; 
      begin 
       select employee_id,last_name into id,ln 
       from employees 
       where employee_id = 100; 
       dbms_output.put_line(id||' '||ln); 
      end; 

我得到 -

  100 King 

如果我想要檢索多行的話,我會用光標。但是可以使用前面提到的簡單SQL語句來檢索這些多行。那麼,使用PL/SQL Declare..Begin..End語句有什麼用?

回答

0

PL/SQL用於編寫程序,函數和程序,這些程序,函數和程序需要過程邏輯,這些過程邏輯不能方便地表示爲SQL語句的集合。

分享和享受。