SHARE
TWEET

Oracle

AbdullahAL-Rashdan Apr 24th, 2019 (edited) 82 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #########################################
  2. #  Smashing Dr.Ahmad FOR Fun AND Profit  #
  3. #########################################
  4. Basic Code Block Command :
  5.     DECLARE
  6.     BEGIN
  7.     END
  8.     EXCEPTION
  9.  
  10. Data TYPE :
  11.     VARCHAR2
  12.     VARCHAR
  13.     NUMBER
  14.     INT
  15.     DATE
  16. TO Get TYPE FROM TABLE :
  17.     e.g :
  18.         name student.s_name%TYPE;
  19.  
  20. Basic Code
  21.     variable_name := VALUE;
  22.     SET SERVEROUTPUT ON;
  23.     DBMS_OUTPUT.PUT_LINE('display_text');
  24.     new_string := string1 || string2;
  25.     LTRIM();
  26.     RTRIM();
  27.     LENGTH();
  28.     UPPER();
  29.     LOWER();
  30.     IF condition1 THEN
  31.         ...
  32.     ELSIF condition2 THEN
  33.         ...
  34.     ELSE
  35.         ...
  36.     END IF;
  37.  
  38.  
  39. WHILE condition LOOP
  40.      program statements
  41. END LOOP;
  42.  
  43.  
  44. LOOP
  45.     ...
  46. END LOOP;
  47.  
  48.  
  49.  
  50. Steps FOR creating AND USING explicit CURSOR :
  51.     - DECLARE CURSOR
  52.     - OPEN CURSOR
  53.     - FETCH data ROWS
  54.     - CLOSE CURSOR
  55.  
  56.  
  57. e.g
  58.  
  59. DECLARE
  60.     CURSOR c IS SELECT s_id , s_name FROM student;
  61.     id student.s_id%TYPE;
  62.     name student.s_name%TYPE;
  63. BEGIN
  64.     OPEN c;
  65.     LOOP
  66.         FETCH c INTO id , name;
  67.         EXIT WHEN c%NOTFOUND;
  68.         dbms_output.put_line(id || '   ' || name);
  69.     END LOOP;
  70.     CLOSE c;
  71. END;
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top