Bence12345

Tárolt eljárás PLSQL

Dec 3rd, 2020
659
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. CREATE OR REPLACE FUNCTION SF_CHECK_RENDSZAM(
  2.     p_rendszam autok.rendszam%TYPE
  3. ) RETURN VARCHAR2
  4. AS
  5. BEGIN
  6.     IF(LENGTH(p_rendszam) <> 7) THEN
  7.         RETURN 'false';
  8.     END IF;
  9.  
  10.     FOR i IN 1..7 LOOP
  11.         IF(i < 4) THEN
  12.             IF(NOT(ASCII(SUBSTR(p_rendszam,i,1)) BETWEEN ASCII('A') AND ASCII('Z'))) THEN
  13.                 RETURN 'false';
  14.             END IF;
  15.         END IF;
  16.  
  17.         IF(i = 4 AND SUBSTR(p_rendszam,i,1) <> '-') THEN
  18.             RETURN 'false';
  19.         END IF;
  20.  
  21.         IF(i > 4) THEN
  22.             IF(NOT(ASCII(SUBSTR(p_rendszam,i,1)) BETWEEN ASCII('0') AND ASCII('9'))) THEN
  23.                 RETURN 'false';
  24.             END IF;
  25.         END IF;        
  26.     END LOOP;
  27.     RETURN 'true';
  28. END SF_CHECK_RENDSZAM;
RAW Paste Data