PLSQL Tutorial

https://www.dotnettricks.com/learn/sqlserver/difference-between-stored-procedure-and-function-in-sql-server

http://index-of.co.uk/Database/Oracle%20Database/Oracle%20PL-SQL%20Programming,%206th%20Edition.pdf


https://www.plsql.co/ 1. Khai báo biến

tên_biến  kiểu_dữ_liệu  [default] [giá_trị_khởi_tạo]

ví dụ:

name varchar(20) default "Nguyen Huy Bo";

point number(10,2) default 22 ;      giá trị lớn nhất là   9999999999,99

PI constant double default 3.14;


DECLARE
   --global variable
   a integer := 10;
   b integer := 20;
   c integer;
   f real;

BEGIN

   c := a + b;

   f := 70.0/3.0;

   DECLARE
      -- Local variables
      num1 number := 195;
      num2 number := 185;
   BEGIN
      -- code here
   END;

END;
/


IF THEN END IF;

IF (a <= 20) THEN
-- can update or insert or .... 
c:= c+1; 
END IF;

IF THEN ELSE END IF;

IF( a < 20 ) THEN
      -- if condition is true then print the following 
      dbms_output.put_line('a is less than 20 ' );
   ELSE
      dbms_output.put_line('a is not less than 20 ' );
   END IF;

IF THEN [ELSIF THEN] ... END IF;

IF ( a = 10 ) THEN
      dbms_output.put_line('Value of a is 10' );
   ELSIF ( a = 20 ) THEN
      dbms_output.put_line('Value of a is 20' );
   ELSIF ( a = 30 ) THEN
      dbms_output.put_line('Value of a is 30' );
   ELSE
       dbms_output.put_line('None of the values is matching');
   END IF;

CASE WHEN END CASE;

CASE selector
   WHEN 'value1' THEN S1;
   WHEN 'value2' THEN S2;
   WHEN 'value3' THEN S3;
   ...
   ELSE Sn;  -- default case
END CASE;





Comments

Popular posts from this blog

Fixing the DeepSpeed Import Error While Fine-Tuning the Qwen Model

Amazon Linux 2023 - User data configuration for launch templates to connect to the EKS cluster

How to create ISM policy and rotate logs in opensearch