>
DECLARE
last_name VARCHAR2(10) := 'King';
BEGIN
DELETE FROM employees2 WHERE last_name = main.last_name;
DBMS_OUTPUT.PUT_LINE('Deleted ' || SQL%ROWCOUNT || ' rows.');
END;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/column-name-precedence-6.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/column-name-precedence.html
DECLARE
FUNCTION dept_name (department_id IN NUMBER)
RETURN departments.department_name%TYPE
IS
department_name departments.department_name%TYPE;
BEGIN
SELECT department_name INTO dept_name.department_name
-- ^column ^local variable
FROM departments
WHERE department_id = dept_name.department_id;
-- ^column ^formal parameter
RETURN department_name;
END dept_name;
BEGIN
FOR item IN (
SELECT department_id
FROM departments
ORDER BY department_name) LOOP
DBMS_OUTPUT.PUT_LINE ('Department: ' || dept_name(item.department_id));
END LOOP;
END;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/compile-time-warnings-1.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/compile-time-warnings.html
ALTER SESSION SET PLSQL_WARNINGS='ENABLE:ALL';
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/compile-time-warnings-11.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/compile-time-warnings.html
ALTER PROCEDURE unreachable_code COMPILE;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/compile-time-warnings-13.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/compile-time-warnings.html
SHOW ERRORS
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/compile-time-warnings-2.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/compile-time-warnings.html
ALTER SESSION SET PLSQL_WARNINGS='ENABLE:PERFORMANCE';
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/compile-time-warnings-3.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/compile-time-warnings.html
ALTER PROCEDURE loc_var
COMPILE PLSQL_WARNINGS='ENABLE:PERFORMANCE'
REUSE SETTINGS;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/compile-time-warnings-4.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/compile-time-warnings.html
ALTER SESSION
SET PLSQL_WARNINGS='ENABLE:SEVERE', 'DISABLE:PERFORMANCE', 'ERROR:06002';
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/compile-time-warnings-5.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/compile-time-warnings.html
ALTER SESSION SET PLSQL_WARNINGS='DISABLE:ALL';
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/compile-time-warnings-6.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/compile-time-warnings.html
ALTER SESSION SET PLSQL_WARNINGS='DISABLE:ALL';
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/compile-time-warnings-7.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/compile-time-warnings.html
CREATE OR REPLACE PROCEDURE unreachable_code AUTHID DEFINER AS
x CONSTANT BOOLEAN := TRUE;
BEGIN
IF x THEN
DBMS_OUTPUT.PUT_LINE('TRUE');
ELSE
DBMS_OUTPUT.PUT_LINE('FALSE');
END IF;
END unreachable_code;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/compile-time-warnings-8.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/compile-time-warnings.html
CALL DBMS_WARNING.set_warning_setting_string ('ENABLE:ALL', 'SESSION');
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/compile-time-warnings-9.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/compile-time-warnings.html
SELECT DBMS_WARNING.get_warning_setting_string() FROM DUAL;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/compiling-pl-sql-units-native-execution-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/compiling-pl-sql-units-native-execution.html
ALTER PROCEDURE my_proc COMPILE PLSQL_CODE_TYPE=NATIVE REUSE SETTINGS;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/compiling-pl-sql-units-native-execution-1.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/compiling-pl-sql-units-native-execution.html
SPOOL pre_update_invalid.log
SELECT o.OWNER, o.OBJECT_NAME, o.OBJECT_TYPE
FROM DBA_OBJECTS o, DBA_PLSQL_OBJECT_SETTINGS s
WHERE o.OBJECT_NAME = s.NAME AND o.STATUS='INVALID';
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/compiling-pl-sql-units-native-execution-2.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/compiling-pl-sql-units-native-execution.html
ALTER PACKAGE SYS.DBMS_OUTPUT COMPILE BODY REUSE SETTINGS;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/compiling-pl-sql-units-native-execution-3.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/compiling-pl-sql-units-native-execution.html
SELECT TYPE, PLSQL_CODE_TYPE, COUNT(*)
FROM DBA_PLSQL_OBJECT_SETTINGS
WHERE PLSQL_CODE_TYPE IS NOT NULL AND ORIGIN_CON_ID=SYS_CONTEXT('USERENV', 'CON_ID')
GROUP BY TYPE, PLSQL_CODE_TYPE
ORDER BY TYPE, PLSQL_CODE_TYPE;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/compiling-pl-sql-units-native-execution-4.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/compiling-pl-sql-units-native-execution.html
ALTER SYSTEM ENABLE RESTRICTED SESSION;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/compiling-pl-sql-units-native-execution-5.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/compiling-pl-sql-units-native-execution.html
ALTER SYSTEM DISABLE RESTRICTED SESSION;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/conditional-compilation1-10.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/conditional-compilation1.html
BEGIN
DBMS_OUTPUT.PUT_LINE('$$PLSCOPE_SETTINGS = ' || $$PLSCOPE_SETTINGS);
DBMS_OUTPUT.PUT_LINE('$$PLSQL_CCFLAGS = ' || $$PLSQL_CCFLAGS);
DBMS_OUTPUT.PUT_LINE('$$PLSQL_CODE_TYPE = ' || $$PLSQL_CODE_TYPE);
DBMS_OUTPUT.PUT_LINE('$$PLSQL_OPTIMIZE_LEVEL = ' || $$PLSQL_OPTIMIZE_LEVEL);
DBMS_OUTPUT.PUT_LINE('$$PLSQL_WARNINGS = ' || $$PLSQL_WARNINGS);
DBMS_OUTPUT.PUT_LINE('$$NLS_LENGTH_SEMANTICS = ' || $$NLS_LENGTH_SEMANTICS);
END;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/conditional-compilation1-12.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/conditional-compilation1.html
ALTER SESSION SET PLSQL_CCFLAGS =
'name1:value1, name2:value2, ... namen:valuen'
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/conditional-compilation1-13.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/conditional-compilation1.html
ALTER SESSION SET PLSQL_CCFLAGS = 'flag:TRUE, flag:5'
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/conditional-compilation1-14.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/conditional-compilation1.html
ALTER SESSION SET
PLSQL_CCFlags = 'Some_Flag:1, Some_Flag:2, PLSQL_CCFlags:99'
/
BEGIN
DBMS_OUTPUT.PUT_LINE($$Some_Flag);
DBMS_OUTPUT.PUT_LINE($$PLSQL_CCFlags);
END;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/conditional-compilation1-18.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/conditional-compilation1.html
ALTER SESSION SET PLSQL_CCFLAGS = 'my_debug:FALSE, my_tracing:FALSE';
CREATE OR REPLACE PACKAGE my_pkg AUTHID DEFINER AS
SUBTYPE my_real IS
$IF DBMS_DB_VERSION.VERSION < 10 $THEN
NUMBER;
$ELSE
BINARY_DOUBLE;
$END
my_pi my_real;
my_e my_real;
END my_pkg;
/
CREATE OR REPLACE PACKAGE BODY my_pkg AS
BEGIN
$IF DBMS_DB_VERSION.VERSION < 10 $THEN
my_pi := 3.14159265358979323846264338327950288420;
my_e := 2.71828182845904523536028747135266249775;
$ELSE
my_pi := 3.14159265358979323846264338327950288420d;
my_e := 2.71828182845904523536028747135266249775d;
$END
END my_pkg;
/
CREATE OR REPLACE PROCEDURE circle_area(radius my_pkg.my_real) AUTHID DEFINER IS
my_area my_pkg.my_real;
my_data_type VARCHAR2(30);
BEGIN
my_area := my_pkg.my_pi * (radius**2);
DBMS_OUTPUT.PUT_LINE
('Radius: ' || TO_CHAR(radius) || ' Area: ' || TO_CHAR(my_area));
$IF $$my_debug $THEN
SELECT DATA_TYPE INTO my_data_type
FROM USER_ARGUMENTS
WHERE OBJECT_NAME = 'CIRCLE_AREA'
AND ARGUMENT_NAME = 'RADIUS';
DBMS_OUTPUT.PUT_LINE
('Data type of the RADIUS argument is: ' || my_data_type);
$END
END;
/
CALL DBMS_PREPROCESSOR.PRINT_POST_PROCESSED_SOURCE
('PACKAGE', 'HR', 'MY_PKG');
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/conditional-compilation1-20.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/conditional-compilation1.html
CALL DBMS_PREPROCESSOR.PRINT_POST_PROCESSED_SOURCE (
'PACKAGE', 'HR', 'MY_PKG'
);
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/conditional-compilation1-21.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/conditional-compilation1.html
CREATE PACKAGE my_pkg AUTHID DEFINERs AS
SUBTYPE my_real IS
BINARY_DOUBLE;
my_pi my_real;
my_e my_real;
END my_pkg;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/conditional-compilation1-23.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/conditional-compilation1.html
CREATE OR REPLACE PACKAGE cc_pkg
AUTHID DEFINER
$IF $$XFLAG $THEN ACCESSIBLE BY(p1_pkg) $END
IS
i NUMBER := 10;
trace CONSTANT BOOLEAN := TRUE;
END cc_pkg;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/conditional-compilation1-25.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/conditional-compilation1.html
CREATE OR REPLACE PROCEDURE my_proc (
$IF $$xxx $THEN i IN PLS_INTEGER $ELSE i IN INTEGER $END
) IS
BEGIN
NULL;
END my_proc;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/conditional-selection-statements-10.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/conditional-selection-statements.html
DECLARE
PROCEDURE p (
sales NUMBER,
quota NUMBER,
emp_id NUMBER
)
IS
bonus NUMBER := 0;
BEGIN
IF sales > (quota + 200) THEN
bonus := (sales - quota)/4;
ELSE
IF sales > quota THEN
bonus := 50;
ELSE
bonus := 0;
END IF;
END IF;
DBMS_OUTPUT.PUT_LINE('bonus = ' || bonus);
UPDATE employees
SET salary = salary + bonus
WHERE employee_id = emp_id;
END p;
BEGIN
p(10100, 10000, 120);
p(10500, 10000, 121);
p(9500, 10000, 122);
END;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/conditional-selection-statements-14.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/conditional-selection-statements.html
DECLARE
PROCEDURE p (sales NUMBER)
IS
bonus NUMBER := 0;
BEGIN
IF sales > 50000 THEN
bonus := 1500;
ELSIF sales > 35000 THEN
bonus := 500;
ELSE
bonus := 100;
END IF;
DBMS_OUTPUT.PUT_LINE (
'Sales = ' || sales || ', bonus = ' || bonus || '.'
);
END p;
BEGIN
p(55000);
p(40000);
p(30000);
END;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/conditional-selection-statements-16.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/conditional-selection-statements.html
DECLARE
grade CHAR(1);
BEGIN
grade := 'B';
IF grade = 'A' THEN
DBMS_OUTPUT.PUT_LINE('Excellent');
ELSIF grade = 'B' THEN
DBMS_OUTPUT.PUT_LINE('Very Good');
ELSIF grade = 'C' THEN
DBMS_OUTPUT.PUT_LINE('Good');
ELSIF grade = 'D' THEN
DBMS_OUTPUT. PUT_LINE('Fair');
ELSIF grade = 'F' THEN
DBMS_OUTPUT.PUT_LINE('Poor');
ELSE
DBMS_OUTPUT.PUT_LINE('No such grade');
END IF;
END;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/conditional-selection-statements-19.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/conditional-selection-statements.html
DECLARE
grade CHAR(1);
BEGIN
grade := 'B';
CASE grade
WHEN 'A' THEN DBMS_OUTPUT.PUT_LINE('Excellent');
WHEN 'B' THEN DBMS_OUTPUT.PUT_LINE('Very Good');
WHEN 'C' THEN DBMS_OUTPUT.PUT_LINE('Good');
WHEN 'D' THEN DBMS_OUTPUT.PUT_LINE('Fair');
WHEN 'F' THEN DBMS_OUTPUT.PUT_LINE('Poor');
ELSE DBMS_OUTPUT.PUT_LINE('No such grade');
END CASE;
END;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/conditional-selection-statements-21.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/conditional-selection-statements.html
DECLARE
grade NUMBER;
BEGIN
grade := '85';
CASE grade
WHEN < 0, > 100 THEN DBMS_OUTPUT.PUT_LINE('No such grade');
WHEN > 89 THEN DBMS_OUTPUT.PUT_LINE('A');
WHEN > 79 THEN DBMS_OUTPUT.PUT_LINE('B');
WHEN > 69 THEN DBMS_OUTPUT.PUT_LINE('C');
WHEN > 59 THEN DBMS_OUTPUT.PUT_LINE('D');
ELSE DBMS_OUTPUT.PUT_LINE('F');
END CASE;
END;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/conditional-selection-statements-24.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/conditional-selection-statements.html
DECLARE
grade CHAR(1);
BEGIN
grade := 'B';
CASE
WHEN grade = 'A' THEN DBMS_OUTPUT.PUT_LINE('Excellent');
WHEN grade = 'B' THEN DBMS_OUTPUT.PUT_LINE('Very Good');
WHEN grade = 'C' THEN DBMS_OUTPUT.PUT_LINE('Good');
WHEN grade = 'D' THEN DBMS_OUTPUT.PUT_LINE('Fair');
WHEN grade = 'F' THEN DBMS_OUTPUT.PUT_LINE('Poor');
ELSE DBMS_OUTPUT.PUT_LINE('No such grade');
END CASE;
END;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/conditional-selection-statements-26.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/conditional-selection-statements.html
DECLARE
grade CHAR(1);
BEGIN
grade := 'B';
CASE
WHEN grade = 'A' THEN DBMS_OUTPUT.PUT_LINE('Excellent');
WHEN grade = 'B' THEN DBMS_OUTPUT.PUT_LINE('Very Good');
WHEN grade = 'C' THEN DBMS_OUTPUT.PUT_LINE('Good');
WHEN grade = 'D' THEN DBMS_OUTPUT.PUT_LINE('Fair');
WHEN grade = 'F' THEN DBMS_OUTPUT.PUT_LINE('Poor');
END CASE;
EXCEPTION
WHEN CASE_NOT_FOUND THEN
DBMS_OUTPUT.PUT_LINE('No such grade');
END;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/conditional-selection-statements-5.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/conditional-selection-statements.html
DECLARE
PROCEDURE p (
sales NUMBER,
quota NUMBER,
emp_id NUMBER
)
IS
bonus NUMBER := 0;
updated VARCHAR2(3) := 'No';
BEGIN
IF sales > (quota + 200) THEN
bonus := (sales - quota)/4;
UPDATE employees
SET salary = salary + bonus
WHERE employee_id = emp_id;
updated := 'Yes';
END IF;
DBMS_OUTPUT.PUT_LINE (
'Table updated? ' || updated || ', ' ||
'bonus = ' || bonus || '.'
);
END p;
BEGIN
p(10100, 10000, 120);
p(10500, 10000, 121);
END;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/conditional-selection-statements-8.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/conditional-selection-statements.html
DECLARE
PROCEDURE p (
sales NUMBER,
quota NUMBER,
emp_id NUMBER
)
IS
bonus NUMBER := 0;
BEGIN
IF sales > (quota + 200) THEN
bonus := (sales - quota)/4;
ELSE
bonus := 50;
END IF;
DBMS_OUTPUT.PUT_LINE('bonus = ' || bonus);
UPDATE employees
SET salary = salary + bonus
WHERE employee_id = emp_id;
END p;
BEGIN
p(10100, 10000, 120);
p(10500, 10000, 121);
END;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/continuing-execution-handling-exceptions-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/continuing-execution-handling-exceptions.html
DROP TABLE employees_temp;
CREATE TABLE employees_temp AS
SELECT employee_id, salary, commission_pct
FROM employees;
DECLARE
sal_calc NUMBER(8,2);
BEGIN
INSERT INTO employees_temp (employee_id, salary, commission_pct)
VALUES (301, 2500, 0);
SELECT (salary / commission_pct) INTO sal_calc
FROM employees_temp
WHERE employee_id = 301;
INSERT INTO employees_temp VALUES (302, sal_calc/100, .1);
DBMS_OUTPUT.PUT_LINE('Row inserted.');
EXCEPTION
WHEN ZERO_DIVIDE THEN
DBMS_OUTPUT.PUT_LINE('Division by zero.');
END;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/continuing-execution-handling-exceptions-2.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/continuing-execution-handling-exceptions.html
DECLARE
sal_calc NUMBER(8,2);
BEGIN
INSERT INTO employees_temp (employee_id, salary, commission_pct)
VALUES (301, 2500, 0);
BEGIN
SELECT (salary / commission_pct) INTO sal_calc
FROM employees_temp
WHERE employee_id = 301;
EXCEPTION
WHEN ZERO_DIVIDE THEN
DBMS_OUTPUT.PUT_LINE('Substituting 2500 for undefined number.');
sal_calc := 2500;
END;
INSERT INTO employees_temp VALUES (302, sal_calc/100, .1);
DBMS_OUTPUT.PUT_LINE('Enclosing block: Row inserted.');
EXCEPTION
WHEN ZERO_DIVIDE THEN
DBMS_OUTPUT.PUT_LINE('Enclosing block: Division by zero.');
END;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/correlation-names-and-pseudorecords-11.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/correlation-names-and-pseudorecords.html
UPDATE employees
SET salary = salary * 1.05
WHERE department_id IN (10, 20, 90);
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/correlation-names-and-pseudorecords-13.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/correlation-names-and-pseudorecords.html
SELECT salary FROM employees WHERE job_id = 'AD_PRES';
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/correlation-names-and-pseudorecords-15.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/correlation-names-and-pseudorecords.html
DROP TABLE tab1;
CREATE TABLE tab1 (c1 CLOB);
INSERT INTO tab1 VALUES ('HTML Document Fragment
Some text.', 3);
CREATE OR REPLACE TRIGGER trg1
BEFORE UPDATE ON tab1
FOR EACH ROW
BEGIN
DBMS_OUTPUT.PUT_LINE('Old value of CLOB column: '||:OLD.c1);
DBMS_OUTPUT.PUT_LINE('Proposed new value of CLOB column: '||:NEW.c1);
:NEW.c1 := :NEW.c1 || TO_CLOB('
Standard footer paragraph.');
DBMS_OUTPUT.PUT_LINE('Final value of CLOB column: '||:NEW.c1);
END;
/
SET SERVEROUTPUT ON;
UPDATE tab1 SET c1 = '
Different Document Fragment
Different text.';
SELECT * FROM tab1;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/correlation-names-and-pseudorecords-16.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/correlation-names-and-pseudorecords.html
CREATE TABLE new (
field1 NUMBER,
field2 VARCHAR2(20)
);
CREATE OR REPLACE TRIGGER Print_salary_changes
BEFORE UPDATE ON new
REFERENCING new AS Newest
FOR EACH ROW
BEGIN
:Newest.Field2 := TO_CHAR (:newest.field1);
END;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/correlation-names-and-pseudorecords-17.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/correlation-names-and-pseudorecords.html
CREATE OR REPLACE TYPE t AUTHID DEFINER AS OBJECT (n NUMBER, m NUMBER)
/
CREATE TABLE tbl OF t
/
BEGIN
FOR j IN 1..5 LOOP
INSERT INTO tbl VALUES (t(j, 0));
END LOOP;
END;
/
SELECT * FROM tbl ORDER BY n;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/correlation-names-and-pseudorecords-19.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/correlation-names-and-pseudorecords.html
CREATE TABLE tbl_history ( d DATE, old_obj t, new_obj t)
/
CREATE OR REPLACE TRIGGER Tbl_Trg
AFTER UPDATE ON tbl
FOR EACH ROW
BEGIN
INSERT INTO tbl_history (d, old_obj, new_obj)
VALUES (SYSDATE, :OLD.OBJECT_VALUE, :NEW.OBJECT_VALUE);
END Tbl_Trg;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/correlation-names-and-pseudorecords-2.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/correlation-names-and-pseudorecords.html
DROP TABLE Emp_log;
CREATE TABLE Emp_log (
Emp_id NUMBER,
Log_date DATE,
New_salary NUMBER,
Action VARCHAR2(20));
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/correlation-names-and-pseudorecords-20.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/correlation-names-and-pseudorecords.html
UPDATE tbl SET tbl.n = tbl.n+1
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/correlation-names-and-pseudorecords-22.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/correlation-names-and-pseudorecords.html
BEGIN
FOR j IN (SELECT d, old_obj, new_obj FROM tbl_history) LOOP
DBMS_OUTPUT.PUT_LINE (
j.d ||
' -- old: ' || j.old_obj.n || ' ' || j.old_obj.m ||
' -- new: ' || j.new_obj.n || ' ' || j.new_obj.m
);
END LOOP;
END;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/correlation-names-and-pseudorecords-3.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/correlation-names-and-pseudorecords.html
CREATE OR REPLACE TRIGGER log_salary_increase
AFTER UPDATE OF salary ON employees
FOR EACH ROW
BEGIN
INSERT INTO Emp_log (Emp_id, Log_date, New_salary, Action)
VALUES (:NEW.employee_id, SYSDATE, :NEW.salary, 'New Salary');
END;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/correlation-names-and-pseudorecords-4.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/correlation-names-and-pseudorecords.html
UPDATE employees
SET salary = salary + 1000.0
WHERE Department_id = 20;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/correlation-names-and-pseudorecords-6.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/correlation-names-and-pseudorecords.html
SELECT * FROM Emp_log;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/correlation-names-and-pseudorecords-8.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/correlation-names-and-pseudorecords.html
CREATE OR REPLACE TRIGGER print_salary_changes
BEFORE DELETE OR INSERT OR UPDATE ON employees
FOR EACH ROW
WHEN (NEW.job_id <> 'AD_PRES') -- do not print information about President
DECLARE
sal_diff NUMBER;
BEGIN
sal_diff := :NEW.salary - :OLD.salary;
DBMS_OUTPUT.PUT(:NEW.last_name || ': ');
DBMS_OUTPUT.PUT('Old salary = ' || :OLD.salary || ', ');
DBMS_OUTPUT.PUT('New salary = ' || :NEW.salary || ', ');
DBMS_OUTPUT.PUT_LINE('Difference: ' || sal_diff);
END;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/correlation-names-and-pseudorecords-9.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/correlation-names-and-pseudorecords.html
SELECT last_name, department_id, salary, job_id
FROM employees
WHERE department_id IN (10, 20, 90)
ORDER BY department_id, last_name;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/cursor-expressions-1.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/cursor-expressions.html
DECLARE
TYPE emp_cur_typ IS REF CURSOR;
emp_cur emp_cur_typ;
dept_name departments.department_name%TYPE;
emp_name employees.last_name%TYPE;
CURSOR c1 IS
SELECT department_name,
CURSOR ( SELECT e.last_name
FROM employees e
WHERE e.department_id = d.department_id
ORDER BY e.last_name
) employees
FROM departments d
WHERE department_name LIKE 'A%'
ORDER BY department_name;
BEGIN
OPEN c1;
LOOP -- Process each row of query result set
FETCH c1 INTO dept_name, emp_cur;
EXIT WHEN c1%NOTFOUND;
DBMS_OUTPUT.PUT_LINE('Department: ' || dept_name);
LOOP -- Process each row of subquery result set
FETCH emp_cur INTO emp_name;
EXIT WHEN emp_cur%NOTFOUND;
DBMS_OUTPUT.PUT_LINE('-- Employee: ' || emp_name);
END LOOP;
END LOOP;
CLOSE c1;
END;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/cursor-variables-1.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/cursor-variables.html
DECLARE
TYPE empcurtyp IS REF CURSOR RETURN employees%ROWTYPE; -- strong type
TYPE genericcurtyp IS REF CURSOR; -- weak type
cursor1 empcurtyp; -- strong cursor variable
cursor2 genericcurtyp; -- weak cursor variable
my_cursor SYS_REFCURSOR; -- weak cursor variable
TYPE deptcurtyp IS REF CURSOR RETURN departments%ROWTYPE; -- strong type
dept_cv deptcurtyp; -- strong cursor variable
BEGIN
NULL;
END;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/cursor-variables-10.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/cursor-variables.html
DECLARE
sal employees.salary%TYPE;
sal_multiple employees.salary%TYPE;
factor INTEGER := 2;
cv SYS_REFCURSOR;
BEGIN
DBMS_OUTPUT.PUT_LINE('factor = ' || factor);
OPEN cv FOR
SELECT salary, salary*factor
FROM employees
WHERE job_id LIKE 'AD_%'; -- PL/SQL evaluates factor
LOOP
FETCH cv INTO sal, sal_multiple;
EXIT WHEN cv%NOTFOUND;
DBMS_OUTPUT.PUT_LINE('sal = ' || sal);
DBMS_OUTPUT.PUT_LINE('sal_multiple = ' || sal_multiple);
END LOOP;
factor := factor + 1;
DBMS_OUTPUT.PUT_LINE('factor = ' || factor);
OPEN cv FOR
SELECT salary, salary*factor
FROM employees
WHERE job_id LIKE 'AD_%'; -- PL/SQL evaluates factor
LOOP
FETCH cv INTO sal, sal_multiple;
EXIT WHEN cv%NOTFOUND;
DBMS_OUTPUT.PUT_LINE('sal = ' || sal);
DBMS_OUTPUT.PUT_LINE('sal_multiple = ' || sal_multiple);
END LOOP;
CLOSE cv;
END;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/cursor-variables-12.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/cursor-variables.html
CREATE OR REPLACE PACKAGE pkg AUTHID DEFINER AS
TYPE rec IS RECORD(f1 NUMBER, f2 VARCHAR2(30));
TYPE mytab IS TABLE OF rec INDEX BY pls_integer;
END;
/
DECLARE
v1 pkg.mytab; -- collection of records
v2 pkg.rec;
c1 SYS_REFCURSOR;
BEGIN
v1(1).f1 := 1;
v1(1).f2 := 'one';
OPEN c1 FOR SELECT * FROM TABLE(v1);
FETCH c1 INTO v2;
CLOSE c1;
DBMS_OUTPUT.PUT_LINE('Values in record are ' || v2.f1 || ' and ' || v2.f2);
END;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/cursor-variables-14.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/cursor-variables.html
CREATE OR REPLACE PACKAGE emp_data AUTHID DEFINER AS
TYPE empcurtyp IS REF CURSOR RETURN employees%ROWTYPE;
PROCEDURE open_emp_cv (emp_cv IN OUT empcurtyp);
END emp_data;
/
CREATE OR REPLACE PACKAGE BODY emp_data AS
PROCEDURE open_emp_cv (emp_cv IN OUT EmpCurTyp) IS
BEGIN
OPEN emp_cv FOR SELECT * FROM employees;
END open_emp_cv;
END emp_data;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/cursor-variables-15.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/cursor-variables.html
CREATE OR REPLACE PACKAGE emp_data AUTHID DEFINER AS
TYPE empcurtyp IS REF CURSOR RETURN employees%ROWTYPE;
PROCEDURE open_emp_cv (emp_cv IN OUT empcurtyp, choice INT);
END emp_data;
/
CREATE OR REPLACE PACKAGE BODY emp_data AS
PROCEDURE open_emp_cv (emp_cv IN OUT empcurtyp, choice INT) IS
BEGIN
IF choice = 1 THEN
OPEN emp_cv FOR SELECT *
FROM employees
WHERE commission_pct IS NOT NULL;
ELSIF choice = 2 THEN
OPEN emp_cv FOR SELECT *
FROM employees
WHERE salary > 2500;
ELSIF choice = 3 THEN
OPEN emp_cv FOR SELECT *
FROM employees
WHERE department_id = 100;
END IF;
END;
END emp_data;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/cursor-variables-16.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/cursor-variables.html
CREATE OR REPLACE PACKAGE admin_data AUTHID DEFINER AS
TYPE gencurtyp IS REF CURSOR;
PROCEDURE open_cv (generic_cv IN OUT gencurtyp, choice INT);
END admin_data;
/
CREATE OR REPLACE PACKAGE BODY admin_data AS
PROCEDURE open_cv (generic_cv IN OUT gencurtyp, choice INT) IS
BEGIN
IF choice = 1 THEN
OPEN generic_cv FOR SELECT * FROM employees;
ELSIF choice = 2 THEN
OPEN generic_cv FOR SELECT * FROM departments;
ELSIF choice = 3 THEN
OPEN generic_cv FOR SELECT * FROM jobs;
END IF;
END;
END admin_data;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/cursor-variables-17.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/cursor-variables.html
BEGIN
OPEN :emp_cv FOR SELECT * FROM employees;
OPEN :dept_cv FOR SELECT * FROM departments;
OPEN :loc_cv FOR SELECT * FROM locations;
END;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/cursor-variables-18.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/cursor-variables.html
BEGIN
CLOSE :emp_cv;
CLOSE :dept_cv;
CLOSE :loc_cv;
END;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/cursor-variables-19.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/cursor-variables.html
BEGIN
OPEN :c1 FOR SELECT 1 FROM DUAL;
OPEN :c2 FOR SELECT 1 FROM DUAL;
OPEN :c3 FOR SELECT 1 FROM DUAL;
END;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/cursor-variables-2.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/cursor-variables.html
DECLARE
TYPE EmpRecTyp IS RECORD (
employee_id NUMBER,
last_name VARCHAR2(25),
salary NUMBER(8,2));
TYPE EmpCurTyp IS REF CURSOR RETURN EmpRecTyp;
emp_cv EmpCurTyp;
BEGIN
NULL;
END;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/cursor-variables-3.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/cursor-variables.html
DECLARE
cv SYS_REFCURSOR; -- cursor variable
v_lastname employees.last_name%TYPE; -- variable for last_name
v_jobid employees.job_id%TYPE; -- variable for job_id
query_2 VARCHAR2(200) :=
'SELECT * FROM employees
WHERE REGEXP_LIKE (job_id, ''[ACADFIMKSA]_M[ANGR]'')
ORDER BY job_id';
v_employees employees%ROWTYPE; -- record variable row of table
BEGIN
OPEN cv FOR
SELECT last_name, job_id FROM employees
WHERE REGEXP_LIKE (job_id, 'S[HT]_CLERK')
ORDER BY last_name;
LOOP -- Fetches 2 columns into variables
FETCH cv INTO v_lastname, v_jobid;
EXIT WHEN cv%NOTFOUND;
DBMS_OUTPUT.PUT_LINE( RPAD(v_lastname, 25, ' ') || v_jobid );
END LOOP;
DBMS_OUTPUT.PUT_LINE( '-------------------------------------' );
OPEN cv FOR query_2;
LOOP -- Fetches entire row into the v_employees record
FETCH cv INTO v_employees;
EXIT WHEN cv%NOTFOUND;
DBMS_OUTPUT.PUT_LINE( RPAD(v_employees.last_name, 25, ' ') ||
v_employees.job_id );
END LOOP;
CLOSE cv;
END;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/cursor-variables-5.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/cursor-variables.html
DECLARE
TYPE empcurtyp IS REF CURSOR;
TYPE namelist IS TABLE OF employees.last_name%TYPE;
TYPE sallist IS TABLE OF employees.salary%TYPE;
emp_cv empcurtyp;
names namelist;
sals sallist;
BEGIN
OPEN emp_cv FOR
SELECT last_name, salary FROM employees
WHERE job_id = 'SA_REP'
ORDER BY salary DESC;
FETCH emp_cv BULK COLLECT INTO names, sals;
CLOSE emp_cv;
-- loop through the names and sals collections
FOR i IN names.FIRST .. names.LAST
LOOP
DBMS_OUTPUT.PUT_LINE
('Name = ' || names(i) || ', salary = ' || sals(i));
END LOOP;
END;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/cursor-variables-8.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/cursor-variables.html
DECLARE
sal employees.salary%TYPE;
sal_multiple employees.salary%TYPE;
factor INTEGER := 2;
cv SYS_REFCURSOR;
BEGIN
OPEN cv FOR
SELECT salary, salary*factor
FROM employees
WHERE job_id LIKE 'AD_%'; -- PL/SQL evaluates factor
LOOP
FETCH cv INTO sal, sal_multiple;
EXIT WHEN cv%NOTFOUND;
DBMS_OUTPUT.PUT_LINE('factor = ' || factor);
DBMS_OUTPUT.PUT_LINE('sal = ' || sal);
DBMS_OUTPUT.PUT_LINE('sal_multiple = ' || sal_multiple);
factor := factor + 1; -- Does not affect sal_multiple
END LOOP;
CLOSE cv;
END;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/cursors-overview-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/cursors-overview.html
DROP TABLE dept_temp;
CREATE TABLE dept_temp AS
SELECT * FROM departments;
CREATE OR REPLACE PROCEDURE p (
dept_no NUMBER
) AUTHID CURRENT_USER AS
BEGIN
DELETE FROM dept_temp
WHERE department_id = dept_no;
IF SQL%FOUND THEN
DBMS_OUTPUT.PUT_LINE (
'Delete succeeded for department number ' || dept_no
);
ELSE
DBMS_OUTPUT.PUT_LINE ('No department number ' || dept_no);
END IF;
END;
/
BEGIN
p(270);
p(400);
END;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/cursors-overview-10.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/cursors-overview.html
DECLARE
CURSOR c IS
SELECT e.job_id, j.job_title
FROM employees e, jobs j
WHERE e.job_id = j.job_id AND e.manager_id = 100
ORDER BY last_name;
-- Record variables for rows of cursor result set:
job1 c%ROWTYPE;
job2 c%ROWTYPE;
job3 c%ROWTYPE;
job4 c%ROWTYPE;
job5 c%ROWTYPE;
BEGIN
OPEN c;
FETCH c INTO job1; -- fetches first row
FETCH c INTO job2; -- fetches second row
FETCH c INTO job3; -- fetches third row
FETCH c INTO job4; -- fetches fourth row
FETCH c INTO job5; -- fetches fifth row
CLOSE c;
DBMS_OUTPUT.PUT_LINE(job1.job_title || ' (' || job1.job_id || ')');
DBMS_OUTPUT.PUT_LINE(job2.job_title || ' (' || job2.job_id || ')');
DBMS_OUTPUT.PUT_LINE(job3.job_title || ' (' || job3.job_id || ')');
DBMS_OUTPUT.PUT_LINE(job4.job_title || ' (' || job4.job_id || ')');
DBMS_OUTPUT.PUT_LINE(job5.job_title || ' (' || job5.job_id || ')');
END;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/cursors-overview-12.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/cursors-overview.html
DECLARE
sal employees.salary%TYPE;
sal_multiple employees.salary%TYPE;
factor INTEGER := 2;
CURSOR c1 IS
SELECT salary, salary*factor FROM employees
WHERE job_id LIKE 'AD_%';
BEGIN
OPEN c1; -- PL/SQL evaluates factor
LOOP
FETCH c1 INTO sal, sal_multiple;
EXIT WHEN c1%NOTFOUND;
DBMS_OUTPUT.PUT_LINE('factor = ' || factor);
DBMS_OUTPUT.PUT_LINE('sal = ' || sal);
DBMS_OUTPUT.PUT_LINE('sal_multiple = ' || sal_multiple);
factor := factor + 1; -- Does not affect sal_multiple
END LOOP;
CLOSE c1;
END;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/cursors-overview-14.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/cursors-overview.html
DECLARE
sal employees.salary%TYPE;
sal_multiple employees.salary%TYPE;
factor INTEGER := 2;
CURSOR c1 IS
SELECT salary, salary*factor FROM employees
WHERE job_id LIKE 'AD_%';
BEGIN
DBMS_OUTPUT.PUT_LINE('factor = ' || factor);
OPEN c1; -- PL/SQL evaluates factor
LOOP
FETCH c1 INTO sal, sal_multiple;
EXIT WHEN c1%NOTFOUND;
DBMS_OUTPUT.PUT_LINE('sal = ' || sal);
DBMS_OUTPUT.PUT_LINE('sal_multiple = ' || sal_multiple);
END LOOP;
CLOSE c1;
factor := factor + 1;
DBMS_OUTPUT.PUT_LINE('factor = ' || factor);
OPEN c1; -- PL/SQL evaluates factor
LOOP
FETCH c1 INTO sal, sal_multiple;
EXIT WHEN c1%NOTFOUND;
DBMS_OUTPUT.PUT_LINE('sal = ' || sal);
DBMS_OUTPUT.PUT_LINE('sal_multiple = ' || sal_multiple);
END LOOP;
CLOSE c1;
END;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/cursors-overview-16.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/cursors-overview.html
DECLARE
CURSOR c1 IS
SELECT employee_id,
(salary * .05) raise
FROM employees
WHERE job_id LIKE '%_MAN'
ORDER BY employee_id;
emp_rec c1%ROWTYPE;
BEGIN
OPEN c1;
LOOP
FETCH c1 INTO emp_rec;
EXIT WHEN c1%NOTFOUND;
DBMS_OUTPUT.PUT_LINE (
'Raise for employee #' || emp_rec.employee_id ||
' is $' || emp_rec.raise
);
END LOOP;
CLOSE c1;
END;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/cursors-overview-18.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/cursors-overview.html
DECLARE
CURSOR c (job VARCHAR2, max_sal NUMBER) IS
SELECT last_name, first_name, (salary - max_sal) overpayment
FROM employees
WHERE job_id = job
AND salary > max_sal
ORDER BY salary;
PROCEDURE print_overpaid IS
last_name_ employees.last_name%TYPE;
first_name_ employees.first_name%TYPE;
overpayment_ employees.salary%TYPE;
BEGIN
LOOP
FETCH c INTO last_name_, first_name_, overpayment_;
EXIT WHEN c%NOTFOUND;
DBMS_OUTPUT.PUT_LINE(last_name_ || ', ' || first_name_ ||
' (by ' || overpayment_ || ')');
END LOOP;
END print_overpaid;
BEGIN
DBMS_OUTPUT.PUT_LINE('----------------------');
DBMS_OUTPUT.PUT_LINE('Overpaid Stock Clerks:');
DBMS_OUTPUT.PUT_LINE('----------------------');
OPEN c('ST_CLERK', 5000);
print_overpaid;
CLOSE c;
DBMS_OUTPUT.PUT_LINE('-------------------------------');
DBMS_OUTPUT.PUT_LINE('Overpaid Sales Representatives:');
DBMS_OUTPUT.PUT_LINE('-------------------------------');
OPEN c('SA_REP', 10000);
print_overpaid;
CLOSE c;
END;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/cursors-overview-2.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/cursors-overview.html
DROP TABLE employees_temp;
CREATE TABLE employees_temp AS
SELECT * FROM employees;
DECLARE
mgr_no NUMBER(6) := 122;
BEGIN
DELETE FROM employees_temp WHERE manager_id = mgr_no;
DBMS_OUTPUT.PUT_LINE
('Number of employees deleted: ' || TO_CHAR(SQL%ROWCOUNT));
END;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/cursors-overview-20.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/cursors-overview.html
DECLARE
CURSOR c (location NUMBER DEFAULT 1700) IS
SELECT d.department_name,
e.last_name manager,
l.city
FROM departments d, employees e, locations l
WHERE l.location_id = location
AND l.location_id = d.location_id
AND d.department_id = e.department_id
ORDER BY d.department_id;
PROCEDURE print_depts IS
dept_name departments.department_name%TYPE;
mgr_name employees.last_name%TYPE;
city_name locations.city%TYPE;
BEGIN
LOOP
FETCH c INTO dept_name, mgr_name, city_name;
EXIT WHEN c%NOTFOUND;
DBMS_OUTPUT.PUT_LINE(dept_name || ' (Manager: ' || mgr_name || ')');
END LOOP;
END print_depts;
BEGIN
DBMS_OUTPUT.PUT_LINE('DEPARTMENTS AT HEADQUARTERS:');
DBMS_OUTPUT.PUT_LINE('--------------------------------');
OPEN c;
print_depts;
DBMS_OUTPUT.PUT_LINE('--------------------------------');
CLOSE c;
DBMS_OUTPUT.PUT_LINE('DEPARTMENTS IN CANADA:');
DBMS_OUTPUT.PUT_LINE('--------------------------------');
OPEN c(1800); -- Toronto
print_depts;
CLOSE c;
OPEN c(1900); -- Whitehorse
print_depts;
CLOSE c;
END;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/cursors-overview-22.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/cursors-overview.html
DECLARE
CURSOR c (job VARCHAR2, max_sal NUMBER,
hired DATE DEFAULT TO_DATE('31-DEC-1999', 'DD-MON-YYYY')) IS
SELECT last_name, first_name, (salary - max_sal) overpayment
FROM employees
WHERE job_id = job
AND salary > max_sal
AND hire_date > hired
ORDER BY salary;
PROCEDURE print_overpaid IS
last_name_ employees.last_name%TYPE;
first_name_ employees.first_name%TYPE;
overpayment_ employees.salary%TYPE;
BEGIN
LOOP
FETCH c INTO last_name_, first_name_, overpayment_;
EXIT WHEN c%NOTFOUND;
DBMS_OUTPUT.PUT_LINE(last_name_ || ', ' || first_name_ ||
' (by ' || overpayment_ || ')');
END LOOP;
END print_overpaid;
BEGIN
DBMS_OUTPUT.PUT_LINE('-------------------------------');
DBMS_OUTPUT.PUT_LINE('Overpaid Sales Representatives:');
DBMS_OUTPUT.PUT_LINE('-------------------------------');
OPEN c('SA_REP', 10000); -- existing reference
print_overpaid;
CLOSE c;
DBMS_OUTPUT.PUT_LINE('------------------------------------------------');
DBMS_OUTPUT.PUT_LINE('Overpaid Sales Representatives Hired After 2014:');
DBMS_OUTPUT.PUT_LINE('------------------------------------------------');
OPEN c('SA_REP', 10000, TO_DATE('31-DEC-2014', 'DD-MON-YYYY'));
-- new reference
print_overpaid;
CLOSE c;
END;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/cursors-overview-24.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/cursors-overview.html
DECLARE
CURSOR c1 IS
SELECT last_name, salary FROM employees
WHERE ROWNUM < 11;
the_name employees.last_name%TYPE;
the_salary employees.salary%TYPE;
BEGIN
IF NOT c1%ISOPEN THEN
OPEN c1;
END IF;
FETCH c1 INTO the_name, the_salary;
IF c1%ISOPEN THEN
CLOSE c1;
END IF;
END;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/cursors-overview-25.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/cursors-overview.html
DECLARE
CURSOR c1 IS
SELECT last_name, salary FROM employees
WHERE ROWNUM < 11
ORDER BY last_name;
my_ename employees.last_name%TYPE;
my_salary employees.salary%TYPE;
BEGIN
OPEN c1;
LOOP
FETCH c1 INTO my_ename, my_salary;
IF c1%FOUND THEN -- fetch succeeded
DBMS_OUTPUT.PUT_LINE('Name = ' || my_ename || ', salary = ' || my_salary);
ELSE -- fetch failed
EXIT;
END IF;
END LOOP;
END;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/cursors-overview-27.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/cursors-overview.html
DECLARE
CURSOR c1 IS
SELECT last_name, salary FROM employees
WHERE ROWNUM < 11
ORDER BY last_name;
my_ename employees.last_name%TYPE;
my_salary employees.salary%TYPE;
BEGIN
OPEN c1;
LOOP
FETCH c1 INTO my_ename, my_salary;
IF c1%NOTFOUND THEN -- fetch failed
EXIT;
ELSE -- fetch succeeded
DBMS_OUTPUT.PUT_LINE
('Name = ' || my_ename || ', salary = ' || my_salary);
END IF;
END LOOP;
END;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/cursors-overview-29.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/cursors-overview.html
DECLARE
CURSOR c1 IS
SELECT last_name FROM employees
WHERE ROWNUM < 11
ORDER BY last_name;
name employees.last_name%TYPE;
BEGIN
OPEN c1;
LOOP
FETCH c1 INTO name;
EXIT WHEN c1%NOTFOUND OR c1%NOTFOUND IS NULL;
DBMS_OUTPUT.PUT_LINE(c1%ROWCOUNT || '. ' || name);
IF c1%ROWCOUNT = 5 THEN
DBMS_OUTPUT.PUT_LINE('--- Fetched 5th row ---');
END IF;
END LOOP;
CLOSE c1;
END;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/cursors-overview-6.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/cursors-overview.html
DECLARE
CURSOR c1 RETURN departments%ROWTYPE; -- Declare c1
CURSOR c2 IS -- Declare and define c2
SELECT employee_id, job_id, salary FROM employees
WHERE salary > 2000;
CURSOR c1 RETURN departments%ROWTYPE IS -- Define c1,
SELECT * FROM departments -- repeating return type
WHERE department_id = 110;
CURSOR c3 RETURN locations%ROWTYPE; -- Declare c3
CURSOR c3 IS -- Define c3,
SELECT * FROM locations -- omitting return type
WHERE country_id = 'JP';
BEGIN
NULL;
END;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/cursors-overview-7.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/cursors-overview.html
FETCH cursor_name INTO into_clause
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/cursors-overview-8.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/cursors-overview.html
DECLARE
CURSOR c1 IS
SELECT last_name, job_id FROM employees
WHERE REGEXP_LIKE (job_id, 'S[HT]_CLERK')
ORDER BY last_name;
v_lastname employees.last_name%TYPE; -- variable for last_name
v_jobid employees.job_id%TYPE; -- variable for job_id
CURSOR c2 IS
SELECT * FROM employees
WHERE REGEXP_LIKE (job_id, '[ACADFIMKSA]_M[ANGR]')
ORDER BY job_id;
v_employees employees%ROWTYPE; -- record variable for row of table
BEGIN
OPEN c1;
LOOP -- Fetches 2 columns into variables
FETCH c1 INTO v_lastname, v_jobid;
EXIT WHEN c1%NOTFOUND;
DBMS_OUTPUT.PUT_LINE( RPAD(v_lastname, 25, ' ') || v_jobid );
END LOOP;
CLOSE c1;
DBMS_OUTPUT.PUT_LINE( '-------------------------------------' );
OPEN c2;
LOOP -- Fetches entire row into the v_employees record
FETCH c2 INTO v_employees;
EXIT WHEN c2%NOTFOUND;
DBMS_OUTPUT.PUT_LINE( RPAD(v_employees.last_name, 25, ' ') ||
v_employees.job_id );
END LOOP;
CLOSE c2;
END;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/dbms_sql-package-1.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/dbms_sql-package.html
CREATE OR REPLACE PROCEDURE p AUTHID DEFINER AS
c1 SYS_REFCURSOR;
c2 SYS_REFCURSOR;
BEGIN
OPEN c1 FOR
SELECT first_name, last_name
FROM employees
WHERE employee_id = 176;
DBMS_SQL.RETURN_RESULT (c1);
-- Now p cannot access the result.
OPEN c2 FOR
SELECT city, state_province
FROM locations
WHERE country_id = 'AU';
DBMS_SQL.RETURN_RESULT (c2);
-- Now p cannot access the result.
END;
/
BEGIN
p;
END;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/dbms_sql-package-4.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/dbms_sql-package.html
CREATE OR REPLACE PROCEDURE get_employee_info (id IN VARCHAR2) AUTHID DEFINER AS
rc SYS_REFCURSOR;
BEGIN
-- Return employee info
OPEN rc FOR SELECT first_name, last_name, email, phone_number
FROM employees
WHERE employee_id = id;
DBMS_SQL.RETURN_RESULT(rc);
-- Return employee job history
OPEN RC FOR SELECT job_title, start_date, end_date
FROM job_history jh, jobs j
WHERE jh.employee_id = id AND
jh.job_id = j.job_id
ORDER BY start_date DESC;
DBMS_SQL.RETURN_RESULT(rc);
END;
/
<>
DECLARE
c INTEGER;
rc SYS_REFCURSOR;
n NUMBER;
first_name VARCHAR2(20);
last_name VARCHAR2(25);
email VARCHAR2(25);
phone_number VARCHAR2(20);
job_title VARCHAR2(35);
start_date DATE;
end_date DATE;
BEGIN
c := DBMS_SQL.OPEN_CURSOR(true);
DBMS_SQL.PARSE(c, 'BEGIN get_employee_info(:id); END;', DBMS_SQL.NATIVE);
DBMS_SQL.BIND_VARIABLE(c, ':id', 176);
n := DBMS_SQL.EXECUTE(c);
-- Get employee info
dbms_sql.get_next_result(c, rc);
FETCH rc INTO first_name, last_name, email, phone_number;
DBMS_OUTPUT.PUT_LINE('Employee: '||first_name || ' ' || last_name);
DBMS_OUTPUT.PUT_LINE('Email: ' ||email);
DBMS_OUTPUT.PUT_LINE('Phone: ' ||phone_number);
-- Get employee job history
DBMS_OUTPUT.PUT_LINE('Titles:');
DBMS_SQL.GET_NEXT_RESULT(c, rc);
LOOP
FETCH rc INTO job_title, start_date, end_date;
EXIT WHEN rc%NOTFOUND;
DBMS_OUTPUT.PUT_LINE
('- '||job_title||' ('||start_date||' - ' ||end_date||')');
END LOOP;
DBMS_SQL.CLOSE_CURSOR(c);
END main;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/dbms_sql-package-6.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/dbms_sql-package.html
CREATE OR REPLACE TYPE vc_array IS TABLE OF VARCHAR2(200);
/
CREATE OR REPLACE TYPE numlist IS TABLE OF NUMBER;
/
CREATE OR REPLACE PROCEDURE do_query_1 (
placeholder vc_array,
bindvars vc_array,
sql_stmt VARCHAR2
) AUTHID DEFINER
IS
TYPE curtype IS REF CURSOR;
src_cur curtype;
curid NUMBER;
bindnames vc_array;
empnos numlist;
depts numlist;
ret NUMBER;
isopen BOOLEAN;
BEGIN
-- Open SQL cursor number:
curid := DBMS_SQL.OPEN_CURSOR;
-- Parse SQL cursor number:
DBMS_SQL.PARSE(curid, sql_stmt, DBMS_SQL.NATIVE);
bindnames := placeholder;
-- Bind variables:
FOR i IN 1 .. bindnames.COUNT LOOP
DBMS_SQL.BIND_VARIABLE(curid, bindnames(i), bindvars(i));
END LOOP;
-- Run SQL cursor number:
ret := DBMS_SQL.EXECUTE(curid);
-- Switch from DBMS_SQL to native dynamic SQL:
src_cur := DBMS_SQL.TO_REFCURSOR(curid);
FETCH src_cur BULK COLLECT INTO empnos, depts;
-- This would cause an error because curid was converted to a REF CURSOR:
-- isopen := DBMS_SQL.IS_OPEN(curid);
CLOSE src_cur;
END;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/dbms_sql-package-7.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/dbms_sql-package.html
CREATE OR REPLACE PROCEDURE do_query_2 (
sql_stmt VARCHAR2
) AUTHID DEFINER
IS
TYPE curtype IS REF CURSOR;
src_cur curtype;
curid NUMBER;
desctab DBMS_SQL.DESC_TAB;
colcnt NUMBER;
namevar VARCHAR2(50);
numvar NUMBER;
datevar DATE;
empno NUMBER := 100;
BEGIN
-- sql_stmt := SELECT ... FROM employees WHERE employee_id = :b1';
-- Open REF CURSOR variable:
OPEN src_cur FOR sql_stmt USING empno;
-- Switch from native dynamic SQL to DBMS_SQL package:
curid := DBMS_SQL.TO_CURSOR_NUMBER(src_cur);
DBMS_SQL.DESCRIBE_COLUMNS(curid, colcnt, desctab);
-- Define columns:
FOR i IN 1 .. colcnt LOOP
IF desctab(i).col_type = 2 THEN
DBMS_SQL.DEFINE_COLUMN(curid, i, numvar);
ELSIF desctab(i).col_type = 12 THEN
DBMS_SQL.DEFINE_COLUMN(curid, i, datevar);
-- statements
ELSE
DBMS_SQL.DEFINE_COLUMN(curid, i, namevar, 50);
END IF;
END LOOP;
-- Fetch rows with DBMS_SQL package:
WHILE DBMS_SQL.FETCH_ROWS(curid) > 0 LOOP
FOR i IN 1 .. colcnt LOOP
IF (desctab(i).col_type = 1) THEN
DBMS_SQL.COLUMN_VALUE(curid, i, namevar);
ELSIF (desctab(i).col_type = 2) THEN
DBMS_SQL.COLUMN_VALUE(curid, i, numvar);
ELSIF (desctab(i).col_type = 12) THEN
DBMS_SQL.COLUMN_VALUE(curid, i, datevar);
-- statements
END IF;
END LOOP;
END LOOP;
DBMS_SQL.CLOSE_CURSOR(curid);
END;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/declarations-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/declarations.html
DECLARE
acct_id INTEGER(4) NOT NULL := 9999;
a NATURALN := 9999;
b POSITIVEN := 9999;
c SIMPLE_INTEGER := 9999;
BEGIN
NULL;
END;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/declarations-1.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/declarations.html
DECLARE
null_string VARCHAR2(80) := TO_CHAR('');
address VARCHAR2(80);
zip_code VARCHAR2(80) := SUBSTR(address, 25, 0);
name VARCHAR2(80);
valid BOOLEAN := (name != '');
BEGIN
NULL;
END;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/declarations-11.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/declarations.html
DECLARE
name VARCHAR(25) NOT NULL := 'Smith';
surname name%TYPE := 'Jones';
BEGIN
DBMS_OUTPUT.PUT_LINE('name=' || name);
DBMS_OUTPUT.PUT_LINE('surname=' || surname);
END;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/declarations-2.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/declarations.html
DECLARE
part_number NUMBER(6);
part_name VARCHAR2(20);
in_stock BOOLEAN;
part_price NUMBER(6,2);
part_description VARCHAR2(50);
BEGIN
NULL;
END;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/declarations-3.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/declarations.html
DECLARE
credit_limit CONSTANT REAL := 5000.00;
max_days_in_year CONSTANT INTEGER := 366;
urban_legend CONSTANT BOOLEAN := FALSE;
BEGIN
NULL;
END;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/declarations-4.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/declarations.html
DECLARE
hours_worked INTEGER := 40;
employee_count INTEGER := 0;
pi CONSTANT REAL := 3.14159;
radius REAL := 1;
area REAL := (pi * radius**2);
BEGIN
NULL;
END;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/declarations-5.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/declarations.html
DECLARE
counter INTEGER; -- initial value is NULL by default
BEGIN
counter := counter + 1; -- NULL + 1 is still NULL
IF counter IS NULL THEN
DBMS_OUTPUT.PUT_LINE('counter is NULL.');
END IF;
END;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/declarations-9.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/declarations.html
DECLARE
surname employees.last_name%TYPE;
BEGIN
DBMS_OUTPUT.PUT_LINE('surname=' || surname);
END;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/description-static-sql-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/description-static-sql.html
DROP TABLE employees_temp;
CREATE TABLE employees_temp AS
SELECT employee_id, first_name, last_name
FROM employees;
DECLARE
emp_id employees_temp.employee_id%TYPE := 299;
emp_first_name employees_temp.first_name%TYPE := 'Bob';
emp_last_name employees_temp.last_name%TYPE := 'Henry';
BEGIN
INSERT INTO employees_temp (employee_id, first_name, last_name)
VALUES (emp_id, emp_first_name, emp_last_name);
UPDATE employees_temp
SET first_name = 'Robert'
WHERE employee_id = emp_id;
DELETE FROM employees_temp
WHERE employee_id = emp_id
RETURNING first_name, last_name
INTO emp_first_name, emp_last_name;
COMMIT;
DBMS_OUTPUT.PUT_LINE (emp_first_name || ' ' || emp_last_name);
END;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/description-static-sql-2.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/description-static-sql.html
DROP TABLE employees_temp;
CREATE TABLE employees_temp AS
SELECT employee_id, first_name, last_name
FROM employees;
DROP TABLE employees_temp2;
CREATE TABLE employees_temp2 AS
SELECT employee_id, first_name, last_name
FROM employees;
DECLARE
seq_value NUMBER;
BEGIN
-- Generate initial sequence number
seq_value := employees_seq.NEXTVAL;
-- Print initial sequence number:
DBMS_OUTPUT.PUT_LINE (
'Initial sequence value: ' || TO_CHAR(seq_value)
);
-- Use NEXTVAL to create unique number when inserting data:
INSERT INTO employees_temp (employee_id, first_name, last_name)
VALUES (employees_seq.NEXTVAL, 'Lynette', 'Smith');
-- Use CURRVAL to store same value somewhere else:
INSERT INTO employees_temp2 VALUES (employees_seq.CURRVAL,
'Morgan', 'Smith');
/* Because NEXTVAL values might be referenced
by different users and applications,
and some NEXTVAL values might not be stored in database,
there might be gaps in sequence. */
-- Use CURRVAL to specify record to delete:
seq_value := employees_seq.CURRVAL;
DELETE FROM employees_temp2
WHERE employee_id = seq_value;
-- Update employee_id with NEXTVAL for specified record:
UPDATE employees_temp
SET employee_id = employees_seq.NEXTVAL
WHERE first_name = 'Lynette'
AND last_name = 'Smith';
-- Display final value of CURRVAL:
seq_value := employees_seq.CURRVAL;
DBMS_OUTPUT.PUT_LINE (
'Ending sequence value: ' || TO_CHAR(seq_value)
);
END;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/dml-triggers-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/dml-triggers.html
CREATE OR REPLACE TRIGGER t
BEFORE
INSERT OR
UPDATE OF salary, department_id OR
DELETE
ON employees
BEGIN
CASE
WHEN INSERTING THEN
DBMS_OUTPUT.PUT_LINE('Inserting');
WHEN UPDATING('salary') THEN
DBMS_OUTPUT.PUT_LINE('Updating salary');
WHEN UPDATING('department_id') THEN
DBMS_OUTPUT.PUT_LINE('Updating department ID');
WHEN DELETING THEN
DBMS_OUTPUT.PUT_LINE('Deleting');
END CASE;
END;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/dml-triggers-1.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/dml-triggers.html
CREATE OR REPLACE VIEW order_info AS
SELECT c.customer_id, c.cust_last_name, c.cust_first_name,
o.order_id, o.order_date, o.order_status
FROM customers c, orders o
WHERE c.customer_id = o.customer_id;
CREATE OR REPLACE TRIGGER order_info_insert
INSTEAD OF INSERT ON order_info
DECLARE
duplicate_info EXCEPTION;
PRAGMA EXCEPTION_INIT (duplicate_info, -00001);
BEGIN
INSERT INTO customers
(customer_id, cust_last_name, cust_first_name)
VALUES (
:new.customer_id,
:new.cust_last_name,
:new.cust_first_name);
INSERT INTO orders (order_id, order_date, customer_id)
VALUES (
:new.order_id,
:new.order_date,
:new.customer_id);
EXCEPTION
WHEN duplicate_info THEN
RAISE_APPLICATION_ERROR (
num=> -20107,
msg=> 'Duplicate customer or order ID');
END order_info_insert;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/dml-triggers-10.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/dml-triggers.html
SELECT COUNT(*) FROM orders WHERE customer_id = 999;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/dml-triggers-12.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/dml-triggers.html
CREATE OR REPLACE TYPE nte
AUTHID DEFINER IS
OBJECT (
emp_id NUMBER(6),
lastname VARCHAR2(25),
job VARCHAR2(10),
sal NUMBER(8,2)
);
/
CREATE OR REPLACE TYPE emp_list_ IS
TABLE OF nte;
/
CREATE OR REPLACE VIEW dept_view AS
SELECT d.department_id,
d.department_name,
CAST (MULTISET (SELECT e.employee_id, e.last_name, e.job_id, e.salary
FROM employees e
WHERE e.department_id = d.department_id
)
AS emp_list_
) emplist
FROM departments d;
CREATE OR REPLACE TRIGGER dept_emplist_tr
INSTEAD OF INSERT ON NESTED TABLE emplist OF dept_view
REFERENCING NEW AS Employee
PARENT AS Department
FOR EACH ROW
BEGIN
-- Insert on nested table translates to insert on base table:
INSERT INTO employees (
employee_id,
last_name,
email,
hire_date,
job_id,
salary,
department_id
)
VALUES (
:Employee.emp_id, -- employee_id
:Employee.lastname, -- last_name
:Employee.lastname || '@example.com', -- email
SYSDATE, -- hire_date
:Employee.job, -- job_id
:Employee.sal, -- salary
:Department.department_id -- department_id
);
END;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/dml-triggers-13.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/dml-triggers.html
SELECT emplist FROM dept_view WHERE department_id=10;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/dml-triggers-15.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/dml-triggers.html
SELECT employee_id, last_name, job_id, salary
FROM employees
WHERE department_id = 10;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/dml-triggers-17.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/dml-triggers.html
INSERT INTO TABLE (
SELECT d.emplist
FROM dept_view d
WHERE department_id = 10
)
VALUES (1001, 'Glenn', 'AC_MGR', 10000);
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/dml-triggers-18.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/dml-triggers.html
SELECT emplist FROM dept_view WHERE department_id=10;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/dml-triggers-2.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/dml-triggers.html
SELECT COUNT(*) FROM order_info WHERE customer_id = 999;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/dml-triggers-20.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/dml-triggers.html
SELECT employee_id, last_name, job_id, salary
FROM employees
WHERE department_id = 10;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/dml-triggers-23.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/dml-triggers.html
INSERT INTO Target
SELECT c1, c2, c3
FROM Source
WHERE Source.c1 > 0
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/dml-triggers-24.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/dml-triggers.html
CREATE TABLE employee_salaries (
employee_id NUMBER NOT NULL,
change_date DATE NOT NULL,
salary NUMBER(8,2) NOT NULL,
CONSTRAINT pk_employee_salaries PRIMARY KEY (employee_id, change_date),
CONSTRAINT fk_employee_salaries FOREIGN KEY (employee_id)
REFERENCES employees (employee_id)
ON DELETE CASCADE)
/
CREATE OR REPLACE TRIGGER maintain_employee_salaries
FOR UPDATE OF salary ON employees
COMPOUND TRIGGER
-- Declarative Part:
-- Choose small threshhold value to show how example works:
threshhold CONSTANT SIMPLE_INTEGER := 7;
TYPE salaries_t IS TABLE OF employee_salaries%ROWTYPE INDEX BY SIMPLE_INTEGER;
salaries salaries_t;
idx SIMPLE_INTEGER := 0;
PROCEDURE flush_array IS
n CONSTANT SIMPLE_INTEGER := salaries.count();
BEGIN
FORALL j IN 1..n
INSERT INTO employee_salaries VALUES salaries(j);
salaries.delete();
idx := 0;
DBMS_OUTPUT.PUT_LINE('Flushed ' || n || ' rows');
END flush_array;
-- AFTER EACH ROW Section:
AFTER EACH ROW IS
BEGIN
idx := idx + 1;
salaries(idx).employee_id := :NEW.employee_id;
salaries(idx).change_date := SYSTIMESTAMP;
salaries(idx).salary := :NEW.salary;
IF idx >= threshhold THEN
flush_array();
END IF;
END AFTER EACH ROW;
-- AFTER STATEMENT Section:
AFTER STATEMENT IS
BEGIN
flush_array();
END AFTER STATEMENT;
END maintain_employee_salaries;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/dml-triggers-25.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/dml-triggers.html
UPDATE employees
SET salary = salary * 1.1
WHERE department_id = 50
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/dml-triggers-27.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/dml-triggers.html
BEGIN
DBMS_SESSION.SLEEP(2);
END;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/dml-triggers-28.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/dml-triggers.html
UPDATE employees
SET salary = salary * 1.05
WHERE department_id = 50
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/dml-triggers-30.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/dml-triggers.html
SELECT employee_id, count(*) c
FROM employee_salaries
GROUP BY employee_id
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/dml-triggers-32.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/dml-triggers.html
CREATE OR REPLACE TRIGGER Check_Employee_Salary_Raise
FOR UPDATE OF Salary ON Employees
COMPOUND TRIGGER
Ten_Percent CONSTANT NUMBER := 0.1;
TYPE Salaries_t IS TABLE OF Employees.Salary%TYPE;
Avg_Salaries Salaries_t;
TYPE Department_IDs_t IS TABLE OF Employees.Department_ID%TYPE;
Department_IDs Department_IDs_t;
-- Declare collection type and variable:
TYPE Department_Salaries_t IS TABLE OF Employees.Salary%TYPE
INDEX BY VARCHAR2(80);
Department_Avg_Salaries Department_Salaries_t;
BEFORE STATEMENT IS
BEGIN
SELECT AVG(e.Salary), NVL(e.Department_ID, -1)
BULK COLLECT INTO Avg_Salaries, Department_IDs
FROM Employees e
GROUP BY e.Department_ID;
FOR j IN 1..Department_IDs.COUNT() LOOP
Department_Avg_Salaries(Department_IDs(j)) := Avg_Salaries(j);
END LOOP;
END BEFORE STATEMENT;
AFTER EACH ROW IS
BEGIN
IF :NEW.Salary - :Old.Salary >
Ten_Percent*Department_Avg_Salaries(:NEW.Department_ID)
THEN
Raise_Application_Error(-20000, 'Raise too big');
END IF;
END AFTER EACH ROW;
END Check_Employee_Salary_Raise;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/dml-triggers-33.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/dml-triggers.html
CREATE TABLE emp (
Empno NUMBER NOT NULL,
Ename VARCHAR2(10),
Job VARCHAR2(9),
Mgr NUMBER(4),
Hiredate DATE,
Sal NUMBER(7,2),
Comm NUMBER(7,2),
Deptno NUMBER(2) NOT NULL);
CREATE TABLE dept (
Deptno NUMBER(2) NOT NULL,
Dname VARCHAR2(14),
Loc VARCHAR2(13),
Mgr_no NUMBER,
Dept_type NUMBER);
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/dml-triggers-34.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/dml-triggers.html
CREATE OR REPLACE TRIGGER emp_dept_check
BEFORE INSERT OR UPDATE OF Deptno ON emp
FOR EACH ROW WHEN (NEW.Deptno IS NOT NULL)
-- Before row is inserted or DEPTNO is updated in emp table,
-- fire this trigger to verify that new foreign key value (DEPTNO)
-- is present in dept table.
DECLARE
Dummy INTEGER; -- Use for cursor fetch
Invalid_department EXCEPTION;
Valid_department EXCEPTION;
Mutating_table EXCEPTION;
PRAGMA EXCEPTION_INIT (Invalid_department, -4093);
PRAGMA EXCEPTION_INIT (Valid_department, -4092);
PRAGMA EXCEPTION_INIT (Mutating_table, -4091);
-- Cursor used to verify parent key value exists.
-- If present, lock parent key's row so it cannot be deleted
-- by another transaction until this transaction is
-- committed or rolled back.
CURSOR Dummy_cursor (Dn NUMBER) IS
SELECT Deptno FROM dept
WHERE Deptno = Dn
FOR UPDATE OF Deptno;
BEGIN
OPEN Dummy_cursor (:NEW.Deptno);
FETCH Dummy_cursor INTO Dummy;
-- Verify parent key.
-- If not found, raise user-specified error code and message.
-- If found, close cursor before allowing triggering statement to complete:
IF Dummy_cursor%NOTFOUND THEN
RAISE Invalid_department;
ELSE
RAISE Valid_department;
END IF;
CLOSE Dummy_cursor;
EXCEPTION
WHEN Invalid_department THEN
CLOSE Dummy_cursor;
Raise_application_error(-20000, 'Invalid Department'
|| ' Number' || TO_CHAR(:NEW.deptno));
WHEN Valid_department THEN
CLOSE Dummy_cursor;
WHEN Mutating_table THEN
NULL;
END;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/dml-triggers-35.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/dml-triggers.html
CREATE OR REPLACE TRIGGER dept_restrict
BEFORE DELETE OR UPDATE OF Deptno ON dept
FOR EACH ROW
-- Before row is deleted from dept or primary key (DEPTNO) of dept is updated,
-- check for dependent foreign key values in emp;
-- if any are found, roll back.
DECLARE
Dummy INTEGER; -- Use for cursor fetch
employees_present EXCEPTION;
employees_not_present EXCEPTION;
PRAGMA EXCEPTION_INIT (employees_present, -4094);
PRAGMA EXCEPTION_INIT (employees_not_present, -4095);
-- Cursor used to check for dependent foreign key values.
CURSOR Dummy_cursor (Dn NUMBER) IS
SELECT Deptno FROM emp WHERE Deptno = Dn;
BEGIN
OPEN Dummy_cursor (:OLD.Deptno);
FETCH Dummy_cursor INTO Dummy;
-- If dependent foreign key is found, raise user-specified
-- error code and message. If not found, close cursor
-- before allowing triggering statement to complete.
IF Dummy_cursor%FOUND THEN
RAISE employees_present; -- Dependent rows exist
ELSE
RAISE employees_not_present; -- No dependent rows exist
END IF;
CLOSE Dummy_cursor;
EXCEPTION
WHEN employees_present THEN
CLOSE Dummy_cursor;
Raise_application_error(-20001, 'Employees Present in'
|| ' Department ' || TO_CHAR(:OLD.DEPTNO));
WHEN employees_not_present THEN
CLOSE Dummy_cursor;
END;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/dml-triggers-36.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/dml-triggers.html
CREATE OR REPLACE TRIGGER dept_set_null
AFTER DELETE OR UPDATE OF Deptno ON dept
FOR EACH ROW
-- Before row is deleted from dept or primary key (DEPTNO) of dept is updated,
-- set all corresponding dependent foreign key values in emp to NULL:
BEGIN
IF UPDATING AND :OLD.Deptno != :NEW.Deptno OR DELETING THEN
UPDATE emp SET emp.Deptno = NULL
WHERE emp.Deptno = :OLD.Deptno;
END IF;
END;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/dml-triggers-37.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/dml-triggers.html
CREATE OR REPLACE TRIGGER dept_del_cascade
AFTER DELETE ON dept
FOR EACH ROW
-- Before row is deleted from dept,
-- delete all rows from emp table whose DEPTNO is same as
-- DEPTNO being deleted from dept table:
BEGIN
DELETE FROM emp
WHERE emp.Deptno = :OLD.Deptno;
END;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/dml-triggers-38.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/dml-triggers.html
CREATE SEQUENCE Update_sequence
INCREMENT BY 1 MAXVALUE 5000 CYCLE;
CREATE OR REPLACE PACKAGE Integritypackage AUTHID DEFINER AS
Updateseq NUMBER;
END Integritypackage;
/
CREATE OR REPLACE PACKAGE BODY Integritypackage AS
END Integritypackage;
/
ALTER TABLE emp ADD Update_id NUMBER;
CREATE OR REPLACE TRIGGER dept_cascade1
BEFORE UPDATE OF Deptno ON dept
DECLARE
-- Before updating dept table (this is a statement trigger),
-- generate sequence number
-- & assign it to public variable UPDATESEQ of
-- user-defined package named INTEGRITYPACKAGE:
BEGIN
Integritypackage.Updateseq := Update_sequence.NEXTVAL;
END;
/
CREATE OR REPLACE TRIGGER dept_cascade2
AFTER DELETE OR UPDATE OF Deptno ON dept
FOR EACH ROW
-- For each department number in dept that is updated,
-- cascade update to dependent foreign keys in emp table.
-- Cascade update only if child row was not updated by this trigger:
BEGIN
IF UPDATING THEN
UPDATE emp
SET Deptno = :NEW.Deptno,
Update_id = Integritypackage.Updateseq --from 1st
WHERE emp.Deptno = :OLD.Deptno
AND Update_id IS NULL;
/* Only NULL if not updated by 3rd trigger
fired by same triggering statement */
END IF;
IF DELETING THEN
-- After row is deleted from dept,
-- delete all rows from emp table whose DEPTNO is same as
-- DEPTNO being deleted from dept table:
DELETE FROM emp
WHERE emp.Deptno = :OLD.Deptno;
END IF;
END;
/
CREATE OR REPLACE TRIGGER dept_cascade3
AFTER UPDATE OF Deptno ON dept
BEGIN UPDATE emp
SET Update_id = NULL
WHERE Update_id = Integritypackage.Updateseq;
END;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/dml-triggers-39.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/dml-triggers.html
CREATE TABLE Salgrade (
Grade NUMBER,
Losal NUMBER,
Hisal NUMBER,
Job_classification VARCHAR2(9));
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/dml-triggers-4.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/dml-triggers.html
INSERT INTO order_info VALUES
(999, 'Smith', 'John', 2500, TO_DATE('13-MAR-2001', 'DD-MON-YYYY'), 0);
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/dml-triggers-40.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/dml-triggers.html
CREATE OR REPLACE TRIGGER salary_check
BEFORE INSERT OR UPDATE OF Sal, Job ON Emp
FOR EACH ROW
DECLARE
Minsal NUMBER;
Maxsal NUMBER;
Salary_out_of_range EXCEPTION;
PRAGMA EXCEPTION_INIT (Salary_out_of_range, -4096);
BEGIN
/* Retrieve minimum & maximum salary for employee's new job classification
from SALGRADE table into MINSAL and MAXSAL: */
SELECT Losal, Hisal INTO Minsal, Maxsal
FROM Salgrade
WHERE Job_classification = :NEW.Job;
/* If employee's new salary is less than or greater than
job classification's limits, raise exception.
Exception message is returned and pending INSERT or UPDATE statement
that fired the trigger is rolled back: */
IF (:NEW.Sal < Minsal OR :NEW.Sal > Maxsal) THEN
RAISE Salary_out_of_range;
END IF;
EXCEPTION
WHEN Salary_out_of_range THEN
Raise_application_error (
-20300,
'Salary '|| TO_CHAR(:NEW.Sal) ||' out of range for '
|| 'job classification ' ||:NEW.Job
||' for employee ' || :NEW.Ename
);
WHEN NO_DATA_FOUND THEN
Raise_application_error(-20322, 'Invalid Job Classification');
END;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/dml-triggers-41.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/dml-triggers.html
CREATE OR REPLACE TRIGGER Employee_permit_changes
BEFORE INSERT OR DELETE OR UPDATE ON employees
DECLARE
Dummy INTEGER;
Not_on_weekends EXCEPTION;
Nonworking_hours EXCEPTION;
PRAGMA EXCEPTION_INIT (Not_on_weekends, -4097);
PRAGMA EXCEPTION_INIT (Nonworking_hours, -4099);
BEGIN
-- Check for weekends:
IF (TO_CHAR(Sysdate, 'DAY') = 'SAT' OR
TO_CHAR(Sysdate, 'DAY') = 'SUN') THEN
RAISE Not_on_weekends;
END IF;
-- Check for work hours (8am to 6pm):
IF (TO_CHAR(Sysdate, 'HH24') < 8 OR
TO_CHAR(Sysdate, 'HH24') > 18) THEN
RAISE Nonworking_hours;
END IF;
EXCEPTION
WHEN Not_on_weekends THEN
Raise_application_error(-20324,'Might not change '
||'employee table during the weekend');
WHEN Nonworking_hours THEN
Raise_application_error(-20326,'Might not change '
||'emp table during Nonworking hours');
END;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/dml-triggers-42.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/dml-triggers.html
ALTER TABLE Emp ADD(
Uppername VARCHAR2(20),
Soundexname VARCHAR2(20));
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/dml-triggers-43.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/dml-triggers.html
CREATE OR REPLACE TRIGGER Derived
BEFORE INSERT OR UPDATE OF Ename ON Emp
/* Before updating the ENAME field, derive the values for
the UPPERNAME and SOUNDEXNAME fields. Restrict users
from updating these fields directly: */
FOR EACH ROW
BEGIN
:NEW.Uppername := UPPER(:NEW.Ename);
:NEW.Soundexname := SOUNDEX(:NEW.Ename);
END;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/dml-triggers-44.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/dml-triggers.html
CREATE OR REPLACE TYPE Book_t AS OBJECT (
Booknum NUMBER,
Title VARCHAR2(20),
Author VARCHAR2(20),
Available CHAR(1)
);
/
CREATE OR REPLACE TYPE Book_list_t AS TABLE OF Book_t;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/dml-triggers-45.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/dml-triggers.html
DROP TABLE Book_table;
CREATE TABLE Book_table (
Booknum NUMBER,
Section VARCHAR2(20),
Title VARCHAR2(20),
Author VARCHAR2(20),
Available CHAR(1)
);
INSERT INTO Book_table (
Booknum, Section, Title, Author, Available
)
VALUES (
121001, 'Classic', 'Iliad', 'Homer', 'Y'
);
INSERT INTO Book_table (
Booknum, Section, Title, Author, Available
)
VALUES (
121002, 'Novel', 'Gone with the Wind', 'Mitchell M', 'N'
);
SELECT * FROM Book_table ORDER BY Booknum;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/dml-triggers-47.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/dml-triggers.html
DROP TABLE Library_table;
CREATE TABLE Library_table (Section VARCHAR2(20));
INSERT INTO Library_table (Section)
VALUES ('Novel');
INSERT INTO Library_table (Section)
VALUES ('Classic');
SELECT * FROM Library_table ORDER BY Section;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/dml-triggers-49.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/dml-triggers.html
CREATE OR REPLACE VIEW Library_view AS
SELECT i.Section, CAST (
MULTISET (
SELECT b.Booknum, b.Title, b.Author, b.Available
FROM Book_table b
WHERE b.Section = i.Section
) AS Book_list_t
) BOOKLIST
FROM Library_table i;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/dml-triggers-50.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/dml-triggers.html
CREATE OR REPLACE TRIGGER Library_trigger
INSTEAD OF
INSERT ON Library_view
FOR EACH ROW
DECLARE
Bookvar Book_t;
i INTEGER;
BEGIN
INSERT INTO Library_table
VALUES (:NEW.Section);
FOR i IN 1..:NEW.Booklist.COUNT LOOP
Bookvar := :NEW.Booklist(i);
INSERT INTO Book_table (
Booknum, Section, Title, Author, Available
)
VALUES (
Bookvar.booknum, :NEW.Section, Bookvar.Title,
Bookvar.Author, bookvar.Available
);
END LOOP;
END;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/dml-triggers-51.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/dml-triggers.html
INSERT INTO Library_view (Section, Booklist)
VALUES (
'History',
book_list_t (book_t (121330, 'Alexander', 'Mirth', 'Y'))
);
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/dml-triggers-52.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/dml-triggers.html
SELECT * FROM Library_view ORDER BY Section;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/dml-triggers-54.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/dml-triggers.html
SELECT * FROM Book_table ORDER BY Booknum;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/dml-triggers-56.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/dml-triggers.html
SELECT * FROM Library_table ORDER BY Section;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/dml-triggers-6.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/dml-triggers.html
SELECT COUNT(*) FROM order_info WHERE customer_id = 999;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/dml-triggers-8.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/dml-triggers.html
SELECT COUNT(*) FROM customers WHERE customer_id = 999;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/exception-handling-triggers-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/exception-handling-triggers.html
CREATE OR REPLACE TRIGGER employees_tr
AFTER INSERT ON employees
FOR EACH ROW
BEGIN
-- When remote database is unavailable, compilation fails here:
INSERT INTO employees@remote (
employee_id, first_name, last_name, email, hire_date, job_id
)
VALUES (
99, 'Jane', 'Doe', 'jane.doe@example.com', SYSDATE, 'ST_MAN'
);
EXCEPTION
WHEN OTHERS THEN
INSERT INTO emp_log (Emp_id, Log_date, New_salary, Action)
VALUES (99, SYSDATE, NULL, 'Could not insert');
RAISE;
END;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/exception-handling-triggers-1.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/exception-handling-triggers.html
CREATE OR REPLACE PROCEDURE insert_row_proc AUTHID CURRENT_USER AS
no_remote_db EXCEPTION; -- declare exception
PRAGMA EXCEPTION_INIT (no_remote_db, -20000);
-- assign error code to exception
BEGIN
INSERT INTO employees@remote (
employee_id, first_name, last_name, email, hire_date, job_id
)
VALUES (
99, 'Jane', 'Doe', 'jane.doe@example.com', SYSDATE, 'ST_MAN'
);
EXCEPTION
WHEN OTHERS THEN
INSERT INTO emp_log (Emp_id, Log_date, New_salary, Action)
VALUES (99, SYSDATE, NULL, 'Could not insert row.');
RAISE_APPLICATION_ERROR (-20000, 'Remote database is unavailable.');
END;
/
CREATE OR REPLACE TRIGGER employees_tr
AFTER INSERT ON employees
FOR EACH ROW
BEGIN
insert_row_proc;
END;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/exception-propagation-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/exception-propagation.html
CREATE OR REPLACE PROCEDURE p AUTHID DEFINER AS
BEGIN
DECLARE
past_due EXCEPTION;
PRAGMA EXCEPTION_INIT (past_due, -4910);
due_date DATE := trunc(SYSDATE) - 1;
todays_date DATE := trunc(SYSDATE);
BEGIN
IF due_date < todays_date THEN
RAISE past_due;
END IF;
END;
EXCEPTION
WHEN OTHERS THEN
ROLLBACK;
RAISE;
END;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/exception-propagation-1.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/exception-propagation.html
BEGIN
DECLARE
past_due EXCEPTION;
due_date DATE := trunc(SYSDATE) - 1;
todays_date DATE := trunc(SYSDATE);
BEGIN
IF due_date < todays_date THEN
RAISE past_due;
END IF;
END;
END;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/exception-propagation-11.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/exception-propagation.html
CREATE OR REPLACE PROCEDURE print_reciprocal (n NUMBER) AUTHID DEFINER IS
BEGIN
BEGIN
DBMS_OUTPUT.PUT_LINE(1/n);
EXCEPTION
WHEN ZERO_DIVIDE THEN
DBMS_OUTPUT.PUT_LINE('Error in inner block:');
DBMS_OUTPUT.PUT_LINE(1/n || ' is undefined.');
END;
EXCEPTION
WHEN ZERO_DIVIDE THEN -- handles exception raised in exception handler
DBMS_OUTPUT.PUT('Error in outer block: ');
DBMS_OUTPUT.PUT_LINE('1/0 is undefined.');
END;
/
BEGIN
print_reciprocal(0);
END;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/exception-propagation-13.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/exception-propagation.html
CREATE OR REPLACE PROCEDURE descending_reciprocals (n INTEGER) AUTHID DEFINER IS
i INTEGER;
i_is_one EXCEPTION;
BEGIN
i := n;
LOOP
IF i = 1 THEN
RAISE i_is_one;
ELSE
DBMS_OUTPUT.PUT_LINE('Reciprocal of ' || i || ' is ' || 1/i);
END IF;
i := i - 1;
END LOOP;
EXCEPTION
WHEN i_is_one THEN
DBMS_OUTPUT.PUT_LINE('1 is its own reciprocal.');
DBMS_OUTPUT.PUT_LINE('Reciprocal of ' || TO_CHAR(i-1) ||
' is ' || TO_CHAR(1/(i-1)));
WHEN ZERO_DIVIDE THEN
DBMS_OUTPUT.PUT_LINE('Error:');
DBMS_OUTPUT.PUT_LINE(1/n || ' is undefined');
END;
/
BEGIN
descending_reciprocals(3);
END;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/exception-propagation-15.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/exception-propagation.html
CREATE OR REPLACE PROCEDURE descending_reciprocals (n INTEGER) AUTHID DEFINER IS
i INTEGER;
i_is_one EXCEPTION;
BEGIN
BEGIN
i := n;
LOOP
IF i = 1 THEN
RAISE i_is_one;
ELSE
DBMS_OUTPUT.PUT_LINE('Reciprocal of ' || i || ' is ' || 1/i);
END IF;
i := i - 1;
END LOOP;
EXCEPTION
WHEN i_is_one THEN
DBMS_OUTPUT.PUT_LINE('1 is its own reciprocal.');
DBMS_OUTPUT.PUT_LINE('Reciprocal of ' || TO_CHAR(i-1) ||
' is ' || TO_CHAR(1/(i-1)));
WHEN ZERO_DIVIDE THEN
DBMS_OUTPUT.PUT_LINE('Error:');
DBMS_OUTPUT.PUT_LINE(1/n || ' is undefined');
END;
EXCEPTION
WHEN ZERO_DIVIDE THEN -- handles exception raised in exception handler
DBMS_OUTPUT.PUT_LINE('Error:');
DBMS_OUTPUT.PUT_LINE('1/0 is undefined');
END;
/
BEGIN
descending_reciprocals(3);
END;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/exception-propagation-3.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/exception-propagation.html
DECLARE
credit_limit CONSTANT NUMBER(3) := 5000; -- Maximum value is 999
BEGIN
NULL;
EXCEPTION
WHEN VALUE_ERROR THEN
DBMS_OUTPUT.PUT_LINE('Exception raised in declaration.');
END;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/exception-propagation-5.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/exception-propagation.html
BEGIN
DECLARE
credit_limit CONSTANT NUMBER(3) := 5000;
BEGIN
NULL;
END;
EXCEPTION
WHEN VALUE_ERROR THEN
DBMS_OUTPUT.PUT_LINE('Exception raised in declaration.');
END;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/exception-propagation-7.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/exception-propagation.html
CREATE OR REPLACE PROCEDURE print_reciprocal (n NUMBER) AUTHID DEFINER IS
BEGIN
DBMS_OUTPUT.PUT_LINE(1/n); -- handled
EXCEPTION
WHEN ZERO_DIVIDE THEN
DBMS_OUTPUT.PUT_LINE('Error:');
DBMS_OUTPUT.PUT_LINE(1/n || ' is undefined'); -- not handled
END;
/
BEGIN -- invoking block
print_reciprocal(0);
END;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/exception-propagation-9.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/exception-propagation.html
CREATE OR REPLACE PROCEDURE print_reciprocal (n NUMBER) AUTHID DEFINER IS
BEGIN
DBMS_OUTPUT.PUT_LINE(1/n);
EXCEPTION
WHEN ZERO_DIVIDE THEN
DBMS_OUTPUT.PUT_LINE('Error:');
DBMS_OUTPUT.PUT_LINE(1/n || ' is undefined');
END;
/
BEGIN -- invoking block
print_reciprocal(0);
EXCEPTION
WHEN ZERO_DIVIDE THEN -- handles exception raised in exception handler
DBMS_OUTPUT.PUT_LINE('1/0 is undefined.');
END;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/expressions-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/expressions.html
DECLARE
x VARCHAR2(4) := 'suit';
y VARCHAR2(4) := 'case';
BEGIN
DBMS_OUTPUT.PUT_LINE (x || y);
END;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/expressions-10.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/expressions.html
DECLARE
salary NUMBER := 60000;
commission NUMBER := 0.10;
BEGIN
-- Division has higher precedence than addition:
DBMS_OUTPUT.PUT_LINE('5 + 12 / 4 = ' || TO_CHAR(5 + 12 / 4));
DBMS_OUTPUT.PUT_LINE('12 / 4 + 5 = ' || TO_CHAR(12 / 4 + 5));
-- Parentheses override default operator precedence:
DBMS_OUTPUT.PUT_LINE('8 + 6 / 2 = ' || TO_CHAR(8 + 6 / 2));
DBMS_OUTPUT.PUT_LINE('(8 + 6) / 2 = ' || TO_CHAR((8 + 6) / 2));
-- Most deeply nested operation is evaluated first:
DBMS_OUTPUT.PUT_LINE('100 + (20 / 5 + (7 - 3)) = '
|| TO_CHAR(100 + (20 / 5 + (7 - 3))));
-- Parentheses, even when unnecessary, improve readability:
DBMS_OUTPUT.PUT_LINE('(salary * 0.05) + (commission * 0.25) = '
|| TO_CHAR((salary * 0.05) + (commission * 0.25))
);
DBMS_OUTPUT.PUT_LINE('salary * 0.05 + commission * 0.25 = '
|| TO_CHAR(salary * 0.05 + commission * 0.25)
);
END;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/expressions-12.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/expressions.html
CREATE OR REPLACE PROCEDURE print_boolean (
b_name VARCHAR2,
b_value BOOLEAN
) AUTHID DEFINER IS
BEGIN
IF b_value IS NULL THEN
DBMS_OUTPUT.PUT_LINE (b_name || ' = NULL');
ELSIF b_value = TRUE THEN
DBMS_OUTPUT.PUT_LINE (b_name || ' = TRUE');
ELSE
DBMS_OUTPUT.PUT_LINE (b_name || ' = FALSE');
END IF;
END;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/expressions-13.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/expressions.html
DECLARE
PROCEDURE print_x_and_y (
x BOOLEAN,
y BOOLEAN
) IS
BEGIN
print_boolean ('x', x);
print_boolean ('y', y);
print_boolean ('x AND y', x AND y);
END print_x_and_y;
BEGIN
print_x_and_y (FALSE, FALSE);
print_x_and_y (TRUE, FALSE);
print_x_and_y (FALSE, TRUE);
print_x_and_y (TRUE, TRUE);
print_x_and_y (TRUE, NULL);
print_x_and_y (FALSE, NULL);
print_x_and_y (NULL, TRUE);
print_x_and_y (NULL, FALSE);
END;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/expressions-15.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/expressions.html
DECLARE
PROCEDURE print_x_or_y (
x BOOLEAN,
y BOOLEAN
) IS
BEGIN
print_boolean ('x', x);
print_boolean ('y', y);
print_boolean ('x OR y', x OR y);
END print_x_or_y;
BEGIN
print_x_or_y (FALSE, FALSE);
print_x_or_y (TRUE, FALSE);
print_x_or_y (FALSE, TRUE);
print_x_or_y (TRUE, TRUE);
print_x_or_y (TRUE, NULL);
print_x_or_y (FALSE, NULL);
print_x_or_y (NULL, TRUE);
print_x_or_y (NULL, FALSE);
END;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/expressions-17.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/expressions.html
DECLARE
PROCEDURE print_not_x (
x BOOLEAN
) IS
BEGIN
print_boolean ('x', x);
print_boolean ('NOT x', NOT x);
END print_not_x;
BEGIN
print_not_x (TRUE);
print_not_x (FALSE);
print_not_x (NULL);
END;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/expressions-19.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/expressions.html
DECLARE
x NUMBER := 5;
y NUMBER := NULL;
BEGIN
IF x != y THEN -- yields NULL, not TRUE
DBMS_OUTPUT.PUT_LINE('x != y'); -- not run
ELSIF x = y THEN -- also yields NULL
DBMS_OUTPUT.PUT_LINE('x = y');
ELSE
DBMS_OUTPUT.PUT_LINE
('Can''t tell if x and y are equal or not.');
END IF;
END;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/expressions-2.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/expressions.html
BEGIN
DBMS_OUTPUT.PUT_LINE ('apple' || NULL || NULL || 'sauce');
END;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/expressions-21.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/expressions.html
DECLARE
a NUMBER := NULL;
b NUMBER := NULL;
BEGIN
IF a = b THEN -- yields NULL, not TRUE
DBMS_OUTPUT.PUT_LINE('a = b'); -- not run
ELSIF a != b THEN -- yields NULL, not TRUE
DBMS_OUTPUT.PUT_LINE('a != b'); -- not run
ELSE
DBMS_OUTPUT.PUT_LINE('Can''t tell if two NULLs are equal');
END IF;
END;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/expressions-23.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/expressions.html
DECLARE
x INTEGER := 2;
Y INTEGER := 5;
high INTEGER;
BEGIN
IF (x > y) -- If x or y is NULL, then (x > y) is NULL
THEN high := x; -- run if (x > y) is TRUE
ELSE high := y; -- run if (x > y) is FALSE or NULL
END IF;
IF NOT (x > y) -- If x or y is NULL, then NOT (x > y) is NULL
THEN high := y; -- run if NOT (x > y) is TRUE
ELSE high := x; -- run if NOT (x > y) is FALSE or NULL
END IF;
END;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/expressions-24.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/expressions.html
DECLARE
x BOOLEAN := FALSE;
y BOOLEAN := FALSE;
BEGIN
print_boolean ('NOT x AND y', NOT x AND y);
print_boolean ('NOT (x AND y)', NOT (x AND y));
print_boolean ('(NOT x) AND y', (NOT x) AND y);
END;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/expressions-26.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/expressions.html
DECLARE
on_hand INTEGER := 0;
on_order INTEGER := 100;
BEGIN
-- Does not cause divide-by-zero error;
-- evaluation stops after first expression
IF (on_hand = 0) OR ((on_order / on_hand) < 5) THEN
DBMS_OUTPUT.PUT_LINE('On hand quantity is zero.');
END IF;
END;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/expressions-28.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/expressions.html
BEGIN
print_boolean ('(2 + 2 = 4)', 2 + 2 = 4);
print_boolean ('(2 + 2 <> 4)', 2 + 2 <> 4);
print_boolean ('(2 + 2 != 4)', 2 + 2 != 4);
print_boolean ('(2 + 2 ~= 4)', 2 + 2 ~= 4);
print_boolean ('(2 + 2 ^= 4)', 2 + 2 ^= 4);
print_boolean ('(1 < 2)', 1 < 2);
print_boolean ('(1 > 2)', 1 > 2);
print_boolean ('(1 <= 2)', 1 <= 2);
print_boolean ('(1 >= 1)', 1 >= 1);
END;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/expressions-35.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/expressions.html
DECLARE
PROCEDURE compare (
value VARCHAR2,
pattern VARCHAR2
) IS
BEGIN
IF value LIKE pattern THEN
DBMS_OUTPUT.PUT_LINE ('TRUE');
ELSE
DBMS_OUTPUT.PUT_LINE ('FALSE');
END IF;
END;
BEGIN
compare('Johnson', 'J%s_n');
compare('Johnson', 'J%S_N');
END;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/expressions-37.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/expressions.html
DECLARE
PROCEDURE half_off (sale_sign VARCHAR2) IS
BEGIN
IF sale_sign LIKE '50\% off!' ESCAPE '\' THEN
DBMS_OUTPUT.PUT_LINE ('TRUE');
ELSE
DBMS_OUTPUT.PUT_LINE ('FALSE');
END IF;
END;
BEGIN
half_off('Going out of business!');
half_off('50% off!');
END;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/expressions-39.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/expressions.html
BEGIN
print_boolean ('2 BETWEEN 1 AND 3', 2 BETWEEN 1 AND 3);
print_boolean ('2 BETWEEN 2 AND 3', 2 BETWEEN 2 AND 3);
print_boolean ('2 BETWEEN 1 AND 2', 2 BETWEEN 1 AND 2);
print_boolean ('2 BETWEEN 3 AND 4', 2 BETWEEN 3 AND 4);
END;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/expressions-4.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/expressions.html
DECLARE
a INTEGER := 1+2**2;
b INTEGER := (1+2)**2;
BEGIN
DBMS_OUTPUT.PUT_LINE('a = ' || TO_CHAR(a));
DBMS_OUTPUT.PUT_LINE('b = ' || TO_CHAR(b));
END;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/expressions-41.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/expressions.html
DECLARE
letter VARCHAR2(1) := 'm';
BEGIN
print_boolean (
'letter IN (''a'', ''b'', ''c'')',
letter IN ('a', 'b', 'c')
);
print_boolean (
'letter IN (''z'', ''m'', ''y'', ''p'')',
letter IN ('z', 'm', 'y', 'p')
);
END;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/expressions-43.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/expressions.html
DECLARE
a INTEGER; -- Initialized to NULL by default
b INTEGER := 10;
c INTEGER := 100;
BEGIN
print_boolean ('100 IN (a, b, c)', 100 IN (a, b, c));
print_boolean ('100 NOT IN (a, b, c)', 100 NOT IN (a, b, c));
print_boolean ('100 IN (a, b)', 100 IN (a, b));
print_boolean ('100 NOT IN (a, b)', 100 NOT IN (a, b));
print_boolean ('a IN (a, b)', a IN (a, b));
print_boolean ('a NOT IN (a, b)', a NOT IN (a, b));
END;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/expressions-46.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/expressions.html
DECLARE
done BOOLEAN;
BEGIN
-- These WHILE loops are equivalent
done := FALSE;
WHILE done = FALSE
LOOP
done := TRUE;
END LOOP;
done := FALSE;
WHILE NOT (done = TRUE)
LOOP
done := TRUE;
END LOOP;
done := FALSE;
WHILE NOT done
LOOP
done := TRUE;
END LOOP;
END;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/expressions-48.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/expressions.html
DECLARE
grade CHAR(1) := 'B';
appraisal VARCHAR2(20);
BEGIN
appraisal :=
CASE grade
WHEN 'A' THEN 'Excellent'
WHEN 'B' THEN 'Very Good'
WHEN 'C' THEN 'Good'
WHEN 'D' THEN 'Fair'
WHEN 'F' THEN 'Poor'
ELSE 'No such grade'
END;
DBMS_OUTPUT.PUT_LINE ('Grade ' || grade || ' is ' || appraisal);
END;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/expressions-50.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/expressions.html
DECLARE
grade CHAR(1); -- NULL by default
appraisal VARCHAR2(20);
BEGIN
appraisal :=
CASE grade
WHEN NULL THEN 'No grade assigned'
WHEN 'A' THEN 'Excellent'
WHEN 'B' THEN 'Very Good'
WHEN 'C' THEN 'Good'
WHEN 'D' THEN 'Fair'
WHEN 'F' THEN 'Poor'
ELSE 'No such grade'
END;
DBMS_OUTPUT.PUT_LINE ('Grade ' || grade || ' is ' || appraisal);
END;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/expressions-52.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/expressions.html
DECLARE
salary NUMBER := 7000;
salary_level VARCHAR2(20);
BEGIN
salary_level :=
CASE salary
WHEN 1000, 2000 THEN 'low'
WHEN 3000, 4000, 5000 THEN 'normal'
WHEN 6000, 7000, 8000 THEN 'high'
ELSE 'executive pay'
END;
DBMS_OUTPUT.PUT_LINE('Salary level is: ' || salary_level);
END;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/expressions-54.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/expressions.html
DECLARE
data_val NUMBER := 30;
status VARCHAR2(20);
BEGIN
status :=
CASE data_val/2
WHEN < 0, > 50 THEN 'outlier'
WHEN BETWEEN 10 AND 30 THEN 'good'
ELSE 'bad'
END;
DBMS_OUTPUT.PUT_LINE('The data status is: ' || status);
END;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/expressions-57.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/expressions.html
DECLARE
grade CHAR(1) := 'B';
appraisal VARCHAR2(120);
id NUMBER := 8429862;
attendance NUMBER := 150;
min_days CONSTANT NUMBER := 200;
FUNCTION attends_this_school (id NUMBER)
RETURN BOOLEAN IS
BEGIN
RETURN TRUE;
END;
BEGIN
appraisal :=
CASE
WHEN attends_this_school(id) = FALSE
THEN 'Student not enrolled'
WHEN grade = 'F' OR attendance < min_days
THEN 'Poor (poor performance or bad attendance)'
WHEN grade = 'A' THEN 'Excellent'
WHEN grade = 'B' THEN 'Very Good'
WHEN grade = 'C' THEN 'Good'
WHEN grade = 'D' THEN 'Fair'
ELSE 'No such grade'
END;
DBMS_OUTPUT.PUT_LINE
('Result for student ' || id || ' is ' || appraisal);
END;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/expressions-59.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/expressions.html
DECLARE
grade CHAR(1); -- NULL by default
appraisal VARCHAR2(20);
BEGIN
appraisal :=
CASE
WHEN grade IS NULL THEN 'No grade assigned'
WHEN grade = 'A' THEN 'Excellent'
WHEN grade = 'B' THEN 'Very Good'
WHEN grade = 'C' THEN 'Good'
WHEN grade = 'D' THEN 'Fair'
WHEN grade = 'F' THEN 'Poor'
ELSE 'No such grade'
END;
DBMS_OUTPUT.PUT_LINE ('Grade ' || grade || ' is ' || appraisal);
END;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/expressions-6.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/expressions.html
DECLARE
a INTEGER := ((1+2)*(3+4))/7;
BEGIN
DBMS_OUTPUT.PUT_LINE('a = ' || TO_CHAR(a));
END;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/expressions-62.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/expressions.html
CREATE PACKAGE my_debug IS
debug CONSTANT BOOLEAN := TRUE;
trace CONSTANT BOOLEAN := TRUE;
END my_debug;
/
CREATE PROCEDURE my_proc1 AUTHID DEFINER IS
BEGIN
$IF my_debug.debug $THEN
DBMS_OUTPUT.put_line('Debugging ON');
$ELSE
DBMS_OUTPUT.put_line('Debugging OFF');
$END
END my_proc1;
/
CREATE PROCEDURE my_proc2 AUTHID DEFINER IS
BEGIN
$IF my_debug.trace $THEN
DBMS_OUTPUT.put_line('Tracing ON');
$ELSE
DBMS_OUTPUT.put_line('Tracing OFF');
$END
END my_proc2;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/expressions-8.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/expressions.html
DECLARE
a INTEGER := 2**2*3**2;
b INTEGER := (2**2)*(3**2);
BEGIN
DBMS_OUTPUT.PUT_LINE('a = ' || TO_CHAR(a));
DBMS_OUTPUT.PUT_LINE('b = ' || TO_CHAR(b));
END;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/external-subprograms-1.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/external-subprograms.html
CREATE OR REPLACE PROCEDURE raise_salary (
empid NUMBER,
pct NUMBER
) AS
LANGUAGE JAVA NAME 'Adjuster.raiseSalary (int, float)'; -- call specification
/
BEGIN
raise_salary(120, 10); -- invoke Adjuster.raiseSalary by PL/SQL name
END;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/external-subprograms-2.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/external-subprograms.html
CREATE PROCEDURE java_sleep (
milli_seconds IN NUMBER
) AS LANGUAGE JAVA NAME 'java.lang.Thread.sleep(long)';
/
CREATE OR REPLACE PROCEDURE sleep (
milli_seconds IN NUMBER
) AUTHID DEFINER IS
BEGIN
DBMS_OUTPUT.PUT_LINE(DBMS_UTILITY.get_time());
java_sleep (milli_seconds);
DBMS_OUTPUT.PUT_LINE(DBMS_UTILITY.get_time());
END;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/external-subprograms-4.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/external-subprograms.html
CREATE OR REPLACE FUNCTION js_raise_sal(
p_empno NUMBER,
p_percent NUMBER
) RETURN NUMBER
AS MLE MODULE js_adjuster
SIGNATURE 'raiseSal';
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/external-subprograms-5.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/external-subprograms.html
SET SERVEROUTPUT ON;
DECLARE
l_new_sal NUMBER;
l_old_sal NUMBER;
l_empNo NUMBER := 100;
BEGIN
SELECT salary
INTO l_old_sal
FROM hr.employees
WHERE employee_id = l_empNo;
DBMS_OUTPUT.PUT_LINE('Current salary for employee ' || l_empNo
|| ' amounts to ' || l_old_sal);
l_new_sal := js_raise_sal(
p_empno => l_empNo,
p_percent => 10
);
DBMS_OUTPUT.PUT_LINE('New salary for employee ' || l_empNo
|| ' increased to ' || l_new_sal);
END;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/forward-declaration-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/forward-declaration.html
DECLARE
-- Declare proc1 (forward declaration):
PROCEDURE proc1(number1 NUMBER);
-- Declare and define proc2:
PROCEDURE proc2(number2 NUMBER) IS
BEGIN
proc1(number2);
END;
-- Define proc 1:
PROCEDURE proc1(number1 NUMBER) IS
BEGIN
proc2 (number1);
END;
BEGIN
NULL;
END;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/inserting-records-tables-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/inserting-records-tables.html
DROP TABLE schedule;
CREATE TABLE schedule (
week NUMBER,
Mon VARCHAR2(10),
Tue VARCHAR2(10),
Wed VARCHAR2(10),
Thu VARCHAR2(10),
Fri VARCHAR2(10),
Sat VARCHAR2(10),
Sun VARCHAR2(10)
);
DECLARE
default_week schedule%ROWTYPE;
i NUMBER;
BEGIN
default_week.Mon := '0800-1700';
default_week.Tue := '0800-1700';
default_week.Wed := '0800-1700';
default_week.Thu := '0800-1700';
default_week.Fri := '0800-1700';
default_week.Sat := 'Day Off';
default_week.Sun := 'Day Off';
FOR i IN 1..6 LOOP
default_week.week := i;
INSERT INTO schedule VALUES default_week;
END LOOP;
END;
/
COLUMN week FORMAT 99
COLUMN Mon FORMAT A9
COLUMN Tue FORMAT A9
COLUMN Wed FORMAT A9
COLUMN Thu FORMAT A9
COLUMN Fri FORMAT A9
COLUMN Sat FORMAT A9
COLUMN Sun FORMAT A9
SELECT * FROM schedule;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/invokers-rights-and-definers-rights-authid-property-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/invokers-rights-and-definers-rights-authid-property.html
GRANT INHERIT PRIVILEGES ON current_user TO PUBLIC
GRANT INHERIT PRIVILEGES ON current_user TO unit_owner
GRANT INHERIT ANY PRIVILEGES TO unit_owner
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/invokers-rights-and-definers-rights-authid-property-2.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/invokers-rights-and-definers-rights-authid-property.html
GRANT read, execute TO FUNCTION scott.func, PACKAGE sys.pkg
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/invokers-rights-and-definers-rights-authid-property-3.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/invokers-rights-and-definers-rights-authid-property.html
CREATE OR REPLACE PROCEDURE hr_remote_db_link
AS
v_employee_id VARCHAR(50);
BEGIN
EXECUTE IMMEDIATE 'SELECT employee_id FROM employees@dblink' into v_employee_id;
DBMS_OUTPUT.PUT_LINE('employee_id: ' || v_employee_id);
END ;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/lexical-units-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/lexical-units.html
SELECT TYPE_NAME FROM ALL_TYPES WHERE PREDEFINED='YES';
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/lexical-units-10.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/lexical-units.html
DECLARE
"HELLO" varchar2(10) := 'hello'; -- HELLO is not a reserved word
"BEGIN" varchar2(10) := 'begin'; -- BEGIN is a reserved word
BEGIN
DBMS_Output.Put_Line(Hello); -- Double quotation marks are optional
DBMS_Output.Put_Line(BEGIN); -- Double quotation marks are required
end;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/lexical-units-12.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/lexical-units.html
DECLARE
"HELLO" varchar2(10) := 'hello'; -- HELLO is not a reserved word
"BEGIN" varchar2(10) := 'begin'; -- BEGIN is a reserved word
BEGIN
DBMS_Output.Put_Line(Hello); -- Identifier is case-insensitive
DBMS_Output.Put_Line("Begin"); -- Identifier is case-sensitive
END;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/lexical-units-15.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/lexical-units.html
BEGIN
DBMS_OUTPUT.PUT_LINE('This string breaks
here.');
END;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/lexical-units-17.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/lexical-units.html
BEGIN
DBMS_OUTPUT.PUT_LINE('This string ' ||
'contains no line-break character.');
END;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/lexical-units-20.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/lexical-units.html
DECLARE
howmany NUMBER;
num_tables NUMBER;
BEGIN
-- Begin processing
SELECT COUNT(*) INTO howmany
FROM USER_OBJECTS
WHERE OBJECT_TYPE = 'TABLE'; -- Check number of tables
num_tables := howmany; -- Compute another value
END;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/lexical-units-23.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/lexical-units.html
DECLARE
some_condition BOOLEAN;
pi NUMBER := 3.1415926;
radius NUMBER := 15;
area NUMBER;
BEGIN
/* Perform some simple tests and assignments */
IF 2 + 2 = 4 THEN
some_condition := TRUE;
/* We expect this THEN to always be performed */
END IF;
/* This line computes the area of a circle using pi,
which is the ratio between the circumference and diameter.
After the area is computed, the result is displayed. */
area := pi * radius**2;
DBMS_OUTPUT.PUT_LINE('The area is: ' || TO_CHAR(area));
END;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/lexical-units-25.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/lexical-units.html
DECLARE
x NUMBER := 10;
y NUMBER := 5;
max NUMBER;
BEGIN
IF x>y THEN max:=x;ELSE max:=y;END IF; -- correct but hard to read
-- Easier to read:
IF x > y THEN
max:=x;
ELSE
max:=y;
END IF;
END;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/lexical-units-4.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/lexical-units.html
DECLARE
"HELLO" varchar2(10) := 'hello';
BEGIN
DBMS_Output.Put_Line(Hello);
END;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/lexical-units-6.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/lexical-units.html
DECLARE
"HELLO" varchar2(10) := 'hello';
BEGIN
DBMS_Output.Put_Line("Hello");
END;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/lexical-units-8.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/lexical-units.html
DECLARE
"BEGIN" varchar2(15) := 'UPPERCASE';
"Begin" varchar2(15) := 'Initial Capital';
"begin" varchar2(15) := 'lowercase';
BEGIN
DBMS_Output.Put_Line("BEGIN");
DBMS_Output.Put_Line("Begin");
DBMS_Output.Put_Line("begin");
END;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/loop-statements-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/loop-statements.html
BEGIN
FOR i IN 1..3 LOOP
IF i < 3 THEN
DBMS_OUTPUT.PUT_LINE (TO_CHAR(i));
ELSE
i := 2;
END IF;
END LOOP;
END;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/loop-statements-10.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/loop-statements.html
DECLARE
i PLS_INTEGER;
BEGIN
FOR i IN 1..3, REVERSE i+1..i+10, 51..55 LOOP
DBMS_OUTPUT.PUT_LINE(i);
END LOOP;
END;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/loop-statements-13.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/loop-statements.html
BEGIN
FOR i IN 1..3 LOOP
DBMS_OUTPUT.PUT_LINE (i);
END LOOP;
END;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/loop-statements-15.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/loop-statements.html
BEGIN
FOR i IN REVERSE 1..3 LOOP
DBMS_OUTPUT.PUT_LINE (i);
END LOOP;
END;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/loop-statements-17.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/loop-statements.html
BEGIN
FOR n NUMBER(5,1) IN 1.0 .. 3.0 BY 0.5 LOOP
DBMS_OUTPUT.PUT_LINE(n);
END LOOP;
END;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/loop-statements-19.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/loop-statements.html
BEGIN
FOR i IN 5..15 BY 5 LOOP
DBMS_OUTPUT.PUT_LINE (i);
END LOOP;
END;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/loop-statements-2.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/loop-statements.html
BEGIN
FOR i IN 1..3 LOOP
DBMS_OUTPUT.PUT_LINE ('Inside loop, i is ' || TO_CHAR(i));
END LOOP;
DBMS_OUTPUT.PUT_LINE ('Outside loop, i is ' || TO_CHAR(i));
END;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/loop-statements-25.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/loop-statements.html
BEGIN
FOR i IN 1 LOOP
DBMS_OUTPUT.PUT_LINE(i);
END LOOP;
END;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/loop-statements-27.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/loop-statements.html
BEGIN
FOR i IN 1, REPEAT i*2 WHILE i < 100 LOOP
DBMS_OUTPUT.PUT_LINE(i);
END LOOP;
END;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/loop-statements-31.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/loop-statements.html
OPEN c FOR SELECT id, data FROM T;
CLOSE c;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/loop-statements-33.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/loop-statements.html
DECLARE
cursor_str VARCHAR2(500) := 'SELECT last_name, employee_id FROM hr.employees ORDER BY last_name';
TYPE rec_t IS RECORD (last_name VARCHAR2(25),
employee_id NUMBER);
BEGIN
FOR r rec_t IN VALUES OF (EXECUTE IMMEDIATE cursor_str) WHEN r.employee_id < 103 LOOP
DBMS_OUTPUT.PUT_LINE(r.last_name || ', ' || r.employee_id);
END LOOP;
END;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/loop-statements-37.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/loop-statements.html
BEGIN
FOR power IN 1, REPEAT power*2 WHILE power <= 64 LOOP
DBMS_OUTPUT.PUT_LINE(power);
END LOOP;
END;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/loop-statements-39.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/loop-statements.html
BEGIN
FOR power IN 2, REPEAT power*2 WHILE power <= 64 WHEN MOD(power, 32)= 0 LOOP
DBMS_OUTPUT.PUT_LINE(power);
END LOOP;
END;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/loop-statements-4.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/loop-statements.html
DECLARE
i NUMBER := 5;
BEGIN
FOR i IN 1..3 LOOP
DBMS_OUTPUT.PUT_LINE ('Inside loop, i is ' || TO_CHAR(i));
END LOOP;
DBMS_OUTPUT.PUT_LINE ('Outside loop, i is ' || TO_CHAR(i));
END;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/loop-statements-6.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/loop-statements.html
<> -- Label block.
DECLARE
i NUMBER := 5;
BEGIN
FOR i IN 1..3 LOOP
DBMS_OUTPUT.PUT_LINE (
'local: ' || TO_CHAR(i) || ', global: ' ||
TO_CHAR(main.i) -- Qualify reference with block label.
);
END LOOP;
END main;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/loop-statements-8.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/loop-statements.html
BEGIN
<>
FOR i IN 1..3 LOOP
<>
FOR i IN 1..3 LOOP
IF outer_loop.i = 2 THEN
DBMS_OUTPUT.PUT_LINE
('outer: ' || TO_CHAR(outer_loop.i) || ' inner: '
|| TO_CHAR(inner_loop.i));
END IF;
END LOOP inner_loop;
END LOOP outer_loop;
END;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/main-features-pl-sql-1.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/main-features-pl-sql.html
BEGIN
FOR someone IN (
SELECT * FROM employees
WHERE employee_id < 120
ORDER BY employee_id
)
LOOP
DBMS_OUTPUT.PUT_LINE('First name = ' || someone.first_name ||
', Last name = ' || someone.last_name);
END LOOP;
END;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/minimizing-cpu-overhead-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/minimizing-cpu-overhead.html
DECLARE
starting_time TIMESTAMP WITH TIME ZONE;
ending_time TIMESTAMP WITH TIME ZONE;
BEGIN
-- Invokes SQRT for every row of employees table:
SELECT SYSTIMESTAMP INTO starting_time FROM DUAL;
FOR item IN (
SELECT DISTINCT(SQRT(department_id)) col_alias
FROM employees
ORDER BY col_alias
)
LOOP
DBMS_OUTPUT.PUT_LINE('Square root of dept. ID = ' || item.col_alias);
END LOOP;
SELECT SYSTIMESTAMP INTO ending_time FROM DUAL;
DBMS_OUTPUT.PUT_LINE('Time = ' || TO_CHAR(ending_time - starting_time));
-- Invokes SQRT for every distinct department_id of employees table:
SELECT SYSTIMESTAMP INTO starting_time FROM DUAL;
FOR item IN (
SELECT SQRT(department_id) col_alias
FROM (SELECT DISTINCT department_id FROM employees)
ORDER BY col_alias
)
LOOP
IF item.col_alias IS NOT NULL THEN
DBMS_OUTPUT.PUT_LINE('Square root of dept. ID = ' || item.col_alias);
END IF;
END LOOP;
SELECT SYSTIMESTAMP INTO ending_time FROM DUAL;
DBMS_OUTPUT.PUT_LINE('Time = ' || TO_CHAR(ending_time - starting_time));
END;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/minimizing-cpu-overhead-2.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/minimizing-cpu-overhead.html
DECLARE
TYPE EmpTabTyp IS TABLE OF employees%ROWTYPE;
emp_tab EmpTabTyp := EmpTabTyp(NULL); -- initialize
t1 NUMBER;
t2 NUMBER;
t3 NUMBER;
PROCEDURE get_time (t OUT NUMBER) IS
BEGIN
t := DBMS_UTILITY.get_time;
END;
PROCEDURE do_nothing1 (tab IN OUT EmpTabTyp) IS
BEGIN
NULL;
END;
PROCEDURE do_nothing2 (tab IN OUT NOCOPY EmpTabTyp) IS
BEGIN
NULL;
END;
BEGIN
SELECT * INTO emp_tab(1)
FROM employees
WHERE employee_id = 100;
emp_tab.EXTEND(49999, 1); -- Copy element 1 into 2..50000
get_time(t1);
do_nothing1(emp_tab); -- Pass IN OUT parameter
get_time(t2);
do_nothing2(emp_tab); -- Pass IN OUT NOCOPY parameter
get_time(t3);
DBMS_OUTPUT.PUT_LINE ('Call Duration (secs)');
DBMS_OUTPUT.PUT_LINE ('--------------------');
DBMS_OUTPUT.PUT_LINE ('Just IN OUT: ' || TO_CHAR((t2 - t1)/100.0));
DBMS_OUTPUT.PUT_LINE ('With NOCOPY: ' || TO_CHAR((t3 - t2))/100.0);
END;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/multidimensional-collections-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/multidimensional-collections.html
DECLARE
TYPE t1 IS VARRAY(10) OF INTEGER; -- varray of integer
va t1 := t1(2,3,5);
TYPE nt1 IS VARRAY(10) OF t1; -- varray of varray of integer
nva nt1 := nt1(va, t1(55,6,73), t1(2,4), va);
i INTEGER;
va1 t1;
BEGIN
i := nva(2)(3);
DBMS_OUTPUT.PUT_LINE('i = ' || i);
nva.EXTEND;
nva(5) := t1(56, 32); -- replace inner varray elements
nva(4) := t1(45,43,67,43345); -- replace an inner integer element
nva(4)(4) := 1; -- replace 43345 with 1
nva(4).EXTEND; -- add element to 4th varray element
nva(4)(5) := 89; -- store integer 89 there
END;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/multidimensional-collections-2.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/multidimensional-collections.html
DECLARE
TYPE tb1 IS TABLE OF VARCHAR2(20); -- nested table of strings
vtb1 tb1 := tb1('one', 'three');
TYPE ntb1 IS TABLE OF tb1; -- nested table of nested tables of strings
vntb1 ntb1 := ntb1(vtb1);
TYPE tv1 IS VARRAY(10) OF INTEGER; -- varray of integers
TYPE ntb2 IS TABLE OF tv1; -- nested table of varrays of integers
vntb2 ntb2 := ntb2(tv1(3,5), tv1(5,7,3));
BEGIN
vntb1.EXTEND;
vntb1(2) := vntb1(1);
vntb1.DELETE(1); -- delete first element of vntb1
vntb1(2).DELETE(1); -- delete first string from second table in nested table
END;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/multidimensional-collections-3.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/multidimensional-collections.html
DECLARE
TYPE tb1 IS TABLE OF INTEGER INDEX BY PLS_INTEGER; -- associative arrays
v4 tb1;
v5 tb1;
TYPE aa1 IS TABLE OF tb1 INDEX BY PLS_INTEGER; -- associative array of
v2 aa1; -- associative arrays
TYPE va1 IS VARRAY(10) OF VARCHAR2(20); -- varray of strings
v1 va1 := va1('hello', 'world');
TYPE ntb2 IS TABLE OF va1 INDEX BY PLS_INTEGER; -- associative array of varrays
v3 ntb2;
BEGIN
v4(1) := 34; -- populate associative array
v4(2) := 46456;
v4(456) := 343;
v2(23) := v4; -- populate associative array of associative arrays
v3(34) := va1(33, 456, 656, 343); -- populate associative array varrays
v2(35) := v5; -- assign empty associative array to v2(35)
v2(35)(2) := 78;
END;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/native-dynamic-sql-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/native-dynamic-sql.html
CREATE OR REPLACE PROCEDURE create_dept (
deptid IN OUT NUMBER,
dname IN VARCHAR2,
mgrid IN NUMBER,
locid IN NUMBER
) AUTHID DEFINER AS
BEGIN
deptid := departments_seq.NEXTVAL;
INSERT INTO departments (
department_id,
department_name,
manager_id,
location_id
)
VALUES (deptid, dname, mgrid, locid);
END;
/
DECLARE
plsql_block VARCHAR2(500);
new_deptid NUMBER(4);
new_dname VARCHAR2(30) := 'Advertising';
new_mgrid NUMBER(6) := 200;
new_locid NUMBER(4) := 1700;
BEGIN
-- Dynamic PL/SQL block invokes subprogram:
plsql_block := 'BEGIN create_dept(:a, :b, :c, :d); END;';
/* Specify bind variables in USING clause.
Specify mode for first parameter.
Modes of other parameters are correct by default. */
EXECUTE IMMEDIATE plsql_block
USING IN OUT new_deptid, new_dname, new_mgrid, new_locid;
END;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/native-dynamic-sql-1.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/native-dynamic-sql.html
CREATE OR REPLACE PROCEDURE p (x BOOLEAN) AUTHID DEFINER AS
BEGIN
IF x THEN
DBMS_OUTPUT.PUT_LINE('x is true');
END IF;
END;
/
DECLARE
dyn_stmt VARCHAR2(200);
b BOOLEAN := TRUE;
BEGIN
dyn_stmt := 'BEGIN p(:x); END;';
EXECUTE IMMEDIATE dyn_stmt USING b;
END;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/native-dynamic-sql-11.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/native-dynamic-sql.html
CREATE TABLE employees_temp AS SELECT * FROM EMPLOYEES;
DECLARE
a_null CHAR(1); -- Set to NULL automatically at run time
BEGIN
EXECUTE IMMEDIATE 'UPDATE employees_temp SET commission_pct = :x'
USING a_null;
END;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/native-dynamic-sql-12.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/native-dynamic-sql.html
DECLARE
TYPE EmpCurTyp IS REF CURSOR;
v_emp_cursor EmpCurTyp;
emp_record employees%ROWTYPE;
v_stmt_str VARCHAR2(200);
v_e_job employees.job_id%TYPE;
BEGIN
-- Dynamic SQL statement with placeholder:
v_stmt_str := 'SELECT * FROM employees WHERE job_id = :j';
-- Open cursor & specify bind variable in USING clause:
OPEN v_emp_cursor FOR v_stmt_str USING 'MANAGER';
-- Fetch rows from result set one at a time:
LOOP
FETCH v_emp_cursor INTO emp_record;
EXIT WHEN v_emp_cursor%NOTFOUND;
END LOOP;
-- Close cursor:
CLOSE v_emp_cursor;
END;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/native-dynamic-sql-13.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/native-dynamic-sql.html
CREATE OR REPLACE PACKAGE pkg AUTHID DEFINER AS
TYPE rec IS RECORD(f1 NUMBER, f2 VARCHAR2(30));
TYPE mytab IS TABLE OF rec INDEX BY pls_integer;
END;
/
DECLARE
v1 pkg.mytab; -- collection of records
v2 pkg.rec;
c1 SYS_REFCURSOR;
BEGIN
OPEN c1 FOR 'SELECT * FROM TABLE(:1)' USING v1;
FETCH c1 INTO v2;
CLOSE c1;
DBMS_OUTPUT.PUT_LINE('Values in record are ' || v2.f1 || ' and ' || v2.f2);
END;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/native-dynamic-sql-15.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/native-dynamic-sql.html
EXECUTE IMMEDIATE sql_stmt USING a, b, c, d;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/native-dynamic-sql-16.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/native-dynamic-sql.html
INSERT INTO payroll VALUES (a, b, c, d)
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/native-dynamic-sql-17.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/native-dynamic-sql.html
EXECUTE IMMEDIATE sql_stmt USING a, a, b, a;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/native-dynamic-sql-18.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/native-dynamic-sql.html
INSERT INTO payroll VALUES (a, a, b, a)
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/native-dynamic-sql-19.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/native-dynamic-sql.html
CREATE PROCEDURE calc_stats (
w NUMBER,
x NUMBER,
y NUMBER,
z NUMBER )
IS
BEGIN
DBMS_OUTPUT.PUT_LINE(w + x + y + z);
END;
/
DECLARE
a NUMBER := 4;
b NUMBER := 7;
plsql_block VARCHAR2(100);
BEGIN
plsql_block := 'BEGIN calc_stats(:x, :x, :y, :x); END;';
EXECUTE IMMEDIATE plsql_block USING a, b; -- calc_stats(a, a, b, a)
END;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/native-dynamic-sql-3.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/native-dynamic-sql.html
CREATE OR REPLACE PACKAGE pkg AUTHID DEFINER AS
TYPE rec IS RECORD (n1 NUMBER, n2 NUMBER);
PROCEDURE p (x OUT rec, y NUMBER, z NUMBER);
END pkg;
/
CREATE OR REPLACE PACKAGE BODY pkg AS
PROCEDURE p (x OUT rec, y NUMBER, z NUMBER) AS
BEGIN
x.n1 := y;
x.n2 := z;
END p;
END pkg;
/
DECLARE
r pkg.rec;
dyn_str VARCHAR2(3000);
BEGIN
dyn_str := 'BEGIN pkg.p(:x, 6, 8); END;';
EXECUTE IMMEDIATE dyn_str USING OUT r;
DBMS_OUTPUT.PUT_LINE('r.n1 = ' || r.n1);
DBMS_OUTPUT.PUT_LINE('r.n2 = ' || r.n2);
END;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/native-dynamic-sql-5.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/native-dynamic-sql.html
CREATE OR REPLACE PACKAGE pkg AUTHID DEFINER AS
TYPE number_names IS TABLE OF VARCHAR2(5)
INDEX BY PLS_INTEGER;
PROCEDURE print_number_names (x number_names);
END pkg;
/
CREATE OR REPLACE PACKAGE BODY pkg AS
PROCEDURE print_number_names (x number_names) IS
BEGIN
FOR i IN x.FIRST .. x.LAST LOOP
DBMS_OUTPUT.PUT_LINE(x(i));
END LOOP;
END;
END pkg;
/
DECLARE
digit_names pkg.number_names;
dyn_stmt VARCHAR2(3000);
BEGIN
digit_names(0) := 'zero';
digit_names(1) := 'one';
digit_names(2) := 'two';
digit_names(3) := 'three';
digit_names(4) := 'four';
digit_names(5) := 'five';
digit_names(6) := 'six';
digit_names(7) := 'seven';
digit_names(8) := 'eight';
digit_names(9) := 'nine';
dyn_stmt := 'BEGIN pkg.print_number_names(:x); END;';
EXECUTE IMMEDIATE dyn_stmt USING digit_names;
END;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/native-dynamic-sql-7.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/native-dynamic-sql.html
CREATE OR REPLACE PACKAGE pkg AUTHID DEFINER AS
TYPE names IS TABLE OF VARCHAR2(10);
PROCEDURE print_names (x names);
END pkg;
/
CREATE OR REPLACE PACKAGE BODY pkg AS
PROCEDURE print_names (x names) IS
BEGIN
FOR i IN x.FIRST .. x.LAST LOOP
DBMS_OUTPUT.PUT_LINE(x(i));
END LOOP;
END;
END pkg;
/
DECLARE
fruits pkg.names;
dyn_stmt VARCHAR2(3000);
BEGIN
fruits := pkg.names('apple', 'banana', 'cherry');
dyn_stmt := 'BEGIN pkg.print_names(:x); END;';
EXECUTE IMMEDIATE dyn_stmt USING fruits;
END;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/native-dynamic-sql-9.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/native-dynamic-sql.html
CREATE OR REPLACE PACKAGE pkg AUTHID DEFINER AS
TYPE foursome IS VARRAY(4) OF VARCHAR2(5);
PROCEDURE print_foursome (x foursome);
END pkg;
/
CREATE OR REPLACE PACKAGE BODY pkg AS
PROCEDURE print_foursome (x foursome) IS
BEGIN
IF x.COUNT = 0 THEN
DBMS_OUTPUT.PUT_LINE('Empty');
ELSE
FOR i IN x.FIRST .. x.LAST LOOP
DBMS_OUTPUT.PUT_LINE(x(i));
END LOOP;
END IF;
END;
END pkg;
/
DECLARE
directions pkg.foursome;
dyn_stmt VARCHAR2(3000);
BEGIN
directions := pkg.foursome('north', 'south', 'east', 'west');
dyn_stmt := 'BEGIN pkg.print_foursome(:x); END;';
EXECUTE IMMEDIATE dyn_stmt USING directions;
END;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/overloaded-subprograms-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/overloaded-subprograms.html
DECLARE
TYPE date_tab_typ IS TABLE OF DATE INDEX BY PLS_INTEGER;
TYPE num_tab_typ IS TABLE OF NUMBER INDEX BY PLS_INTEGER;
hiredate_tab date_tab_typ;
sal_tab num_tab_typ;
PROCEDURE initialize (tab OUT date_tab_typ, n INTEGER) IS
BEGIN
DBMS_OUTPUT.PUT_LINE('Invoked first version');
FOR i IN 1..n LOOP
tab(i) := SYSDATE;
END LOOP;
END initialize;
PROCEDURE initialize (tab OUT num_tab_typ, n INTEGER) IS
BEGIN
DBMS_OUTPUT.PUT_LINE('Invoked second version');
FOR i IN 1..n LOOP
tab(i) := 0.0;
END LOOP;
END initialize;
BEGIN
initialize(hiredate_tab, 50);
initialize(sal_tab, 100);
END;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/overloaded-subprograms-10.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/overloaded-subprograms.html
CREATE OR REPLACE PACKAGE pkg3 AUTHID DEFINER IS
PROCEDURE s (p1 VARCHAR2);
PROCEDURE s (p1 VARCHAR2, p2 VARCHAR2 := 'p2');
END pkg3;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/overloaded-subprograms-11.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/overloaded-subprograms.html
CREATE OR REPLACE PROCEDURE p AUTHID DEFINER IS
a1 VARCHAR2(10) := 'a1';
a2 VARCHAR2(10) := 'a2';
BEGIN
pkg3.s(p1=>a1, p2=>a2); -- Compiles without error
pkg3.s(p1=>a1); -- Causes compile-time error PLS-00307
END p;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/overloaded-subprograms-12.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/overloaded-subprograms.html
CREATE OR REPLACE PACKAGE pack1 AUTHID DEFINER AS
PROCEDURE proc1 (a NUMBER, b VARCHAR2);
PROCEDURE proc1 (a NUMBER, b NUMBER);
END;
/
CREATE OR REPLACE PACKAGE BODY pack1 AS
PROCEDURE proc1 (a NUMBER, b VARCHAR2) IS BEGIN NULL; END;
PROCEDURE proc1 (a NUMBER, b NUMBER) IS BEGIN NULL; END;
END;
/
BEGIN
pack1.proc1(1,'2'); -- Compiles without error
pack1.proc1(1,2); -- Compiles without error
pack1.proc1('1','2'); -- Causes compile-time error PLS-00307
pack1.proc1('1',2); -- Causes compile-time error PLS-00307
END;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/overloaded-subprograms-13.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/overloaded-subprograms.html
ALTER SESSION SET PLSQL_IMPLICIT_CONVERSION_BOOL = FALSE;
CREATE OR REPLACE PACKAGE pkg1 AUTHID DEFINER IS
PROCEDURE s (p INTEGER);
PROCEDURE s (p BOOLEAN);
END pkg1;
/
CREATE OR REPLACE PACKAGE BODY pkg1 IS
PROCEDURE s (p INTEGER) AS
BEGIN
dbms_output.put_line ( 'Integer' );
END;
PROCEDURE s (p BOOLEAN) AS
BEGIN
dbms_output.put_line ( 'Boolean' );
END;
END pkg1;
/
BEGIN
pkg1.s('1'); -- Compiles without error
END;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/overloaded-subprograms-15.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/overloaded-subprograms.html
ALTER SESSION SET PLSQL_IMPLICIT_CONVERSION_BOOL = TRUE;
exec pkg1.s('1'); -- Causes compile-time error PLS-00307
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/overloaded-subprograms-5.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/overloaded-subprograms.html
CREATE OR REPLACE PACKAGE pkg1 AUTHID DEFINER IS
PROCEDURE s (p VARCHAR2);
PROCEDURE s (p VARCHAR2);
END pkg1;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/overloaded-subprograms-6.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/overloaded-subprograms.html
CREATE OR REPLACE PACKAGE pkg2 AUTHID DEFINER IS
SUBTYPE t1 IS VARCHAR2(10);
SUBTYPE t2 IS VARCHAR2(10);
PROCEDURE s (p t1);
PROCEDURE s (p t2);
END pkg2;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/overloaded-subprograms-7.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/overloaded-subprograms.html
CREATE OR REPLACE PROCEDURE p AUTHID DEFINER IS
a pkg2.t1 := 'a';
BEGIN
pkg2.s(a); -- Causes compile-time error PLS-00307
END p;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/overloaded-subprograms-8.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/overloaded-subprograms.html
CREATE OR REPLACE PACKAGE pkg2 AUTHID DEFINER IS
SUBTYPE t1 IS VARCHAR2(10);
SUBTYPE t2 IS VARCHAR2(10);
PROCEDURE s (p1 t1);
PROCEDURE s (p2 t2);
END pkg2;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/overloaded-subprograms-9.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/overloaded-subprograms.html
CREATE OR REPLACE PROCEDURE p AUTHID DEFINER IS
a pkg2.t1 := 'a';
BEGIN
pkg2.s(p1=>a); -- Compiles without error
END p;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/overview-exception-handling-1.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/overview-exception-handling.html
CREATE OR REPLACE PROCEDURE select_item (
t_column VARCHAR2,
t_name VARCHAR2
) AUTHID DEFINER
IS
temp VARCHAR2(30);
BEGIN
temp := t_column; -- For error message if next SELECT fails
-- Fails if table t_name does not have column t_column:
SELECT COLUMN_NAME INTO temp
FROM USER_TAB_COLS
WHERE TABLE_NAME = UPPER(t_name)
AND COLUMN_NAME = UPPER(t_column);
temp := t_name; -- For error message if next SELECT fails
-- Fails if there is no table named t_name:
SELECT OBJECT_NAME INTO temp
FROM USER_OBJECTS
WHERE OBJECT_NAME = UPPER(t_name)
AND OBJECT_TYPE = 'TABLE';
EXCEPTION
WHEN NO_DATA_FOUND THEN
DBMS_OUTPUT.PUT_LINE ('No Data found for SELECT on ' || temp);
WHEN OTHERS THEN
DBMS_OUTPUT.PUT_LINE ('Unexpected error');
RAISE;
END;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/overview-exception-handling-2.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/overview-exception-handling.html
BEGIN
select_item('departments', 'last_name');
END;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/overview-exception-handling-4.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/overview-exception-handling.html
BEGIN
select_item('emp', 'last_name');
END;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/overview-exception-handling-6.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/overview-exception-handling.html
CREATE OR REPLACE PROCEDURE loc_var AUTHID DEFINER IS
stmt_no POSITIVE;
name_ VARCHAR2(100);
BEGIN
stmt_no := 1;
SELECT table_name INTO name_
FROM user_tables
WHERE table_name LIKE 'ABC%';
stmt_no := 2;
SELECT table_name INTO name_
FROM user_tables
WHERE table_name LIKE 'XYZ%';
EXCEPTION
WHEN NO_DATA_FOUND THEN
DBMS_OUTPUT.PUT_LINE ('Table name not found in query ' || stmt_no);
END;
/
CALL loc_var();
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/overview-polymorphic-table-functions-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/overview-polymorphic-table-functions.html
SELECT *
FROM noop(emp);
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/overview-polymorphic-table-functions-1.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/overview-polymorphic-table-functions.html
WITH e AS
(SELECT * FROM emp NATURAL JOIN dept)
SELECT t.* FROM noop(e) t;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/overview-polymorphic-table-functions-10.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/overview-polymorphic-table-functions.html
SELECT * FROM skip_col_pkg.skip_col(scott.dept, 'number', flip => 'True');
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/overview-polymorphic-table-functions-12.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/overview-polymorphic-table-functions.html
SELECT * FROM skip_col_by_type(scott.dept, 'number', flip => 'True');
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/overview-polymorphic-table-functions-14.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/overview-polymorphic-table-functions.html
SELECT *
FROM skip_col_pkg.skip_col(scott.emp, COLUMNS(comm, hiredate, mgr))
WHERE deptno = 20;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/overview-polymorphic-table-functions-16.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/overview-polymorphic-table-functions.html
CREATE PACKAGE to_doc_p AS
FUNCTION describe(tab IN OUT DBMS_TF.TABLE_T,
cols IN DBMS_TF.COLUMNS_T DEFAULT NULL)
RETURN DBMS_TF.DESCRIBE_T;
PROCEDURE fetch_rows;
END to_doc_p;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/overview-polymorphic-table-functions-17.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/overview-polymorphic-table-functions.html
CREATE PACKAGE BODY to_doc_p AS
FUNCTION describe(tab IN OUT DBMS_TF.TABLE_T,
cols IN DBMS_TF.COLUMNS_T DEFAULT NULL)
RETURN DBMS_TF.DESCRIBE_T AS
BEGIN
FOR i IN 1 .. tab.column.count LOOP
CONTINUE WHEN NOT DBMS_TF.SUPPORTED_TYPE(tab.column(i).DESCRIPTION.TYPE);
IF cols IS NULL THEN
tab.column(i).FOR_READ := TRUE;
tab.column(i).PASS_THROUGH := FALSE;
CONTINUE;
END IF;
FOR j IN 1 .. cols.count LOOP
IF (tab.column(i).DESCRIPTION.NAME = cols(j)) THEN
tab.column(i).FOR_READ := TRUE;
tab.column(i).PASS_THROUGH := FALSE;
END IF;
END LOOP;
END LOOP;
RETURN DBMS_TF.describe_t(new_columns => DBMS_TF.COLUMNS_NEW_T(1 =>
DBMS_TF.COLUMN_METADATA_T(name =>'DOCUMENT')));
END;
PROCEDURE fetch_rows AS
rst DBMS_TF.ROW_SET_T;
col DBMS_TF.TAB_VARCHAR2_T;
rct PLS_INTEGER;
BEGIN
DBMS_TF.GET_ROW_SET(rst, row_count => rct);
FOR rid IN 1 .. rct LOOP
col(rid) := DBMS_TF.ROW_TO_CHAR(rst, rid);
END LOOP;
DBMS_TF.PUT_COL(1, col);
END;
END to_doc_p;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/overview-polymorphic-table-functions-18.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/overview-polymorphic-table-functions.html
CREATE FUNCTION to_doc(
tab TABLE,
cols COLUMNS DEFAULT NULL)
RETURN TABLE
PIPELINED ROW POLYMORPHIC USING to_doc_p;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/overview-polymorphic-table-functions-19.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/overview-polymorphic-table-functions.html
SELECT * FROM to_doc(scott.dept);
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/overview-polymorphic-table-functions-2.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/overview-polymorphic-table-functions.html
CREATE PACKAGE skip_col_pkg AS
-- OVERLOAD 1: Skip by name --
FUNCTION skip_col(tab TABLE,
col COLUMNS)
RETURN TABLE PIPELINED ROW POLYMORPHIC USING skip_col_pkg;
FUNCTION describe(tab IN OUT DBMS_TF.TABLE_T,
col DBMS_TF.COLUMNS_T)
RETURN DBMS_TF.DESCRIBE_T;
-- OVERLOAD 2: Skip by type --
FUNCTION skip_col(tab TABLE,
type_name VARCHAR2,
flip VARCHAR2 DEFAULT 'False')
RETURN TABLE PIPELINED ROW POLYMORPHIC USING skip_col_pkg;
FUNCTION describe(tab IN OUT DBMS_TF.TABLE_T,
type_name VARCHAR2,
flip VARCHAR2 DEFAULT 'False')
RETURN DBMS_TF.DESCRIBE_T;
END skip_col_pkg;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/overview-polymorphic-table-functions-21.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/overview-polymorphic-table-functions.html
SELECT deptno, ename, document
FROM to_doc(scott.emp, COLUMNS(empno,job,mgr,hiredate,sal,comm))
WHERE deptno IN (10, 30)
ORDER BY 1, 2;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/overview-polymorphic-table-functions-23.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/overview-polymorphic-table-functions.html
WITH e AS (
SELECT ename name, sal, deptno, loc
FROM scott.emp NATURAL JOIN scott.dept
WHERE job = 'CLERK')
SELECT ROWNUM doc_id, t.*
FROM to_doc(e) t;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/overview-polymorphic-table-functions-25.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/overview-polymorphic-table-functions.html
WITH t(c1,c2,c3) AS (
SELECT NULL, NULL, NULL FROM dual
UNION ALL
SELECT 1, NULL, NULL FROM dual
UNION ALL
SELECT NULL, 2, NULL FROM dual
UNION ALL
SELECT 0, NULL, 3 FROM dual)
SELECT *
FROM to_doc(t);
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/overview-polymorphic-table-functions-27.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/overview-polymorphic-table-functions.html
SELECT JSON_VALUE(document, '$.ENAME') ename,
JSON_VALUE(document, '$.COMM') comm
FROM to_doc(scott.emp)
WHERE JSON_VALUE(document, '$.DEPTNO') = 30;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/overview-polymorphic-table-functions-29.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/overview-polymorphic-table-functions.html
CREATE PACKAGE implicit_echo_package AS
prefix DBMS_ID := '"ECHO_';
FUNCTION DESCRIBE(tab IN OUT DBMS_TF.TABLE_T,
cols IN DBMS_TF.COLUMNS_T)
RETURN DBMS_TF.DESCRIBE_T;
PROCEDURE FETCH_ROWS;
-- PTF FUNCTION: WITHOUT USING CLAUSE --
FUNCTION implicit_echo(tab TABLE, cols COLUMNS)
RETURN TABLE PIPELINED ROW POLYMORPHIC;
END implicit_echo_package;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/overview-polymorphic-table-functions-30.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/overview-polymorphic-table-functions.html
CREATE PACKAGE BODY implicit_echo_package AS
FUNCTION DESCRIBE(tab IN OUT DBMS_TF.TABLE_T,
cols IN DBMS_TF.COLUMNS_T)
RETURN DBMS_TF.DESCRIBE_T
AS
new_cols DBMS_TF.COLUMNS_NEW_T;
col_id PLS_INTEGER := 1;
BEGIN
FOR i in 1 .. tab.column.COUNT LOOP
FOR j in 1 .. cols.COUNT LOOP
IF (tab.column(i).description.name = cols(j)) THEN
IF (NOT DBMS_TF.SUPPORTED_TYPE(tab.column(i).description.type)) THEN
RAISE_APPLICATION_ERROR(-20102, 'Unsupported column type['||
tab.column(i).description.type||']');
END IF;
tab.column(i).for_read := TRUE;
new_cols(col_id) := tab.column(i).description;
new_cols(col_id).name := prefix||
REGEXP_REPLACE(tab.column(i).description.name,
'^"|"$');
col_id := col_id + 1;
EXIT;
END IF;
END LOOP;
END LOOP;
/* VERIFY ALL COLUMNS WERE FOUND */
IF (col_id - 1 != cols.COUNT) then
RAISE_APPLICATION_ERROR(-20101,'Column mismatch['||col_id-1||'],
['||cols.COUNT||']');
END IF;
RETURN DBMS_TF.DESCRIBE_T(new_columns => new_cols);
END;
PROCEDURE FETCH_ROWS AS
rowset DBMS_TF.ROW_SET_T;
BEGIN
DBMS_TF.GET_ROW_SET(rowset);
DBMS_TF.PUT_ROW_SET(rowset);
END;
END implicit_echo_package;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/overview-polymorphic-table-functions-31.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/overview-polymorphic-table-functions.html
SELECT ENAME, ECHO_ENAME
FROM implicit_echo_package.implicit_echo(SCOTT.EMP, COLUMNS(SCOTT.ENAME));
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/overview-polymorphic-table-functions-4.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/overview-polymorphic-table-functions.html
CREATE FUNCTION skip_col_by_name(tab TABLE,
col COLUMNS)
RETURN TABLE PIPELINED ROW POLYMORPHIC USING skip_col_pkg;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/overview-polymorphic-table-functions-5.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/overview-polymorphic-table-functions.html
CREATE FUNCTION skip_col_by_type(tab TABLE,
type_name VARCHAR2,
flip VARCHAR2 DEFAULT 'False')
RETURN TABLE PIPELINED ROW POLYMORPHIC USING skip_col_pkg;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/overview-polymorphic-table-functions-6.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/overview-polymorphic-table-functions.html
SELECT * FROM skip_col_pkg.skip_col(scott.dept, 'number');
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/overview-polymorphic-table-functions-8.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/overview-polymorphic-table-functions.html
SELECT * FROM skip_col_by_type(scott.dept, 'number');
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/package-body-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/package-body.html
CREATE PACKAGE emp_bonus AS
PROCEDURE calc_bonus (date_hired employees.hire_date%TYPE);
END emp_bonus;
/
CREATE PACKAGE BODY emp_bonus AS
-- DATE does not match employees.hire_date%TYPE
PROCEDURE calc_bonus (date_hired DATE) IS
BEGIN
DBMS_OUTPUT.PUT_LINE
('Employees hired on ' || date_hired || ' get bonus.');
END;
END emp_bonus;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/package-body-2.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/package-body.html
SHOW ERRORS
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/package-body-4.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/package-body.html
CREATE OR REPLACE PACKAGE BODY emp_bonus AS
PROCEDURE calc_bonus
(date_hired employees.hire_date%TYPE) IS
BEGIN
DBMS_OUTPUT.PUT_LINE
('Employees hired on ' || date_hired || ' get bonus.');
END;
END emp_bonus;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/package-example-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/package-example.html
DROP TABLE log;
CREATE TABLE log (
date_of_action DATE,
user_id VARCHAR2(20),
package_name VARCHAR2(30)
);
CREATE OR REPLACE PACKAGE emp_admin AUTHID DEFINER AS
-- Declare public type, cursor, and exception:
TYPE EmpRecTyp IS RECORD (emp_id NUMBER, sal NUMBER);
CURSOR desc_salary RETURN EmpRecTyp;
invalid_salary EXCEPTION;
-- Declare public subprograms:
FUNCTION hire_employee (
last_name VARCHAR2,
first_name VARCHAR2,
email VARCHAR2,
phone_number VARCHAR2,
job_id VARCHAR2,
salary NUMBER,
commission_pct NUMBER,
manager_id NUMBER,
department_id NUMBER
) RETURN NUMBER;
-- Overload preceding public subprogram:
PROCEDURE fire_employee (emp_id NUMBER);
PROCEDURE fire_employee (emp_email VARCHAR2);
PROCEDURE raise_salary (emp_id NUMBER, amount NUMBER);
FUNCTION nth_highest_salary (n NUMBER) RETURN EmpRecTyp;
END emp_admin;
/
CREATE OR REPLACE PACKAGE BODY emp_admin AS
number_hired NUMBER; -- private variable, visible only in this package
-- Define cursor declared in package specification:
CURSOR desc_salary RETURN EmpRecTyp IS
SELECT employee_id, salary
FROM employees
ORDER BY salary DESC;
-- Define subprograms declared in package specification:
FUNCTION hire_employee (
last_name VARCHAR2,
first_name VARCHAR2,
email VARCHAR2,
phone_number VARCHAR2,
job_id VARCHAR2,
salary NUMBER,
commission_pct NUMBER,
manager_id NUMBER,
department_id NUMBER
) RETURN NUMBER
IS
new_emp_id NUMBER;
BEGIN
new_emp_id := employees_seq.NEXTVAL;
INSERT INTO employees (
employee_id,
last_name,
first_name,
email,
phone_number,
hire_date,
job_id,
salary,
commission_pct,
manager_id,
department_id
)
VALUES (
new_emp_id,
hire_employee.last_name,
hire_employee.first_name,
hire_employee.email,
hire_employee.phone_number,
SYSDATE,
hire_employee.job_id,
hire_employee.salary,
hire_employee.commission_pct,
hire_employee.manager_id,
hire_employee.department_id
);
number_hired := number_hired + 1;
DBMS_OUTPUT.PUT_LINE('The number of employees hired is '
|| TO_CHAR(number_hired) );
RETURN new_emp_id;
END hire_employee;
PROCEDURE fire_employee (emp_id NUMBER) IS
BEGIN
DELETE FROM employees WHERE employee_id = emp_id;
END fire_employee;
PROCEDURE fire_employee (emp_email VARCHAR2) IS
BEGIN
DELETE FROM employees WHERE email = emp_email;
END fire_employee;
-- Define private function, available only inside package:
FUNCTION sal_ok (
jobid VARCHAR2,
sal NUMBER
) RETURN BOOLEAN
IS
min_sal NUMBER;
max_sal NUMBER;
BEGIN
SELECT MIN(salary), MAX(salary)
INTO min_sal, max_sal
FROM employees
WHERE job_id = jobid;
RETURN (sal >= min_sal) AND (sal <= max_sal);
END sal_ok;
PROCEDURE raise_salary (
emp_id NUMBER,
amount NUMBER
)
IS
sal NUMBER(8,2);
jobid VARCHAR2(10);
BEGIN
SELECT job_id, salary INTO jobid, sal
FROM employees
WHERE employee_id = emp_id;
IF sal_ok(jobid, sal + amount) THEN -- Invoke private function
UPDATE employees
SET salary = salary + amount
WHERE employee_id = emp_id;
ELSE
RAISE invalid_salary;
END IF;
EXCEPTION
WHEN invalid_salary THEN
DBMS_OUTPUT.PUT_LINE ('The salary is out of the specified range.');
END raise_salary;
FUNCTION nth_highest_salary (
n NUMBER
) RETURN EmpRecTyp
IS
emp_rec EmpRecTyp;
BEGIN
OPEN desc_salary;
FOR i IN 1..n LOOP
FETCH desc_salary INTO emp_rec;
END LOOP;
CLOSE desc_salary;
RETURN emp_rec;
END nth_highest_salary;
BEGIN -- initialization part of package body
INSERT INTO log (date_of_action, user_id, package_name)
VALUES (SYSDATE, USER, 'EMP_ADMIN');
number_hired := 0;
END emp_admin;
/
DECLARE
new_emp_id NUMBER(6);
BEGIN
new_emp_id := emp_admin.hire_employee (
'Belden',
'Enrique',
'EBELDEN',
'555.111.2222',
'ST_CLERK',
2500,
.1,
101,
110
);
DBMS_OUTPUT.PUT_LINE ('The employee id is ' || TO_CHAR(new_emp_id));
emp_admin.raise_salary (new_emp_id, 100);
DBMS_OUTPUT.PUT_LINE (
'The 10th highest salary is '||
TO_CHAR (emp_admin.nth_highest_salary(10).sal) ||
', belonging to employee: ' ||
TO_CHAR (emp_admin.nth_highest_salary(10).emp_id)
);
emp_admin.fire_employee(new_emp_id);
-- You can also delete the newly added employee as follows:
-- emp_admin.fire_employee('EBELDEN');
END;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/package-specification-1.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/package-specification.html
CREATE OR REPLACE PACKAGE trans_data AUTHID DEFINER AS
TYPE TimeRec IS RECORD (
minutes SMALLINT,
hours SMALLINT);
TYPE TransRec IS RECORD (
category VARCHAR2(10),
account INT,
amount REAL,
time_of TimeRec);
minimum_balance CONSTANT REAL := 10.00;
number_processed INT;
insufficient_funds EXCEPTION;
PRAGMA EXCEPTION_INIT(insufficient_funds, -4097);
END trans_data;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/package-specification-2.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/package-specification.html
CREATE OR REPLACE PACKAGE aa_pkg AUTHID DEFINER IS
TYPE aa_type IS TABLE OF INTEGER INDEX BY VARCHAR2(15);
END;
/
CREATE OR REPLACE PROCEDURE print_aa (
aa aa_pkg.aa_type
) AUTHID DEFINER IS
i VARCHAR2(15);
BEGIN
i := aa.FIRST;
WHILE i IS NOT NULL LOOP
DBMS_OUTPUT.PUT_LINE (aa(i) || ' ' || i);
i := aa.NEXT(i);
END LOOP;
END;
/
DECLARE
aa_var aa_pkg.aa_type;
BEGIN
aa_var('zero') := 0;
aa_var('one') := 1;
aa_var('two') := 2;
print_aa(aa_var);
END;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/package-writing-guidelines-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/package-writing-guidelines.html
CREATE PACKAGE emp_stuff AS
CURSOR c1 RETURN employees%ROWTYPE; -- Declare cursor
END emp_stuff;
/
CREATE PACKAGE BODY emp_stuff AS
CURSOR c1 RETURN employees%ROWTYPE IS
SELECT * FROM employees WHERE salary > 2500; -- Define cursor
END emp_stuff;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/package-writing-guidelines-1.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/package-writing-guidelines.html
CREATE OR REPLACE PACKAGE helper
AUTHID DEFINER
ACCESSIBLE BY (api)
IS
PROCEDURE h1;
PROCEDURE h2;
END;
/
CREATE OR REPLACE PACKAGE BODY helper
IS
PROCEDURE h1 IS
BEGIN
DBMS_OUTPUT.PUT_LINE('Helper procedure h1');
END;
PROCEDURE h2 IS
BEGIN
DBMS_OUTPUT.PUT_LINE('Helper procedure h2');
END;
END;
/
CREATE OR REPLACE PACKAGE api
AUTHID DEFINER
IS
PROCEDURE p1;
PROCEDURE p2;
END;
/
CREATE OR REPLACE PACKAGE BODY api
IS
PROCEDURE p1 IS
BEGIN
DBMS_OUTPUT.PUT_LINE('API procedure p1');
helper.h1;
END;
PROCEDURE p2 IS
BEGIN
DBMS_OUTPUT.PUT_LINE('API procedure p2');
helper.h2;
END;
END;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/package-writing-guidelines-2.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/package-writing-guidelines.html
BEGIN
api.p1;
api.p2;
END;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/package-writing-guidelines-4.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/package-writing-guidelines.html
BEGIN
helper.h1;
END;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/pl-sql-function-result-cache-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/pl-sql-function-result-cache.html
SELECT rc1.NAME, rc2.STATUS, rc3.STATUS, rc2.BLOCK_COUNT
FROM V$RESULT_CACHE_OBJECTS rc1, V$RESULT_CACHE_OBJECTS rc2
WHERE rc1.TYPE = 'Result'
AND rc2.TYPE = 'Temp'
AND rc1.CACHE_KEY = rc2.CACHE_KEY;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/pl-sql-function-result-cache-1.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/pl-sql-function-result-cache.html
SELECT SCAN_COUNT, COUNT(CACHE_KEY)
FROM V$RESULT_CACHE_OBJECTS
WHERE NAMESPACE = 'PLSQL'
GROUP BY SCAN_COUNT;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/pl-sql-function-result-cache-10.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/pl-sql-function-result-cache.html
CREATE OR REPLACE FUNCTION get_hire_date (emp_id NUMBER)
RETURN VARCHAR
RESULT_CACHE
AUTHID DEFINER
IS
date_hired DATE;
BEGIN
SELECT hire_date INTO date_hired
FROM HR.EMPLOYEES
WHERE EMPLOYEE_ID = emp_id;
RETURN TO_CHAR(date_hired);
END;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/pl-sql-function-result-cache-11.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/pl-sql-function-result-cache.html
SELECT value FROM config_tab WHERE name = param_name;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/pl-sql-function-result-cache-12.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/pl-sql-function-result-cache.html
SELECT value FROM config_tab
WHERE name = param_name
AND app_id = SYS_CONTEXT('Config', 'App_ID');
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/pl-sql-function-result-cache-13.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/pl-sql-function-result-cache.html
CREATE OR REPLACE FUNCTION get_param_value (
param_name VARCHAR,
appctx VARCHAR DEFAULT SYS_CONTEXT('Config', 'App_ID')
) RETURN VARCHAR
RESULT_CACHE
AUTHID DEFINER
IS
rec VARCHAR(2000);
BEGIN
SELECT val INTO rec
FROM config_tab
WHERE name = param_name;
RETURN rec;
END;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/pl-sql-function-result-cache-15.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/pl-sql-function-result-cache.html
CREATE OR REPLACE FUNCTION get_product_name_1 (
prod_id NUMBER,
lang_id VARCHAR2
)
RETURN NVARCHAR2
RESULT_CACHE
AUTHID DEFINER
IS
result_ VARCHAR2(50);
BEGIN
SELECT translated_name INTO result_
FROM OE.Product_Descriptions
WHERE PRODUCT_ID = prod_id
AND LANGUAGE_ID = lang_id;
RETURN result_;
END;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/pl-sql-function-result-cache-16.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/pl-sql-function-result-cache.html
CREATE OR REPLACE FUNCTION get_product_name_2 (
prod_id NUMBER,
lang_id VARCHAR2
)
RETURN NVARCHAR2
AUTHID DEFINER
IS
TYPE product_names IS TABLE OF NVARCHAR2(50) INDEX BY PLS_INTEGER;
FUNCTION all_product_names (lang_id VARCHAR2)
RETURN product_names
RESULT_CACHE
IS
all_names product_names;
BEGIN
FOR c IN (SELECT * FROM OE.Product_Descriptions
WHERE LANGUAGE_ID = lang_id) LOOP
all_names(c.PRODUCT_ID) := c.TRANSLATED_NAME;
END LOOP;
RETURN all_names;
END;
BEGIN
RETURN all_product_names(lang_id)(prod_id);
END;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/pl-sql-function-result-cache-17.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/pl-sql-function-result-cache.html
SELECT cache_id, COUNT(cache_key) AS uniq_args
FROM GV$RESULT_CACHE_OBJECTS
WHERE type = 'Result'
GROUP BY cache_id
ORDER BY uniq_args DESC;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/pl-sql-function-result-cache-18.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/pl-sql-function-result-cache.html
SELECT object_no, SUM(invalidations) AS num_invals
FROM GV$RESULT_CACHE_OBJECTS
WHERE type = 'Dependency'
GROUP BY object_no
ORDER BY num_invals DESC;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/pl-sql-function-result-cache-19.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/pl-sql-function-result-cache.html
BEGIN
DBMS_RESULT_CACHE.Bypass(TRUE);
DBMS_RESULT_CACHE.Flush;
END;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/pl-sql-function-result-cache-20.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/pl-sql-function-result-cache.html
BEGIN
DBMS_RESULT_CACHE.Bypass(FALSE);
END;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/pl-sql-function-result-cache-4.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/pl-sql-function-result-cache.html
CREATE OR REPLACE PACKAGE department_pkg AUTHID DEFINER IS
TYPE dept_info_record IS RECORD (
dept_name departments.department_name%TYPE,
mgr_name employees.last_name%TYPE,
dept_size PLS_INTEGER
);
-- Function declaration
FUNCTION get_dept_info (dept_id NUMBER)
RETURN dept_info_record
RESULT_CACHE;
END department_pkg;
/
CREATE OR REPLACE PACKAGE BODY department_pkg IS
-- Function definition
FUNCTION get_dept_info (dept_id NUMBER)
RETURN dept_info_record
RESULT_CACHE
IS
rec dept_info_record;
BEGIN
SELECT department_name INTO rec.dept_name
FROM departments
WHERE department_id = dept_id;
SELECT e.last_name INTO rec.mgr_name
FROM departments d, employees e
WHERE d.department_id = dept_id
AND d.manager_id = e.employee_id;
SELECT COUNT(*) INTO rec.dept_size
FROM EMPLOYEES
WHERE department_id = dept_id;
RETURN rec;
END get_dept_info;
END department_pkg;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/pl-sql-function-result-cache-5.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/pl-sql-function-result-cache.html
DROP TABLE global_config_params;
CREATE TABLE global_config_params
(name VARCHAR2(20), -- parameter NAME
val VARCHAR2(20), -- parameter VALUE
PRIMARY KEY (name)
);
CREATE TABLE app_level_config_params
(app_id VARCHAR2(20), -- application ID
name VARCHAR2(20), -- parameter NAME
val VARCHAR2(20), -- parameter VALUE
PRIMARY KEY (app_id, name)
);
CREATE TABLE role_level_config_params
(role_id VARCHAR2(20), -- application (role) ID
name VARCHAR2(20), -- parameter NAME
val VARCHAR2(20), -- parameter VALUE
PRIMARY KEY (role_id, name)
);
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/pl-sql-function-result-cache-6.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/pl-sql-function-result-cache.html
CREATE OR REPLACE FUNCTION get_value
(p_param VARCHAR2,
p_app_id NUMBER,
p_role_id NUMBER
)
RETURN VARCHAR2
RESULT_CACHE
AUTHID DEFINER
IS
answer VARCHAR2(20);
BEGIN
-- Is parameter set at role level?
BEGIN
SELECT val INTO answer
FROM role_level_config_params
WHERE role_id = p_role_id
AND name = p_param;
RETURN answer; -- Found
EXCEPTION
WHEN no_data_found THEN
NULL; -- Fall through to following code
END;
-- Is parameter set at application level?
BEGIN
SELECT val INTO answer
FROM app_level_config_params
WHERE app_id = p_app_id
AND name = p_param;
RETURN answer; -- Found
EXCEPTION
WHEN no_data_found THEN
NULL; -- Fall through to following code
END;
-- Is parameter set at global level?
SELECT val INTO answer
FROM global_config_params
WHERE name = p_param;
RETURN answer;
END;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/pl-sql-function-result-cache-7.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/pl-sql-function-result-cache.html
CREATE OR REPLACE FUNCTION fibonacci (n NUMBER)
RETURN NUMBER
RESULT_CACHE
AUTHID DEFINER
IS
BEGIN
IF (n =0) OR (n =1) THEN
RETURN 1;
ELSE
RETURN fibonacci(n - 1) + fibonacci(n - 2);
END IF;
END;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/pl-sql-function-result-cache-9.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/pl-sql-function-result-cache.html
CREATE OR REPLACE FUNCTION get_hire_date (emp_id NUMBER, fmt VARCHAR)
RETURN VARCHAR
RESULT_CACHE
AUTHID DEFINER
IS
date_hired DATE;
BEGIN
SELECT hire_date INTO date_hired
FROM HR.EMPLOYEES
WHERE EMPLOYEE_ID = emp_id;
RETURN TO_CHAR(date_hired, fmt);
END;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/pls_integer-and-binary_integer-data-types-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/pls_integer-and-binary_integer-data-types.html
DECLARE
p1 PLS_INTEGER := 2147483647;
p2 PLS_INTEGER := 1;
n NUMBER;
BEGIN
n := p1 + p2;
END;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/pls_integer-and-binary_integer-data-types-2.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/pls_integer-and-binary_integer-data-types.html
DECLARE
p1 PLS_INTEGER := 2147483647;
p2 INTEGER := 1;
n NUMBER;
BEGIN
n := p1 + p2;
END;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/pls_integer-and-binary_integer-data-types-4.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/pls_integer-and-binary_integer-data-types.html
DECLARE
a SIMPLE_INTEGER := 1;
b PLS_INTEGER := NULL;
BEGIN
a := b;
END;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/pls_integer-and-binary_integer-data-types-6.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/pls_integer-and-binary_integer-data-types.html
DECLARE
n SIMPLE_INTEGER := 2147483645;
BEGIN
FOR j IN 1..4 LOOP
n := n + 1;
DBMS_OUTPUT.PUT_LINE(TO_CHAR(n, 'S9999999999'));
END LOOP;
FOR j IN 1..4 LOOP
n := n - 1;
DBMS_OUTPUT.PUT_LINE(TO_CHAR(n, 'S9999999999'));
END LOOP;
END;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/plsql-program-limits-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/plsql-program-limits.html
CREATE OR REPLACE PACKAGE pkg1 AS
TYPE numset_t IS TABLE OF NUMBER;
FUNCTION f1(x NUMBER) RETURN numset_t PIPELINED;
END pkg1;
/
CREATE OR REPLACE PACKAGE BODY pkg1 AS
-- FUNCTION f1 returns a collection of elements (1,2,3,... x)
FUNCTION f1(x NUMBER) RETURN numset_t PIPELINED IS
BEGIN
FOR i IN 1..x LOOP
PIPE ROW(i);
END LOOP;
RETURN;
END f1;
END pkg1;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/plsql-program-limits-1.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/plsql-program-limits.html
COLUMN name FORMAT A4
COLUMN type FORMAT A12
COLUMN source_size FORMAT 999
COLUMN parsed_size FORMAT 999
COLUMN code_size FORMAT 999
COLUMN error_size FORMAT 999
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/plsql-program-limits-2.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/plsql-program-limits.html
SELECT * FROM user_object_size WHERE name = 'PKG1' ORDER BY type;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/predefined-exceptions-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/predefined-exceptions.html
DECLARE
stock_price NUMBER := 9.73;
net_earnings NUMBER := 0;
pe_ratio NUMBER;
BEGIN
pe_ratio := stock_price / net_earnings; -- raises ZERO_DIVIDE exception
DBMS_OUTPUT.PUT_LINE('Price/earnings ratio = ' || pe_ratio);
EXCEPTION
WHEN ZERO_DIVIDE THEN
DBMS_OUTPUT.PUT_LINE('Company had zero earnings.');
pe_ratio := NULL;
END;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/predefined-exceptions-2.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/predefined-exceptions.html
DECLARE
stock_price NUMBER := 9.73;
net_earnings NUMBER := 0;
pe_ratio NUMBER;
BEGIN
pe_ratio :=
CASE net_earnings
WHEN 0 THEN NULL
ELSE stock_price / net_earnings
END;
END;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/predefined-exceptions-3.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/predefined-exceptions.html
CREATE OR REPLACE PACKAGE emp_dept_data AUTHID DEFINER AS
TYPE cv_type IS REF CURSOR;
PROCEDURE open_cv (
cv IN OUT cv_type,
discrim IN POSITIVE
);
END emp_dept_data;
/
CREATE OR REPLACE PACKAGE BODY emp_dept_data AS
PROCEDURE open_cv (
cv IN OUT cv_type,
discrim IN POSITIVE) IS
BEGIN
IF discrim = 1 THEN
OPEN cv FOR
SELECT * FROM EMPLOYEES ORDER BY employee_id;
ELSIF discrim = 2 THEN
OPEN cv FOR
SELECT * FROM DEPARTMENTS ORDER BY department_id;
END IF;
END open_cv;
END emp_dept_data;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/predefined-exceptions-4.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/predefined-exceptions.html
DECLARE
emp_rec EMPLOYEES%ROWTYPE;
dept_rec DEPARTMENTS%ROWTYPE;
cv Emp_dept_data.CV_TYPE;
BEGIN
emp_dept_data.open_cv(cv, 1); -- Open cv for EMPLOYEES fetch.
FETCH cv INTO dept_rec; -- Fetch from DEPARTMENTS.
DBMS_OUTPUT.PUT(dept_rec.DEPARTMENT_ID);
DBMS_OUTPUT.PUT_LINE(' ' || dept_rec.LOCATION_ID);
EXCEPTION
WHEN ROWTYPE_MISMATCH THEN
BEGIN
DBMS_OUTPUT.PUT_LINE
('Row type mismatch, fetching EMPLOYEES data ...');
FETCH cv INTO emp_rec;
DBMS_OUTPUT.PUT(emp_rec.DEPARTMENT_ID);
DBMS_OUTPUT.PUT_LINE(' ' || emp_rec.LAST_NAME);
END;
END;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/processing-query-result-sets-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/processing-query-result-sets.html
BEGIN
FOR item IN (
SELECT last_name, job_id
FROM employees
WHERE job_id LIKE '%CLERK%'
AND manager_id > 120
ORDER BY last_name
)
LOOP
DBMS_OUTPUT.PUT_LINE
('Name = ' || item.last_name || ', Job = ' || item.job_id);
END LOOP;
END;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/processing-query-result-sets-10.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/processing-query-result-sets.html
DECLARE
CURSOR c1 IS
SELECT department_id, last_name, salary
FROM employees t
WHERE salary > ( SELECT AVG(salary)
FROM employees
WHERE t.department_id = department_id
)
ORDER BY department_id, last_name;
BEGIN
FOR person IN c1
LOOP
DBMS_OUTPUT.PUT_LINE('Making above-average salary = ' || person.last_name);
END LOOP;
END;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/processing-query-result-sets-2.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/processing-query-result-sets.html
DECLARE
CURSOR c1 IS
SELECT last_name, job_id FROM employees
WHERE job_id LIKE '%CLERK%' AND manager_id > 120
ORDER BY last_name;
BEGIN
FOR item IN c1
LOOP
DBMS_OUTPUT.PUT_LINE
('Name = ' || item.last_name || ', Job = ' || item.job_id);
END LOOP;
END;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/processing-query-result-sets-4.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/processing-query-result-sets.html
DECLARE
CURSOR c1 (job VARCHAR2, max_wage NUMBER) IS
SELECT * FROM employees
WHERE job_id = job
AND salary > max_wage;
BEGIN
FOR person IN c1('ST_CLERK', 3000)
LOOP
-- process data record
DBMS_OUTPUT.PUT_LINE (
'Name = ' || person.last_name || ', salary = ' ||
person.salary || ', Job Id = ' || person.job_id
);
END LOOP;
END;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/processing-query-result-sets-6.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/processing-query-result-sets.html
BEGIN
FOR item IN (
SELECT first_name || ' ' || last_name AS full_name,
salary * 10 AS dream_salary
FROM employees
WHERE ROWNUM <= 5
ORDER BY dream_salary DESC, last_name ASC
) LOOP
DBMS_OUTPUT.PUT_LINE
(item.full_name || ' dreams of making ' || item.dream_salary);
END LOOP;
END;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/processing-query-result-sets-8.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/processing-query-result-sets.html
DECLARE
CURSOR c1 IS
SELECT t1.department_id, department_name, staff
FROM departments t1,
( SELECT department_id, COUNT(*) AS staff
FROM employees
GROUP BY department_id
) t2
WHERE (t1.department_id = t2.department_id) AND staff >= 5
ORDER BY staff;
BEGIN
FOR dept IN c1
LOOP
DBMS_OUTPUT.PUT_LINE ('Department = '
|| dept.department_name || ', staff = ' || dept.staff);
END LOOP;
END;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/qualified-names-and-dot-notation-6.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/qualified-names-and-dot-notation.html
CREATE OR REPLACE PACKAGE pkg1 AUTHID DEFINER AS
m NUMBER;
TYPE t1 IS RECORD (a NUMBER);
v1 t1;
TYPE t2 IS TABLE OF t1 INDEX BY PLS_INTEGER;
v2 t2;
FUNCTION f1 (p1 NUMBER) RETURN t1;
FUNCTION f2 (q1 NUMBER) RETURN t2;
END pkg1;
/
CREATE OR REPLACE PACKAGE BODY pkg1 AS
FUNCTION f1 (p1 NUMBER) RETURN t1 IS
n NUMBER;
BEGIN
n := m; -- Unqualified variable name
n := pkg1.m; -- Variable name qualified by package name
n := pkg1.f1.p1; -- Parameter name qualified by function name,
-- which is qualified by package name
n := v1.a; -- Variable name followed by component name
n := pkg1.v1.a; -- Variable name qualified by package name
-- and followed by component name
n := v2(10).a; -- Indexed name followed by component name
n := f1(10).a; -- Function invocation followed by component name
n := f2(10)(10).a; -- Function invocation followed by indexed name
-- and followed by component name
n := hr.pkg1.f2(10)(10).a; -- Schema name, package name,
-- function invocation, index, component name
v1.a := p1;
RETURN v1;
END f1;
FUNCTION f2 (q1 NUMBER) RETURN t2 IS
v_t1 t1;
v_t2 t2;
BEGIN
v_t1.a := q1;
v_t2(1) := v_t1;
RETURN v_t2;
END f2;
END pkg1;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/raising-exceptions-explicitly-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/raising-exceptions-explicitly.html
CREATE PROCEDURE account_status (
due_date DATE,
today DATE
) AUTHID DEFINER
IS
past_due EXCEPTION; -- declare exception
BEGIN
IF due_date < today THEN
RAISE past_due; -- explicitly raise exception
END IF;
EXCEPTION
WHEN past_due THEN -- handle exception
DBMS_OUTPUT.PUT_LINE ('Account past due.');
END;
/
BEGIN
account_status (TO_DATE('01-JUL-2010', 'DD-MON-YYYY'),
TO_DATE('09-JUL-2010', 'DD-MON-YYYY'));
END;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/raising-exceptions-explicitly-2.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/raising-exceptions-explicitly.html
DROP TABLE t;
CREATE TABLE t (c NUMBER);
CREATE PROCEDURE p (n NUMBER) AUTHID DEFINER IS
default_number NUMBER := 0;
BEGIN
IF n < 0 THEN
RAISE INVALID_NUMBER; -- raise explicitly
ELSE
INSERT INTO t VALUES(TO_NUMBER('100.00', '9G999')); -- raise implicitly
END IF;
EXCEPTION
WHEN INVALID_NUMBER THEN
DBMS_OUTPUT.PUT_LINE('Substituting default value for invalid number.');
INSERT INTO t VALUES(default_number);
END;
/
BEGIN
p(-1);
END;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/raising-exceptions-explicitly-3.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/raising-exceptions-explicitly.html
BEGIN
p(1);
END;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/raising-exceptions-explicitly-5.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/raising-exceptions-explicitly.html
DECLARE
salary_too_high EXCEPTION;
current_salary NUMBER := 20000;
max_salary NUMBER := 10000;
erroneous_salary NUMBER;
BEGIN
BEGIN
IF current_salary > max_salary THEN
RAISE salary_too_high; -- raise exception
END IF;
EXCEPTION
WHEN salary_too_high THEN -- start handling exception
erroneous_salary := current_salary;
DBMS_OUTPUT.PUT_LINE('Salary ' || erroneous_salary ||' is out of range.');
DBMS_OUTPUT.PUT_LINE ('Maximum salary is ' || max_salary || '.');
RAISE; -- reraise current exception (exception name is optional)
END;
EXCEPTION
WHEN salary_too_high THEN -- finish handling exception
current_salary := max_salary;
DBMS_OUTPUT.PUT_LINE (
'Revising salary from ' || erroneous_salary ||
' to ' || current_salary || '.'
);
END;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/raising-exceptions-explicitly-9.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/raising-exceptions-explicitly.html
CREATE OR REPLACE PROCEDURE account_status (
due_date DATE,
today DATE
) AUTHID DEFINER
IS
BEGIN
IF due_date < today THEN -- explicitly raise exception
RAISE_APPLICATION_ERROR(-20000, 'Account past due.');
END IF;
END;
/
DECLARE
past_due EXCEPTION; -- declare exception
PRAGMA EXCEPTION_INIT (past_due, -20000); -- assign error code to exception
BEGIN
account_status (TO_DATE('01-JUL-2010', 'DD-MON-YYYY'),
TO_DATE('09-JUL-2010', 'DD-MON-YYYY')); -- invoke procedure
EXCEPTION
WHEN past_due THEN -- handle exception
DBMS_OUTPUT.PUT_LINE(TO_CHAR(SQLERRM(-20000)));
END;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/record-variables-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/record-variables.html
DECLARE
TYPE My_Rec IS RECORD (a NUMBER, b NUMBER);
r CONSTANT My_Rec := My_Rec(0,1);
BEGIN
DBMS_OUTPUT.PUT_LINE('r.a = ' || r.a);
DBMS_OUTPUT.PUT_LINE('r.b = ' || r.b);
END;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/record-variables-1.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/record-variables.html
CREATE OR REPLACE PACKAGE My_Types AUTHID CURRENT_USER IS
TYPE My_Rec IS RECORD (a NUMBER, b NUMBER);
FUNCTION Init_My_Rec RETURN My_Rec;
END My_Types;
/
CREATE OR REPLACE PACKAGE BODY My_Types IS
FUNCTION Init_My_Rec RETURN My_Rec IS
Rec My_Rec;
BEGIN
Rec.a := 0;
Rec.b := 1;
RETURN Rec;
END Init_My_Rec;
END My_Types;
/
DECLARE
r CONSTANT My_Types.My_Rec := My_Types.Init_My_Rec();
BEGIN
DBMS_OUTPUT.PUT_LINE('r.a = ' || r.a);
DBMS_OUTPUT.PUT_LINE('r.b = ' || r.b);
END;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/record-variables-11.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/record-variables.html
CREATE OR REPLACE PACKAGE pkg AS
TYPE rec_type IS RECORD ( -- package RECORD type
f1 INTEGER,
f2 VARCHAR2(4)
);
PROCEDURE print_rec_type (rec rec_type);
END pkg;
/
CREATE OR REPLACE PACKAGE BODY pkg AS
PROCEDURE print_rec_type (rec rec_type) IS
BEGIN
DBMS_OUTPUT.PUT_LINE(rec.f1);
DBMS_OUTPUT.PUT_LINE(rec.f2);
END;
END pkg;
/
DECLARE
TYPE rec_type IS RECORD ( -- local RECORD type
f1 INTEGER,
f2 VARCHAR2(4)
);
r1 pkg.rec_type; -- package type
r2 rec_type; -- local type
BEGIN
r1.f1 := 10; r1.f2 := 'abcd';
r2.f1 := 25; r2.f2 := 'wxyz';
pkg.print_rec_type(r1); -- succeeds
pkg.print_rec_type(r2); -- fails
END;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/record-variables-14.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/record-variables.html
DECLARE
dept_rec departments%ROWTYPE;
BEGIN
-- Assign values to fields:
dept_rec.department_id := 10;
dept_rec.department_name := 'Administration';
dept_rec.manager_id := 200;
dept_rec.location_id := 1700;
-- Print fields:
DBMS_OUTPUT.PUT_LINE('dept_id: ' || dept_rec.department_id);
DBMS_OUTPUT.PUT_LINE('dept_name: ' || dept_rec.department_name);
DBMS_OUTPUT.PUT_LINE('mgr_id: ' || dept_rec.manager_id);
DBMS_OUTPUT.PUT_LINE('loc_id: ' || dept_rec.location_id);
END;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/record-variables-16.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/record-variables.html
CREATE OR REPLACE PROCEDURE print (n INTEGER) IS
BEGIN
IF n IS NOT NULL THEN
DBMS_OUTPUT.PUT_LINE(n);
ELSE
DBMS_OUTPUT.PUT_LINE('NULL');
END IF;
END print;
/
DROP TABLE t1;
CREATE TABLE t1 (
c1 INTEGER DEFAULT 0 NOT NULL,
c2 INTEGER DEFAULT 1 NOT NULL
);
DECLARE
t1_row t1%ROWTYPE;
BEGIN
DBMS_OUTPUT.PUT('t1.c1 = ');
DBMS_OUTPUT.PUT_LINE(NVL(TO_CHAR(t1_row.c1), 'NULL'));
DBMS_OUTPUT.PUT('t1.c2 = '); print(t1_row.c2);
DBMS_OUTPUT.PUT_LINE(NVL(TO_CHAR(t1_row.c2), 'NULL'));
END;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/record-variables-19.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/record-variables.html
DECLARE
CURSOR c IS
SELECT first_name, last_name, phone_number
FROM employees;
friend c%ROWTYPE;
BEGIN
friend.first_name := 'John';
friend.last_name := 'Smith';
friend.phone_number := '1-650-555-1234';
DBMS_OUTPUT.PUT_LINE (
friend.first_name || ' ' ||
friend.last_name || ', ' ||
friend.phone_number
);
END;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/record-variables-21.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/record-variables.html
DECLARE
CURSOR c2 IS
SELECT employee_id, email, employees.manager_id, location_id
FROM employees, departments
WHERE employees.department_id = departments.department_id;
join_rec c2%ROWTYPE; -- includes columns from two tables
BEGIN
NULL;
END;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/record-variables-22.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/record-variables.html
DROP TABLE plch_departure;
CREATE TABLE plch_departure (
destination VARCHAR2(100),
departure_time DATE,
delay NUMBER(10),
expected GENERATED ALWAYS AS (departure_time + delay/24/60/60)
);
DECLARE
dep_rec plch_departure%ROWTYPE;
BEGIN
dep_rec.destination := 'X';
dep_rec.departure_time := SYSDATE;
dep_rec.delay := 1500;
INSERT INTO plch_departure VALUES dep_rec;
END;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/record-variables-24.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/record-variables.html
DECLARE
dep_rec plch_departure%rowtype;
BEGIN
dep_rec.destination := 'X';
dep_rec.departure_time := SYSDATE;
dep_rec.delay := 1500;
INSERT INTO plch_departure (destination, departure_time, delay)
VALUES (dep_rec.destination, dep_rec.departure_time, dep_rec.delay);
end;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/record-variables-26.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/record-variables.html
CREATE TABLE t (a INT, b INT, c INT INVISIBLE);
INSERT INTO t (a, b, c) VALUES (1, 2, 3);
COMMIT;
DECLARE
t_rec t%ROWTYPE; -- t_rec has fields a and b, but not c
BEGIN
SELECT * INTO t_rec FROM t WHERE ROWNUM < 2; -- t_rec(a)=1, t_rec(b)=2
DBMS_OUTPUT.PUT_LINE('c = ' || t_rec.c);
END;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/record-variables-28.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/record-variables.html
ALTER TABLE t MODIFY (c VISIBLE);
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/record-variables-3.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/record-variables.html
DECLARE
TYPE t_size IS RECORD (x NUMBER, y NUMBER);
c_small CONSTANT t_size := t_size(32,36);
c_large CONSTANT t_size := t_size(x => 192, y => 292);
BEGIN
DBMS_OUTPUT.PUT_LINE('Small size is ' || c_small.x || ' by ' || c_small.y);
DBMS_OUTPUT.PUT_LINE('Large size is ' || c_large.x || ' by ' || c_large.y);
END;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/record-variables-30.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/record-variables.html
DECLARE
t_rec t%ROWTYPE; -- t_rec has fields a, b, and c
BEGIN
SELECT * INTO t_rec FROM t WHERE ROWNUM < 2; -- t_rec(a)=1, t_rec(b)=2,
-- t_rec(c)=3
DBMS_OUTPUT.PUT_LINE('c = ' || t_rec.c);
END;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/record-variables-5.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/record-variables.html
DECLARE
TYPE DeptRecTyp IS RECORD (
dept_id NUMBER(4) NOT NULL := 10,
dept_name VARCHAR2(30) NOT NULL := 'Administration',
mgr_id NUMBER(6) := 200,
loc_id NUMBER(4) := 1700
);
dept_rec DeptRecTyp;
BEGIN
DBMS_OUTPUT.PUT_LINE('dept_id: ' || dept_rec.dept_id);
DBMS_OUTPUT.PUT_LINE('dept_name: ' || dept_rec.dept_name);
DBMS_OUTPUT.PUT_LINE('mgr_id: ' || dept_rec.mgr_id);
DBMS_OUTPUT.PUT_LINE('loc_id: ' || dept_rec.loc_id);
END;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/record-variables-7.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/record-variables.html
DECLARE
TYPE name_rec IS RECORD (
first employees.first_name%TYPE,
last employees.last_name%TYPE
);
TYPE contact IS RECORD (
name name_rec, -- nested record
phone employees.phone_number%TYPE
);
friend contact;
BEGIN
friend.name.first := 'John';
friend.name.last := 'Smith';
friend.phone := '1-650-555-1234';
DBMS_OUTPUT.PUT_LINE (
friend.name.first || ' ' ||
friend.name.last || ', ' ||
friend.phone
);
END;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/record-variables-9.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/record-variables.html
DECLARE
TYPE full_name IS VARRAY(2) OF VARCHAR2(20);
TYPE contact IS RECORD (
name full_name := full_name('John', 'Smith'), -- varray field
phone employees.phone_number%TYPE
);
friend contact;
BEGIN
friend.phone := '1-650-555-1234';
DBMS_OUTPUT.PUT_LINE (
friend.name(1) || ' ' ||
friend.name(2) || ', ' ||
friend.phone
);
END;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/recursive-subprograms-1.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/recursive-subprograms.html
CREATE OR REPLACE FUNCTION factorial (
n POSITIVE
) RETURN POSITIVE
AUTHID DEFINER
IS
BEGIN
IF n = 1 THEN -- terminating condition
RETURN n;
ELSE
RETURN n * factorial(n-1); -- recursive invocation
END IF;
END;
/
BEGIN
FOR i IN 1..5 LOOP
DBMS_OUTPUT.PUT_LINE(i || '! = ' || factorial(i));
END LOOP;
END;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/recursive-subprograms-3.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/recursive-subprograms.html
CREATE OR REPLACE FUNCTION fibonacci (
n PLS_INTEGER
) RETURN PLS_INTEGER
AUTHID DEFINER
IS
fib_1 PLS_INTEGER := 0;
fib_2 PLS_INTEGER := 1;
BEGIN
IF n = 1 THEN -- terminating condition
RETURN fib_1;
ELSIF n = 2 THEN
RETURN fib_2; -- terminating condition
ELSE
RETURN fibonacci(n-2) + fibonacci(n-1); -- recursive invocations
END IF;
END;
/
BEGIN
FOR i IN 1..10 LOOP
DBMS_OUTPUT.PUT(fibonacci(i));
IF i < 10 THEN
DBMS_OUTPUT.PUT(', ');
END IF;
END LOOP;
DBMS_OUTPUT.PUT_LINE(' ...');
END;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/redeclared-predefined-exceptions-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/redeclared-predefined-exceptions.html
DROP TABLE t;
CREATE TABLE t (c NUMBER);
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/redeclared-predefined-exceptions-1.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/redeclared-predefined-exceptions.html
DECLARE
default_number NUMBER := 0;
BEGIN
INSERT INTO t VALUES(TO_NUMBER('100.00', '9G999'));
EXCEPTION
WHEN INVALID_NUMBER THEN
DBMS_OUTPUT.PUT_LINE('Substituting default value for invalid number.');
INSERT INTO t VALUES(default_number);
END;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/redeclared-predefined-exceptions-3.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/redeclared-predefined-exceptions.html
DECLARE
default_number NUMBER := 0;
i NUMBER := 5;
invalid_number EXCEPTION; -- redeclare predefined exception
BEGIN
INSERT INTO t VALUES(TO_NUMBER('100.00', '9G999'));
EXCEPTION
WHEN INVALID_NUMBER THEN
DBMS_OUTPUT.PUT_LINE('Substituting default value for invalid number.');
INSERT INTO t VALUES(default_number);
END;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/redeclared-predefined-exceptions-5.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/redeclared-predefined-exceptions.html
DECLARE
default_number NUMBER := 0;
i NUMBER := 5;
invalid_number EXCEPTION; -- redeclare predefined exception
BEGIN
INSERT INTO t VALUES(TO_NUMBER('100.00', '9G999'));
EXCEPTION
WHEN STANDARD.INVALID_NUMBER THEN
DBMS_OUTPUT.PUT_LINE('Substituting default value for invalid number.');
INSERT INTO t VALUES(default_number);
END;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/references-identifiers-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/references-identifiers.html
DECLARE
a INTEGER; -- Declaration
BEGIN
a := 1; -- Reference with simple name
END;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/release-changes-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/release-changes.html
CREATE OR REPLACE FUNCTION useBool(p1 BOOLEAN) RETURN NUMBER AS
BEGIN
IF p1 THEN RETURN 100;
ELSE
RETURN 200;
END IF;
END;
/
SET SERVEROUTPUT ON;
DECLARE
v1 NUMBER;
v2 BOOLEAN := TRUE;
BEGIN
SELECT useBool(v2) INTO v1 FROM dual; --boolean argument function called from SELECT
DBMS_OUTPUT.PUT_LINE(v1);
END;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/release-changes-2.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/release-changes.html
CREATE PROCEDURE IF NOT EXISTS hello AS
BEGIN
DBMS_OUTPUT.PUT_LINE('Hello there');
END;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/release-changes-3.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/release-changes.html
CREATE PROCEDURE IF NOT EXISTS hello AS
BEGIN
DBMS_OUTPUT.PUT_LINE('Second hello');
END;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/release-changes-4.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/release-changes.html
SELECT TEXT FROM USER_SOURCE WHERE NAME='HELLO';
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/retrieving-error-code-and-error-message-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/retrieving-error-code-and-error-message.html
DROP TABLE errors;
CREATE TABLE errors (
code NUMBER,
message VARCHAR2(64)
);
CREATE OR REPLACE PROCEDURE p AUTHID DEFINER AS
name EMPLOYEES.LAST_NAME%TYPE;
v_code NUMBER;
v_errm VARCHAR2(64);
BEGIN
SELECT last_name INTO name
FROM EMPLOYEES
WHERE EMPLOYEE_ID = -1;
EXCEPTION
WHEN OTHERS THEN
v_code := SQLCODE;
v_errm := SUBSTR(SQLERRM, 1, 64);
DBMS_OUTPUT.PUT_LINE
('Error code ' || v_code || ': ' || v_errm);
/* Invoke another procedure,
declared with PRAGMA AUTONOMOUS_TRANSACTION,
to insert information about errors. */
INSERT INTO errors (code, message)
VALUES (v_code, v_errm);
RAISE;
END;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/retrying-transactions-handling-exceptions-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/retrying-transactions-handling-exceptions.html
DROP TABLE results;
CREATE TABLE results (
res_name VARCHAR(20),
res_answer VARCHAR2(3)
);
CREATE UNIQUE INDEX res_name_ix ON results (res_name);
INSERT INTO results (res_name, res_answer) VALUES ('SMYTHE', 'YES');
INSERT INTO results (res_name, res_answer) VALUES ('JONES', 'NO');
DECLARE
name VARCHAR2(20) := 'SMYTHE';
answer VARCHAR2(3) := 'NO';
suffix NUMBER := 1;
BEGIN
FOR i IN 1..5 LOOP -- Try transaction at most 5 times.
DBMS_OUTPUT.PUT('Try #' || i);
BEGIN -- sub-block begins
SAVEPOINT start_transaction;
-- transaction begins
DELETE FROM results WHERE res_answer = 'NO';
INSERT INTO results (res_name, res_answer) VALUES (name, answer);
-- Nonunique name raises DUP_VAL_ON_INDEX.
-- If transaction succeeded:
COMMIT;
DBMS_OUTPUT.PUT_LINE(' succeeded.');
EXIT;
EXCEPTION
WHEN DUP_VAL_ON_INDEX THEN
DBMS_OUTPUT.PUT_LINE(' failed; trying again.');
ROLLBACK TO start_transaction; -- Undo changes.
suffix := suffix + 1; -- Try to fix problem.
name := name || TO_CHAR(suffix);
END; -- sub-block ends
END LOOP;
END;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/scope-and-visibility-identifiers-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/scope-and-visibility-identifiers.html
DECLARE
a CHAR; -- Scope of a (CHAR) begins
b REAL; -- Scope of b begins
BEGIN
-- Visible: a (CHAR), b
-- First sub-block:
DECLARE
a INTEGER; -- Scope of a (INTEGER) begins
c REAL; -- Scope of c begins
BEGIN
-- Visible: a (INTEGER), b, c
NULL;
END; -- Scopes of a (INTEGER) and c end
-- Second sub-block:
DECLARE
d REAL; -- Scope of d begins
BEGIN
-- Visible: a (CHAR), b, d
NULL;
END; -- Scope of d ends
-- Visible: a (CHAR), b
END; -- Scopes of a (CHAR) and b end
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/scope-and-visibility-identifiers-1.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/scope-and-visibility-identifiers.html
<> -- label
DECLARE
birthdate DATE := TO_DATE('09-AUG-70', 'DD-MON-YY');
BEGIN
DECLARE
birthdate DATE := TO_DATE('29-SEP-70', 'DD-MON-YY');
BEGIN
IF birthdate = outer.birthdate THEN
DBMS_OUTPUT.PUT_LINE ('Same Birthday');
ELSE
DBMS_OUTPUT.PUT_LINE ('Different Birthday');
END IF;
END;
END;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/scope-and-visibility-identifiers-11.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/scope-and-visibility-identifiers.html
<>
<>
DECLARE
numerator NUMBER := 22;
denominator NUMBER := 7;
BEGIN
<>
DECLARE
denominator NUMBER := 0;
BEGIN
DBMS_OUTPUT.PUT_LINE('Ratio with compute_ratio.denominator = ');
DBMS_OUTPUT.PUT_LINE(numerator/compute_ratio.denominator);
DBMS_OUTPUT.PUT_LINE('Ratio with another_label.denominator = ');
DBMS_OUTPUT.PUT_LINE(numerator/another_label.denominator);
EXCEPTION
WHEN ZERO_DIVIDE THEN
DBMS_OUTPUT.PUT_LINE('Divide-by-zero error: can''t divide '
|| numerator || ' by ' || denominator);
WHEN OTHERS THEN
DBMS_OUTPUT.PUT_LINE('Unexpected error.');
END another_label;
END compute_ratio;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/scope-and-visibility-identifiers-3.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/scope-and-visibility-identifiers.html
CREATE OR REPLACE PROCEDURE check_credit (credit_limit NUMBER) AS
rating NUMBER := 3;
FUNCTION check_rating RETURN BOOLEAN IS
rating NUMBER := 1;
over_limit BOOLEAN;
BEGIN
IF check_credit.rating <= credit_limit THEN -- reference global variable
over_limit := FALSE;
ELSE
over_limit := TRUE;
rating := credit_limit; -- reference local variable
END IF;
RETURN over_limit;
END check_rating;
BEGIN
IF check_rating THEN
DBMS_OUTPUT.PUT_LINE
('Credit rating over limit (' || TO_CHAR(credit_limit) || '). '
|| 'Rating: ' || TO_CHAR(rating));
ELSE
DBMS_OUTPUT.PUT_LINE
('Credit rating OK. ' || 'Rating: ' || TO_CHAR(rating));
END IF;
END;
/
BEGIN
check_credit(1);
END;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/scope-and-visibility-identifiers-5.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/scope-and-visibility-identifiers.html
DECLARE
id BOOLEAN;
id VARCHAR2(5); -- duplicate identifier
BEGIN
id := FALSE;
END;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/scope-and-visibility-identifiers-7.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/scope-and-visibility-identifiers.html
DECLARE
PROCEDURE p
IS
x VARCHAR2(1);
BEGIN
x := 'a'; -- Assign the value 'a' to x
DBMS_OUTPUT.PUT_LINE('In procedure p, x = ' || x);
END;
PROCEDURE q
IS
x VARCHAR2(1);
BEGIN
x := 'b'; -- Assign the value 'b' to x
DBMS_OUTPUT.PUT_LINE('In procedure q, x = ' || x);
END;
BEGIN
p;
q;
END;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/scope-and-visibility-identifiers-9.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/scope-and-visibility-identifiers.html
<>
DECLARE
x NUMBER := 5;
PROCEDURE echo AS
x NUMBER := 0;
BEGIN
DBMS_OUTPUT.PUT_LINE('x = ' || x);
DBMS_OUTPUT.PUT_LINE('echo.x = ' || echo.x);
END;
BEGIN
echo;
END;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/sequential-control-statements-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/sequential-control-statements.html
DECLARE
v_job_id VARCHAR2(10);
v_emp_id NUMBER(6) := 110;
BEGIN
SELECT job_id INTO v_job_id
FROM employees
WHERE employee_id = v_emp_id;
IF v_job_id = 'SA_REP' THEN
UPDATE employees
SET commission_pct = commission_pct * 1.2;
ELSE
NULL; -- Employee is not a sales rep
END IF;
END;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/sequential-control-statements-1.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/sequential-control-statements.html
CREATE OR REPLACE PROCEDURE award_bonus (
emp_id NUMBER,
bonus NUMBER
) AUTHID DEFINER AS
BEGIN -- Executable part starts here
NULL; -- Placeholder
-- (raises "unreachable code" if warnings enabled)
END award_bonus;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/sequential-control-statements-2.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/sequential-control-statements.html
CREATE OR REPLACE PROCEDURE print_grade (
grade CHAR
) AUTHID DEFINER AS
BEGIN
CASE grade
WHEN 'A' THEN DBMS_OUTPUT.PUT_LINE('Excellent');
WHEN 'B' THEN DBMS_OUTPUT.PUT_LINE('Very Good');
WHEN 'C' THEN DBMS_OUTPUT.PUT_LINE('Good');
WHEN 'D' THEN DBMS_OUTPUT.PUT_LINE('Fair');
WHEN 'F' THEN DBMS_OUTPUT.PUT_LINE('Poor');
ELSE NULL;
END CASE;
END;
/
BEGIN
print_grade('A');
print_grade('S');
END;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/serially_reusable-packages-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/serially_reusable-packages.html
CREATE OR REPLACE PACKAGE bodiless_pkg AUTHID DEFINER IS
PRAGMA SERIALLY_REUSABLE;
n NUMBER := 5;
END;
/
CREATE OR REPLACE PACKAGE pkg AUTHID DEFINER IS
PRAGMA SERIALLY_REUSABLE;
n NUMBER := 5;
END;
/
CREATE OR REPLACE PACKAGE BODY pkg IS
PRAGMA SERIALLY_REUSABLE;
BEGIN
n := 5;
END;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/serially_reusable-packages-1.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/serially_reusable-packages.html
CREATE OR REPLACE PACKAGE pkg IS
n NUMBER := 5;
END pkg;
/
CREATE OR REPLACE PACKAGE sr_pkg IS
PRAGMA SERIALLY_REUSABLE;
n NUMBER := 5;
END sr_pkg;
/
BEGIN
pkg.n := 10;
sr_pkg.n := 10;
END;
/
BEGIN
DBMS_OUTPUT.PUT_LINE('pkg.n: ' || pkg.n);
DBMS_OUTPUT.PUT_LINE('sr_pkg.n: ' || sr_pkg.n);
END;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/serially_reusable-packages-3.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/serially_reusable-packages.html
DROP TABLE people;
CREATE TABLE people (name VARCHAR2(20));
INSERT INTO people (name) VALUES ('John Smith');
INSERT INTO people (name) VALUES ('Mary Jones');
INSERT INTO people (name) VALUES ('Joe Brown');
INSERT INTO people (name) VALUES ('Jane White');
CREATE OR REPLACE PACKAGE sr_pkg IS
PRAGMA SERIALLY_REUSABLE;
CURSOR c IS SELECT name FROM people;
END sr_pkg;
/
CREATE OR REPLACE PROCEDURE fetch_from_cursor IS
v_name people.name%TYPE;
BEGIN
IF sr_pkg.c%ISOPEN THEN
DBMS_OUTPUT.PUT_LINE('Cursor is open.');
ELSE
DBMS_OUTPUT.PUT_LINE('Cursor is closed; opening now.');
OPEN sr_pkg.c;
END IF;
FETCH sr_pkg.c INTO v_name;
DBMS_OUTPUT.PUT_LINE('Fetched: ' || v_name);
FETCH sr_pkg.c INTO v_name;
DBMS_OUTPUT.PUT_LINE('Fetched: ' || v_name);
END fetch_from_cursor;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/serially_reusable-packages-4.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/serially_reusable-packages.html
BEGIN
fetch_from_cursor;
fetch_from_cursor;
END;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/serially_reusable-packages-6.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/serially_reusable-packages.html
BEGIN
fetch_from_cursor;
fetch_from_cursor;
END;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/sql-data-types-1.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/sql-data-types.html
DECLARE
t_b boolean := TRUE;
f_b boolean := FALSE;
BEGIN
DBMS_OUTPUT.PUT_LINE('My bool is: ' || t_b);
DBMS_OUTPUT.PUT_LINE('My bool is: ' || f_b);
END;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/sql-data-types-10.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/sql-data-types.html
DECLARE
TYPE theNSTTAB IS TABLE OF NUMBER;
myNSTTAB theNSTTAB;
BEGIN
myNSTTAB := JSON_VALUE(JSON('{"1":10, "2":20, "3":30, "4":40}'), '$' RETURNING theNSTTAB);
END;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/sql-data-types-12.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/sql-data-types.html
DECLARE
TYPE theIBPLS IS TABLE OF NUMBER INDEX BY PLS_INTEGER;
myIBPLS theIBPLS := theIBPLS(-1=>1, 2=>2, -3=>3);
myJSON JSON;
BEGIN
myJSON := JSON(myIBPLS);
DBMS_OUTPUT.PUT_LINE(JSON_SERIALIZE(myJSON));
END;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/sql-data-types-14.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/sql-data-types.html
DECLARE
TYPE theNSTTAB IS TABLE OF NUMBER;
myNSTTAB theNSTTAB := theNSTTAB(1=>1, 2=>2, 3=>3);
myJSON JSON;
BEGIN
myNSTTAB.delete(2); --myNSTTAB becomes sparse when elements are deleted
myJSON := JSON(myNSTTAB);
DBMS_OUTPUT.PUT_LINE(JSON_SERIALIZE(myJSON));
END;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/sql-data-types-16.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/sql-data-types.html
DECLARE
TYPE theIBPLS IS TABLE OF NUMBER INDEX BY PLS_INTEGER;
myIBPLS theIBPLS;
BEGIN
myIBPLS := JSON_VALUE(JSON('[1, 2, 3, 4, 5]'), '$' RETURNING theIBPLS);
END;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/sql-data-types-18.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/sql-data-types.html
DECLARE
TYPE theVARRAY IS VARRAY(5) OF NUMBER;
myVARRAY theVARRAY;
BEGIN
myVARRAY := JSON_VALUE(JSON('[1, 2, 3, 4, 5]'), '$' RETURNING theVARRAY);
END;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/sql-data-types-20.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/sql-data-types.html
DECLARE
TYPE theNESTEDTABLE IS TABLE OF NUMBER;
myNESTEDTABLE theNESTEDTABLE;
BEGIN
myNESTEDTABLE := JSON_VALUE(JSON('[1, 2, 3, 4, 5]'), '$' RETURNING theNESTEDTABLE);
END;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/sql-data-types-22.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/sql-data-types.html
DECLARE
TYPE theVarray IS VARRAY(4) OF NUMBER;
myVarray theVarray := theVarray(1, 2, 3, null);
myJSON JSON;
BEGIN
myJSON := JSON(myVarray);
DBMS_OUTPUT.PUT_LINE(JSON_SERIALIZE(myJSON));
END;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/sql-data-types-24.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/sql-data-types.html
DECLARE
TYPE theASCARRAY IS TABLE OF NUMBER INDEX BY VARCHAR2(10);
myAscArray theASCARRAY;
BEGIN
myAscArray := JSON_VALUE(JSON('{"Key1":10, "Key2":20}'), '$' RETURNING theASCARRAY);
END;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/sql-data-types-26.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/sql-data-types.html
DECLARE
TYPE AsscArray IS TABLE OF VARCHAR2(10) INDEX BY VARCHAR2(10);
myAsscArray AsscArray := AsscArray('FIRST_NAME' => 'Bob', 'LAST_NAME' => 'Jones');
myJson JSON;
BEGIN
myJson := JSON(myAsscArray);
DBMS_OUTPUT.PUT_LINE(JSON_SERIALIZE(myJson));
END;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/sql-data-types-29.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/sql-data-types.html
CREATE TABLE PLS_VEC_TAB(
v1 vector,
v2 vector(100),
v3 vector(*, INT8),
v4 vector(100, INT8),
v5 vector(1024, BINARY),
v6 vector(100, FLOAT32, DENSE),
v7 vector(100, FLOAT32, SPARSE)
);
DECLARE
vec0 vector; -- dimension and format are flexible, storage format is DENSE
vec1 PLS_VEC_TAB.v1%TYPE; -- dimension and format are flexible, storage format is DENSE
vec2 PLS_VEC_TAB.v2%TYPE; -- dimension is 100, format is flexible, storage format is DENSE
vec3 PLS_VEC_TAB.v3%TYPE; -- dimension is flexible, format is INT8, storage format is DENSE
vec4 PLS_VEC_TAB.v4%TYPE; -- dimension is 100, format is INT8, storage format is DENSE
vec5 PLS_VEC_TAB.v5%TYPE; -- dimension is 1024, format is BINARY, storage format is DENSE
vec6 PLS_VEC_TAB.v6%TYPE; -- dimension is 100, format is FLOAT32, storage format is DENSE
vec7 PLS_VEC_TAB.v7%TYPE; -- dimension is 100, format is FLOAT32, storage format is SPARSE
vec_0 vec0%TYPE; -- dimension and format are flexible, storage format is DENSE
vec_1 vec1%TYPE; -- dimension and format are flexible, storage format is DENSE
vec_2 vec2%TYPE; -- dimension is 100, format is flexible, storage format is DENSE
vec_3 vec3%TYPE; -- dimension is flexible, format is INT8, storage format is DENSE
vec_4 vec4%TYPE; -- dimension is 100, format is INT8, storage format is DENSE
vec_5 vec5%TYPE; -- dimension is 1024, format is BINARY, storage format is DENSE
vec_6 vec6%TYPE; -- dimension is 100, format is FLOAT32, storage format is DENSE
vec_7 vec7%TYPE; -- dimension is 100, format is FLOAT32, storage format is SPARSE
BEGIN
NULL;
END;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/sql-data-types-3.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/sql-data-types.html
DECLARE
TYPE personrecord IS RECORD(first VARCHAR2(10), last VARCHAR2(10));
p personrecord;
BEGIN
p := JSON_VALUE(JSON('{"FIRST":"Jane", "LAST":"Cooper"}'), '$'
RETURNING personrecord USING CASE_SENSITIVE MAPPING);
DBMS_OUTPUT.PUT_LINE(p.first ||' '|| p.last);
END;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/sql-data-types-31.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/sql-data-types.html
SELECT VECTOR_DISTANCE(v1, v2, COSINE) INTO dist;
SELECT v1 <=> v2 INTO dist;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/sql-data-types-32.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/sql-data-types.html
DROP TABLE theVectorTable;
CREATE TABLE theVectorTable (embedding VECTOR(3, float32), id NUMBER);
INSERT INTO theVectorTable VALUES ('[1.11, 2.22, 3.33]', 1);
INSERT INTO theVectorTable VALUES ('[4.44, 5.55, 6.66]', 2);
INSERT INTO theVectorTable VALUES ('[7.77, 8.88, 9.99]', 3);
SET SERVEROUTPUT ON;
DECLARE
v_embedding theVectorTable.embedding%TYPE;
BEGIN
SELECT embedding INTO v_embedding FROM theVectorTable WHERE id=3;
DBMS_OUTPUT.PUT_LINE('Embedding is ' || FROM_VECTOR(v_embedding));
END;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/sql-data-types-34.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/sql-data-types.html
DECLARE
TYPE vecTabT IS TABLE OF theVectorTable%ROWTYPE INDEX BY BINARY_INTEGER;
v_vecTabT vecTabT;
CURSOR c IS SELECT * FROM theVectorTable;
BEGIN
OPEN c;
FETCH c BULK COLLECT INTO v_vecTabT;
CLOSE c;
-- display the contents of the vector index table
FOR i IN 1..v_vecTabT.LAST LOOP
DBMS_OUTPUT.PUT_LINE('Embedding ID ' || v_vecTabT(i).id || ': ' ||
FROM_VECTOR(v_vecTabT(i).embedding));
END LOOP;
END;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/sql-data-types-36.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/sql-data-types.html
DROP TABLE vecLogTable;
DROP SEQUENCE vecTrgSeq;
CREATE TABLE vecLogTable (embedding VECTOR(3, float32),
describe VARCHAR2(25), seq NUMBER);
CREATE SEQUENCE vecTrgSeq;
CREATE OR REPLACE TRIGGER vecTrg
BEFORE UPDATE ON theVectorTable
FOR EACH ROW
BEGIN
INSERT INTO vecLogTable VALUES (:old.embedding, 'OLD.VECTRG',
vecTrgSeq.NEXTVAL);
INSERT INTO vecLogTable VALUES (:new.embedding, 'NEW.VECTRG',
vecTrgSeq.NEXTVAL);
END;
/
UPDATE theVectorTable SET embedding='[2.22, 4.44, 6.66]' WHERE id=2;
SELECT * FROM vecLogTable ORDER BY seq;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/sql-data-types-38.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/sql-data-types.html
DECLARE
v1 VECTOR := TO_VECTOR('[1, 2, 3]');
v2 VECTOR := TO_VECTOR('[4, 5, 6]');
v3 VECTOR := TO_VECTOR('[1, 2, 0, 6]', *, BINARY);
v4 VECTOR := TO_VECTOR('[0, 6, 0, 3]', *, BINARY);
man_dist NUMBER;
euc_dist NUMBER;
cos_dist NUMBER;
inn_dist NUMBER;
ham_dist NUMBER;
dot_dist NUMBER;
jac_dist NUMBER;
BEGIN
man_dist := L1_DISTANCE(v1, v2); --Manhattan Distance
euc_dist := L2_DISTANCE(v1, v2); --Euclidean Distance
cos_dist := COSINE_DISTANCE(v1, v2); --Cosine Distance
inn_dist := INNER_PRODUCT(v1, v2); --Inner Product
--The Hamming Distance has no standalone function in PL/SQL
ham_dist := VECTOR_DISTANCE(v1, v2, HAMMING);
--The Negative Inner (Dot) Product has no standalone function in PL/SQL
dot_dist := VECTOR_DISTANCE(v1, v2, DOT);
--The Jaccard Distance has no standalone function in PL/SQL
jac_dist := VECTOR_DISTANCE(v3, v4, JACCARD);
DBMS_OUTPUT.PUT_LINE('The Manhattan distance is: ' || man_dist);
DBMS_OUTPUT.PUT_LINE('The Euclidean distance is: ' || euc_dist);
DBMS_OUTPUT.PUT_LINE('The Cosine distance is: ' || cos_dist);
DBMS_OUTPUT.PUT_LINE('The Inner Product is: ' || inn_dist);
DBMS_OUTPUT.PUT_LINE('The Hamming distance is: ' || ham_dist);
DBMS_OUTPUT.PUT_LINE('The Dot Product is: ' || dot_dist);
DBMS_OUTPUT.PUT_LINE('The Jaccard Distance between the BINARY vectors v3 and v4 is: ' || jac_dist);
END;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/sql-data-types-4.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/sql-data-types.html
DECLARE
TYPE theRec1 IS RECORD (field1 NUMBER, field2 VARCHAR2(10));
TYPE theRec2 IS RECORD ("fIeLd2" VARCHAR2(20), "FielD1" NUMBER);
Rec1 theRec1;
Rec2 theRec2;
BEGIN
Rec1 := JSON_VALUE(JSON('{"FIELD1":10, "field2":"hello"}'), '$' RETURNING theRec1);
Rec2 := JSON_VALUE(JSON('{"FIELD1":10, "field2":"hello"}'), '$' RETURNING theRec2);
END;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/sql-data-types-42.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/sql-data-types.html
DECLARE
v1 VECTOR := VECTOR('[10, 20, 30]', 3, INT8);
v2 VECTOR := VECTOR('[6, 4, 2]', 3, INT8);
BEGIN
DBMS_OUTPUT.PUT_LINE(TO_CHAR(v1 + v2));
DBMS_OUTPUT.PUT_LINE(TO_CHAR(v1 - v2));
DBMS_OUTPUT.PUT_LINE(TO_CHAR(v1 * v2));
END;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/sql-data-types-44.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/sql-data-types.html
DECLARE
vs1 VECTOR(*, *, SPARSE) := VECTOR('[10, [0, 3, 4, 6, 7], [1.9, 4, 7.2, 30, 60]]', *, *, SPARSE);
vs2 VECTOR(*, *, SPARSE) := VECTOR('[10, [1, 3, 4, 8, 9], [4.5, 7.6, 4, 8.1, 5]]', *, *, SPARSE);
vd1 VECTOR(*, *, DENSE) := VECTOR('[1.9, 0, 0, 4, 7.2, 0, 30, 60, 0, 0]', *, *, DENSE);
vd2 VECTOR(*, *, DENSE) := VECTOR('[0, 4.5, 0, 7.6, 4, 0, 0, 0, 8.1, 5]', *, *, DENSE);
BEGIN
DBMS_OUTPUT.PUT_LINE('Vector Distance Sparse: ' || TRUNC(VECTOR_DISTANCE(vs1, vs2), 5));
DBMS_OUTPUT.PUT_LINE('Vector Distance Dense: ' || TRUNC(VECTOR_DISTANCE(vd1, vd2), 5));
END;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/sql-data-types-46.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/sql-data-types.html
DECLARE
c VARCHAR2(3 CHAR);
BEGIN
c := 'abc ';
END;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/sql-data-types-48.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/sql-data-types.html
DROP TABLE t;
CREATE TABLE t (c CHAR(3 CHAR));
DECLARE
s VARCHAR2(5 CHAR) := 'abc ';
BEGIN
INSERT INTO t(c) VALUES(s);
END;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/sql-data-types-50.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/sql-data-types.html
DECLARE
c VARCHAR2(3 CHAR);
BEGIN
c := RTRIM('abc ');
INSERT INTO t(c) VALUES(RTRIM('abc '));
END;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/sql-data-types-52.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/sql-data-types.html
DECLARE
first_name CHAR(10 CHAR);
last_name VARCHAR2(10 CHAR);
BEGIN
first_name := 'John ';
last_name := 'Chen ';
DBMS_OUTPUT.PUT_LINE('*' || first_name || '*');
DBMS_OUTPUT.PUT_LINE('*' || last_name || '*');
END;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/sql-data-types-6.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/sql-data-types.html
DECLARE
TYPE theRec IS RECORD(field1 NUMBER, "Field2" NUMBER);
myRec theRec := theRec(10, 20);
myJson JSON;
BEGIN
myJson := JSON(myRec);
DBMS_OUTPUT.PUT_LINE(JSON_SERIALIZE(myJson));
END;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/sql-data-types-8.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/sql-data-types.html
DECLARE
TYPE theIBPLS IS TABLE OF NUMBER INDEX BY BINARY_INTEGER;
myIBPLS theIBPLS;
BEGIN
myIBPLS := JSON_VALUE(JSON('{"-10":10, "-1":1, "100":-100}'), '$' RETURNING theIBPLS);
END;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/sql-injection-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/sql-injection.html
DROP TABLE secret_records;
CREATE TABLE secret_records (
user_name VARCHAR2(9),
service_type VARCHAR2(12),
value VARCHAR2(30),
date_created DATE
);
INSERT INTO secret_records (
user_name, service_type, value, date_created
)
VALUES ('Andy', 'Waiter', 'Serve dinner at Cafe Pete', SYSDATE);
INSERT INTO secret_records (
user_name, service_type, value, date_created
)
VALUES ('Chuck', 'Merger', 'Buy company XYZ', SYSDATE);
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/sql-injection-1.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/sql-injection.html
CREATE OR REPLACE PROCEDURE get_record (
user_name IN VARCHAR2,
service_type IN VARCHAR2,
rec OUT VARCHAR2
) AUTHID DEFINER
IS
query VARCHAR2(4000);
BEGIN
-- Following SELECT statement is vulnerable to modification
-- because it uses concatenation to build WHERE clause.
query := 'SELECT value FROM secret_records WHERE user_name='''
|| user_name
|| ''' AND service_type='''
|| service_type
|| '''';
DBMS_OUTPUT.PUT_LINE('Query: ' || query);
EXECUTE IMMEDIATE query INTO rec ;
DBMS_OUTPUT.PUT_LINE('Rec: ' || rec );
END;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/sql-injection-10.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/sql-injection.html
SELECT * FROM secret_records ORDER BY user_name;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/sql-injection-12.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/sql-injection.html
BEGIN
p('Anybody', 'Anything'');
DELETE FROM secret_records WHERE service_type=INITCAP(''Merger');
END;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/sql-injection-13.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/sql-injection.html
DELETE FROM secret_records WHERE service_type=INITCAP('Merger');
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/sql-injection-14.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/sql-injection.html
SELECT * FROM secret_records;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/sql-injection-16.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/sql-injection.html
SELECT * FROM secret_records;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/sql-injection-18.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/sql-injection.html
CREATE OR REPLACE PROCEDURE get_recent_record (
user_name IN VARCHAR2,
service_type IN VARCHAR2,
rec OUT VARCHAR2
) AUTHID DEFINER
IS
query VARCHAR2(4000);
BEGIN
/* Following SELECT statement is vulnerable to modification
because it uses concatenation to build WHERE clause
and because SYSDATE depends on the value of NLS_DATE_FORMAT. */
query := 'SELECT value FROM secret_records WHERE user_name='''
|| user_name
|| ''' AND service_type='''
|| service_type
|| ''' AND date_created>'''
|| (SYSDATE - 30)
|| '''';
DBMS_OUTPUT.PUT_LINE('Query: ' || query);
EXECUTE IMMEDIATE query INTO rec;
DBMS_OUTPUT.PUT_LINE('Rec: ' || rec);
END;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/sql-injection-19.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/sql-injection.html
SET SERVEROUTPUT ON;
ALTER SESSION SET NLS_DATE_FORMAT='DD-MON-YYYY';
DECLARE
record_value VARCHAR2(4000);
BEGIN
get_recent_record('Andy', 'Waiter', record_value);
END;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/sql-injection-2.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/sql-injection.html
SET SERVEROUTPUT ON;
DECLARE
record_value VARCHAR2(4000);
BEGIN
get_record('Andy', 'Waiter', record_value);
END;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/sql-injection-21.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/sql-injection.html
ALTER SESSION SET NLS_DATE_FORMAT='"'' OR service_type=''Merger"';
DECLARE
record_value VARCHAR2(4000);
BEGIN
get_recent_record('Anybody', 'Anything', record_value);
END;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/sql-injection-23.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/sql-injection.html
CREATE OR REPLACE PROCEDURE get_record_2 (
user_name IN VARCHAR2,
service_type IN VARCHAR2,
rec OUT VARCHAR2
) AUTHID DEFINER
IS
query VARCHAR2(4000);
BEGIN
query := 'SELECT value FROM secret_records
WHERE user_name=:a
AND service_type=:b';
DBMS_OUTPUT.PUT_LINE('Query: ' || query);
EXECUTE IMMEDIATE query INTO rec USING user_name, service_type;
DBMS_OUTPUT.PUT_LINE('Rec: ' || rec);
END;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/sql-injection-24.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/sql-injection.html
SET SERVEROUTPUT ON;
DECLARE
record_value VARCHAR2(4000);
BEGIN
get_record_2('Andy', 'Waiter', record_value);
END;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/sql-injection-26.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/sql-injection.html
DECLARE
record_value VARCHAR2(4000);
BEGIN
get_record_2('Anybody '' OR service_type=''Merger''--',
'Anything',
record_value);
END;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/sql-injection-28.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/sql-injection.html
CREATE OR REPLACE PROCEDURE raise_emp_salary (
column_value NUMBER,
emp_column VARCHAR2,
amount NUMBER ) AUTHID DEFINER
IS
v_column VARCHAR2(30);
sql_stmt VARCHAR2(200);
BEGIN
-- Check validity of column name that was given as input:
SELECT column_name INTO v_column
FROM USER_TAB_COLS
WHERE TABLE_NAME = 'EMPLOYEES'
AND COLUMN_NAME = emp_column;
sql_stmt := 'UPDATE employees SET salary = salary + :1 WHERE '
|| DBMS_ASSERT.ENQUOTE_NAME(v_column,FALSE) || ' = :2';
EXECUTE IMMEDIATE sql_stmt USING amount, column_value;
-- If column name is valid:
IF SQL%ROWCOUNT > 0 THEN
DBMS_OUTPUT.PUT_LINE('Salaries were updated for: '
|| emp_column || ' = ' || column_value);
END IF;
-- If column name is not valid:
EXCEPTION
WHEN NO_DATA_FOUND THEN
DBMS_OUTPUT.PUT_LINE ('Invalid Column: ' || emp_column);
END raise_emp_salary;
/
DECLARE
plsql_block VARCHAR2(500);
BEGIN
-- Invoke raise_emp_salary from a dynamic PL/SQL block:
plsql_block :=
'BEGIN raise_emp_salary(:cvalue, :cname, :amt); END;';
EXECUTE IMMEDIATE plsql_block
USING 110, 'DEPARTMENT_ID', 10;
-- Invoke raise_emp_salary from a dynamic SQL statement:
EXECUTE IMMEDIATE 'BEGIN raise_emp_salary(:cvalue, :cname, :amt); END;'
USING 112, 'EMPLOYEE_ID', 10;
END;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/sql-injection-30.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/sql-injection.html
CREATE OR REPLACE PROCEDURE get_recent_record (
user_name IN VARCHAR2,
service_type IN VARCHAR2,
rec OUT VARCHAR2
) AUTHID DEFINER
IS
query VARCHAR2(4000);
BEGIN
/* Following SELECT statement is vulnerable to modification
because it uses concatenation to build WHERE clause. */
query := 'SELECT value FROM secret_records WHERE user_name='''
|| user_name
|| ''' AND service_type='''
|| service_type
|| ''' AND date_created> DATE '''
|| TO_CHAR(SYSDATE - 30,'YYYY-MM-DD')
|| '''';
DBMS_OUTPUT.PUT_LINE('Query: ' || query);
EXECUTE IMMEDIATE query INTO rec;
DBMS_OUTPUT.PUT_LINE('Rec: ' || rec);
END;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/sql-injection-31.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/sql-injection.html
ALTER SESSION SET NLS_DATE_FORMAT='"'' OR service_type=''Merger"';
DECLARE
record_value VARCHAR2(4000);
BEGIN
get_recent_record('Anybody', 'Anything', record_value);
END;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/sql-injection-4.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/sql-injection.html
DECLARE
record_value VARCHAR2(4000);
BEGIN
get_record(
'Anybody '' OR service_type=''Merger''--',
'Anything',
record_value);
END;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/sql-injection-6.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/sql-injection.html
CREATE OR REPLACE PROCEDURE p (
user_name IN VARCHAR2,
service_type IN VARCHAR2
) AUTHID DEFINER
IS
block1 VARCHAR2(4000);
BEGIN
-- Following block is vulnerable to statement injection
-- because it is built by concatenation.
block1 :=
'BEGIN
DBMS_OUTPUT.PUT_LINE(''user_name: ' || user_name || ''');'
|| 'DBMS_OUTPUT.PUT_LINE(''service_type: ' || service_type || ''');
END;';
DBMS_OUTPUT.PUT_LINE('Block1: ' || block1);
EXECUTE IMMEDIATE block1;
END;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/sql-injection-7.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/sql-injection.html
SET SERVEROUTPUT ON;
BEGIN
p('Andy', 'Waiter');
END;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/sql-injection-9.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/sql-injection.html
COLUMN date_created FORMAT A12;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/subprogram-invocation-resolution-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/subprogram-invocation-resolution.html
DECLARE
PROCEDURE swap (
n1 NUMBER,
n2 NUMBER
)
IS
num1 NUMBER;
num2 NUMBER;
FUNCTION balance
(bal NUMBER)
RETURN NUMBER
IS
x NUMBER := 10;
PROCEDURE swap (
d1 DATE,
d2 DATE
) IS
BEGIN
NULL;
END;
PROCEDURE swap (
b1 BOOLEAN,
b2 BOOLEAN
) IS
BEGIN
NULL;
END;
BEGIN -- balance
swap(num1, num2);
RETURN x;
END balance;
BEGIN -- enclosing procedure swap
NULL;
END swap;
BEGIN -- anonymous block
NULL;
END; -- anonymous block
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/subprogram-parameters-10.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/subprogram-parameters.html
CREATE OR REPLACE PROCEDURE p (
n NUMBER
) AUTHID DEFINER IS
BEGIN
NULL;
END;
/
DECLARE
x NUMBER := 1;
y VARCHAR2(1) := '1';
BEGIN
p(x); -- No conversion needed
p(y); -- z implicitly converted from VARCHAR2 to NUMBER
p(TO_NUMBER(y)); -- z explicitly converted from VARCHAR2 to NUMBER
END;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/subprogram-parameters-12.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/subprogram-parameters.html
CREATE OR REPLACE PROCEDURE p (x OUT INTEGER, y OUT INTEGER) AS
BEGIN
x := 17; y := 93;
END;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/subprogram-parameters-13.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/subprogram-parameters.html
CREATE OR REPLACE PROCEDURE p (
a PLS_INTEGER, -- IN by default
b IN PLS_INTEGER,
c OUT PLS_INTEGER,
d IN OUT BINARY_FLOAT
) AUTHID DEFINER IS
BEGIN
-- Print values of parameters:
DBMS_OUTPUT.PUT_LINE('Inside procedure p:');
DBMS_OUTPUT.PUT('IN a = ');
DBMS_OUTPUT.PUT_LINE(NVL(TO_CHAR(a), 'NULL'));
DBMS_OUTPUT.PUT('IN b = ');
DBMS_OUTPUT.PUT_LINE(NVL(TO_CHAR(b), 'NULL'));
DBMS_OUTPUT.PUT('OUT c = ');
DBMS_OUTPUT.PUT_LINE(NVL(TO_CHAR(c), 'NULL'));
DBMS_OUTPUT.PUT_LINE('IN OUT d = ' || TO_CHAR(d));
-- Can reference IN parameters a and b,
-- but cannot assign values to them.
c := a+10; -- Assign value to OUT parameter
d := 10/b; -- Assign value to IN OUT parameter
END;
/
DECLARE
aa CONSTANT PLS_INTEGER := 1;
bb PLS_INTEGER := 2;
cc PLS_INTEGER := 3;
dd BINARY_FLOAT := 4;
ee PLS_INTEGER;
ff BINARY_FLOAT := 5;
BEGIN
DBMS_OUTPUT.PUT_LINE('Before invoking procedure p:');
DBMS_OUTPUT.PUT('aa = ');
DBMS_OUTPUT.PUT_LINE(NVL(TO_CHAR(aa), 'NULL'));
DBMS_OUTPUT.PUT('bb = ');
DBMS_OUTPUT.PUT_LINE(NVL(TO_CHAR(bb), 'NULL'));
DBMS_OUTPUT.PUT('cc = ');
DBMS_OUTPUT.PUT_LINE(NVL(TO_CHAR(cc), 'NULL'));
DBMS_OUTPUT.PUT_LINE('dd = ' || TO_CHAR(dd));
p (aa, -- constant
bb, -- initialized variable
cc, -- initialized variable
dd -- initialized variable
);
DBMS_OUTPUT.PUT_LINE('After invoking procedure p:');
DBMS_OUTPUT.PUT('aa = ');
DBMS_OUTPUT.PUT_LINE(NVL(TO_CHAR(aa), 'NULL'));
DBMS_OUTPUT.PUT('bb = ');
DBMS_OUTPUT.PUT_LINE(NVL(TO_CHAR(bb), 'NULL'));
DBMS_OUTPUT.PUT('cc = ');
DBMS_OUTPUT.PUT_LINE(NVL(TO_CHAR(cc), 'NULL'));
DBMS_OUTPUT.PUT_LINE('dd = ' || TO_CHAR(dd));
DBMS_OUTPUT.PUT_LINE('Before invoking procedure p:');
DBMS_OUTPUT.PUT('ee = ');
DBMS_OUTPUT.PUT_LINE(NVL(TO_CHAR(ee), 'NULL'));
DBMS_OUTPUT.PUT_LINE('ff = ' || TO_CHAR(ff));
p (1, -- literal
(bb+3)*4, -- expression
ee, -- uninitialized variable
ff -- initialized variable
);
DBMS_OUTPUT.PUT_LINE('After invoking procedure p:');
DBMS_OUTPUT.PUT('ee = ');
DBMS_OUTPUT.PUT_LINE(NVL(TO_CHAR(ee), 'NULL'));
DBMS_OUTPUT.PUT_LINE('ff = ' || TO_CHAR(ff));
END;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/subprogram-parameters-15.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/subprogram-parameters.html
DECLARE
j PLS_INTEGER := 10;
k BINARY_FLOAT := 15;
BEGIN
DBMS_OUTPUT.PUT_LINE('Before invoking procedure p:');
DBMS_OUTPUT.PUT('j = ');
DBMS_OUTPUT.PUT_LINE(NVL(TO_CHAR(j), 'NULL'));
DBMS_OUTPUT.PUT_LINE('k = ' || TO_CHAR(k));
p(4, 0, j, k); -- causes p to exit with exception ZERO_DIVIDE
EXCEPTION
WHEN ZERO_DIVIDE THEN
DBMS_OUTPUT.PUT_LINE('After invoking procedure p:');
DBMS_OUTPUT.PUT('j = ');
DBMS_OUTPUT.PUT_LINE(NVL(TO_CHAR(j), 'NULL'));
DBMS_OUTPUT.PUT_LINE('k = ' || TO_CHAR(k));
END;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/subprogram-parameters-17.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/subprogram-parameters.html
CREATE OR REPLACE PACKAGE r_types AUTHID DEFINER IS
TYPE r_type_1 IS RECORD (f VARCHAR2(5) := 'abcde');
TYPE r_type_2 IS RECORD (f VARCHAR2(5));
END;
/
CREATE OR REPLACE PROCEDURE p (
x OUT r_types.r_type_1,
y OUT r_types.r_type_2,
z OUT VARCHAR2)
AUTHID CURRENT_USER IS
BEGIN
DBMS_OUTPUT.PUT_LINE('x.f is ' || NVL(x.f,'NULL'));
DBMS_OUTPUT.PUT_LINE('y.f is ' || NVL(y.f,'NULL'));
DBMS_OUTPUT.PUT_LINE('z is ' || NVL(z,'NULL'));
END;
/
DECLARE
r1 r_types.r_type_1;
r2 r_types.r_type_2;
s VARCHAR2(5) := 'fghij';
BEGIN
p (r1, r2, s);
END;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/subprogram-parameters-19.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/subprogram-parameters.html
DECLARE
TYPE Definition IS RECORD (
word VARCHAR2(20),
meaning VARCHAR2(200)
);
TYPE Dictionary IS VARRAY(2000) OF Definition;
lexicon Dictionary := Dictionary(); -- global variable
PROCEDURE add_entry (
word_list IN OUT NOCOPY Dictionary -- formal NOCOPY parameter
) IS
BEGIN
word_list(1).word := 'aardvark';
END;
BEGIN
lexicon.EXTEND;
lexicon(1).word := 'aardwolf';
add_entry(lexicon); -- global variable is actual parameter
DBMS_OUTPUT.PUT_LINE(lexicon(1).word);
END;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/subprogram-parameters-2.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/subprogram-parameters.html
DECLARE
emp_num NUMBER(6) := 120;
bonus NUMBER(6) := 100;
merit NUMBER(4) := 50;
PROCEDURE raise_salary (
emp_id NUMBER, -- formal parameter
amount NUMBER -- formal parameter
) IS
BEGIN
UPDATE employees
SET salary = salary + amount -- reference to formal parameter
WHERE employee_id = emp_id; -- reference to formal parameter
END raise_salary;
BEGIN
raise_salary(emp_num, bonus); -- actual parameters
/* raise_salary runs this statement:
UPDATE employees
SET salary = salary + 100
WHERE employee_id = 120; */
raise_salary(emp_num, merit + bonus); -- actual parameters
/* raise_salary runs this statement:
UPDATE employees
SET salary = salary + 150
WHERE employee_id = 120; */
END;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/subprogram-parameters-21.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/subprogram-parameters.html
DECLARE
n NUMBER := 10;
PROCEDURE p (
n1 IN NUMBER,
n2 IN OUT NUMBER,
n3 IN OUT NOCOPY NUMBER
) IS
BEGIN
n2 := 20; -- actual parameter is 20 only after procedure succeeds
DBMS_OUTPUT.put_line(n1); -- actual parameter value is still 10
n3 := 30; -- might change actual parameter immediately
DBMS_OUTPUT.put_line(n1); -- actual parameter value is either 10 or 30
END;
BEGIN
p(n, n, n);
DBMS_OUTPUT.put_line(n);
END;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/subprogram-parameters-24.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/subprogram-parameters.html
DECLARE
TYPE EmpCurTyp IS REF CURSOR;
c1 EmpCurTyp;
c2 EmpCurTyp;
PROCEDURE get_emp_data (
emp_cv1 IN OUT EmpCurTyp,
emp_cv2 IN OUT EmpCurTyp
)
IS
emp_rec employees%ROWTYPE;
BEGIN
OPEN emp_cv1 FOR SELECT * FROM employees;
emp_cv2 := emp_cv1; -- now both variables refer to same location
FETCH emp_cv1 INTO emp_rec; -- fetches first row of employees
FETCH emp_cv1 INTO emp_rec; -- fetches second row of employees
FETCH emp_cv2 INTO emp_rec; -- fetches third row of employees
CLOSE emp_cv1; -- closes both variables
FETCH emp_cv2 INTO emp_rec; -- causes error when get_emp_data is invoked
END;
BEGIN
get_emp_data(c1, c2);
END;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/subprogram-parameters-26.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/subprogram-parameters.html
DECLARE
PROCEDURE raise_salary (
emp_id IN employees.employee_id%TYPE,
amount IN employees.salary%TYPE := 100,
extra IN employees.salary%TYPE := 50
) IS
BEGIN
UPDATE employees
SET salary = salary + amount + extra
WHERE employee_id = emp_id;
END raise_salary;
BEGIN
raise_salary(120); -- same as raise_salary(120, 100, 50)
raise_salary(121, 200); -- same as raise_salary(121, 200, 50)
END;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/subprogram-parameters-27.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/subprogram-parameters.html
DECLARE
global PLS_INTEGER := 0;
FUNCTION f RETURN PLS_INTEGER IS
BEGIN
DBMS_OUTPUT.PUT_LINE('Inside f.');
global := global + 1;
RETURN global * 2;
END f;
PROCEDURE p (
x IN PLS_INTEGER := f()
) IS
BEGIN
DBMS_OUTPUT.PUT_LINE (
'Inside p. ' ||
' global = ' || global ||
', x = ' || x || '.'
);
DBMS_OUTPUT.PUT_LINE('--------------------------------');
END p;
PROCEDURE pre_p IS
BEGIN
DBMS_OUTPUT.PUT_LINE (
'Before invoking p, global = ' || global || '.'
);
DBMS_OUTPUT.PUT_LINE('Invoking p.');
END pre_p;
BEGIN
pre_p;
p(); -- default expression is evaluated
pre_p;
p(100); -- default expression is not evaluated
pre_p;
p(); -- default expression is evaluated
END;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/subprogram-parameters-29.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/subprogram-parameters.html
CREATE OR REPLACE PROCEDURE print_name (
first VARCHAR2,
last VARCHAR2
) AUTHID DEFINER IS
BEGIN
DBMS_OUTPUT.PUT_LINE(first || ' ' || last);
END print_name;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/subprogram-parameters-30.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/subprogram-parameters.html
BEGIN
print_name('John', 'Doe');
END;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/subprogram-parameters-32.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/subprogram-parameters.html
CREATE OR REPLACE PROCEDURE print_name (
first VARCHAR2,
last VARCHAR2,
mi VARCHAR2 := NULL
) AUTHID DEFINER IS
BEGIN
IF mi IS NULL THEN
DBMS_OUTPUT.PUT_LINE(first || ' ' || last);
ELSE
DBMS_OUTPUT.PUT_LINE(first || ' ' || mi || '. ' || last);
END IF;
END print_name;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/subprogram-parameters-33.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/subprogram-parameters.html
BEGIN
print_name('John', 'Doe'); -- original invocation
print_name('John', 'Public', 'Q'); -- new invocation
END;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/subprogram-parameters-36.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/subprogram-parameters.html
DECLARE
emp_num NUMBER(6) := 120;
bonus NUMBER(6) := 50;
PROCEDURE raise_salary (
emp_id NUMBER,
amount NUMBER
) IS
BEGIN
UPDATE employees
SET salary = salary + amount
WHERE employee_id = emp_id;
END raise_salary;
BEGIN
-- Equivalent invocations:
raise_salary(emp_num, bonus); -- positional notation
raise_salary(amount => bonus, emp_id => emp_num); -- named notation
raise_salary(emp_id => emp_num, amount => bonus); -- named notation
raise_salary(emp_num, amount => bonus); -- mixed notation
END;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/subprogram-parameters-37.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/subprogram-parameters.html
CREATE OR REPLACE FUNCTION compute_bonus (
emp_id NUMBER,
bonus NUMBER
) RETURN NUMBER
AUTHID DEFINER
IS
emp_sal NUMBER;
BEGIN
SELECT salary INTO emp_sal
FROM employees
WHERE employee_id = emp_id;
RETURN emp_sal + bonus;
END compute_bonus;
/
SELECT compute_bonus(120, 50) FROM DUAL;
SELECT compute_bonus(bonus => 50, emp_id => 120) FROM DUAL;
SELECT compute_bonus(120, bonus => 50) FROM DUAL;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/subprogram-parameters-4.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/subprogram-parameters.html
DECLARE
SUBTYPE License IS VARCHAR2(7) NOT NULL;
n License := 'DLLLDDD';
PROCEDURE p (x License) IS
BEGIN
DBMS_OUTPUT.PUT_LINE(x);
END;
BEGIN
p('1ABC123456789'); -- Succeeds; size is not inherited
p(NULL); -- Raises error; NOT NULL is inherited
END;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/subprogram-parameters-6.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/subprogram-parameters.html
DECLARE
FUNCTION test (p INTEGER) RETURN INTEGER IS
BEGIN
DBMS_OUTPUT.PUT_LINE('p = ' || p);
RETURN p;
END test;
BEGIN
DBMS_OUTPUT.PUT_LINE('test(p) = ' || test(0.66));
END;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/subprogram-parameters-8.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/subprogram-parameters.html
DECLARE
FUNCTION test (p NUMBER) RETURN NUMBER IS
q INTEGER := p; -- Implicitly converts p to INTEGER
BEGIN
DBMS_OUTPUT.PUT_LINE('p = ' || q); -- Display q, not p
RETURN q; -- Return q, not p
END test;
BEGIN
DBMS_OUTPUT.PUT_LINE('test(p) = ' || test(0.66));
END;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/subprogram-parts-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/subprogram-parts.html
DECLARE
first_name employees.first_name%TYPE;
last_name employees.last_name%TYPE;
email employees.email%TYPE;
employer VARCHAR2(8) := 'AcmeCorp';
-- Declare and define procedure
PROCEDURE create_email ( -- Subprogram heading begins
name1 VARCHAR2,
name2 VARCHAR2,
company VARCHAR2
) -- Subprogram heading ends
IS
-- Declarative part begins
error_message VARCHAR2(30) := 'Email address is too long.';
BEGIN -- Executable part begins
email := name1 || '.' || name2 || '@' || company;
EXCEPTION -- Exception-handling part begins
WHEN VALUE_ERROR THEN
DBMS_OUTPUT.PUT_LINE(error_message);
END create_email;
BEGIN
first_name := 'John';
last_name := 'Doe';
create_email(first_name, last_name, employer); -- invocation
DBMS_OUTPUT.PUT_LINE ('With first name first, email is: ' || email);
create_email(last_name, first_name, employer); -- invocation
DBMS_OUTPUT.PUT_LINE ('With last name first, email is: ' || email);
first_name := 'Elizabeth';
last_name := 'MacDonald';
create_email(first_name, last_name, employer); -- invocation
END;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/subprogram-parts-11.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/subprogram-parts.html
BEGIN
BEGIN
DBMS_OUTPUT.PUT_LINE('Inside inner block.');
RETURN;
DBMS_OUTPUT.PUT_LINE('Unreachable statement.');
END;
DBMS_OUTPUT.PUT_LINE('Inside outer block. Unreachable statement.');
END;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/subprogram-parts-2.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/subprogram-parts.html
DECLARE
-- Declare and define function
FUNCTION square (original NUMBER) -- parameter list
RETURN NUMBER -- RETURN clause
AS
-- Declarative part begins
original_squared NUMBER;
BEGIN -- Executable part begins
original_squared := original * original;
RETURN original_squared; -- RETURN statement
END;
BEGIN
DBMS_OUTPUT.PUT_LINE(square(100)); -- invocation
END;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/subprogram-parts-4.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/subprogram-parts.html
DECLARE
x INTEGER;
FUNCTION f (n INTEGER)
RETURN INTEGER
IS
BEGIN
RETURN (n*n);
END;
BEGIN
DBMS_OUTPUT.PUT_LINE (
'f returns ' || f(2) || '. Execution returns here (1).'
);
x := f(2);
DBMS_OUTPUT.PUT_LINE('Execution returns here (2).');
END;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/subprogram-parts-6.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/subprogram-parts.html
CREATE OR REPLACE FUNCTION f (n INTEGER)
RETURN INTEGER
AUTHID DEFINER
IS
BEGIN
IF n = 0 THEN
RETURN 1;
ELSIF n = 1 THEN
RETURN n;
END IF;
END;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/subprogram-parts-7.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/subprogram-parts.html
CREATE OR REPLACE FUNCTION f (n INTEGER)
RETURN INTEGER
AUTHID DEFINER
IS
BEGIN
IF n = 0 THEN
RETURN 1;
ELSIF n = 1 THEN
RETURN n;
ELSE
RETURN n*n;
END IF;
END;
/
BEGIN
FOR i IN 0 .. 3 LOOP
DBMS_OUTPUT.PUT_LINE('f(' || i || ') = ' || f(i));
END LOOP;
END;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/subprogram-parts-9.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/subprogram-parts.html
DECLARE
PROCEDURE p IS
BEGIN
DBMS_OUTPUT.PUT_LINE('Inside p');
RETURN;
DBMS_OUTPUT.PUT_LINE('Unreachable statement.');
END;
BEGIN
p;
DBMS_OUTPUT.PUT_LINE('Control returns here.');
END;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/subprograms-invoked-triggers-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/subprograms-invoked-triggers.html
CREATE OR REPLACE PROCEDURE Before_delete (Id IN NUMBER, Ename VARCHAR2)
IS LANGUAGE Java
name 'thjvTriggers.beforeDelete (oracle.jdbc.NUMBER, oracle.jdbc.CHAR)';
CREATE OR REPLACE TRIGGER Pre_del_trigger BEFORE DELETE ON Tab
FOR EACH ROW
CALL Before_delete (:OLD.Id, :OLD.Ename)
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/system-triggers-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/system-triggers.html
CREATE OR REPLACE TRIGGER drop_trigger
BEFORE DROP ON hr.SCHEMA
BEGIN
RAISE_APPLICATION_ERROR (
num => -20000,
msg => 'Cannot drop object');
END;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/system-triggers-1.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/system-triggers.html
CREATE TRIGGER log_errors
AFTER SERVERERROR ON DATABASE
BEGIN
IF (IS_SERVERERROR (1017)) THEN
NULL; -- (substitute code that processes logon error)
ELSE
NULL; -- (substitute code that logs error code)
END IF;
END;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/system-triggers-2.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/system-triggers.html
CREATE OR REPLACE TRIGGER check_user
AFTER LOGON ON DATABASE
BEGIN
check_user;
EXCEPTION
WHEN OTHERS THEN
RAISE_APPLICATION_ERROR
(-20000, 'Unexpected error: '|| DBMS_Utility.Format_Error_Stack);
END;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/system-triggers-3.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/system-triggers.html
CREATE OR REPLACE TRIGGER t
INSTEAD OF CREATE ON SCHEMA
BEGIN
EXECUTE IMMEDIATE 'CREATE TABLE T (n NUMBER, m NUMBER)';
END;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/transaction-processing-and-control-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/transaction-processing-and-control.html
DROP TABLE accounts;
CREATE TABLE accounts (
account_id NUMBER(6),
balance NUMBER (10,2)
);
INSERT INTO accounts (account_id, balance)
VALUES (7715, 6350.00);
INSERT INTO accounts (account_id, balance)
VALUES (7720, 5100.50);
CREATE OR REPLACE PROCEDURE transfer (
from_acct NUMBER,
to_acct NUMBER,
amount NUMBER
) AUTHID CURRENT_USER AS
BEGIN
UPDATE accounts
SET balance = balance - amount
WHERE account_id = from_acct;
UPDATE accounts
SET balance = balance + amount
WHERE account_id = to_acct;
COMMIT WRITE IMMEDIATE NOWAIT;
END;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/transaction-processing-and-control-1.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/transaction-processing-and-control.html
SELECT * FROM accounts;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/transaction-processing-and-control-11.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/transaction-processing-and-control.html
DROP TABLE emp;
CREATE TABLE emp AS SELECT * FROM employees;
DECLARE
CURSOR c1 IS
SELECT last_name, job_id, rowid
FROM emp; -- no FOR UPDATE clause
my_lastname employees.last_name%TYPE;
my_jobid employees.job_id%TYPE;
my_rowid UROWID;
BEGIN
OPEN c1;
LOOP
FETCH c1 INTO my_lastname, my_jobid, my_rowid;
EXIT WHEN c1%NOTFOUND;
UPDATE emp
SET salary = salary * 1.02
WHERE rowid = my_rowid; -- simulates WHERE CURRENT OF c1
COMMIT;
END LOOP;
CLOSE c1;
END;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/transaction-processing-and-control-2.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/transaction-processing-and-control.html
BEGIN
transfer(7715, 7720, 250);
END;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/transaction-processing-and-control-3.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/transaction-processing-and-control.html
SELECT * FROM accounts;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/transaction-processing-and-control-5.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/transaction-processing-and-control.html
DROP TABLE emp_name;
CREATE TABLE emp_name AS
SELECT employee_id, last_name
FROM employees;
CREATE UNIQUE INDEX empname_ix
ON emp_name (employee_id);
DROP TABLE emp_sal;
CREATE TABLE emp_sal AS
SELECT employee_id, salary
FROM employees;
CREATE UNIQUE INDEX empsal_ix
ON emp_sal (employee_id);
DROP TABLE emp_job;
CREATE TABLE emp_job AS
SELECT employee_id, job_id
FROM employees;
CREATE UNIQUE INDEX empjobid_ix
ON emp_job (employee_id);
DECLARE
emp_id NUMBER(6);
emp_lastname VARCHAR2(25);
emp_salary NUMBER(8,2);
emp_jobid VARCHAR2(10);
BEGIN
SELECT employee_id, last_name, salary, job_id
INTO emp_id, emp_lastname, emp_salary, emp_jobid
FROM employees
WHERE employee_id = 120;
INSERT INTO emp_name (employee_id, last_name)
VALUES (emp_id, emp_lastname);
INSERT INTO emp_sal (employee_id, salary)
VALUES (emp_id, emp_salary);
INSERT INTO emp_job (employee_id, job_id)
VALUES (emp_id, emp_jobid);
EXCEPTION
WHEN DUP_VAL_ON_INDEX THEN
ROLLBACK;
DBMS_OUTPUT.PUT_LINE('Inserts were rolled back');
END;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/transaction-processing-and-control-6.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/transaction-processing-and-control.html
DROP TABLE emp_name;
CREATE TABLE emp_name AS
SELECT employee_id, last_name, salary
FROM employees;
CREATE UNIQUE INDEX empname_ix
ON emp_name (employee_id);
DECLARE
emp_id employees.employee_id%TYPE;
emp_lastname employees.last_name%TYPE;
emp_salary employees.salary%TYPE;
BEGIN
SELECT employee_id, last_name, salary
INTO emp_id, emp_lastname, emp_salary
FROM employees
WHERE employee_id = 120;
UPDATE emp_name
SET salary = salary * 1.1
WHERE employee_id = emp_id;
DELETE FROM emp_name
WHERE employee_id = 130;
SAVEPOINT do_insert;
INSERT INTO emp_name (employee_id, last_name, salary)
VALUES (emp_id, emp_lastname, emp_salary);
EXCEPTION
WHEN DUP_VAL_ON_INDEX THEN
ROLLBACK TO do_insert;
DBMS_OUTPUT.PUT_LINE('Insert was rolled back');
END;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/transaction-processing-and-control-7.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/transaction-processing-and-control.html
DROP TABLE emp_name;
CREATE TABLE emp_name AS
SELECT employee_id, last_name, salary
FROM employees;
CREATE UNIQUE INDEX empname_ix
ON emp_name (employee_id);
DECLARE
emp_id employees.employee_id%TYPE;
emp_lastname employees.last_name%TYPE;
emp_salary employees.salary%TYPE;
BEGIN
SELECT employee_id, last_name, salary
INTO emp_id, emp_lastname, emp_salary
FROM employees
WHERE employee_id = 120;
SAVEPOINT my_savepoint;
UPDATE emp_name
SET salary = salary * 1.1
WHERE employee_id = emp_id;
DELETE FROM emp_name
WHERE employee_id = 130;
SAVEPOINT my_savepoint;
INSERT INTO emp_name (employee_id, last_name, salary)
VALUES (emp_id, emp_lastname, emp_salary);
EXCEPTION
WHEN DUP_VAL_ON_INDEX THEN
ROLLBACK TO my_savepoint;
DBMS_OUTPUT.PUT_LINE('Transaction rolled back.');
END;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/transaction-processing-and-control-8.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/transaction-processing-and-control.html
DECLARE
daily_order_total NUMBER(12,2);
weekly_order_total NUMBER(12,2);
monthly_order_total NUMBER(12,2);
BEGIN
COMMIT; -- end previous transaction
SET TRANSACTION READ ONLY NAME 'Calculate Order Totals';
SELECT SUM (order_total)
INTO daily_order_total
FROM orders
WHERE order_date = SYSDATE;
SELECT SUM (order_total)
INTO weekly_order_total
FROM orders
WHERE order_date = SYSDATE - 7;
SELECT SUM (order_total)
INTO monthly_order_total
FROM orders
WHERE order_date = SYSDATE - 30;
COMMIT; -- ends read-only transaction
END;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/transaction-processing-and-control-9.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/transaction-processing-and-control.html
DROP TABLE emp;
CREATE TABLE emp AS SELECT * FROM employees;
DECLARE
CURSOR c1 IS
SELECT * FROM emp
FOR UPDATE OF salary
ORDER BY employee_id;
emp_rec emp%ROWTYPE;
BEGIN
OPEN c1;
LOOP
FETCH c1 INTO emp_rec; -- fails on second iteration
EXIT WHEN c1%NOTFOUND;
DBMS_OUTPUT.PUT_LINE (
'emp_rec.employee_id = ' ||
TO_CHAR(emp_rec.employee_id)
);
UPDATE emp
SET salary = salary * 1.05
WHERE employee_id = 105;
COMMIT; -- releases locks
END LOOP;
END;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/trigger-design-guidelines-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/trigger-design-guidelines.html
SELECT Username FROM USER_USERS;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/trigger-design-guidelines-1.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/trigger-design-guidelines.html
CREATE OR REPLACE TRIGGER my_trigger
AFTER CREATE ON DATABASE
BEGIN
NULL;
END;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/trigger-restrictions-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/trigger-restrictions.html
DROP TABLE log;
CREATE TABLE log (
emp_id NUMBER(6),
l_name VARCHAR2(25),
f_name VARCHAR2(20)
);
CREATE OR REPLACE TRIGGER log_deletions
AFTER DELETE ON employees
FOR EACH ROW
DECLARE
n INTEGER;
BEGIN
INSERT INTO log VALUES (
:OLD.employee_id,
:OLD.last_name,
:OLD.first_name
);
SELECT COUNT(*) INTO n FROM employees;
DBMS_OUTPUT.PUT_LINE('There are now ' || n || ' employees.');
END;
/
DELETE FROM employees WHERE employee_id = 197;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/trigger-restrictions-11.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/trigger-restrictions.html
UPDATE p SET p1 = p1+1;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/trigger-restrictions-12.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/trigger-restrictions.html
SELECT * FROM p ORDER BY p1;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/trigger-restrictions-14.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/trigger-restrictions.html
SELECT * FROM f ORDER BY f1;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/trigger-restrictions-2.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/trigger-restrictions.html
SELECT count(*) FROM log;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/trigger-restrictions-4.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/trigger-restrictions.html
SELECT employee_id, last_name FROM employees WHERE employee_id = 197;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/trigger-restrictions-6.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/trigger-restrictions.html
DROP TABLE p;
CREATE TABLE p (p1 NUMBER CONSTRAINT pk_p_p1 PRIMARY KEY);
INSERT INTO p VALUES (1);
INSERT INTO p VALUES (2);
INSERT INTO p VALUES (3);
DROP TABLE f;
CREATE TABLE f (f1 NUMBER CONSTRAINT fk_f_f1 REFERENCES p);
INSERT INTO f VALUES (1);
INSERT INTO f VALUES (2);
INSERT INTO f VALUES (3);
CREATE TRIGGER pt
AFTER UPDATE ON p
FOR EACH ROW
BEGIN
UPDATE f SET f1 = :NEW.p1 WHERE f1 = :OLD.p1;
END;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/trigger-restrictions-7.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/trigger-restrictions.html
SELECT * FROM p ORDER BY p1;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/trigger-restrictions-9.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/trigger-restrictions.html
SELECT * FROM f ORDER BY f1;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/triggers-publishing-events-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/triggers-publishing-events.html
TYPE ora_name_list_t IS TABLE OF VARCHAR2(2*(ORA_MAX_NAME_LEN+2)+1);
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/triggers-publishing-events-10.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/triggers-publishing-events.html
DECLARE
name_list ora_name_list_t;
number_modified PLS_INTEGER;
BEGIN
IF (ora_sysevent='ASSOCIATE STATISTICS') THEN
number_modified :=
ora_dict_obj_name_list(name_list);
END IF;
END;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/triggers-publishing-events-12.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/triggers-publishing-events.html
INSERT INTO event_table
VALUES ('object owner is' ||
ora_dict_obj_owner);
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/triggers-publishing-events-14.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/triggers-publishing-events.html
DECLARE
owner_list ora_name_list_t;
number_modified PLS_INTEGER;
BEGIN
IF (ora_sysevent='ASSOCIATE STATISTICS') THEN
number_modified :=
ora_dict_obj_name_list(owner_list);
END IF;
END;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/triggers-publishing-events-16.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/triggers-publishing-events.html
INSERT INTO event_table
VALUES ('This object is a ' ||
ora_dict_obj_type);
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/triggers-publishing-events-18.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/triggers-publishing-events.html
DECLARE
user_list ora_name_list_t;
number_of_grantees PLS_INTEGER;
BEGIN
IF (ora_sysevent = 'GRANT') THEN
number_of_grantees :=
ora_grantee(user_list);
END IF;
END;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/triggers-publishing-events-2.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/triggers-publishing-events.html
DECLARE
v_addr VARCHAR2(11);
BEGIN
IF (ora_sysevent = 'LOGON') THEN
v_addr := ora_client_ip_address;
END IF;
END;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/triggers-publishing-events-20.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/triggers-publishing-events.html
INSERT INTO event_table VALUES ('1');
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/triggers-publishing-events-24.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/triggers-publishing-events.html
INSERT INTO event_table
VALUES ('A nested table is created');
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/triggers-publishing-events-28.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/triggers-publishing-events.html
INSERT INTO event_table
VALUES ('Server error!!');
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/triggers-publishing-events-30.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/triggers-publishing-events.html
SELECT ora_login_user FROM DUAL;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/triggers-publishing-events-34.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/triggers-publishing-events.html
DECLARE
privilege_list ora_name_list_t;
number_of_privileges PLS_INTEGER;
BEGIN
IF (ora_sysevent = 'GRANT' OR
ora_sysevent = 'REVOKE') THEN
number_of_privileges :=
ora_privilege_list(privilege_list);
END IF;
END;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/triggers-publishing-events-36.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/triggers-publishing-events.html
DECLARE
user_list ora_name_list_t;
number_of_users PLS_INTEGER;
BEGIN
IF (ora_sysevent = 'REVOKE') THEN
number_of_users := ora_revokee(user_list);
END IF;
END;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/triggers-publishing-events-38.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/triggers-publishing-events.html
INSERT INTO event_table
VALUES ('top stack error ' ||
ora_server_error(1));
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/triggers-publishing-events-4.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/triggers-publishing-events.html
DECLARE
v_db_name VARCHAR2(50);
BEGIN
v_db_name := ora_database_name;
END;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/triggers-publishing-events-42.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/triggers-publishing-events.html
INSERT INTO event_table
VALUES ('top stack error message' ||
ora_server_error_msg(1));
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/triggers-publishing-events-48.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/triggers-publishing-events.html
CREATE TABLE event_table (col VARCHAR2(2030));
DECLARE
sql_text ora_name_list_t;
n PLS_INTEGER;
v_stmt VARCHAR2(2000);
BEGIN
n := ora_sql_txt(sql_text);
FOR i IN 1..n LOOP
v_stmt := v_stmt || sql_text(i);
END LOOP;
INSERT INTO event_table VALUES ('text of
triggering statement: ' || v_stmt);
END;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/triggers-publishing-events-50.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/triggers-publishing-events.html
INSERT INTO event_table
VALUES (ora_sysevent);
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/triggers-publishing-events-52.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/triggers-publishing-events.html
INSERT INTO event_table
VALUES ('with grant option');
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/triggers-publishing-events-6.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/triggers-publishing-events.html
INSERT INTO event_table
VALUES (ora_des_encrypted_password);
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/triggers-publishing-events-8.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/triggers-publishing-events.html
INSERT INTO event_table
VALUES ('Changed object is ' ||
ora_dict_obj_name);
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/updating-rows-records-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/updating-rows-records.html
DECLARE
default_week schedule%ROWTYPE;
BEGIN
default_week.Mon := 'Day Off';
default_week.Tue := '0900-1800';
default_week.Wed := '0900-1800';
default_week.Thu := '0900-1800';
default_week.Fri := '0900-1800';
default_week.Sat := '0900-1800';
default_week.Sun := 'Day Off';
FOR i IN 1..3 LOOP
default_week.week := i;
UPDATE schedule
SET ROW = default_week
WHERE week = i;
END LOOP;
END;
/
SELECT * FROM schedule;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/user-defined-pl-sql-subtypes-2.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/user-defined-pl-sql-subtypes.html
DECLARE
SUBTYPE Balance IS NUMBER;
checking_account Balance(6,2);
savings_account Balance(8,2);
certificate_of_deposit Balance(8,2);
max_insured CONSTANT Balance(8,2) := 250000.00;
SUBTYPE Counter IS NATURAL;
accounts Counter := 1;
deposits Counter := 0;
withdrawals Counter := 0;
overdrafts Counter := 0;
PROCEDURE deposit (
account IN OUT Balance,
amount IN Balance
) IS
BEGIN
account := account + amount;
deposits := deposits + 1;
END;
BEGIN
NULL;
END;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/user-defined-pl-sql-subtypes-5.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/user-defined-pl-sql-subtypes.html
DECLARE
SUBTYPE Balance IS NUMBER(8,2);
checking_account Balance;
savings_account Balance;
BEGIN
checking_account := 2000.00;
savings_account := 1000000.00;
END;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/user-defined-pl-sql-subtypes-7.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/user-defined-pl-sql-subtypes.html
DECLARE
SUBTYPE Digit IS PLS_INTEGER RANGE 0..9;
SUBTYPE Double_digit IS PLS_INTEGER RANGE 10..99;
SUBTYPE Under_100 IS PLS_INTEGER RANGE 0..99;
d Digit := 4;
dd Double_digit := 35;
u Under_100;
BEGIN
u := d; -- Succeeds; Under_100 range includes Digit range
u := dd; -- Succeeds; Under_100 range includes Double_digit range
dd := d; -- Raises error; Double_digit range does not include Digit range
END;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/user-defined-pl-sql-subtypes-9.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/user-defined-pl-sql-subtypes.html
DECLARE
SUBTYPE Word IS CHAR(6);
SUBTYPE Text IS VARCHAR2(15);
verb Word := 'run';
sentence1 Text;
sentence2 Text := 'Hurry!';
sentence3 Text := 'See Tom run.';
BEGIN
sentence1 := verb; -- 3-character value, 15-character limit
verb := sentence2; -- 6-character value, 6-character limit
verb := sentence3; -- 12-character value, 6-character limit
END;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/views-information-triggers-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/views-information-triggers.html
CREATE OR REPLACE TRIGGER Emp_count
AFTER DELETE ON employees
DECLARE
n INTEGER;
BEGIN
SELECT COUNT(*) INTO n FROM employees;
DBMS_OUTPUT.PUT_LINE('There are now ' || n || ' employees.');
END;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/views-information-triggers-1.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/views-information-triggers.html
COLUMN Trigger_type FORMAT A15
COLUMN Triggering_event FORMAT A16
COLUMN Table_name FORMAT A11
COLUMN Trigger_body FORMAT A50
SET LONG 9999
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/views-information-triggers-2.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/views-information-triggers.html
SELECT Trigger_type, Triggering_event, Table_name
FROM USER_TRIGGERS
WHERE Trigger_name = 'EMP_COUNT';
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/views-information-triggers-4.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/views-information-triggers.html
SELECT Trigger_body
FROM USER_TRIGGERS
WHERE Trigger_name = 'EMP_COUNT';
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/views-information-triggers-5.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/views-information-triggers.html
DECLARE
n INTEGER;
BEGIN
SELECT COUNT(*) INTO n FROM employees;
DBMS_OUTPUT.PUT_LINE('There are now ' || n || '
employees.');
END;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/what-is-capture-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/what-is-capture.html
DROP TABLE tab1;
CREATE TABLE tab1 (col1 NUMBER, col2 NUMBER);
INSERT INTO tab1 (col1, col2) VALUES (100, 10);
DROP TABLE tab2;
CREATE TABLE tab2 (col1 NUMBER);
INSERT INTO tab2 (col1) VALUES (100);
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/what-is-capture-1.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/what-is-capture.html
CREATE OR REPLACE PROCEDURE proc AUTHID DEFINER AS
CURSOR c1 IS
SELECT * FROM tab1
WHERE EXISTS (SELECT * FROM tab2 WHERE col2 = 10);
BEGIN
OPEN c1;
CLOSE c1;
END;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/what-is-capture-2.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/what-is-capture.html
ALTER TABLE tab2 ADD (col2 NUMBER);
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/wrapping-pl-sql-source-text-dbms_ddl-subprograms-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/wrapping-pl-sql-source-text-dbms_ddl-subprograms.html
DECLARE
package_text VARCHAR2(32767); -- text for creating package spec and body
FUNCTION generate_spec (pkgname VARCHAR2) RETURN VARCHAR2 AS
BEGIN
RETURN 'CREATE PACKAGE ' || pkgname || ' AUTHID CURRENT_USER AS
PROCEDURE raise_salary (emp_id NUMBER, amount NUMBER);
PROCEDURE fire_employee (emp_id NUMBER);
END ' || pkgname || ';';
END generate_spec;
FUNCTION generate_body (pkgname VARCHAR2) RETURN VARCHAR2 AS
BEGIN
RETURN 'CREATE PACKAGE BODY ' || pkgname || ' AS
PROCEDURE raise_salary (emp_id NUMBER, amount NUMBER) IS
BEGIN
UPDATE employees
SET salary = salary + amount WHERE employee_id = emp_id;
END raise_salary;
PROCEDURE fire_employee (emp_id NUMBER) IS
BEGIN
DELETE FROM employees WHERE employee_id = emp_id;
END fire_employee;
END ' || pkgname || ';';
END generate_body;
BEGIN
package_text := generate_spec('emp_actions'); -- Generate package spec
EXECUTE IMMEDIATE package_text; -- Create package spec
package_text := generate_body('emp_actions'); -- Generate package body
SYS.DBMS_DDL.CREATE_WRAPPED(package_text); -- Create wrapped package body
END;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/wrapping-pl-sql-source-text-dbms_ddl-subprograms-1.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/wrapping-pl-sql-source-text-dbms_ddl-subprograms.html
SELECT text FROM USER_SOURCE WHERE name = 'EMP_ACTIONS';
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/wrapping-pl-sql-source-text-dbms_ddl-subprograms-2.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/wrapping-pl-sql-source-text-dbms_ddl-subprograms.html
PROCEDURE raise_salary (emp_id NUMBER, amount NUMBER);
PROCEDURE fire_employee (emp_id NUMBER);
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/wrapping-pl-sql-source-text-dbms_ddl-subprograms-3.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/wrapping-pl-sql-source-text-dbms_ddl-subprograms.html
DECLARE
s employees.salary%TYPE;
BEGIN
SELECT salary INTO s FROM employees WHERE employee_id=130;
DBMS_OUTPUT.PUT_LINE('Old salary: ' || s);
emp_actions.raise_salary(130, 100);
SELECT salary INTO s FROM employees WHERE employee_id=130;
DBMS_OUTPUT.PUT_LINE('New salary: ' || s);
END;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/wrapping-pl-sql-source-text-pl-sql-wrapper-utility-4.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/wrapping-pl-sql-source-text-pl-sql-wrapper-utility.html
SELECT COUNT(*) FROM EMPLOYEES
/
CREATE PROCEDURE wraptest AUTHID CURRENT_USER /* C style comment in procedure declaration */ IS
TYPE emp_tab IS TABLE OF employees%ROWTYPE INDEX BY PLS_INTEGER;
all_emps emp_tab;
BEGIN
SELECT * BULK COLLECT INTO all_emps FROM employees;
FOR i IN 1..10 LOOP /* C style in pl/sql source */
DBMS_OUTPUT.PUT_LINE('Emp Id: ' || all_emps(i).employee_id);
END LOOP;
END;
/
CREATE OR REPLACE FUNCTION fibonacci (
n PLS_INTEGER
) RETURN PLS_INTEGER
AUTHID CURRENT_USER -- PL/SQL style comment inside fibonacci function spec
IS
fib_1 PLS_INTEGER := 0;
fib_2 PLS_INTEGER := 1;
BEGIN
IF n = 1 THEN -- terminating condition
RETURN fib_1;
ELSIF n = 2 THEN
RETURN fib_2; -- terminating condition
ELSE
RETURN fibonacci(n-2) + fibonacci(n-1); -- recursive invocations
END IF;
END;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/lnpls/wrapping-pl-sql-source-text-pl-sql-wrapper-utility-7.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/wrapping-pl-sql-source-text-pl-sql-wrapper-utility.html
SELECT COUNT(*) FROM EMPLOYEES
/
CREATE OR REPLACE PROCEDURE wraptest wrapped
a000000
1
abcd
abcd
abcd
abcd
abcd
abcd
abcd
abcd
abcd
abcd
abcd
abcd
abcd
abcd
abcd
7
129 138
qf4HggDBeNMPlWAsPn6pGf+2LGwwg+nwJK5qZ3SVWE4+GayDZaL1bF7RwYm2/zr1qjZY3FrN
48M1bKc/MG5aY9YB+DrtT4SJN370Rpq7ck5D0sc1D5sKAwTyX13HYvRmjwkdXa0vEZ4q/mCU
EQusX23UZbZjxha7CtlCDCx8guGw/M/oHZXc8wDHXL8V8OsqQMv/Hj7z68gINl7OstalRScr
uSZ/l/W1YaaA9Lj8Fbx5/nJw96ZNy1SCY8VsB/G6O5f/65+EDxdThpnfU4e1vrrE9iB3/IpI
+7fE1Tv29fwc+aZq3S7O
/
CREATE OR REPLACE FUNCTION fibonacci wrapped
a000000
1
abcd
abcd
abcd
abcd
abcd
abcd
abcd
abcd
abcd
abcd
abcd
abcd
abcd
abcd
abcd
8
150 ff
BFDvTL9OR04SJbx+qOy5H/h8IcwwgxDcAJnWZ3TNz51mjAmegdQcpNJfq8hUuQtv1Y5xg7Wd
KqMH/HBANhnZ+E1mBWekavYjPxlqV9zIFqZAgB4SBqkqe42sai9Vb0cLEU02/ZCEyxDSfWf3
H1Lp6U9ztRXNy+oDZSNykWCUVLaZro0UmeFrNUBqzE6j9mI3AyRhPw1QbZX5oRMLgLOG3OtS
SGJsz7M+bnhnp+xP4ww+SIlxx5LhDtnyPw==
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ABS-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ABS.html
SELECT ABS(-15) "Absolute"
FROM DUAL;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ACOS-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ACOS.html
SELECT ACOS(.3)"Arc_Cosine"
FROM DUAL;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ADD_MONTHS-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ADD_MONTHS.html
SELECT TO_CHAR(ADD_MONTHS(hire_date, 1), 'DD-MON-YYYY') "Next month"
FROM employees
WHERE last_name = 'Baer';
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ADMINISTER-KEY-MANAGEMENT-10.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ADMINISTER-KEY-MANAGEMENT.html
ADMINISTER KEY MANAGEMENT
SET KEYSTORE OPEN
IDENTIFIED BY "user_id:password";
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ADMINISTER-KEY-MANAGEMENT-11.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ADMINISTER-KEY-MANAGEMENT.html
ADMINISTER KEY MANAGEMENT
SET KEYSTORE OPEN
IDENTIFIED BY EXTERNAL STORE;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ADMINISTER-KEY-MANAGEMENT-12.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ADMINISTER-KEY-MANAGEMENT.html
ADMINISTER KEY MANAGEMENT
SET KEYSTORE CLOSE
IDENTIFIED BY password;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ADMINISTER-KEY-MANAGEMENT-13.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ADMINISTER-KEY-MANAGEMENT.html
ADMINISTER KEY MANAGEMENT
SET KEYSTORE CLOSE;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ADMINISTER-KEY-MANAGEMENT-14.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ADMINISTER-KEY-MANAGEMENT.html
ADMINISTER KEY MANAGEMENT
SET KEYSTORE CLOSE
IDENTIFIED BY "user_id:password";
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ADMINISTER-KEY-MANAGEMENT-15.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ADMINISTER-KEY-MANAGEMENT.html
ADMINISTER KEY MANAGEMENT
SET KEYSTORE CLOSE
IDENTIFIED BY EXTERNAL STORE;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ADMINISTER-KEY-MANAGEMENT-16.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ADMINISTER-KEY-MANAGEMENT.html
ADMINISTER KEY MANAGEMENT
BACKUP KEYSTORE USING 'hr.emp_keystore'
IDENTIFIED BY password
TO '/etc/ORACLE/KEYSTORE/DB1/';
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ADMINISTER-KEY-MANAGEMENT-17.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ADMINISTER-KEY-MANAGEMENT.html
ADMINISTER KEY MANAGEMENT
ALTER KEYSTORE PASSWORD IDENTIFIED BY old_password
SET new_password WITH BACKUP USING 'pwd_change';
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ADMINISTER-KEY-MANAGEMENT-18.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ADMINISTER-KEY-MANAGEMENT.html
ADMINISTER KEY MANAGEMENT
MERGE KEYSTORE '/etc/ORACLE/KEYSTORE/DB1'
AND KEYSTORE '/etc/ORACLE/KEYSTORE/DB2'
IDENTIFIED BY existing_keystore_password
INTO NEW KEYSTORE '/etc/ORACLE/KEYSTORE/DB3'
IDENTIFIED BY new_keystore_password;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ADMINISTER-KEY-MANAGEMENT-19.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ADMINISTER-KEY-MANAGEMENT.html
ADMINISTER KEY MANAGEMENT
MERGE KEYSTORE '/etc/ORACLE/KEYSTORE/DB1'
INTO EXISTING KEYSTORE '/etc/ORACLE/KEYSTORE/DB2'
IDENTIFIED BY existing_keystore_password
WITH BACKUP;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ADMINISTER-KEY-MANAGEMENT-2.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ADMINISTER-KEY-MANAGEMENT.html
SELECT KEY_ID FROM V$ENCRYPTION_KEYS WHERE TAG LIKE 'mytag%'
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ADMINISTER-KEY-MANAGEMENT-20.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ADMINISTER-KEY-MANAGEMENT.html
ADMINISTER KEY MANAGEMENT
SET KEY USING ALGORITHM 'SEED128'
IDENTIFIED BY password
WITH BACKUP;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ADMINISTER-KEY-MANAGEMENT-21.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ADMINISTER-KEY-MANAGEMENT.html
ADMINISTER KEY MANAGEMENT
CREATE KEY USING TAG 'mykey1'
IDENTIFIED BY password
WITH BACKUP;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ADMINISTER-KEY-MANAGEMENT-22.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ADMINISTER-KEY-MANAGEMENT.html
SELECT TAG, KEY_ID
FROM V$ENCRYPTION_KEYS
WHERE TAG = 'mykey1';
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ADMINISTER-KEY-MANAGEMENT-23.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ADMINISTER-KEY-MANAGEMENT.html
ADMINISTER KEY MANAGEMENT
USE KEY 'ARgEtzPxpE/Nv8WdPu8LJJUAAAAAAAAAAAAAAAAAAAAAAAAAAAAA'
IDENTIFIED BY password
WITH BACKUP;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ADMINISTER-KEY-MANAGEMENT-24.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ADMINISTER-KEY-MANAGEMENT.html
ADMINISTER KEY MANAGEMENT
SET TAG 'mykey2' FOR 'ARgEtzPxpE/Nv8WdPu8LJJUAAAAAAAAAAAAAAAAAAAAAAAAAAAAA'
FORCE KEYSTORE
IDENTIFIED BY password
WITH BACKUP;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ADMINISTER-KEY-MANAGEMENT-25.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ADMINISTER-KEY-MANAGEMENT.html
ADMINISTER KEY MANAGEMENT
EXPORT KEYS WITH SECRET "my_secret"
TO '/etc/TDE/export.exp'
IDENTIFIED BY password
WITH IDENTIFIER IN 'AdoxnJ0uH08cv7xkz83ovwsAAAAAAAAAAAAAAAAAAAAAAAAAAAAA',
'AW5z3CoyKE/yv3cNT5CWCXUAAAAAAAAAAAAAAAAAAAAAAAAAAAAA';
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ADMINISTER-KEY-MANAGEMENT-26.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ADMINISTER-KEY-MANAGEMENT.html
ADMINISTER KEY MANAGEMENT
EXPORT KEYS WITH SECRET "my_secret"
TO '/etc/TDE/export.exp'
IDENTIFIED BY password
WITH IDENTIFIER IN
(SELECT KEY_ID FROM V$ENCRYPTION_KEYS WHERE TAG IN ('mytag1', 'mytag2'));
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ADMINISTER-KEY-MANAGEMENT-27.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ADMINISTER-KEY-MANAGEMENT.html
ADMINISTER KEY MANAGEMENT
EXPORT KEYS WITH SECRET "my_secret"
TO '/etc/TDE/export.exp'
IDENTIFIED BY password;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ADMINISTER-KEY-MANAGEMENT-28.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ADMINISTER-KEY-MANAGEMENT.html
ALTER SESSION SET CONTAINER = salespdb;
ADMINISTER KEY MANAGEMENT
EXPORT KEYS WITH SECRET "my_secret"
TO '/etc/TDE/salespdb.exp'
IDENTIFIED BY password;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ADMINISTER-KEY-MANAGEMENT-29.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ADMINISTER-KEY-MANAGEMENT.html
ADMINISTER KEY MANAGEMENT
IMPORT KEYS WITH SECRET "my_secret"
FROM '/etc/TDE/export.exp'
IDENTIFIED BY password
WITH BACKUP;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ADMINISTER-KEY-MANAGEMENT-3.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ADMINISTER-KEY-MANAGEMENT.html
ADMINISTER KEY MANAGEMENT
USE ENCRYPTION KEY '0673C1262AA1D04F14BF26D720480C55B2'
IDENTIFIED BY "external_keystore_password"
MIGRATE USING software_keystore_password;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ADMINISTER-KEY-MANAGEMENT-30.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ADMINISTER-KEY-MANAGEMENT.html
ADMINISTER KEY MANAGEMENT
SET ENCRYPTION KEY IDENTIFIED BY "user_id:password"
MIGRATE USING software_keystore_password
WITH BACKUP;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ADMINISTER-KEY-MANAGEMENT-31.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ADMINISTER-KEY-MANAGEMENT.html
ADMINISTER KEY MANAGEMENT
SET ENCRYPTION KEY IDENTIFIED BY software_keystore_password
REVERSE MIGRATE USING "user_id:password";
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ADMINISTER-KEY-MANAGEMENT-32.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ADMINISTER-KEY-MANAGEMENT.html
ADMINISTER KEY MANAGEMENT
ADD SECRET 'secret1' FOR CLIENT 'client1'
USING TAG 'My first secret'
IDENTIFIED BY password
WITH BACKUP;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ADMINISTER-KEY-MANAGEMENT-33.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ADMINISTER-KEY-MANAGEMENT.html
ADMINISTER KEY MANAGEMENT
ADD SECRET 'secret2' FOR CLIENT 'client2'
USING TAG 'My second secret'
IDENTIFIED BY "user_id:password";
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ADMINISTER-KEY-MANAGEMENT-34.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ADMINISTER-KEY-MANAGEMENT.html
ADMINISTER KEY MANAGEMENT
UPDATE SECRET 'secret1' FOR CLIENT 'client1'
USING TAG 'New Tag 1'
IDENTIFIED BY password
WITH BACKUP;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ADMINISTER-KEY-MANAGEMENT-35.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ADMINISTER-KEY-MANAGEMENT.html
ADMINISTER KEY MANAGEMENT
UPDATE SECRET 'secret2' FOR CLIENT 'client2'
USING TAG 'New Tag 2'
IDENTIFIED BY "user_id:password";
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ADMINISTER-KEY-MANAGEMENT-36.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ADMINISTER-KEY-MANAGEMENT.html
ADMINISTER KEY MANAGEMENT
DELETE SECRET FOR CLIENT 'client1'
IDENTIFIED BY password
WITH BACKUP;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ADMINISTER-KEY-MANAGEMENT-37.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ADMINISTER-KEY-MANAGEMENT.html
ADMINISTER KEY MANAGEMENT
DELETE SECRET FOR CLIENT 'client2'
IDENTIFIED BY "user_id:password";
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ADMINISTER-KEY-MANAGEMENT-6.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ADMINISTER-KEY-MANAGEMENT.html
ADMINISTER KEY MANAGEMENT
CREATE KEYSTORE '/etc/ORACLE/WALLETS/orcl'
IDENTIFIED BY password;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ADMINISTER-KEY-MANAGEMENT-7.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ADMINISTER-KEY-MANAGEMENT.html
ADMINISTER KEY MANAGEMENT
CREATE AUTO_LOGIN KEYSTORE FROM KEYSTORE '/etc/ORACLE/WALLETS/orcl'
IDENTIFIED BY password;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ADMINISTER-KEY-MANAGEMENT-8.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ADMINISTER-KEY-MANAGEMENT.html
ADMINISTER KEY MANAGEMENT
SET KEYSTORE OPEN
IDENTIFIED BY password;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ADMINISTER-KEY-MANAGEMENT-9.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ADMINISTER-KEY-MANAGEMENT.html
ADMINISTER KEY MANAGEMENT
SET KEYSTORE OPEN
IDENTIFIED BY password
CONTAINER = CURRENT;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-ANALYTIC-VIEW-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-ANALYTIC-VIEW.html
ALTER ANALYTIC VIEW sales_av RENAME TO mysales_av;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-ANALYTIC-VIEW-1.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-ANALYTIC-VIEW.html
ALTER ANALYTIC VIEW TKHCSGL308_UNITS_AVIEW_CACHE ADD CACHE
MEASURE GROUP (sales, units, cost)
LEVELS (TIME.FISCAL.FISCAL_QUARTER, WAREHOUSE);
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-AUDIT-POLICY-Unified-Auditing-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-AUDIT-POLICY-Unified-Auditing.html
ALTER AUDIT POLICY hr_audit_policy ADD ONLY TOPLEVEL
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-AUDIT-POLICY-Unified-Auditing-1.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-AUDIT-POLICY-Unified-Auditing.html
ALTER AUDIT POLICY hr_audit_policy DROP ONLY TOPLEVEL
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-AUDIT-POLICY-Unified-Auditing-10.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-AUDIT-POLICY-Unified-Auditing.html
ALTER AUDIT POLICY dp_actions_pol
ADD ACTIONS COMPONENT = datapump EXPORT
DROP ACTIONS COMPONENT = datapump IMPORT;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-AUDIT-POLICY-Unified-Auditing-11.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-AUDIT-POLICY-Unified-Auditing.html
ALTER AUDIT POLICY order_updates_pol
CONDITION DROP;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-AUDIT-POLICY-Unified-Auditing-12.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-AUDIT-POLICY-Unified-Auditing.html
ALTER AUDIT POLICY emp_updates_pol
CONDITION 'UID = 102'
EVALUATE PER STATEMENT;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-AUDIT-POLICY-Unified-Auditing-13.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-AUDIT-POLICY-Unified-Auditing.html
CREATE AUDIT POLICY employee_audit_policy ACTIONS SELECT(sal) on scott.emp;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-AUDIT-POLICY-Unified-Auditing-14.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-AUDIT-POLICY-Unified-Auditing.html
ALTER AUDIT POLICY employee_audit_policy ACTIONS ADD INSERT(dname) on scott.dept;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-AUDIT-POLICY-Unified-Auditing-2.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-AUDIT-POLICY-Unified-Auditing.html
ALTER AUDIT POLICY dml_pol
ADD PRIVILEGES CREATE ANY TABLE, DROP ANY TABLE;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-AUDIT-POLICY-Unified-Auditing-3.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-AUDIT-POLICY-Unified-Auditing.html
ALTER AUDIT POLICY java_pol
ADD ACTIONS CREATE JAVA, ALTER JAVA, DROP JAVA;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-AUDIT-POLICY-Unified-Auditing-4.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-AUDIT-POLICY-Unified-Auditing.html
ALTER AUDIT POLICY table_pol
ADD ROLES dba;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-AUDIT-POLICY-Unified-Auditing-5.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-AUDIT-POLICY-Unified-Auditing.html
ALTER AUDIT POLICY security_pol
ADD PRIVILEGES CREATE ANY LIBRARY, DROP ANY LIBRARY
ACTIONS DELETE on hr.employees,
INSERT on hr.employees,
UPDATE on hr.employees,
ALL on hr.departments
ROLES dba, connect;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-AUDIT-POLICY-Unified-Auditing-6.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-AUDIT-POLICY-Unified-Auditing.html
ALTER AUDIT POLICY table_pol
DROP PRIVILEGES CREATE ANY TABLE;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-AUDIT-POLICY-Unified-Auditing-7.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-AUDIT-POLICY-Unified-Auditing.html
ALTER AUDIT POLICY dml_pol
DROP ACTIONS INSERT on hr.employees,
UPDATE on hr.employees;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-AUDIT-POLICY-Unified-Auditing-8.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-AUDIT-POLICY-Unified-Auditing.html
ALTER AUDIT POLICY java_pol
DROP ROLES java_deploy;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-AUDIT-POLICY-Unified-Auditing-9.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-AUDIT-POLICY-Unified-Auditing.html
ALTER AUDIT POLICY hr_admin_pol
DROP PRIVILEGES CREATE ANY TABLE
ACTIONS LOCK TABLE
ROLES audit_viewer;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-CLUSTER-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-CLUSTER.html
ALTER CLUSTER personnel
SIZE 1024 CACHE;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-CLUSTER-1.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-CLUSTER.html
ALTER CLUSTER language
DEALLOCATE UNUSED KEEP 30 K;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-CLUSTER-2.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-CLUSTER.html
CREATE CLUSTER EMP_DEPT (DEPTNO NUMBER(3))
SIZE 600
TABLESPACE USERS
STORAGE (INITIAL 200K
NEXT 300K
MINEXTENTS 2
PCTINCREASE 33);
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-CLUSTER-3.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-CLUSTER.html
SELECT CLUSTER_NAME, TABLESPACE_NAME, KEY_SIZE, CLUSTER_TYPE, AVG_BLOCKS_PER_KEY, MIN_EXTENTS, MAX_EXTENTS FROM USER_CLUSTERS;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-CLUSTER-4.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-CLUSTER.html
ALTER CLUSTER EMP_DEPT SIZE 1024;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-CLUSTER-5.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-CLUSTER.html
SELECT CLUSTER_NAME, TABLESPACE_NAME, KEY_SIZE, CLUSTER_TYPE, AVG_BLOCKS_PER_KEY, MIN_EXTENTS, MAX_EXTENTS FROM USER_CLUSTERS;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-CLUSTER-6.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-CLUSTER.html
ALTER CLUSTER EMP_DEPT DEALLOCATE UNUSED KEEP 30 K;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-CLUSTER-7.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-CLUSTER.html
SELECT CLUSTER_NAME, TABLESPACE_NAME, KEY_SIZE, CLUSTER_TYPE, AVG_BLOCKS_PER_KEY, MIN_EXTENTS, MAX_EXTENTS FROM USER_CLUSTERS;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-DATABASE-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-DATABASE.html
SELECT PROPERTY_VALUE FROM DATABASE_PROPERTIES
WHERE PROPERTY_NAME = 'DEFAULT_EDITION';
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-DATABASE-1.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-DATABASE.html
ALTER DATABASE db_name PREPARE MIRROR COPY mirror_name WITH HIGH REDUNDANCY
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-DATABASE-10.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-DATABASE.html
ALTER DATABASE
ADD LOGFILE GROUP 3
('diska:log3.log' ,
'diskb:log3.log') SIZE 50K;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-DATABASE-11.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-DATABASE.html
ALTER DATABASE
ADD LOGFILE THREAD 5 GROUP 4
('diska:log4.log',
'diskb:log4:log');
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-DATABASE-12.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-DATABASE.html
ALTER DATABASE
ADD LOGFILE MEMBER 'diskc:log3.log'
TO GROUP 3;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-DATABASE-13.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-DATABASE.html
ALTER DATABASE
DROP LOGFILE MEMBER 'diskb:log3.log';
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-DATABASE-14.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-DATABASE.html
ALTER DATABASE DROP LOGFILE GROUP 3;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-DATABASE-15.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-DATABASE.html
ALTER DATABASE
RENAME FILE 'diskc:log3.log' TO 'diskb:log3.log';
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-DATABASE-16.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-DATABASE.html
ALTER DATABASE
SET DEFAULT BIGFILE TABLESPACE;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-DATABASE-17.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-DATABASE.html
ALTER DATABASE
DEFAULT TEMPORARY TABLESPACE tbs_05;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-DATABASE-18.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-DATABASE.html
ALTER DATABASE
DEFAULT TEMPORARY TABLESPACE tbs_grp_01;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-DATABASE-19.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-DATABASE.html
ALTER DATABASE
CREATE DATAFILE 'tbs_f03.dbf'
AS 'tbs_f04.dbf';
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-DATABASE-2.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-DATABASE.html
ALTER DATABASE DATAFILE td_file.df ENABLE LOST WRITE PROTECTION
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-DATABASE-20.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-DATABASE.html
ALTER DATABASE TEMPFILE 'temp02.dbf' OFFLINE;
ALTER DATABASE RENAME FILE 'temp02.dbf' TO 'temp03.dbf';
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-DATABASE-21.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-DATABASE.html
ALTER DATABASE
RENAME GLOBAL_NAME TO demo.world.example.com;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-DATABASE-22.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-DATABASE.html
ALTER DATABASE
ENABLE BLOCK CHANGE TRACKING
USING FILE 'tracking_file' REUSE;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-DATABASE-23.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-DATABASE.html
ALTER DATABASE
DISABLE BLOCK CHANGE TRACKING;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-DATABASE-24.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-DATABASE.html
ALTER DATABASE
DATAFILE 'diskb:tbs_f5.dbf' RESIZE 10 M;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-DATABASE-25.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-DATABASE.html
ALTER DATABASE
CLEAR LOGFILE 'diskc:log3.log';
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-DATABASE-26.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-DATABASE.html
ALTER DATABASE
RECOVER AUTOMATIC DATABASE;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-DATABASE-27.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-DATABASE.html
ALTER DATABASE
RECOVER LOGFILE 'diskc:log3.log';
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-DATABASE-28.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-DATABASE.html
ALTER DATABASE
RECOVER AUTOMATIC UNTIL TIME '2001-10-27:14:00:00';
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-DATABASE-3.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-DATABASE.html
ALTER DATABASE DATAFILE td_file.df REMOVE LOST WRITE PROTECTION
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-DATABASE-4.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-DATABASE.html
ALTER DATABASE DATAFILE td_file.df SUSPEND LOST WRITE PROTECTION
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-DATABASE-5.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-DATABASE.html
ALTER DATABASE ENABLE LOST WRITE PROTECTION
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-DATABASE-6.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-DATABASE.html
ALTER DATABASE DISABLE LOST WRITE PROTECTION
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-DATABASE-7.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-DATABASE.html
ALTER DATABASE OPEN READ ONLY;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-DATABASE-8.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-DATABASE.html
ALTER DATABASE OPEN READ WRITE RESETLOGS;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-DATABASE-9.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-DATABASE.html
ALTER DATABASE
RECOVER TABLESPACE tbs_03
PARALLEL;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-DATABASE-LINK-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-DATABASE-LINK.html
ALTER DATABASE LINK private_link
CONNECT TO hr IDENTIFIED BY hr_new_password;
ALTER PUBLIC DATABASE LINK public_link
CONNECT TO scott IDENTIFIED BY scott_new_password;
ALTER SHARED PUBLIC DATABASE LINK shared_pub_link
CONNECT TO scott IDENTIFIED BY scott_new_password
AUTHENTICATED BY hr IDENTIFIED BY hr_new_password;
ALTER SHARED DATABASE LINK shared_pub_link
CONNECT TO scott IDENTIFIED BY scott_new_password;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-DIMENSION-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-DIMENSION.html
ALTER DIMENSION customers_dim
DROP ATTRIBUTE country;
ALTER DIMENSION customers_dim
ADD LEVEL zone IS customers.cust_postal_code
ADD ATTRIBUTE zone DETERMINES (cust_city);
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-DISKGROUP-1.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-DISKGROUP.html
ALTER DISKGROUP hmdg ADD FILEGROUP fgtem TEMPLATE SET 'datafile.redundancy'='unprotected'
ALTER DISKGROUP hmdg ADD FILEGROUP fgdb DATABASE NONE FROM TEMPLATE fgtem
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-DISKGROUP-10.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-DISKGROUP.html
ALTER DISKGROUP dgroup_01
MODIFY TEMPLATE template_01
ATTRIBUTES (FINE);
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-DISKGROUP-11.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-DISKGROUP.html
ALTER DISKGROUP dgroup_01
DROP TEMPLATE template_01;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-DISKGROUP-12.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-DISKGROUP.html
ALTER DISKGROUP dgroup_01
ADD DIRECTORY '+dgroup_01/alias_dir';
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-DISKGROUP-13.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-DISKGROUP.html
ALTER DISKGROUP dgroup_01
ADD ALIAS '+dgroup_01/alias_dir/datafile.dbf'
FOR '+dgroup_01.261.1';
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-DISKGROUP-14.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-DISKGROUP.html
ALTER DISKGROUP dgroup_01
SCRUB REPAIR WAIT;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-DISKGROUP-15.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-DISKGROUP.html
ALTER DISKGROUP dgroup_01
DISMOUNT FORCE;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-DISKGROUP-16.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-DISKGROUP.html
ALTER DISKGROUP dgroup_01
MOUNT;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-DISKGROUP-2.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-DISKGROUP.html
ALTER DISKGROUP hmdg ADD FILEGROUP fgtem2 TEMPLATE
CREATE TABLESPACE tbs1 datafile '+hmdg(fg$fgtem2)/dbs/tbs1.f' size 1M
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-DISKGROUP-3.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-DISKGROUP.html
ALTER DISKGROUP dgroup_01
ADD DISK '/devices/disks/d100';
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-DISKGROUP-4.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-DISKGROUP.html
ALTER DISKGROUP dgroup_01
DROP DISK dgroup_01_0000;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-DISKGROUP-5.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-DISKGROUP.html
ALTER DISKGROUP dgroup_01
UNDROP DISKS;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-DISKGROUP-6.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-DISKGROUP.html
ALTER DISKGROUP dgroup_01
RESIZE ALL
SIZE 36G;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-DISKGROUP-7.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-DISKGROUP.html
ALTER DISKGROUP dgroup_01
REBALANCE POWER 11 WAIT;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-DISKGROUP-8.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-DISKGROUP.html
ALTER DISKGROUP dgroup_01
CHECK ALL
REPAIR;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-DISKGROUP-9.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-DISKGROUP.html
ALTER DISKGROUP dgroup_01
ADD TEMPLATE template_01
ATTRIBUTES (UNPROTECTED COARSE);
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-HIERARCHY-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-HIERARCHY.html
ALTER HIERARCHY product_hier RENAME TO myproduct_hier;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-INDEX-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-INDEX.html
ALTER INDEX ord_customer_ix REBUILD REVERSE;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-INDEX-1.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-INDEX.html
ALTER INDEX ord_customer_ix REBUILD PARALLEL;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-INDEX-10.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-INDEX.html
ALTER INDEX cost_ix
SPLIT PARTITION p2 AT (1500)
INTO ( PARTITION p2a TABLESPACE tbs_01 LOGGING,
PARTITION p2b TABLESPACE tbs_02);
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-INDEX-11.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-INDEX.html
ALTER INDEX cost_ix
DROP PARTITION p1;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-INDEX-12.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-INDEX.html
ALTER INDEX prod_idx
MODIFY DEFAULT ATTRIBUTES INITRANS 5;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-INDEX-2.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-INDEX.html
ALTER INDEX oe.cust_lname_ix
INITRANS 5;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-INDEX-3.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-INDEX.html
ALTER INDEX upper_ix PARALLEL;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-INDEX-4.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-INDEX.html
ALTER INDEX upper_ix RENAME TO upper_name_ix;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-INDEX-5.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-INDEX.html
ALTER INDEX cost_ix
MODIFY PARTITION p2 UNUSABLE;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-INDEX-6.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-INDEX.html
ALTER INDEX cost_ix UNUSABLE;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-INDEX-7.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-INDEX.html
ALTER INDEX cost_ix
REBUILD PARTITION p2;
ALTER INDEX cost_ix
REBUILD PARTITION p3 NOLOGGING;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-INDEX-8.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-INDEX.html
ALTER INDEX cost_ix MODIFY PARTITION p3
STORAGE(MAXEXTENTS 30) LOGGING;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-INDEX-9.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-INDEX.html
ALTER INDEX cost_ix
RENAME PARTITION p3 TO p3_Q3;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-INDEXTYPE-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-INDEXTYPE.html
ALTER INDEXTYPE position_indextype COMPILE;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-INMEMORY-JOIN-GROUP-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-INMEMORY-JOIN-GROUP.html
ALTER INMEMORY JOIN GROUP prod_id1
ADD(product_descriptions(product_id));
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-INMEMORY-JOIN-GROUP-1.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-INMEMORY-JOIN-GROUP.html
ALTER INMEMORY JOIN GROUP prod_id1
REMOVE(product_descriptions(product_id));
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-JAVA-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-JAVA.html
ALTER JAVA CLASS "Agent"
RESOLVER (("/usr/bin/bfile_dir/*" pm)(* public))
RESOLVE;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-LOCKDOWN-PROFILE-10.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-LOCKDOWN-PROFILE.html
ALTER LOCKDOWN PROFILE hr_prof
DISABLE OPTION = ('DATABASE QUEUING');
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-LOCKDOWN-PROFILE-11.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-LOCKDOWN-PROFILE.html
ALTER LOCKDOWN PROFILE hr_prof
DISABLE OPTION = ('PARTITIONING');
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-LOCKDOWN-PROFILE-12.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-LOCKDOWN-PROFILE.html
ALTER LOCKDOWN PROFILE hr_prof
ENABLE OPTION = ('DATABASE QUEUING');
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-LOCKDOWN-PROFILE-13.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-LOCKDOWN-PROFILE.html
ALTER LOCKDOWN PROFILE hr_prof
ENABLE OPTION ALL;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-LOCKDOWN-PROFILE-14.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-LOCKDOWN-PROFILE.html
ALTER LOCKDOWN PROFILE hr_prof
DISABLE STATEMENT = ('ALTER DATABASE');
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-LOCKDOWN-PROFILE-15.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-LOCKDOWN-PROFILE.html
ALTER LOCKDOWN PROFILE hr_prof
DISABLE STATEMENT = ('ALTER SYSTEM')
CLAUSE = ('SUSPEND', 'RESUME');
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-LOCKDOWN-PROFILE-16.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-LOCKDOWN-PROFILE.html
ALTER LOCKDOWN PROFILE hr_prof
DISABLE STATEMENT = ('ALTER PLUGGABLE DATABASE')
CLAUSE ALL EXCEPT = ('DEFAULT TABLESPACE', 'DEFAULT TEMPORARY TABLESPACE');
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-LOCKDOWN-PROFILE-17.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-LOCKDOWN-PROFILE.html
ALTER LOCKDOWN PROFILE hr_prof
DISABLE STATEMENT = ('ALTER SESSION')
CLAUSE = ('SET')
OPTION = ('COMMIT_WAIT', 'CURSOR_SHARING');
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-LOCKDOWN-PROFILE-18.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-LOCKDOWN-PROFILE.html
ALTER LOCKDOWN PROFILE hr_prof
DISABLE STATEMENT = ('ALTER SYSTEM')
CLAUSE = ('SET')
OPTION = ('PDB_FILE_NAME_CONVERT')
VALUE = ('cdb1_pdb0', 'cdb1_pdb1');
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-LOCKDOWN-PROFILE-19.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-LOCKDOWN-PROFILE.html
ALTER LOCKDOWN PROFILE hr_prof
DISABLE STATEMENT = ('ALTER SYSTEM')
CLAUSE = ('SET')
OPTION = ('CPU_COUNT')
MINVALUE = '8';
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-LOCKDOWN-PROFILE-2.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-LOCKDOWN-PROFILE.html
CREATE LOCKDOWN PROFILE hr_prof;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-LOCKDOWN-PROFILE-20.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-LOCKDOWN-PROFILE.html
ALTER LOCKDOWN PROFILE hr_prof
DISABLE STATEMENT = ('ALTER SYSTEM')
CLAUSE = ('SET')
OPTION = ('CPU_COUNT')
MAXVALUE = '2';
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-LOCKDOWN-PROFILE-21.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-LOCKDOWN-PROFILE.html
ALTER LOCKDOWN PROFILE hr_prof
DISABLE STATEMENT = ('ALTER SYSTEM')
CLAUSE = ('SET')
OPTION = ('CPU_COUNT')
MINVALUE = '2'
MAXVALUE = '6';
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-LOCKDOWN-PROFILE-22.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-LOCKDOWN-PROFILE.html
ALTER LOCKDOWN PROFILE hr_prof
ENABLE STATEMENT ALL EXCEPT = ('ALTER DATABASE');
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-LOCKDOWN-PROFILE-23.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-LOCKDOWN-PROFILE.html
ALTER LOCKDOWN PROFILE hr_prof
ENABLE STATEMENT = ('ALTER DATABASE')
CLAUSE = ('MOUNT', 'OPEN');
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-LOCKDOWN-PROFILE-24.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-LOCKDOWN-PROFILE.html
ALTER LOCKDOWN PROFILE hr_prof
ENABLE STATEMENT = ('ALTER PLUGGABLE DATABASE')
CLAUSE ALL EXCEPT = ('DEFAULT TABLESPACE', 'DEFAULT TEMPORARY TABLESPACE');
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-LOCKDOWN-PROFILE-25.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-LOCKDOWN-PROFILE.html
ALTER LOCKDOWN PROFILE hr_prof
ENABLE STATEMENT = ('ALTER SESSION')
CLAUSE = ('SET')
OPTION = ('COMMIT_WAIT', 'CURSOR_SHARING');
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-LOCKDOWN-PROFILE-3.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-LOCKDOWN-PROFILE.html
ALTER LOCKDOWN PROFILE hr_prof
DISABLE FEATURE = ('NETWORK_ACCESS');
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-LOCKDOWN-PROFILE-4.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-LOCKDOWN-PROFILE.html
ALTER LOCKDOWN PROFILE hr_prof
DISABLE FEATURE = ('LOB_FILE_ACCESS', 'TRACE_VIEW_ACCESS');
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-LOCKDOWN-PROFILE-5.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-LOCKDOWN-PROFILE.html
ALTER LOCKDOWN PROFILE hr_prof
DISABLE FEATURE ALL EXCEPT = ('COMMON_USER_LOCAL_SCHEMA_ACCESS', 'LOCAL_USER_COMMON_SCHEMA_ACCESS');
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-LOCKDOWN-PROFILE-6.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-LOCKDOWN-PROFILE.html
ALTER LOCKDOWN PROFILE hr_prof
DISABLE FEATURE ALL;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-LOCKDOWN-PROFILE-7.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-LOCKDOWN-PROFILE.html
ALTER LOCKDOWN PROFILE hr_prof
ENABLE FEATURE = ('UTL_HTTP', 'UTL_SMTP', 'OS_ACCESS');
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-LOCKDOWN-PROFILE-8.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-LOCKDOWN-PROFILE.html
ALTER LOCKDOWN PROFILE hr_prof
ENABLE FEATURE ALL EXCEPT = ('AQ_PROTOCOLS', 'CTX_PROTOCOLS');
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-LOCKDOWN-PROFILE-9.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-LOCKDOWN-PROFILE.html
ALTER LOCKDOWN PROFILE hr_prof
ENABLE FEATURE ALL;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-MATERIALIZED-VIEW-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-MATERIALIZED-VIEW.html
ALTER MATERIALIZED VIEW sales_by_month_by_state
REFRESH FAST;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-MATERIALIZED-VIEW-1.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-MATERIALIZED-VIEW.html
ALTER MATERIALIZED VIEW sales_by_month_by_state
REFRESH NEXT SYSDATE+7;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-MATERIALIZED-VIEW-2.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-MATERIALIZED-VIEW.html
ALTER MATERIALIZED VIEW sales_by_month_by_state CONSIDER FRESH;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-MATERIALIZED-VIEW-3.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-MATERIALIZED-VIEW.html
ALTER MATERIALIZED VIEW emp_data
REFRESH COMPLETE
START WITH TRUNC(SYSDATE+1) + 9/24
NEXT SYSDATE+7;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-MATERIALIZED-VIEW-4.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-MATERIALIZED-VIEW.html
ALTER MATERIALIZED VIEW emp_data
ENABLE QUERY REWRITE;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-MATERIALIZED-VIEW-5.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-MATERIALIZED-VIEW.html
ALTER MATERIALIZED VIEW order_data
REFRESH WITH PRIMARY KEY;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-MATERIALIZED-VIEW-6.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-MATERIALIZED-VIEW.html
ALTER MATERIALIZED VIEW order_data COMPILE;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-MATERIALIZED-VIEW-7.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-MATERIALIZED-VIEW.html
ALTER MATERIALIZED VIEW MView1 ANNOTATIONS(DROP Snapshot);
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-MATERIALIZED-VIEW-LOG-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-MATERIALIZED-VIEW-LOG.html
ALTER MATERIALIZED VIEW LOG ON order_items ADD ROWID;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-MATERIALIZED-VIEW-LOG-1.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-MATERIALIZED-VIEW-LOG.html
ALTER MATERIALIZED VIEW LOG ON employees
ADD (commission_pct)
EXCLUDING NEW VALUES;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-MATERIALIZED-ZONEMAP-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-MATERIALIZED-ZONEMAP.html
ALTER MATERIALIZED ZONEMAP sales_zmap
PCTFREE 20 PCTUSED 50 NOCACHE;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-MATERIALIZED-ZONEMAP-1.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-MATERIALIZED-ZONEMAP.html
ALTER MATERIALIZED ZONEMAP sales_zmap
REFRESH FAST ON COMMIT;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-MATERIALIZED-ZONEMAP-2.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-MATERIALIZED-ZONEMAP.html
ALTER MATERIALIZED ZONEMAP sales_zmap
DISABLE PRUNING;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-MATERIALIZED-ZONEMAP-3.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-MATERIALIZED-ZONEMAP.html
ALTER MATERIALIZED ZONEMAP sales_zmap
COMPILE;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-MATERIALIZED-ZONEMAP-4.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-MATERIALIZED-ZONEMAP.html
ALTER MATERIALIZED ZONEMAP sales_zmap
REBUILD;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-MATERIALIZED-ZONEMAP-5.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-MATERIALIZED-ZONEMAP.html
ALTER MATERIALIZED ZONEMAP sales_zmap
UNUSABLE;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-OPERATOR-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-OPERATOR.html
ALTER OPERATOR eq_op COMPILE;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-OUTLINE-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-OUTLINE.html
ALTER OUTLINE salaries REBUILD;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-PLUGGABLE-DATABASE-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-PLUGGABLE-DATABASE.html
ALTER PLUGGABLE DATABASE CDB1_PDB2 UNPLUG INTO '/tmp/cdb1_pdb2.xml' ENCRYPT USING transport_secret
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-PLUGGABLE-DATABASE-1.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-PLUGGABLE-DATABASE.html
ALTER PLUGGABLE DATABASE CDB1_PDB1_1 UNPLUG INTO '/tmp/CDB1_PDB1_1.pdb' ENCRYPT USING transport_secret
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-PLUGGABLE-DATABASE-10.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-PLUGGABLE-DATABASE.html
ALTER PLUGGABLE DATABASE
ENABLE LOST WRITE PROTECTION
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-PLUGGABLE-DATABASE-11.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-PLUGGABLE-DATABASE.html
ALTER PLUGGABLE DATABASE
DISABLE LOST WRITE PROTECTION
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-PLUGGABLE-DATABASE-12.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-PLUGGABLE-DATABASE.html
ALTER PLUGGABLE DATABASE pdb1
UNPLUG INTO '/oracle/data/pdb1.xml';
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-PLUGGABLE-DATABASE-13.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-PLUGGABLE-DATABASE.html
ALTER PLUGGABLE DATABASE pdb2
STORAGE (MAXSIZE 500M);
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-PLUGGABLE-DATABASE-14.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-PLUGGABLE-DATABASE.html
ALTER PLUGGABLE DATABASE pdb3
DATAFILE ALL OFFLINE;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-PLUGGABLE-DATABASE-15.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-PLUGGABLE-DATABASE.html
ALTER PLUGGABLE DATABASE pdb4
OPEN READ ONLY;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-PLUGGABLE-DATABASE-16.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-PLUGGABLE-DATABASE.html
ALTER PLUGGABLE DATABASE pdb4
OPEN READ WRITE FORCE;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-PLUGGABLE-DATABASE-17.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-PLUGGABLE-DATABASE.html
ALTER PLUGGABLE DATABASE pdb4
CLOSE;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-PLUGGABLE-DATABASE-18.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-PLUGGABLE-DATABASE.html
ALTER PLUGGABLE DATABASE pdb4
OPEN READ ONLY RESTRICTED;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-PLUGGABLE-DATABASE-19.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-PLUGGABLE-DATABASE.html
ALTER PLUGGABLE DATABASE pdb5
OPEN READ WRITE INSTANCES = ('ORCLDB_1', 'ORCLDB_2');
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-PLUGGABLE-DATABASE-2.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-PLUGGABLE-DATABASE.html
ALTER PLUGGABLE DATABASE CONTAINERS HOST='myhost.example.com';
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-PLUGGABLE-DATABASE-20.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-PLUGGABLE-DATABASE.html
ALTER PLUGGABLE DATABASE pdb6
CLOSE RELOCATE TO 'ORCLDB_3';
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-PLUGGABLE-DATABASE-21.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-PLUGGABLE-DATABASE.html
ALTER PLUGGABLE DATABASE ALL
OPEN READ ONLY;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-PLUGGABLE-DATABASE-3.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-PLUGGABLE-DATABASE.html
ALTER PLUGGABLE DATABASE CONTAINERS PORT=1599;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-PLUGGABLE-DATABASE-6.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-PLUGGABLE-DATABASE.html
ALTER PLUGGABLE DATABASE APPLICATION hrapp payrollapp employeesapp SYNC
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-PLUGGABLE-DATABASE-7.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-PLUGGABLE-DATABASE.html
ALTER PLUGGABLE DATABASE APPLICATION ALL EXCEPT hrapp payrollapp SYNC
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-PLUGGABLE-DATABASE-8.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-PLUGGABLE-DATABASE.html
ALTER PLUGGABLE DATABASE pdb_name PREPARE MIRROR COPY mirror_name WITH HIGH REDUNDANCY
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-PLUGGABLE-DATABASE-9.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-PLUGGABLE-DATABASE.html
ALTER PLUGGABLE DATABASE PREPARE MIRROR COPY mirror_name WITH HIGH REDUNDANCY
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-PROFILE-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-PROFILE.html
ALTER PROFILE new_profile
LIMIT PASSWORD_REUSE_TIME 90
PASSWORD_REUSE_MAX UNLIMITED;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-PROFILE-1.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-PROFILE.html
ALTER PROFILE app_user
LIMIT PASSWORD_REUSE_TIME DEFAULT
PASSWORD_REUSE_MAX UNLIMITED;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-PROFILE-2.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-PROFILE.html
ALTER PROFILE app_user LIMIT
FAILED_LOGIN_ATTEMPTS 5
PASSWORD_LOCK_TIME 1;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-PROFILE-3.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-PROFILE.html
ALTER PROFILE app_user2 LIMIT
PASSWORD_LIFE_TIME 90
PASSWORD_GRACE_TIME 5;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-PROFILE-4.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-PROFILE.html
ALTER PROFILE app_user2 LIMIT
INACTIVE_ACCOUNT_TIME 30;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-PROFILE-5.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-PROFILE.html
ALTER PROFILE app_user LIMIT SESSIONS_PER_USER 5;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-PROFILE-6.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-PROFILE.html
ALTER PROFILE app_user LIMIT IDLE_TIME DEFAULT;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-PROFILE-7.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-PROFILE.html
ALTER PROFILE default LIMIT IDLE_TIME 2;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-PROFILE-8.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-PROFILE.html
ALTER PROFILE app_user2 LIMIT IDLE_TIME UNLIMITED;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-PROFILE-9.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-PROFILE.html
ALTER PROFILE usr_prof LIMIT PASSWORD_ROLLOVER_TIME 2 ;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-RESOURCE-COST-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-RESOURCE-COST.html
ALTER RESOURCE COST
CPU_PER_SESSION 100
CONNECT_TIME 1;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-RESOURCE-COST-2.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-RESOURCE-COST.html
ALTER RESOURCE COST
LOGICAL_READS_PER_SESSION 2
CONNECT_TIME 0;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-ROLE-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-ROLE.html
ALTER ROLE warehouse_user NOT IDENTIFIED;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-ROLE-1.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-ROLE.html
ALTER ROLE dw_manager
IDENTIFIED BY data;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-ROLE-2.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-ROLE.html
ALTER ROLE dw_manager IDENTIFIED USING hr.admin;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-ROLLBACK-SEGMENT-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-ROLLBACK-SEGMENT.html
ALTER ROLLBACK SEGMENT rbs_one ONLINE;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-ROLLBACK-SEGMENT-1.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-ROLLBACK-SEGMENT.html
ALTER ROLLBACK SEGMENT rbs_one
SHRINK TO 100M;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-SEQUENCE-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-SEQUENCE.html
ALTER SEQUENCE customers_seq
MAXVALUE 1500;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-SEQUENCE-1.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-SEQUENCE.html
ALTER SEQUENCE customers_seq
CYCLE
CACHE 5;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-SESSION-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-SESSION.html
SELECT SYS_CONTEXT('USERENV', 'CURRENT_EDITION_NAME') FROM DUAL;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-SESSION-1.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-SESSION.html
SELECT SYS_CONTEXT('USERENV', 'CON_NAME') FROM DUAL;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-SESSION-13.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-SESSION.html
ALTER SESSION ENABLE PARALLEL DML;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-SESSION-14.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-SESSION.html
ALTER SESSION
ADVISE COMMIT;
INSERT INTO employees@remote
VALUES (8002, 'Juan', 'Fernandez', 'juanf@example.com', NULL,
TO_DATE('04-OCT-1992', 'DD-MON-YYYY'), 'SA_CLERK', 3000,
NULL, 121, 20);
ALTER SESSION
ADVISE ROLLBACK;
DELETE FROM employees@local
WHERE employee_id = 8002;
COMMIT;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-SESSION-15.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-SESSION.html
UPDATE jobs@local SET min_salary = 3000
WHERE job_id = 'SH_CLERK';
COMMIT;
ALTER SESSION
CLOSE DATABASE LINK local;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-SESSION-16.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-SESSION.html
ALTER SESSION
SET NLS_DATE_FORMAT = 'YYYY MM DD HH24:MI:SS';
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-SESSION-17.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-SESSION.html
SELECT TO_CHAR(SYSDATE) Today
FROM DUAL;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-SESSION-18.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-SESSION.html
ALTER SESSION
SET NLS_DATE_LANGUAGE = French;
SELECT TO_CHAR(SYSDATE, 'Day DD Month YYYY') Today
FROM DUAL;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-SESSION-19.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-SESSION.html
ALTER SESSION
SET NLS_ISO_CURRENCY = America;
SELECT TO_CHAR( SUM(salary), 'C999G999D99') Total
FROM employees;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-SESSION-2.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-SESSION.html
SELECT SYS_CONTEXT('USERENV', 'SESSION_DEFAULT_COLLATION') FROM DUAL;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-SESSION-20.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-SESSION.html
ALTER SESSION SET NLS_NUMERIC_CHARACTERS = ',.' ;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-SESSION-21.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-SESSION.html
ALTER SESSION SET NLS_CURRENCY = 'FF';
SELECT TO_CHAR( SUM(salary), 'L999G999D99') Total FROM employees;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-SESSION-22.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-SESSION.html
ALTER SESSION
SET NLS_CURRENCY = 'DM';
SELECT TO_CHAR( SUM(salary), 'L999G999D99') Total
FROM employees;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-SESSION-23.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-SESSION.html
ALTER SESSION
SET NLS_LANGUAGE = FRENCH;
SELECT * FROM DMP;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-SESSION-24.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-SESSION.html
ALTER SESSION
SET NLS_SORT = XSpanish;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-SESSION-25.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-SESSION.html
ALTER SESSION
SET QUERY_REWRITE_ENABLED = TRUE;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-SYNONYM-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-SYNONYM.html
ALTER SYNONYM offices COMPILE;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-SYNONYM-1.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-SYNONYM.html
ALTER PUBLIC SYNONYM emp_table COMPILE;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-SYNONYM-2.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-SYNONYM.html
ALTER SYNONYM offices NONEDITIONABLE;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-SYSTEM-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-SYSTEM.html
ALTER SYSTEM KILL SESSION '20,1' FORCE;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-SYSTEM-1.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-SYSTEM.html
ALTER SYSTEM KILL SESSION '20,1' TIMEOUT 20;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-SYSTEM-10.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-SYSTEM.html
ALTER SYSTEM
ENABLE RESTRICTED SESSION;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-SYSTEM-11.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-SYSTEM.html
ALTER SYSTEM
DISABLE RESTRICTED SESSION;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-SYSTEM-12.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-SYSTEM.html
ALTER SYSTEM SET ENCRYPTION WALLET OPEN IDENTIFIED BY "password";
ALTER SYSTEM SET ENCRYPTION KEY IDENTIFIED BY "password";
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-SYSTEM-13.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-SYSTEM.html
ALTER SYSTEM SET ENCRYPTION WALLET CLOSE IDENTIFIED BY "password";
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-SYSTEM-14.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-SYSTEM.html
ALTER SYSTEM SET ENCRYPTION WALLET CLOSE;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-SYSTEM-15.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-SYSTEM.html
ALTER SYSTEM FLUSH SHARED_POOL;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-SYSTEM-16.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-SYSTEM.html
ALTER SYSTEM CHECKPOINT;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-SYSTEM-17.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-SYSTEM.html
ALTER SYSTEM SET RESOURCE_LIMIT = TRUE;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-SYSTEM-18.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-SYSTEM.html
ALTER SYSTEM SET SHARED_SERVERS = 25;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-SYSTEM-19.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-SYSTEM.html
ALTER SYSTEM
SET DISPATCHERS =
'(INDEX=0)(PROTOCOL=TCP)(DISPATCHERS=5)',
'(INDEX=1)(PROTOCOL=ipc)(DISPATCHERS=10)';
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-SYSTEM-20.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-SYSTEM.html
ALTER SYSTEM
SET LICENSE_MAX_SESSIONS = 64
LICENSE_SESSIONS_WARNING = 54;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-SYSTEM-21.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-SYSTEM.html
ALTER SYSTEM SET LICENSE_MAX_SESSIONS = 0;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-SYSTEM-22.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-SYSTEM.html
ALTER SYSTEM SET LICENSE_MAX_USERS = 200;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-SYSTEM-23.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-SYSTEM.html
ALTER SYSTEM SWITCH LOGFILE;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-SYSTEM-24.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-SYSTEM.html
ALTER SYSTEM ENABLE DISTRIBUTED RECOVERY;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-SYSTEM-25.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-SYSTEM.html
ALTER SYSTEM DISABLE DISTRIBUTED RECOVERY;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-SYSTEM-26.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-SYSTEM.html
SELECT sid, serial#, username
FROM V$SESSION;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-SYSTEM-27.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-SYSTEM.html
ALTER SYSTEM KILL SESSION '39, 23';
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-SYSTEM-28.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-SYSTEM.html
ALTER SYSTEM DISCONNECT SESSION '13, 8' POST_TRANSACTION;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-SYSTEM-3.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-SYSTEM.html
SELECT SYS_CONTEXT('SYS_CLUSTER_PROPERTIES', 'CLUSTER_STATE') FROM DUAL;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-SYSTEM-4.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-SYSTEM.html
SELECT SYS_CONTEXT('SYS_CLUSTER_PROPERTIES', 'CURRENT_PATCHLVL') FROM DUAL;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-SYSTEM-5.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-SYSTEM.html
ALTER SYSTEM SET MANDATORY_USER_PROFILE=c##cdb_profile;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-SYSTEM-7.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-SYSTEM.html
ALTER SYSTEM ARCHIVE LOG CHANGE 9356083;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-SYSTEM-8.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-SYSTEM.html
ALTER SYSTEM ARCHIVE LOG
LOGFILE 'diskl:log6.log'
TO 'diska:[arch$]';
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-SYSTEM-9.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-SYSTEM.html
ALTER SYSTEM SET QUERY_REWRITE_ENABLED = TRUE;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-TABLE-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-TABLE.html
ALTER TABLE employee RESULT_CACHE (MODE DEFAULT)
ALTER TABLE employee RESULT_CACHE (STANDBY ENABLE)
ALTER TABLE employee RESULT_CACHE (MODE DEFAULT, STANDBY ENABLE)
ALTER TABLE employee RESULT_CACHE (STANDBY ENABLE, MODE FORCE)
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-TABLE-10.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-TABLE.html
ALTER TABLE imm_tab NO DELETE UNTIL 120 DAYS AFTER
INSERT;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-TABLE-100.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-TABLE.html
ALTER TABLE departments
DROP PRIMARY KEY CASCADE;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-TABLE-101.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-TABLE.html
ALTER TABLE departments
DROP CONSTRAINT pk_dept CASCADE;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-TABLE-102.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-TABLE.html
ALTER TABLE employees
DROP UNIQUE (email);
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-TABLE-103.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-TABLE.html
ALTER TABLE employees ADD (resume CLOB)
LOB (resume) STORE AS resume_seg (TABLESPACE example);
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-TABLE-104.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-TABLE.html
ALTER TABLE employees MODIFY LOB (resume) (CACHE);
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-TABLE-105.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-TABLE.html
ALTER TABLE employees ADD (resume CLOB)
LOB (resume) STORE AS SECUREFILE resume_seg (TABLESPACE auto_seg_ts);
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-TABLE-106.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-TABLE.html
ALTER TABLE employees MODIFY LOB (resume) (NOCACHE);
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-TABLE-107.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-TABLE.html
ALTER TABLE employees ADD (skills skill_table_type)
NESTED TABLE skills STORE AS nested_skill_table;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-TABLE-108.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-TABLE.html
CREATE TYPE pet_t AS OBJECT
(pet_id NUMBER, pet_name VARCHAR2(10), pet_dob DATE);
/
CREATE TYPE pet AS TABLE OF pet_t;
/
CREATE TABLE vet_service (vet_name VARCHAR2(30),
client pet)
NESTED TABLE client STORE AS client_tab;
ALTER TABLE client_tab ADD UNIQUE (pet_id);
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-TABLE-109.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-TABLE.html
CREATE TYPE emp_t AS OBJECT (eno number, ename char(31));
CREATE TYPE emps_t AS TABLE OF REF emp_t;
CREATE TABLE emptab OF emp_t;
CREATE TABLE dept (dno NUMBER, employees emps_t)
NESTED TABLE employees STORE AS deptemps;
ALTER TABLE deptemps ADD (SCOPE FOR (COLUMN_VALUE) IS emptab);
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-TABLE-11.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-TABLE.html
CREATE TABLE JOBS_Temp AS SELECT * FROM HR.JOBS;
SELECT * FROM JOBS_Temp WHERE MIN_SALARY < 3000;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-TABLE-110.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-TABLE.html
ALTER TABLE deptemps ADD (REF(column_value) WITH ROWID);
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-TABLE-111.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-TABLE.html
CREATE TYPE dept_t AS OBJECT
(deptno NUMBER, dname VARCHAR2(20));
/
CREATE TABLE staff
(name VARCHAR2(100),
salary NUMBER,
dept REF dept_t);
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-TABLE-112.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-TABLE.html
CREATE TABLE offices OF dept_t;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-TABLE-113.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-TABLE.html
ALTER TABLE staff
ADD (SCOPE FOR (dept) IS offices);
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-TABLE-114.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-TABLE.html
ALTER TABLE staff
ADD (REF(dept) WITH ROWID);
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-TABLE-115.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-TABLE.html
CREATE TABLE t1 (n NUMBER, x ANYDATA);
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-TABLE-116.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-TABLE.html
CREATE OR REPLACE TYPE clob_typ AS OBJECT (c clob);
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-TABLE-117.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-TABLE.html
ALTER TABLE t1 MODIFY OPAQUE TYPE x STORE (XMLType, clob_typ) UNPACKED;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-TABLE-118.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-TABLE.html
INSERT INTO t1
VALUES(1, anydata.convertobject(XMLType('This is test XML')));
INSERT INTO t1
VALUES(2, anydata.convertobject(clob_typ(TO_CLOB('This is a test CLOB'))));
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-TABLE-119.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-TABLE.html
SELECT t1.*, anydata.getTypeName(t1.x) typename FROM t1;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-TABLE-12.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-TABLE.html
UPDATE JOBS_Temp SET MIN_SALARY = 2300 WHERE MIN_SALARY < 2010;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-TABLE-120.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-TABLE.html
CREATE FUNCTION get_xmltype (ad IN ANYDATA) RETURN VARCHAR2 AS
rtn_val PLS_INTEGER;
my_xmltype XMLType;
string_val VARCHAR2(30);
BEGIN
rtn_val := ad.getObject(my_xmltype);
string_val := my_xmltype.getstringval();
return (string_val);
END;
/
CREATE FUNCTION get_clob_typ (ad IN ANYDATA) RETURN VARCHAR2 AS
rtn_val PLS_INTEGER;
my_clob_typ clob_typ;
string_val VARCHAR2(30);
BEGIN
rtn_val := ad.getObject(my_clob_typ);
string_val := (my_clob_typ.c);
return (string_val);
END;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-TABLE-121.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-TABLE.html
SELECT t1.*, anydata.getTypeName(t1.x) typename,
CASE
WHEN anydata.gettypename(t1.x) = 'SYS.XMLTYPE' THEN get_xmltype(t1.x)
WHEN anydata.gettypename(t1.x) = 'HR.CLOB_TYP' THEN get_clob_typ(t1.x)
END string_value
FROM t1;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-TABLE-122.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-TABLE.html
CREATE TABLE table1 (T NUMBER) ANNOTATIONS(Operations 'Sort', Hidden);
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-TABLE-123.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-TABLE.html
ALTER TABLE table1 ANNOTATIONS(DROP Operations, DROP Hidden);
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-TABLE-124.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-TABLE.html
ALTER TABLE table1 ANNOTATIONS(ADD Operations '["Sort", "Group"]');
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-TABLE-125.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-TABLE.html
ALTER TABLE table1 MODIFY T ANNOTATIONS(Identity 'ID');
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-TABLE-126.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-TABLE.html
ALTER TABLE table1 MODIFY T ANNOTATIONS(ADD Hidden, DROP Identity);
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-TABLE-127.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-TABLE.html
CREATE SHARDED TABLE departments
( department_id NUMBER(6)
, department_name VARCHAR2(30) CONSTRAINT dept_name_nn NOT NULL
, manager_id NUMBER(6)
, location_id NUMBER(4)
, CONSTRAINT dept_id_pk PRIMARY KEY(department_id)
)
PARTITION BY DIRECTORY (department_id)
(
PARTITION p_1 TABLESPACE tbs1,
PARTITION p_2 TABLESPACE tbs2
);
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-TABLE-128.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-TABLE.html
ALTER TABLE departments ADD
PARTITION p_3 TABLESPACE tbs3,
PARTITION p_4 TABLESPACE tbs4;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-TABLE-129.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-TABLE.html
ALTER TABLE departments
SPLIT PARTITION p_1 INTO
(PARTITION p_1 TABLESPACE tbs1,
PARTITION p_3 TABLESPACE tbs3)
UPDATE INDEXES;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-TABLE-13.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-TABLE.html
ALTER TABLE JOBS_Temp ADD CONSTRAINT chk_sal_min CHECK (MIN_SALARY >=2010);
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-TABLE-14.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-TABLE.html
SELECT * FROM JOBS_Temp WHERE MIN_SALARY < 3000;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-TABLE-15.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-TABLE.html
SELECT CONSTRAINT_NAME FROM USER_CONSTRAINTS WHERE TABLE_NAME='JOBS_TEMP';
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-TABLE-16.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-TABLE.html
CREATE TABLE product(
id NUMBER NOT NULL PRIMARY KEY,
name VARCHAR2(50),
price NUMBER CHECK (mod(price,4) = 0 and 10 <> price) PRECHECK,
color NUMBER CHECK (color >= 10 and color <=50 and mod(color,2) = 0)
PRECHECK,
description VARCHAR2(50) CHECK (length(description) <= 40) PRECHECK,
constant NUMBER CHECK (constant=10) PRECHECK,
CONSTRAINT TC1 CHECK (color > 0 AND price > 10) PRECHECK,
CONSTRAINT TC2 CHECK (CATEGORY IN ('home', 'apparel') AND price > 10)
);
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-TABLE-17.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-TABLE.html
ALTER TABLE product MODIFY (name VARCHAR2(50) CHECK
(regexp_like(name, '^Product')) PRECHECK);
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-TABLE-18.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-TABLE.html
ALTER TABLE product MODIFY CONSTRAINT TC2 PRECHECK;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-TABLE-19.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-TABLE.html
ALTER TABLE product MODIFY CONSTRAINT TC1 NOPRECHECK;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-TABLE-20.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-TABLE.html
ALTER TABLE print_media MODIFY NESTED TABLE ad_textdocs_ntab
RETURN AS VALUE;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-TABLE-21.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-TABLE.html
ALTER TABLE customers
PARALLEL;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-TABLE-22.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-TABLE.html
ALTER TABLE employees
ENABLE VALIDATE CONSTRAINT emp_manager_fk
EXCEPTIONS INTO exceptions;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-TABLE-23.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-TABLE.html
SELECT e.*
FROM employees e, exceptions ex
WHERE e.rowid = ex.row_id
AND ex.table_name = 'EMPLOYEES'
AND ex.constraint = 'EMP_MANAGER_FK';
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-TABLE-24.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-TABLE.html
ALTER TABLE employees
ENABLE NOVALIDATE PRIMARY KEY
ENABLE NOVALIDATE CONSTRAINT emp_last_name_nn;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-TABLE-25.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-TABLE.html
ALTER TABLE locations
MODIFY PRIMARY KEY DISABLE CASCADE;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-TABLE-26.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-TABLE.html
EXECUTE DBMS_IOT.BUILD_EXCEPTIONS_TABLE ('hr', 'countries', 'except_table');
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-TABLE-27.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-TABLE.html
ALTER TABLE countries
ENABLE PRIMARY KEY
EXCEPTIONS INTO except_table;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-TABLE-28.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-TABLE.html
ALTER TABLE employees ADD CONSTRAINT check_comp
CHECK (salary + (commission_pct*salary) <= 5000)
DISABLE;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-TABLE-29.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-TABLE.html
ALTER TABLE employees
ENABLE ALL TRIGGERS;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-TABLE-30.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-TABLE.html
ALTER TABLE employees
DEALLOCATE UNUSED;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-TABLE-31.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-TABLE.html
CREATE TABLE students (last_name VARCHAR2(20), id NUMBER);
INSERT INTO students VALUES('Dodd', 364);
INSERT INTO students VALUES('de Niro', 132);
INSERT INTO students VALUES('Vogel', 837);
INSERT INTO students VALUES('van der Kamp', 549);
INSERT INTO students VALUES('van Der Meer', 624);
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-TABLE-32.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-TABLE.html
SELECT last_name, id
FROM students
ORDER BY last_name;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-TABLE-33.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-TABLE.html
ALTER TABLE students
MODIFY (last_name COLLATE BINARY_CI);
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-TABLE-34.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-TABLE.html
SELECT last_name, id
FROM students
ORDER BY last_name;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-TABLE-35.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-TABLE.html
ALTER TABLE customers
RENAME COLUMN credit_limit TO credit_amount;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-TABLE-36.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-TABLE.html
CREATE TABLE t1 (
pk NUMBER PRIMARY KEY,
fk NUMBER,
c1 NUMBER,
c2 NUMBER,
CONSTRAINT ri FOREIGN KEY (fk) REFERENCES t1,
CONSTRAINT ck1 CHECK (pk > 0 and c1 > 0),
CONSTRAINT ck2 CHECK (c2 > 0)
);
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-TABLE-37.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-TABLE.html
ALTER TABLE t1 DROP (pk);
ALTER TABLE t1 DROP (c1);
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-TABLE-38.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-TABLE.html
ALTER TABLE t1 DROP (pk) CASCADE CONSTRAINTS;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-TABLE-39.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-TABLE.html
ALTER TABLE t1 DROP (pk, fk, c1);
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-TABLE-4.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-TABLE.html
ALTER TABLE t ADD (jcol JSON)
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-TABLE-40.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-TABLE.html
CREATE TABLE JOBS_Temp AS SELECT * FROM HR.JOBS;
SELECT * FROM JOBS_Temp WHERE MAX_SALARY > 20000;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-TABLE-41.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-TABLE.html
ALTER TABLE JOBS_Temp ADD (DUMMY1 NUMBER(2), DUMMY2 NUMBER(2));
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-TABLE-42.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-TABLE.html
INSERT INTO JOBS_Temp(JOB_ID, JOB_TITLE, DUMMY1, DUMMY2) VALUES ('D','DUMMY',10,20);
INSERT INTO JOBS_Temp(JOB_ID, JOB_TITLE, DUMMY1, DUMMY2) VALUES ('D','DUMMY',10,20)
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-TABLE-43.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-TABLE.html
ALTER TABLE JOBS_TEMP SET UNUSED (DUMMY1, DUMMY2);
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-TABLE-44.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-TABLE.html
SELECT * FROM USER_UNUSED_COL_TABS WHERE TABLE_NAME='JOBS_TEMP';
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-TABLE-45.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-TABLE.html
ALTER TABLE JOBS_TEMP DROP UNUSED COLUMNS;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-TABLE-46.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-TABLE.html
SELECT * FROM JOBS_TEMP;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-TABLE-47.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-TABLE.html
ALTER TABLE countries_demo INITRANS 4;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-TABLE-48.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-TABLE.html
ALTER TABLE countries_demo ADD OVERFLOW;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-TABLE-49.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-TABLE.html
ALTER TABLE countries_demo OVERFLOW INITRANS 4;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-TABLE-5.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-TABLE.html
CREATE DOMAIN phone_number as VARCHAR2(12)
CONSTRAINT CHECK (phone_number not like '%[0-9]%')
NOT NULL;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-TABLE-50.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-TABLE.html
ALTER TABLE sales SPLIT PARTITION SALES_Q4_2000
AT (TO_DATE('15-NOV-2000','DD-MON-YYYY'))
INTO (PARTITION SALES_Q4_2000, PARTITION SALES_Q4_2000b);
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-TABLE-51.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-TABLE.html
ALTER TABLE sales SPLIT PARTITION SALES_Q1_2002 INTO (
PARTITION SALES_JAN_2002 VALUES LESS THAN (TO_DATE('01-FEB-2002','DD-MON-YYYY')),
PARTITION SALES_FEB_2002 VALUES LESS THAN (TO_DATE('01-MAR-2002','DD-MON-YYYY')),
PARTITION SALES_MAR_2002);
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-TABLE-52.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-TABLE.html
CREATE TABLE print_media_part (
product_id NUMBER(6),
ad_id NUMBER(6),
ad_composite BLOB,
ad_sourcetext CLOB,
ad_finaltext CLOB,
ad_fltextn NCLOB,
ad_textdocs_ntab TEXTDOC_TAB,
ad_photo BLOB,
ad_graphic BFILE,
ad_header ADHEADER_TYP)
NESTED TABLE ad_textdocs_ntab STORE AS textdoc_nt
PARTITION BY RANGE (product_id)
(PARTITION p1 VALUES LESS THAN (100),
PARTITION p2 VALUES LESS THAN (200));
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-TABLE-53.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-TABLE.html
ALTER TABLE print_media_part
SPLIT PARTITION p2 AT (150) INTO
(PARTITION p2a TABLESPACE omf_ts1
LOB (ad_photo, ad_composite) STORE AS (TABLESPACE omf_ts2),
PARTITION p2b
LOB (ad_photo, ad_composite) STORE AS (TABLESPACE omf_ts2))
NESTED TABLE ad_textdocs_ntab INTO (PARTITION nt_p2a, PARTITION nt_p2b);
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-TABLE-54.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-TABLE.html
ALTER TABLE sales
MERGE PARTITIONS sales_q4_2000, sales_q4_2000b
INTO PARTITION sales_q4_2000;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-TABLE-55.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-TABLE.html
ALTER TABLE print_media_part
MERGE PARTITIONS p2a, p2b INTO PARTITION p2ab TABLESPACE example
NESTED TABLE ad_textdocs_ntab STORE AS nt_p2ab;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-TABLE-56.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-TABLE.html
ALTER TABLE sales
MERGE PARTITIONS sales_q1_2000 TO sales_q4_2000
INTO PARTITION sales_all_2000;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-TABLE-57.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-TABLE.html
ALTER TABLE print_media_part ADD PARTITION p3 VALUES LESS THAN (400)
LOB(ad_photo, ad_composite) STORE AS (TABLESPACE omf_ts1)
LOB(ad_sourcetext, ad_finaltext) STORE AS (TABLESPACE omf_ts2)
NESTED TABLE ad_textdocs_ntab STORE AS nt_p3;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-TABLE-58.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-TABLE.html
ALTER TABLE print_media_part ADD
PARTITION p3 values less than (300),
PARTITION p4 values less than (400),
PARTITION p5 values less than (500);
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-TABLE-59.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-TABLE.html
ALTER TABLE list_customers SPLIT PARTITION rest
VALUES ('MEXICO', 'COLOMBIA')
INTO (PARTITION south, PARTITION rest);
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-TABLE-6.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-TABLE.html
ALTER TABLE customers ADD (cust_cell_phone_number Varchar2(12) DOMAIN phone_number);
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-TABLE-60.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-TABLE.html
ALTER TABLE list_customers
MERGE PARTITIONS asia, rest INTO PARTITION rest;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-TABLE-61.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-TABLE.html
ALTER TABLE list_customers SPLIT PARTITION rest
VALUES ('CHINA', 'THAILAND')
INTO (PARTITION asia, PARTITION rest);
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-TABLE-62.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-TABLE.html
ALTER TABLE print_media_part DROP PARTITION p3;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-TABLE-63.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-TABLE.html
CREATE TABLE exchange_table (
customer_id NUMBER(6),
cust_first_name VARCHAR2(20),
cust_last_name VARCHAR2(20),
cust_address CUST_ADDRESS_TYP,
nls_territory VARCHAR2(30),
cust_email VARCHAR2(40));
ALTER TABLE list_customers
EXCHANGE PARTITION rest WITH TABLE exchange_table
WITHOUT VALIDATION;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-TABLE-64.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-TABLE.html
ALTER TABLE list_customers MODIFY PARTITION asia
UNUSABLE LOCAL INDEXES;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-TABLE-65.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-TABLE.html
ALTER TABLE list_customers MODIFY PARTITION asia
REBUILD UNUSABLE LOCAL INDEXES;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-TABLE-66.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-TABLE.html
ALTER TABLE print_media_part
MOVE PARTITION p2b TABLESPACE omf_ts1;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-TABLE-67.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-TABLE.html
ALTER TABLE sales RENAME PARTITION sales_q4_2003 TO sales_currentq;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-TABLE-68.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-TABLE.html
ALTER TABLE print_media_demo
TRUNCATE PARTITION p1 DROP STORAGE;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-TABLE-69.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-TABLE.html
ALTER TABLE sales SPLIT PARTITION sales_q1_2000
AT (TO_DATE('16-FEB-2000','DD-MON-YYYY'))
INTO (PARTITION q1a_2000, PARTITION q1b_2000)
UPDATE GLOBAL INDEXES;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-TABLE-7.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-TABLE.html
ALTER TABLE customers ADD (cust_cell_phone_number Varchar2(12) DOMAIN phone_number DEFAULT ON NULL '650-000-0000');
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-TABLE-70.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-TABLE.html
CREATE INDEX cost_ix ON costs(channel_id) LOCAL;
ALTER TABLE costs
SPLIT PARTITION costs_q4_2003 at
(TO_DATE('01-Nov-2003','dd-mon-yyyy'))
INTO (PARTITION c_p1, PARTITION c_p2)
UPDATE INDEXES (cost_ix (PARTITION c_p1 tablespace tbs_02,
PARTITION c_p2 tablespace tbs_03));
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-TABLE-71.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-TABLE.html
CREATE TYPE emp_t AS OBJECT (empno NUMBER, address CHAR(30));
CREATE TABLE emp OF emp_t (
empno PRIMARY KEY)
OBJECT IDENTIFIER IS PRIMARY KEY;
CREATE TABLE dept (dno NUMBER, mgr_ref REF emp_t SCOPE is emp);
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-TABLE-72.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-TABLE.html
ALTER TABLE dept ADD CONSTRAINT mgr_cons FOREIGN KEY (mgr_ref)
REFERENCES emp;
ALTER TABLE dept ADD sr_mgr REF emp_t REFERENCES emp;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-TABLE-73.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-TABLE.html
ALTER TABLE countries
ADD (duty_pct NUMBER(2,2) CHECK (duty_pct < 10.5),
visa_needed VARCHAR2(3));
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-TABLE-74.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-TABLE.html
CREATE TABLE emp2 AS SELECT * FROM employees;
ALTER TABLE emp2 ADD (income AS (salary + (salary*commission_pct)));
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-TABLE-75.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-TABLE.html
ALTER TABLE countries
MODIFY (duty_pct NUMBER(3,2));
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-TABLE-76.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-TABLE.html
ALTER TABLE employees
PCTFREE 30
PCTUSED 60;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-TABLE-77.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-TABLE.html
CREATE TABLE JOBS_TEMP AS SELECT * FROM HR.JOBS;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-TABLE-78.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-TABLE.html
SELECT initial_extent,
next_extent,
min_extents,
max_extents,
pct_increase,
blocks,
sample_size
FROM user_tables
WHERE table_name = 'JOBS_TEMP';
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-TABLE-79.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-TABLE.html
ALTER TABLE JOBS_TEMP MOVE
STORAGE ( INITIAL 20K
NEXT 40K
MINEXTENTS 2
MAXEXTENTS 20
PCTINCREASE 0 )
TABLESPACE USERS;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-TABLE-8.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-TABLE.html
ALTER TABLE t1 DROP COLUMN f1 DROP (f2);
ALTER TABLE t1 DROP COLUMN f1 SET UNUSED (f2);
ALTER TABLE t1 DROP (f1) ADD (f2 NUMBER);
ALTER TABLE t1 SET UNUSED (f3)
ADD (CONSTRAINT ck1 CHECK (f2 > 0));
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-TABLE-80.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-TABLE.html
SELECT initial_extent,
next_extent,
min_extents,
max_extents,
pct_increase,
blocks,
sample_size
FROM user_tables
WHERE table_name = 'JOBS_TEMP';
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-TABLE-81.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-TABLE.html
CREATE TABLE JOBS_Temp AS SELECT * FROM HR.JOBS;
SELECT * FROM JOBS_Temp WHERE MAX_SALARY > 30000;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-TABLE-82.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-TABLE.html
ALTER TABLE JOBS_Temp MODIFY(JOB_TITLE VARCHAR2(100));
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-TABLE-83.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-TABLE.html
ALTER TABLE JOBS_Temp ADD (BONUS NUMBER (7,2), COMM NUMBER (5,2), DUMMY NUMBER(2));
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-TABLE-84.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-TABLE.html
SELECT JOB_ID, BONUS, COMM, DUMMY FROM JOBS_Temp WHERE MAX_SALARY > 20000;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-TABLE-85.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-TABLE.html
ALTER TABLE JOBS_Temp RENAME COLUMN COMM TO COMMISSION;
SELECT JOB_ID, COMMISSION FROM JOBS_Temp WHERE MAX_SALARY > 20000;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-TABLE-86.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-TABLE.html
ALTER TABLE JOBS_Temp DROP COLUMN DUMMY;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-TABLE-87.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-TABLE.html
ALTER TABLE JOBS_Temp DROP (BONUS, COMMISSION);
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-TABLE-88.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-TABLE.html
ALTER TABLE employees
MODIFY (salary ENCRYPT USING 'AES256' 'NOMAC');
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-TABLE-89.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-TABLE.html
ALTER TABLE customers
ADD (online_acct_pw VARCHAR2(8) ENCRYPT 'NOMAC' NO SALT);
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-TABLE-9.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-TABLE.html
ALTER TABLE imm_tab NO DROP UNTIL 50 DAYS IDLE;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-TABLE-90.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-TABLE.html
ALTER TABLE customers
MODIFY (online_acct_pw DECRYPT);
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-TABLE-91.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-TABLE.html
ALTER TABLE employees
ALLOCATE EXTENT (SIZE 5K INSTANCE 4);
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-TABLE-92.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-TABLE.html
ALTER TABLE product_information
MODIFY (min_price DEFAULT 10);
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-TABLE-93.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-TABLE.html
INSERT INTO product_information (product_id, product_name,
list_price)
VALUES (300, 'left-handed mouse', 40.50);
SELECT product_id, product_name, list_price, min_price
FROM product_information
WHERE product_id = 300;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-TABLE-94.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-TABLE.html
ALTER TABLE product_information
MODIFY (min_price DEFAULT NULL);
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-TABLE-95.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-TABLE.html
CREATE SEQUENCE s1 START WITH 1;
CREATE TABLE t1 (name VARCHAR2(10));
INSERT INTO t1 VALUES('Kevin');
INSERT INTO t1 VALUES('Julia');
INSERT INTO t1 VALUES('Ryan');
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-TABLE-96.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-TABLE.html
ALTER TABLE t1 ADD (id NUMBER DEFAULT ON NULL s1.NEXTVAL NOT NULL);
SELECT id, name FROM t1 ORDER BY id;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-TABLE-97.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-TABLE.html
INSERT INTO t1(id, name) VALUES(NULL, 'Sean');
SELECT id, name FROM t1 ORDER BY id;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-TABLE-98.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-TABLE.html
ALTER TABLE xwarehouses
ADD (PRIMARY KEY(XMLDATA."WarehouseID"));
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-TABLE-99.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-TABLE.html
ALTER TABLE customers RENAME CONSTRAINT cust_fname_nn
TO cust_firstname_nn;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-TABLESPACE-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-TABLESPACE.html
ALTER SYSTEM SET UNDO_TABLESPACE = new_tablespace_name SCOPE = MEMORY;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-TABLESPACE-1.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-TABLESPACE.html
ALTER TABLESPACE tbsu1 ENABLE LOST WRITE PROTECTION
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-TABLESPACE-10.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-TABLESPACE.html
ALTER TABLESPACE tbs_03
DROP DATAFILE 'tbs_f04.dbf';
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-TABLESPACE-11.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-TABLESPACE.html
ALTER TABLESPACE temp_demo ADD TEMPFILE 'temp05.dbf' SIZE 5 AUTOEXTEND ON;
ALTER TABLESPACE temp_demo DROP TEMPFILE 'temp05.dbf';
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-TABLESPACE-12.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-TABLESPACE.html
ALTER TABLESPACE temp_demo SHRINK SPACE;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-TABLESPACE-13.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-TABLESPACE.html
ALTER TABLESPACE omf_ts1 ADD DATAFILE;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-TABLESPACE-14.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-TABLESPACE.html
ALTER TABLESPACE tbs_03 NOLOGGING;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-TABLESPACE-15.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-TABLESPACE.html
ALTER TABLESPACE undots1
RETENTION NOGUARANTEE;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-TABLESPACE-16.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-TABLESPACE.html
ALTER TABLESPACE undots1
RETENTION GUARANTEE;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-TABLESPACE-2.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-TABLESPACE.html
ALTER TABLESPACE tbsu1 REMOVE LOST WRITE PROTECTION
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-TABLESPACE-3.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-TABLESPACE.html
ALTER TABLESPACE tbsu1 SUSPEND LOST WRITE PROTECTION
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-TABLESPACE-4.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-TABLESPACE.html
ALTER TABLESPACE tbs_01
BEGIN BACKUP;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-TABLESPACE-5.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-TABLESPACE.html
ALTER TABLESPACE tbs_01
END BACKUP;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-TABLESPACE-6.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-TABLESPACE.html
ALTER TABLESPACE tbs_02 OFFLINE NORMAL;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-TABLESPACE-7.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-TABLESPACE.html
ALTER TABLESPACE tbs_02
RENAME DATAFILE 'diskb:tbs_f5.dbf'
TO 'diska:tbs_f5.dbf';
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-TABLESPACE-8.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-TABLESPACE.html
ALTER TABLESPACE tbs_02 ONLINE;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-TABLESPACE-9.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-TABLESPACE.html
ALTER TABLESPACE tbs_03
ADD DATAFILE 'tbs_f04.dbf'
SIZE 100K
AUTOEXTEND ON
NEXT 10K
MAXSIZE 100K;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-TABLESPACE-SET-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-TABLESPACE-SET.html
ALTER TABLESPACE SET ts1
FORCE LOGGING;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-USER-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-USER.html
ALTER USER u1 IDENTIFIED BY p3;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-USER-1.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-USER.html
ALTER USER u1 IDENTIFIED BY p3 REPLACE p1;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-USER-10.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-USER.html
ALTER USER sidney PASSWORD EXPIRE;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-USER-11.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-USER.html
ALTER USER sh
TEMPORARY TABLESPACE tbs_grp_01;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-USER-12.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-USER.html
ALTER USER app_user1
GRANT CONNECT THROUGH sh
WITH ROLE warehouse_user;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-USER-13.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-USER.html
ALTER USER app_user1 REVOKE CONNECT THROUGH sh;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-USER-14.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-USER.html
ALTER USER sully GRANT CONNECT THROUGH OAS1
AUTHENTICATED USING PASSWORD;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-USER-15.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-USER.html
ALTER USER app_user1
GRANT CONNECT THROUGH ENTERPRISE USERS;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-USER-2.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-USER.html
ALTER USER u1 IDENTIFIED BY p3 REPLACE p2;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-USER-4.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-USER.html
ALTER USER user PASSWORD EXPIRE HTTP DIGEST ENABLE;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-USER-5.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-USER.html
ALTER USER user PASSWORD EXPIRE HTTP DIGEST DISABLE;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-USER-6.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-USER.html
ALTER USER sidney
IDENTIFIED BY second_2nd_pwd
DEFAULT TABLESPACE example;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-USER-7.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-USER.html
ALTER USER sh
PROFILE new_profile;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-USER-8.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-USER.html
ALTER USER sh
DEFAULT ROLE ALL EXCEPT dw_manager;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-USER-9.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-USER.html
ALTER USER app_user1 IDENTIFIED GLOBALLY AS 'CN=tom,O=oracle,C=US';
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-VIEW-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-VIEW.html
ALTER VIEW customer_ro
COMPILE;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ALTER-VIEW-1.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-VIEW.html
ALTER VIEW HighWageEmp ANNOTATIONS(DROP Title, ADD Identity);
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ANALYZE-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ANALYZE.html
ANALYZE TABLE orders DELETE STATISTICS;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ANALYZE-1.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ANALYZE.html
ANALYZE INDEX inv_product_ix VALIDATE STRUCTURE;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ANALYZE-2.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ANALYZE.html
ANALYZE TABLE employees VALIDATE STRUCTURE CASCADE;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ANALYZE-3.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ANALYZE.html
ANALYZE TABLE customers VALIDATE REF UPDATE;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ANALYZE-4.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ANALYZE.html
ANALYZE TABLE customers VALIDATE STRUCTURE ONLINE;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ANALYZE-5.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ANALYZE.html
ANALYZE CLUSTER personnel
VALIDATE STRUCTURE CASCADE;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ANALYZE-6.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ANALYZE.html
ANALYZE TABLE orders
LIST CHAINED ROWS INTO chained_rows;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ANALYZE-7.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ANALYZE.html
SELECT owner_name, table_name, head_rowid, analyze_timestamp
FROM chained_rows
ORDER BY owner_name, table_name, head_rowid, analyze_timestamp;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ANY_VALUE-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ANY_VALUE.html
SELECT c.cust_id, ANY_VALUE(cust_last_name), SUM(amount_sold)
FROM customers c, sales s
WHERE s.cust_id = c.cust_id
GROUP BY c.cust_id;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/APPROX_COUNT-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/APPROX_COUNT.html
SELECT department_id, job_id,
APPROX_COUNT(*)
FROM employees
GROUP BY department_id, job_id
HAVING
APPROX_RANK (
PARTITION BY department_id
ORDER BY APPROX_COUNT(*)
DESC ) <= 10;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/APPROX_COUNT_DISTINCT-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/APPROX_COUNT_DISTINCT.html
SELECT APPROX_COUNT_DISTINCT(manager_id) AS "Active Managers"
FROM employees;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/APPROX_COUNT_DISTINCT-1.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/APPROX_COUNT_DISTINCT.html
SELECT prod_id, APPROX_COUNT_DISTINCT(cust_id) AS "Number of Customers"
FROM sales
GROUP BY prod_id
ORDER BY prod_id;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/APPROX_COUNT_DISTINCT_DETAIL-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/APPROX_COUNT_DISTINCT_DETAIL.html
CREATE MATERIALIZED VIEW daily_prod_count_mv AS
SELECT t.calendar_year year,
t.calendar_month_number month,
t.day_number_in_month day,
APPROX_COUNT_DISTINCT_DETAIL(s.prod_id) daily_detail
FROM times t, sales s
WHERE t.time_id = s.time_id
GROUP BY t.calendar_year, t.calendar_month_number, t.day_number_in_month;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/APPROX_COUNT_DISTINCT_DETAIL-1.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/APPROX_COUNT_DISTINCT_DETAIL.html
CREATE MATERIALIZED VIEW monthly_prod_count_mv AS
SELECT year,
month,
APPROX_COUNT_DISTINCT_AGG(daily_detail) monthly_detail
FROM daily_prod_count_mv
GROUP BY year, month;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/APPROX_COUNT_DISTINCT_DETAIL-2.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/APPROX_COUNT_DISTINCT_DETAIL.html
CREATE MATERIALIZED VIEW annual_prod_count_mv AS
SELECT year,
APPROX_COUNT_DISTINCT_AGG(daily_detail) annual_detail
FROM daily_prod_count_mv
GROUP BY year;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/APPROX_COUNT_DISTINCT_DETAIL-3.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/APPROX_COUNT_DISTINCT_DETAIL.html
SELECT year,
month,
day,
TO_APPROX_COUNT_DISTINCT(daily_detail) "NUM PRODUCTS"
FROM daily_prod_count_mv
ORDER BY year, month, day;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/APPROX_COUNT_DISTINCT_DETAIL-4.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/APPROX_COUNT_DISTINCT_DETAIL.html
SELECT year,
month,
TO_APPROX_COUNT_DISTINCT(monthly_detail) "NUM PRODUCTS"
FROM monthly_prod_count_mv
ORDER BY year, month;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/APPROX_COUNT_DISTINCT_DETAIL-5.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/APPROX_COUNT_DISTINCT_DETAIL.html
SELECT year,
TO_APPROX_COUNT_DISTINCT(annual_detail) "NUM PRODUCTS"
FROM annual_prod_count_mv
ORDER BY year;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/APPROX_MEDIAN-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/APPROX_MEDIAN.html
SELECT department_id "Department",
APPROX_MEDIAN(salary DETERMINISTIC) "Median Salary"
FROM employees
GROUP BY department_id
ORDER BY department_id;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/APPROX_MEDIAN-1.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/APPROX_MEDIAN.html
SELECT department_id "Department",
APPROX_MEDIAN(salary DETERMINISTIC, 'ERROR_RATE') "Error Rate"
FROM employees
GROUP BY department_id
ORDER BY department_id;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/APPROX_MEDIAN-2.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/APPROX_MEDIAN.html
SELECT department_id "Department",
APPROX_MEDIAN(salary DETERMINISTIC, 'CONFIDENCE') "Confidence Level"
FROM employees
GROUP BY department_id
ORDER BY department_id;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/APPROX_MEDIAN-3.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/APPROX_MEDIAN.html
SELECT department_id "Department",
APPROX_MEDIAN(hire_date) "Median Hire Date"
FROM employees
GROUP BY department_id
ORDER BY department_id;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/APPROX_PERCENTILE-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/APPROX_PERCENTILE.html
SELECT department_id "Department",
APPROX_PERCENTILE(0.25 DETERMINISTIC)
WITHIN GROUP (ORDER BY salary ASC) "25th Percentile Salary",
APPROX_PERCENTILE(0.50 DETERMINISTIC)
WITHIN GROUP (ORDER BY salary ASC) "50th Percentile Salary",
APPROX_PERCENTILE(0.75 DETERMINISTIC)
WITHIN GROUP (ORDER BY salary ASC) "75th Percentile Salary"
FROM employees
GROUP BY department_id
ORDER BY department_id;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/APPROX_PERCENTILE-1.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/APPROX_PERCENTILE.html
SELECT department_id "Department",
APPROX_PERCENTILE(0.25 DETERMINISTIC, 'ERROR_RATE')
WITHIN GROUP (ORDER BY salary ASC) "Error Rate"
FROM employees
GROUP BY department_id
ORDER BY department_id;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/APPROX_PERCENTILE-2.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/APPROX_PERCENTILE.html
SELECT department_id "Department",
APPROX_PERCENTILE(0.25 DETERMINISTIC, 'CONFIDENCE')
WITHIN GROUP (ORDER BY salary ASC) "Confidence"
FROM employees
GROUP BY department_id
ORDER BY department_id;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/APPROX_PERCENTILE-3.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/APPROX_PERCENTILE.html
SELECT department_id "Department",
APPROX_PERCENTILE(0.25)
WITHIN GROUP (ORDER BY salary ASC) "25th Percentile Salary",
APPROX_PERCENTILE(0.50)
WITHIN GROUP (ORDER BY salary ASC) "50th Percentile Salary",
APPROX_PERCENTILE(0.75)
WITHIN GROUP (ORDER BY salary ASC) "75th Percentile Salary"
FROM employees
GROUP BY department_id
ORDER BY department_id;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/APPROX_PERCENTILE_DETAIL-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/APPROX_PERCENTILE_DETAIL.html
CREATE MATERIALIZED VIEW amt_sold_by_city_mv
ENABLE QUERY REWRITE AS
SELECT c.country_id country,
c.cust_state_province state,
c.cust_city city,
APPROX_PERCENTILE_DETAIL(s.amount_sold) city_detail
FROM customers c, sales s
WHERE c.cust_id = s.cust_id
GROUP BY c.country_id, c.cust_state_province, c.cust_city;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/APPROX_PERCENTILE_DETAIL-1.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/APPROX_PERCENTILE_DETAIL.html
CREATE MATERIALIZED VIEW amt_sold_by_state_mv AS
SELECT country,
state,
APPROX_PERCENTILE_AGG(city_detail) state_detail
FROM amt_sold_by_city_mv
GROUP BY country, state;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/APPROX_PERCENTILE_DETAIL-2.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/APPROX_PERCENTILE_DETAIL.html
CREATE MATERIALIZED VIEW amt_sold_by_country_mv AS
SELECT country,
APPROX_PERCENTILE_AGG(city_detail) country_detail
FROM amt_sold_by_city_mv
GROUP BY country;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/APPROX_PERCENTILE_DETAIL-3.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/APPROX_PERCENTILE_DETAIL.html
SELECT country,
state,
city,
TO_APPROX_PERCENTILE(city_detail, .25, 'NUMBER') "25th Percentile",
TO_APPROX_PERCENTILE(city_detail, .50, 'NUMBER') "50th Percentile",
TO_APPROX_PERCENTILE(city_detail, .75, 'NUMBER') "75th Percentile"
FROM amt_sold_by_city_mv
ORDER BY country, state, city;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/APPROX_PERCENTILE_DETAIL-4.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/APPROX_PERCENTILE_DETAIL.html
SELECT country,
state,
TO_APPROX_PERCENTILE(state_detail, .25, 'NUMBER') "25th Percentile",
TO_APPROX_PERCENTILE(state_detail, .50, 'NUMBER') "50th Percentile",
TO_APPROX_PERCENTILE(state_detail, .75, 'NUMBER') "75th Percentile"
FROM amt_sold_by_state_mv
ORDER BY country, state;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/APPROX_PERCENTILE_DETAIL-5.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/APPROX_PERCENTILE_DETAIL.html
SELECT country,
TO_APPROX_PERCENTILE(country_detail, .25, 'NUMBER') "25th Percentile",
TO_APPROX_PERCENTILE(country_detail, .50, 'NUMBER') "50th Percentile",
TO_APPROX_PERCENTILE(country_detail, .75, 'NUMBER') "75th Percentile"
FROM amt_sold_by_country_mv
ORDER BY country;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/APPROX_PERCENTILE_DETAIL-6.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/APPROX_PERCENTILE_DETAIL.html
SELECT country,
TO_APPROX_PERCENTILE(APPROX_PERCENTILE_AGG(city_detail), .25, 'NUMBER') "25th Percentile"
FROM amt_sold_by_city_mv
GROUP BY country
ORDER BY country;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/APPROX_PERCENTILE_DETAIL-7.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/APPROX_PERCENTILE_DETAIL.html
SELECT c.country_id country,
APPROX_MEDIAN(s.amount_sold) amount_median
FROM customers c, sales s
WHERE c.cust_id = s.cust_id
GROUP BY c.country_id;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/APPROX_PERCENTILE_DETAIL-8.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/APPROX_PERCENTILE_DETAIL.html
SET LINESIZE 300
SET PAGESIZE 0
COLUMN plan_table_output FORMAT A150
SELECT * FROM TABLE(DBMS_XPLAN.DISPLAY_CURSOR(format=>'BASIC'));
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/APPROX_RANK-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/APPROX_RANK.html
SELECT job_id,
APPROX_SUM(sal),
APPROX_RANK(PARTITION BY department_id ORDER BY APPROX_SUM(salary) DESC)
FROM employees
GROUP BY department_id, job_id
HAVING
APPROX_RANK(
PARTITION BY department_id
ORDER BY APPROX_SUM (salary)
DESC) <= 10;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/APPROX_SUM-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/APPROX_SUM.html
SELECT department_id, job_id,
APPROX_SUM(salary)
FROM employees
GROUP BY department_id, job_id
HAVING
APPROX_RANK (
PARTITION BY department_id
ORDER BY APPROX_SUM(salary)
DESC ) <= 10;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ASCII-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ASCII.html
SELECT last_name
FROM employees
WHERE ASCII(SUBSTR(last_name, 1, 1)) = 76
ORDER BY last_name;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ASCIISTR-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ASCIISTR.html
SELECT ASCIISTR('ABÄCDE')
FROM DUAL;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ASIN-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ASIN.html
SELECT ASIN(.3) "Arc_Sine"
FROM DUAL;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ASSOCIATE-STATISTICS-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ASSOCIATE-STATISTICS.html
ASSOCIATE STATISTICS WITH PACKAGES emp_mgmt DEFAULT SELECTIVITY 10;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ASSOCIATE-STATISTICS-1.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ASSOCIATE-STATISTICS.html
ASSOCIATE STATISTICS WITH INDEXES salary_index DEFAULT COST (100,5,0);
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ATAN-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ATAN.html
SELECT ATAN(.3) "Arc_Tangent"
FROM DUAL;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ATAN2-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ATAN2.html
SELECT ATAN2(.3, .2) "Arc_Tangent2"
FROM DUAL;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/AUDIT-Unified-Auditing-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/AUDIT-Unified-Auditing.html
AUDIT POLICY table_pol;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/AUDIT-Unified-Auditing-1.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/AUDIT-Unified-Auditing.html
SELECT policy_name, enabled_option, entity_name
FROM audit_unified_enabled_policies
WHERE policy_name = 'TABLE_POL';
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/AUDIT-Unified-Auditing-2.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/AUDIT-Unified-Auditing.html
AUDIT POLICY dml_pol BY hr, sh;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/AUDIT-Unified-Auditing-3.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/AUDIT-Unified-Auditing.html
SELECT policy_name, enabled_option, entity_name
FROM audit_unified_enabled_policies
WHERE policy_name = 'DML_POL'
ORDER BY entity_name;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/AUDIT-Unified-Auditing-4.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/AUDIT-Unified-Auditing.html
AUDIT POLICY read_dir_pol EXCEPT hr;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/AUDIT-Unified-Auditing-5.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/AUDIT-Unified-Auditing.html
SELECT policy_name, enabled_option, entity_name
FROM audit_unified_enabled_policies
WHERE policy_name = 'READ_DIR_POL';
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/AUDIT-Unified-Auditing-6.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/AUDIT-Unified-Auditing.html
AUDIT POLICY security_pol BY hr WHENEVER NOT SUCCESSFUL;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/AUDIT-Unified-Auditing-7.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/AUDIT-Unified-Auditing.html
SELECT policy_name, enabled_option, entity_name, success, failure
FROM audit_unified_enabled_policies
WHERE policy_name = 'SECURITY_POL';
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/AUDIT-Unified-Auditing-8.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/AUDIT-Unified-Auditing.html
AUDIT CONTEXT NAMESPACE userenv
ATTRIBUTES current_user, db_name
BY hr;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/AVG-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/AVG.html
SELECT AVG(salary) "Average"
FROM employees;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/AVG-1.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/AVG.html
SELECT manager_id, last_name, hire_date, salary,
AVG(salary) OVER (PARTITION BY manager_id ORDER BY hire_date
ROWS BETWEEN 1 PRECEDING AND 1 FOLLOWING) AS c_mavg
FROM employees
ORDER BY manager_id, hire_date, salary;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/About-SQL-Expressions-2.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/About-SQL-Expressions.html
SET last_name = 'Smith';
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/About-SQL-Expressions-3.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/About-SQL-Expressions.html
SET last_name = INITCAP(last_name);
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/About-User-Defined-Functions-1.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/About-User-Defined-Functions.html
SELECT new_sal FROM new_emps;
SELECT new_emps.new_sal FROM new_emps;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/About-User-Defined-Functions-2.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/About-User-Defined-Functions.html
SELECT hr.new_sal FROM new_emps;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/About-User-Defined-Functions-4.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/About-User-Defined-Functions.html
SELECT hr.tax_rate (ss_no, sal)
INTO income_tax
FROM tax_table WHERE ss_no = tax_id;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/Aggregate-Functions-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/Aggregate-Functions.html
SELECT AVG(MAX(salary))
FROM employees
GROUP BY department_id;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/Arithmetic-Operators-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/Arithmetic-Operators.html
SELECT *
FROM order_items
WHERE quantity = -1
ORDER BY order_id,
line_item_id, product_id;
SELECT *
FROM employees
WHERE -salary < 0
ORDER BY employee_id;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/Arithmetic-Operators-1.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/Arithmetic-Operators.html
SELECT hire_date
FROM employees
WHERE SYSDATE - hire_date > 365
ORDER BY hire_date;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/Arithmetic-Operators-2.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/Arithmetic-Operators.html
UPDATE employees
SET salary = salary * 1.1;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/Automatic-Locks-in-DML-Operations-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/Automatic-Locks-in-DML-Operations.html
UPDATE t SET x = ( SELECT y FROM t2 WHERE t2.z = t.z ) WHERE a > 5;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/BETWEEN-Condition-5.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/BETWEEN-Condition.html
SELECT * FROM employees
WHERE salary
BETWEEN 2000 AND 3000
ORDER BY employee_id;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/BFILENAME-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/BFILENAME.html
CREATE DIRECTORY media_dir AS '/demo/schema/product_media';
INSERT INTO print_media (product_id, ad_id, ad_graphic)
VALUES (3000, 31001, BFILENAME('MEDIA_DIR', 'modem_comp_ad.gif'));
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/BIN_TO_NUM-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/BIN_TO_NUM.html
SELECT BIN_TO_NUM(1,0,1,0)
FROM DUAL;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/BIN_TO_NUM-1.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/BIN_TO_NUM.html
SELECT order_status
FROM orders
WHERE order_id = 2441;
DECLARE
warehouse NUMBER := 1;
ground NUMBER := 1;
insured NUMBER := 1;
result NUMBER;
BEGIN
SELECT BIN_TO_NUM(warehouse, ground, insured) INTO result FROM DUAL;
UPDATE orders SET order_status = result WHERE order_id = 2441;
END;
/
SELECT order_status
FROM orders
WHERE order_id = 2441;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/BITAND-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/BITAND.html
SELECT BITAND(6,3)
FROM DUAL;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/BITAND-1.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/BITAND.html
SELECT BITAND(
BIN_TO_NUM(1,1,0),
BIN_TO_NUM(0,1,1)) "Binary"
FROM DUAL;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/BITAND-2.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/BITAND.html
SELECT order_id, customer_id, order_status,
DECODE(BITAND(order_status, 1), 1, 'Warehouse', 'PostOffice') "Location",
DECODE(BITAND(order_status, 2), 2, 'Ground', 'Air') "Method",
DECODE(BITAND(order_status, 4), 4, 'Insured', 'Certified') "Receipt"
FROM orders
WHERE sales_rep_id = 160
ORDER BY order_id;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/BIT_AND_AGG-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/BIT_AND_AGG.html
SELECT '011' num, bin_to_num(0,1,1) bits FROM dual
UNION ALL SELECT '101' num, bin_to_num(1,0,1) bits FROM dual;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/BIT_AND_AGG-1.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/BIT_AND_AGG.html
SELECT bit_and_agg(bits)
FROM (SELECT '011' num, bin_to_num(0,1,1) bits FROM dual
UNION ALL SELECT '101' num, bin_to_num(1,0,1) bits FROM dual);
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CALL-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CALL.html
CALL my_procedure(arg1 => 3, arg2 => 4)
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CALL-1.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CALL.html
CALL my_procedure(3, 4)
CALL my_procedure(3, arg2 => 4)
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CALL-2.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CALL.html
CALL emp_mgmt.remove_dept(162);
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CALL-3.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CALL.html
ALTER TYPE warehouse_typ
ADD MEMBER FUNCTION ret_name
RETURN VARCHAR2
CASCADE;
CREATE OR REPLACE TYPE BODY warehouse_typ
AS MEMBER FUNCTION ret_name
RETURN VARCHAR2
IS
BEGIN
RETURN self.warehouse_name;
END;
END;
/
VARIABLE x VARCHAR2(25);
CALL warehouse_typ(456, 'Warehouse 456', 2236).ret_name()
INTO :x;
PRINT x;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CALL-4.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CALL.html
CREATE OR REPLACE FUNCTION ret_warehouse_typ(x warehouse_typ)
RETURN warehouse_typ
IS
BEGIN
RETURN x;
END;
/
CALL ret_warehouse_typ(warehouse_typ(234, 'Warehouse 234',
2235)).ret_name()
INTO :x;
PRINT x;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CARDINALITY-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CARDINALITY.html
SELECT product_id, CARDINALITY(ad_textdocs_ntab) cardinality
FROM print_media
ORDER BY product_id;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CASE-Expressions-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CASE-Expressions.html
SELECT cust_last_name,
CASE credit_limit WHEN 100 THEN 'Low'
WHEN 5000 THEN 'High'
ELSE 'Medium' END AS credit
FROM customers
ORDER BY cust_last_name, credit;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CASE-Expressions-1.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CASE-Expressions.html
SELECT AVG(CASE WHEN e.salary > 2000 THEN e.salary
ELSE 2000 END) "Average Salary" FROM employees e;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CAST-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CAST.html
SELECT CAST('22-OCT-1997'
AS TIMESTAMP WITH LOCAL TIME ZONE)
FROM DUAL;
SELECT CAST(TO_DATE('22-Oct-1997', 'DD-Mon-YYYY')
AS TIMESTAMP WITH LOCAL TIME ZONE)
FROM DUAL;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CAST-1.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CAST.html
SELECT product_id, CAST(ad_sourcetext AS VARCHAR2(30)) text
FROM print_media
ORDER BY product_id;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CAST-10.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CAST.html
CREATE TABLE projects
(employee_id NUMBER, project_name VARCHAR2(10));
CREATE TABLE emps_short
(employee_id NUMBER, last_name VARCHAR2(10));
CREATE TYPE project_table_typ AS TABLE OF VARCHAR2(10);
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CAST-11.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CAST.html
SELECT e.last_name,
CAST(MULTISET(SELECT p.project_name
FROM projects p
WHERE p.employee_id = e.employee_id
ORDER BY p.project_name)
AS project_table_typ)
FROM emps_short e
ORDER BY e.last_name;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CAST-12.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CAST.html
SELECT
CAST ( 'yes' AS BOOLEAN ),
CAST ( true AS NUMBER ),
CAST ( false AS VARCHAR2(10) );
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CAST-13.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CAST.html
CREATE DOMAIN day_of_week AS VARCHAR2(3 CHAR)
CONSTRAINT CHECK (day_of_week IN('MON','TUE','WED','THU','FRI','SAT','SUN'))
DISABLE;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CAST-14.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CAST.html
SELECT CAST ( 'N/A' AS day_of_week ) use_constraint_state;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CAST-15.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CAST.html
SELECT CAST ( 'N/A' AS day_of_week VALIDATE ) apply_constraints;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CAST-16.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CAST.html
CREATE DOMAIN day_of_week AS VARCHAR2(3 CHAR)
CONSTRAINT CHECK (day_of_week IN('MON','TUE','WED','THU','FRI','SAT','SUN'))
ENABLE;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CAST-17.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CAST.html
SELECT CAST ( 'N/A' AS day_of_week ) use_constraint_state;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CAST-18.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CAST.html
SELECT CAST ( 'N/A' AS DOMAIN day_of_week NOVALIDATE ) ignore_constraints;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CAST-2.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CAST.html
SELECT CAST(200
AS NUMBER
DEFAULT 0 ON CONVERSION ERROR)
FROM DUAL;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CAST-3.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CAST.html
SELECT CAST('January 15, 1989, 11:00 A.M.'
AS DATE
DEFAULT NULL ON CONVERSION ERROR,
'Month dd, YYYY, HH:MI A.M.')
FROM DUAL;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CAST-4.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CAST.html
SELECT CAST('1999-12-01 11:00:00 -8:00'
AS TIMESTAMP WITH TIME ZONE
DEFAULT '2000-01-01 01:00:00 -8:00' ON CONVERSION ERROR,
'YYYY-MM-DD HH:MI:SS TZH:TZM',
'NLS_DATE_LANGUAGE = American')
FROM DUAL;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CAST-5.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CAST.html
SELECT CAST('N/A'
AS NUMBER
DEFAULT '0' ON CONVERSION ERROR)
FROM DUAL;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CAST-6.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CAST.html
SELECT
CAST ( 'yes' AS BOOLEAN ),
CAST ( true AS NUMBER ),
CAST ( false AS VARCHAR2(10) ) ;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CAST-7.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CAST.html
CREATE TYPE address_book_t AS TABLE OF cust_address_typ;
CREATE TYPE address_array_t AS VARRAY(3) OF cust_address_typ;
CREATE TABLE cust_address (
custno NUMBER,
street_address VARCHAR2(40),
postal_code VARCHAR2(10),
city VARCHAR2(30),
state_province VARCHAR2(10),
country_id CHAR(2));
CREATE TABLE cust_short (custno NUMBER, name VARCHAR2(31));
CREATE TABLE states (state_id NUMBER, addresses address_array_t);
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CAST-8.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CAST.html
SELECT s.custno, s.name,
CAST(MULTISET(SELECT ca.street_address,
ca.postal_code,
ca.city,
ca.state_province,
ca.country_id
FROM cust_address ca
WHERE s.custno = ca.custno)
AS address_book_t)
FROM cust_short s
ORDER BY s.custno;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CAST-9.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CAST.html
SELECT CAST(s.addresses AS address_book_t)
FROM states s
WHERE s.state_id = 111;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CEIL-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CEIL.html
SELECT order_total, CEIL(order_total)
FROM orders
WHERE order_id = 2434;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CHARTOROWID-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CHARTOROWID.html
SELECT last_name
FROM employees
WHERE ROWID = CHARTOROWID('AAAFd1AAFAAAABSAA/');
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CHR-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CHR.html
SELECT CHR(67)||CHR(65)||CHR(84) "Dog"
FROM DUAL;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CHR-1.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CHR.html
SELECT CHR(195)||CHR(193)||CHR(227) "Dog"
FROM DUAL;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CHR-2.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CHR.html
SELECT CHR(41378)
FROM DUAL;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CHR-3.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CHR.html
SELECT CHR(161)||CHR(162)
FROM DUAL;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CHR-4.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CHR.html
SELECT CHR(41378)||CHR(41379)
FROM DUAL;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CHR-5.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CHR.html
SELECT CHR (196 USING NCHAR_CS)
FROM DUAL;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CLUSTER_DETAILS-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CLUSTER_DETAILS.html
SELECT S.cluster_id, probability prob,
CLUSTER_DETAILS(em_sh_clus_sample, S.cluster_id, 5 USING T.*) det
FROM
(SELECT v.*, CLUSTER_SET(em_sh_clus_sample, NULL, 0.2 USING *) pset
FROM mining_data_apply_v v
WHERE cust_id = 100955) T,
TABLE(T.pset) S
ORDER BY 2 DESC;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CLUSTER_DETAILS-1.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CLUSTER_DETAILS.html
SELECT * FROM (
SELECT cust_id,
CLUSTER_ID(INTO 4 USING *) OVER () cls,
CLUSTER_DETAILS(INTO 4 USING *) OVER () cls_details
FROM mining_data_apply_v)
WHERE cust_id <= 100003
ORDER BY 1;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CLUSTER_DISTANCE-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CLUSTER_DISTANCE.html
SELECT cust_id
FROM (
SELECT cust_id,
rank() over
(order by CLUSTER_DISTANCE(km_sh_clus_sample USING *) desc) rnk
FROM mining_data_apply_v)
WHERE rnk <= 11
ORDER BY rnk;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CLUSTER_ID-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CLUSTER_ID.html
SELECT CLUSTER_ID(km_sh_clus_sample USING *) AS clus, COUNT(*) AS cnt
FROM mining_data_apply_v
GROUP BY CLUSTER_ID(km_sh_clus_sample USING *)
ORDER BY cnt DESC;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CLUSTER_ID-1.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CLUSTER_ID.html
SELECT * FROM (
SELECT cust_id,
CLUSTER_ID(INTO 4 USING *) OVER () cls,
CLUSTER_DETAILS(INTO 4 USING *) OVER () cls_details
FROM mining_data_apply_v)
WHERE cust_id <= 100003
ORDER BY 1;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CLUSTER_PROBABILITY-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CLUSTER_PROBABILITY.html
SELECT cust_id
FROM (SELECT cust_id, rank() OVER (ORDER BY prob DESC, cust_id) rnk_clus2
FROM (SELECT cust_id, CLUSTER_PROBABILITY(km_sh_clus_sample, 2 USING *) prob
FROM mining_data_apply_v))
WHERE rnk_clus2 <= 10
ORDER BY rnk_clus2;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CLUSTER_SET-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CLUSTER_SET.html
SELECT S.cluster_id, probability prob,
CLUSTER_DETAILS(em_sh_clus_sample, S.cluster_id, 5 USING T.*) det
FROM
(SELECT v.*, CLUSTER_SET(em_sh_clus_sample, NULL, 0.2 USING *) pset
FROM mining_data_apply_v v
WHERE cust_id = 100955) T,
TABLE(T.pset) S
ORDER BY 2 DESC;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/COALESCE-4.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/COALESCE.html
SELECT product_id, list_price, min_price,
COALESCE(0.9*list_price, min_price, 5) "Sale"
FROM product_information
WHERE supplier_id = 102050
ORDER BY product_id;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/COLLATE-Operator-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/COLLATE-Operator.html
SELECT last_name
FROM employees
ORDER BY last_name COLLATE GENERIC_M;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/COLLATION-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/COLLATION.html
CREATE TABLE id_table
(name VARCHAR2(64) COLLATE BINARY_AI,
id VARCHAR2(8) COLLATE BINARY_CI);
INSERT INTO id_table VALUES('Christopher', 'ABCD1234');
SELECT COLLATION(name), COLLATION(id)
FROM id_table;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/COLLECT-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/COLLECT.html
CREATE TYPE phone_book_t AS TABLE OF phone_list_typ;
/
SELECT CAST(COLLECT(phone_numbers) AS phone_book_t) "Income Level L Phone Book"
FROM customers
WHERE income_level = 'L: 300,000 and above';
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/COLLECT-1.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/COLLECT.html
CREATE TYPE warehouse_name_t AS TABLE OF VARCHAR2(35);
/
SELECT CAST(COLLECT(warehouse_name ORDER BY warehouse_name)
AS warehouse_name_t) "Warehouses"
FROM warehouses;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/COLUMN_VALUE-Pseudocolumn-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/COLUMN_VALUE-Pseudocolumn.html
SELECT *
FROM XMLTABLE('123');
SELECT COLUMN_VALUE
FROM (XMLTable('123'));
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/COLUMN_VALUE-Pseudocolumn-1.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/COLUMN_VALUE-Pseudocolumn.html
CREATE TYPE phone AS TABLE OF NUMBER;
/
CREATE TYPE phone_list AS TABLE OF phone;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/COLUMN_VALUE-Pseudocolumn-2.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/COLUMN_VALUE-Pseudocolumn.html
SELECT t.COLUMN_VALUE
FROM TABLE(phone(1,2,3)) t;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/COLUMN_VALUE-Pseudocolumn-3.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/COLUMN_VALUE-Pseudocolumn.html
SELECT t.COLUMN_VALUE
FROM TABLE(phone_list(phone(1,2,3))) p, TABLE(p.COLUMN_VALUE) t;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/COLUMN_VALUE-Pseudocolumn-4.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/COLUMN_VALUE-Pseudocolumn.html
CREATE TABLE my_customers (
cust_id NUMBER,
name VARCHAR2(25),
phone_numbers phone_list,
credit_limit NUMBER)
NESTED TABLE phone_numbers STORE AS outer_ntab
(NESTED TABLE COLUMN_VALUE STORE AS inner_ntab);
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/COMMENT-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/COMMENT.html
COMMENT ON COLUMN employees.job_id
IS 'abbreviated job title';
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/COMMENT-1.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/COMMENT.html
COMMENT ON COLUMN employees.job_id IS '';
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/COMMIT-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/COMMIT.html
INSERT INTO regions VALUES (5, 'Antarctica');
COMMIT WORK;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/COMMIT-1.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/COMMIT.html
COMMIT WRITE BATCH;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/COMMIT-2.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/COMMIT.html
COMMIT
COMMENT 'In-doubt transaction Code 36, Call (415) 555-2637';
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/COMMIT-3.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/COMMIT.html
COMMIT FORCE '22.57.53';
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/COMPOSE-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/COMPOSE.html
SELECT COMPOSE( 'o' || UNISTR('\0308') )
FROM DUAL;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CONCAT-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CONCAT.html
SELECT CONCAT( last_name, '''s job category is ', job_id) "Job"
FROM employees
WHERE employee_id = 152;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CONVERT-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CONVERT.html
SELECT CONVERT('Ä Ê Í Õ Ø A B C D E ', 'US7ASCII', 'WE8ISO8859P1')
FROM DUAL;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CONVERT-1.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CONVERT.html
SELECT * FROM V$NLS_VALID_VALUES WHERE parameter = 'CHARACTERSET';
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CON_DBID_TO_ID-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CON_DBID_TO_ID.html
SELECT CON_ID, DBID
FROM V$CONTAINERS;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CON_DBID_TO_ID-1.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CON_DBID_TO_ID.html
SELECT CON_DBID_TO_ID(2256797992) "Container ID"
FROM DUAL;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CON_GUID_TO_ID-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CON_GUID_TO_ID.html
SELECT CON_ID, GUID
FROM V$CONTAINERS;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CON_GUID_TO_ID-1.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CON_GUID_TO_ID.html
SELECT CON_GUID_TO_ID(HEXTORAW('D990F4BD938865C1E04305B4F00ACA18')) "Container ID"
FROM DUAL;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CON_NAME_TO_ID-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CON_NAME_TO_ID.html
SELECT CON_ID, NAME
FROM V$CONTAINERS;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CON_NAME_TO_ID-1.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CON_NAME_TO_ID.html
SELECT CON_NAME_TO_ID('SALESPDB') "Container ID"
FROM DUAL;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CON_UID_TO_ID-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CON_UID_TO_ID.html
SELECT CON_ID, CON_UID
FROM V$CONTAINERS;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CON_UID_TO_ID-1.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CON_UID_TO_ID.html
SELECT CON_UID_TO_ID(2256797992) "Container ID"
FROM DUAL;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CORR-1.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CORR.html
SELECT weight_class, CORR(list_price, min_price) "Correlation"
FROM product_information
GROUP BY weight_class
ORDER BY weight_class, "Correlation";
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CORR-2.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CORR.html
SELECT employee_id, job_id,
TO_CHAR((SYSDATE - hire_date) YEAR TO MONTH ) "Yrs-Mns", salary,
CORR(SYSDATE-hire_date, salary)
OVER(PARTITION BY job_id) AS "Correlation"
FROM employees
WHERE department_id in (50, 80)
ORDER BY job_id, employee_id;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CORR_A-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CORR_A.html
SELECT COUNT(*) count,
CORR_S(salary, commission_pct) commission,
CORR_S(salary, employee_id) empid
FROM employees;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CORR_A-1.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CORR_A.html
SELECT CORR_K(salary, commission_pct, 'COEFFICIENT') coefficient,
CORR_K(salary, commission_pct, 'TWO_SIDED_SIG') two_sided_p_value
FROM employees;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/COS-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/COS.html
SELECT COS(180 * 3.14159265359/180) "Cosine of 180 degrees"
FROM DUAL;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/COSH-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/COSH.html
SELECT COSH(0) "Hyperbolic cosine of 0"
FROM DUAL;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/COUNT-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/COUNT.html
SELECT COUNT(*) "Total"
FROM employees;
SELECT COUNT(*) "Allstars"
FROM employees
WHERE commission_pct > 0;
SELECT COUNT(commission_pct) "Count"
FROM employees;
SELECT COUNT(DISTINCT manager_id) "Managers"
FROM employees;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/COUNT-1.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/COUNT.html
SELECT last_name, salary,
COUNT(*) OVER (ORDER BY salary RANGE BETWEEN 50 PRECEDING AND
150 FOLLOWING) AS mov_count
FROM employees
ORDER BY salary, last_name;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/COVAR_POP-1.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/COVAR_POP.html
SELECT job_id,
COVAR_POP(SYSDATE-hire_date, salary) AS covar_pop,
COVAR_SAMP(SYSDATE-hire_date, salary) AS covar_samp
FROM employees
WHERE department_id in (50, 80)
GROUP BY job_id
ORDER BY job_id, covar_pop, covar_samp;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/COVAR_POP-2.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/COVAR_POP.html
SELECT product_id, supplier_id,
COVAR_POP(list_price, min_price)
OVER (ORDER BY product_id, supplier_id)
AS CUM_COVP,
COVAR_SAMP(list_price, min_price)
OVER (ORDER BY product_id, supplier_id)
AS CUM_COVS
FROM product_information p
WHERE category_id = 29
ORDER BY product_id, supplier_id;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CREATE-ANALYTIC-VIEW-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CREATE-ANALYTIC-VIEW.html
desc SALES_FACT
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CREATE-ANALYTIC-VIEW-1.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CREATE-ANALYTIC-VIEW.html
CREATE OR REPLACE ANALYTIC VIEW sales_av
USING sales_fact
DIMENSION BY
(time_attr_dim -- An attribute dimension of time data
KEY month_id REFERENCES month_id
HIERARCHIES (
time_hier DEFAULT),
product_attr_dim -- An attribute dimension of product data
KEY category_id REFERENCES category_id
HIERARCHIES (
product_hier DEFAULT),
geography_attr_dim -- An attribute dimension of store data
KEY state_province_id
REFERENCES state_province_id HIERARCHIES (
geography_hier DEFAULT)
)
MEASURES
(sales FACT sales, -- A base measure
units FACT units, -- A base measure
sales_prior_period AS -- Calculated measures
(LAG(sales) OVER (HIERARCHY time_hier OFFSET 1)),
sales_year_ago AS
(LAG(sales) OVER (HIERARCHY time_hier OFFSET 1
ACROSS ANCESTOR AT LEVEL year)),
chg_sales_year_ago AS
(LAG_DIFF(sales) OVER (HIERARCHY time_hier OFFSET 1
ACROSS ANCESTOR AT LEVEL year)),
pct_chg_sales_year_ago AS
(LAG_DIFF_PERCENT(sales) OVER (HIERARCHY time_hier OFFSET 1
ACROSS ANCESTOR AT LEVEL year)),
sales_qtr_ago AS
(LAG(sales) OVER (HIERARCHY time_hier OFFSET 1
ACROSS ANCESTOR AT LEVEL quarter)),
chg_sales_qtr_ago AS
(LAG_DIFF(sales) OVER (HIERARCHY time_hier OFFSET 1
ACROSS ANCESTOR AT LEVEL quarter)),
pct_chg_sales_qtr_ago AS
(LAG_DIFF_PERCENT(sales) OVER (HIERARCHY time_hier OFFSET 1
ACROSS ANCESTOR AT LEVEL quarter))
)
DEFAULT MEASURE SALES;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CREATE-ATTRIBUTE-DIMENSION-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CREATE-ATTRIBUTE-DIMENSION.html
desc TIME_DIM
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CREATE-ATTRIBUTE-DIMENSION-1.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CREATE-ATTRIBUTE-DIMENSION.html
CREATE OR REPLACE ATTRIBUTE DIMENSION time_attr_dim
DIMENSION TYPE TIME
USING time_dim
ATTRIBUTES
(year_id
CLASSIFICATION caption VALUE 'YEAR_ID'
CLASSIFICATION description VALUE 'YEAR ID',
year_name
CLASSIFICATION caption VALUE 'YEAR_NAME'
CLASSIFICATION description VALUE 'Year',
year_end_date
CLASSIFICATION caption VALUE 'YEAR_END_DATE'
CLASSIFICATION description VALUE 'Year End Date',
quarter_id
CLASSIFICATION caption VALUE 'QUARTER_ID'
CLASSIFICATION description VALUE 'QUARTER ID',
quarter_name
CLASSIFICATION caption VALUE 'QUARTER_NAME'
CLASSIFICATION description VALUE 'Quarter',
quarter_end_date
CLASSIFICATION caption VALUE 'QUARTER_END_DATE'
CLASSIFICATION description VALUE 'Quarter End Date',
quarter_of_year
CLASSIFICATION caption VALUE 'QUARTER_OF_YEAR'
CLASSIFICATION description VALUE 'Quarter of Year',
month_id
CLASSIFICATION caption VALUE 'MONTH_ID'
CLASSIFICATION description VALUE 'MONTH ID',
month_name
CLASSIFICATION caption VALUE 'MONTH_NAME'
CLASSIFICATION description VALUE 'Month',
month_long_name
CLASSIFICATION caption VALUE 'MONTH_LONG_NAME'
CLASSIFICATION description VALUE 'Month Long Name',
month_end_date
CLASSIFICATION caption VALUE 'MONTH_END_DATE'
CLASSIFICATION description VALUE 'Month End Date',
month_of_quarter
CLASSIFICATION caption VALUE 'MONTH_OF_QUARTER'
CLASSIFICATION description VALUE 'Month of Quarter',
month_of_year
CLASSIFICATION caption VALUE 'MONTH_OF_YEAR'
CLASSIFICATION description VALUE 'Month of Year',
season
CLASSIFICATION caption VALUE 'SEASON'
CLASSIFICATION description VALUE 'Season',
season_order
CLASSIFICATION caption VALUE 'SEASON_ORDER'
CLASSIFICATION description VALUE 'Season Order')
LEVEL month
LEVEL TYPE MONTHS
CLASSIFICATION caption VALUE 'MONTH'
CLASSIFICATION description VALUE 'Month'
KEY month_id
MEMBER NAME month_name
MEMBER CAPTION month_name
MEMBER DESCRIPTION month_long_name
ORDER BY month_end_date
DETERMINES (month_end_date,
quarter_id,
season,
season_order,
month_of_year,
month_of_quarter)
LEVEL quarter
LEVEL TYPE QUARTERS
CLASSIFICATION caption VALUE 'QUARTER'
CLASSIFICATION description VALUE 'Quarter'
KEY quarter_id
MEMBER NAME quarter_name
MEMBER CAPTION quarter_name
MEMBER DESCRIPTION quarter_name
ORDER BY quarter_end_date
DETERMINES (quarter_end_date,
quarter_of_year,
year_id)
LEVEL year
LEVEL TYPE YEARS
CLASSIFICATION caption VALUE 'YEAR'
CLASSIFICATION description VALUE 'Year'
KEY year_id
MEMBER NAME year_name
MEMBER CAPTION year_name
MEMBER DESCRIPTION year_name
ORDER BY year_end_date
DETERMINES (year_end_date)
LEVEL season
LEVEL TYPE QUARTERS
CLASSIFICATION caption VALUE 'SEASON'
CLASSIFICATION description VALUE 'Season'
KEY season
MEMBER NAME season
MEMBER CAPTION season
MEMBER DESCRIPTION season
LEVEL month_of_quarter
LEVEL TYPE MONTHS
CLASSIFICATION caption VALUE 'MONTH_OF_QUARTER'
CLASSIFICATION description VALUE 'Month of Quarter'
KEY month_of_quarter;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CREATE-ATTRIBUTE-DIMENSION-2.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CREATE-ATTRIBUTE-DIMENSION.html
desc PRODUCT_DIM
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CREATE-ATTRIBUTE-DIMENSION-3.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CREATE-ATTRIBUTE-DIMENSION.html
CREATE OR REPLACE ATTRIBUTE DIMENSION product_attr_dim
USING product_dim
ATTRIBUTES
(department_id,
department_name,
category_id,
category_name)
LEVEL DEPARTMENT
KEY department_id
ALTERNATE KEY department_name
MEMBER NAME department_name
MEMBER CAPTION department_name
ORDER BY department_name
LEVEL CATEGORY
KEY category_id
ALTERNATE KEY category_name
MEMBER NAME category_name
MEMBER CAPTION category_name
ORDER BY category_name
DETERMINES(department_id)
ALL MEMBER NAME 'ALL PRODUCTS';
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CREATE-ATTRIBUTE-DIMENSION-4.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CREATE-ATTRIBUTE-DIMENSION.html
desc GEOGRAPHY_DIM
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CREATE-ATTRIBUTE-DIMENSION-5.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CREATE-ATTRIBUTE-DIMENSION.html
CREATE OR REPLACE ATTRIBUTE DIMENSION geography_attr_dim
USING geography_dim
ATTRIBUTES
(region_id,
region_name,
country_id,
country_name,
state_province_id,
state_province_name)
LEVEL REGION
KEY region_id
ALTERNATE KEY region_name
MEMBER NAME region_name
MEMBER CAPTION region_name
ORDER BY region_name
LEVEL COUNTRY
KEY country_id
ALTERNATE KEY country_name
MEMBER NAME country_name
MEMBER CAPTION country_name
ORDER BY country_name
DETERMINES(region_id)
LEVEL STATE_PROVINCE
KEY state_province_id
ALTERNATE KEY state_province_name
MEMBER NAME state_province_name
MEMBER CAPTION state_province_name
ORDER BY state_province_name
DETERMINES(country_id)
ALL MEMBER NAME 'ALL CUSTOMERS';
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CREATE-AUDIT-POLICY-Unified-Auditing-1.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CREATE-AUDIT-POLICY-Unified-Auditing.html
AUDIT POLICY mypolicy;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CREATE-AUDIT-POLICY-Unified-Auditing-10.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CREATE-AUDIT-POLICY-Unified-Auditing.html
AUDIT POLICY mypolicy WHENEVER NOT SUCCESSFUL;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CREATE-AUDIT-POLICY-Unified-Auditing-11.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CREATE-AUDIT-POLICY-Unified-Auditing.html
AUDIT POLICY mypolicy;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CREATE-AUDIT-POLICY-Unified-Auditing-14.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CREATE-AUDIT-POLICY-Unified-Auditing.html
CREATE AUDIT POLICY table_pol
PRIVILEGES CREATE ANY TABLE, DROP ANY TABLE;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CREATE-AUDIT-POLICY-Unified-Auditing-15.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CREATE-AUDIT-POLICY-Unified-Auditing.html
SELECT *
FROM audit_unified_policies
WHERE policy_name = 'TABLE_POL';
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CREATE-AUDIT-POLICY-Unified-Auditing-16.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CREATE-AUDIT-POLICY-Unified-Auditing.html
CREATE AUDIT POLICY dml_pol
ACTIONS DELETE on hr.employees,
INSERT on hr.employees,
UPDATE on hr.employees,
ALL on hr.departments;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CREATE-AUDIT-POLICY-Unified-Auditing-17.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CREATE-AUDIT-POLICY-Unified-Auditing.html
CREATE AUDIT POLICY read_dir_pol
ACTIONS READ ON DIRECTORY bfile_dir;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CREATE-AUDIT-POLICY-Unified-Auditing-18.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CREATE-AUDIT-POLICY-Unified-Auditing.html
SELECT name FROM auditable_system_actions
WHERE component = 'Standard'
ORDER BY name;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CREATE-AUDIT-POLICY-Unified-Auditing-19.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CREATE-AUDIT-POLICY-Unified-Auditing.html
CREATE AUDIT POLICY security_pol
ACTIONS ADMINISTER KEY MANAGEMENT;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CREATE-AUDIT-POLICY-Unified-Auditing-2.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CREATE-AUDIT-POLICY-Unified-Auditing.html
CONNECT hr_usr/hr_pwd@hr_pdb;
PASSWORD
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CREATE-AUDIT-POLICY-Unified-Auditing-20.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CREATE-AUDIT-POLICY-Unified-Auditing.html
CREATE AUDIT POLICY dir_pol
ACTIONS READ DIRECTORY, WRITE DIRECTORY, EXECUTE DIRECTORY;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CREATE-AUDIT-POLICY-Unified-Auditing-21.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CREATE-AUDIT-POLICY-Unified-Auditing.html
SELECT name FROM auditable_system_actions
WHERE component = 'Datapump';
EXPORT
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CREATE-AUDIT-POLICY-Unified-Auditing-22.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CREATE-AUDIT-POLICY-Unified-Auditing.html
CREATE AUDIT POLICY dp_actions_pol
ACTIONS COMPONENT = datapump IMPORT;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CREATE-AUDIT-POLICY-Unified-Auditing-23.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CREATE-AUDIT-POLICY-Unified-Auditing.html
CREATE AUDIT POLICY java_pol
ROLES java_admin, java_deploy;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CREATE-AUDIT-POLICY-Unified-Auditing-24.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CREATE-AUDIT-POLICY-Unified-Auditing.html
CREATE AUDIT POLICY hr_admin_pol
PRIVILEGES CREATE ANY TABLE, DROP ANY TABLE
ACTIONS DELETE on hr.employees,
INSERT on hr.employees,
UPDATE on hr.employees,
ALL on hr.departments,
LOCK TABLE
ROLES audit_admin, audit_viewer;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CREATE-AUDIT-POLICY-Unified-Auditing-25.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CREATE-AUDIT-POLICY-Unified-Auditing.html
CREATE AUDIT POLICY order_updates_pol
ACTIONS UPDATE ON oe.orders
WHEN 'SYS_CONTEXT(''USERENV'', ''IDENTIFICATION_TYPE'') = ''EXTERNAL'''
EVALUATE PER SESSION;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CREATE-AUDIT-POLICY-Unified-Auditing-26.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CREATE-AUDIT-POLICY-Unified-Auditing.html
CREATE AUDIT POLICY emp_updates_pol
ACTIONS DELETE on hr.employees,
INSERT on hr.employees,
UPDATE on hr.employees
WHEN 'UID NOT IN (100, 105, 107)'
EVALUATE PER STATEMENT;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CREATE-AUDIT-POLICY-Unified-Auditing-27.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CREATE-AUDIT-POLICY-Unified-Auditing.html
CREATE AUDIT POLICY local_table_pol
PRIVILEGES CREATE ANY TABLE, DROP ANY TABLE
CONTAINER = CURRENT;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CREATE-AUDIT-POLICY-Unified-Auditing-28.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CREATE-AUDIT-POLICY-Unified-Auditing.html
CREATE AUDIT POLICY c##common_role1_pol
ROLES c##role1
CONTAINER = ALL;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CREATE-AUDIT-POLICY-Unified-Auditing-3.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CREATE-AUDIT-POLICY-Unified-Auditing.html
SELECT ACTION_NAME, UNIFIED_AUDIT_POLICIES, OBJECT_NAME FROM UNIFIED_AUDIT_TRAIL;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CREATE-AUDIT-POLICY-Unified-Auditing-30.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CREATE-AUDIT-POLICY-Unified-Auditing.html
CREATE AUDIT POLICY pol ACTIONS INSERT(deptno) on scott.dept;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CREATE-AUDIT-POLICY-Unified-Auditing-4.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CREATE-AUDIT-POLICY-Unified-Auditing.html
SELECT name FROM auditable_system_actions WHERE component = 'Datapump';
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CREATE-AUDIT-POLICY-Unified-Auditing-5.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CREATE-AUDIT-POLICY-Unified-Auditing.html
SELECT name FROM auditable_system_actions WHERE component = 'Direct path API';
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CREATE-AUDIT-POLICY-Unified-Auditing-6.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CREATE-AUDIT-POLICY-Unified-Auditing.html
SELECT name FROM auditable_system_actions WHERE component = 'Label Security';
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CREATE-AUDIT-POLICY-Unified-Auditing-7.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CREATE-AUDIT-POLICY-Unified-Auditing.html
SELECT name FROM auditable_system_actions WHERE component = 'XS';
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CREATE-AUDIT-POLICY-Unified-Auditing-8.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CREATE-AUDIT-POLICY-Unified-Auditing.html
SELECT name FROM auditable_system_actions WHERE component = 'Database Vault';
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CREATE-AUDIT-POLICY-Unified-Auditing-9.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CREATE-AUDIT-POLICY-Unified-Auditing.html
AUDIT POLICY mypolicy;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CREATE-CLUSTER-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CREATE-CLUSTER.html
CREATE CLUSTER personnel
(department NUMBER(4))
SIZE 512
STORAGE (initial 100K next 50K);
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CREATE-CLUSTER-1.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CREATE-CLUSTER.html
CREATE INDEX idx_personnel ON CLUSTER personnel;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CREATE-CLUSTER-10.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CREATE-CLUSTER.html
CREATE INDEX emp_dept_index
ON CLUSTER emp_dept
TABLESPACE USERS
STORAGE (INITIAL 50K
NEXT 50K
MINEXTENTS 2
MAXEXTENTS 10
PCTINCREASE 33);
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CREATE-CLUSTER-11.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CREATE-CLUSTER.html
SELECT CLUSTER_NAME, TABLESPACE_NAME, CLUSTER_TYPE, PCT_INCREASE, MIN_EXTENTS, MAX_EXTENTS FROM USER_CLUSTERS;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CREATE-CLUSTER-12.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CREATE-CLUSTER.html
SELECT * FROM USER_CLU_COLUMNS;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CREATE-CLUSTER-13.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CREATE-CLUSTER.html
SELECT INDEX_NAME, INDEX_TYPE, PCT_INCREASE, MIN_EXTENTS, MAX_EXTENTS FROM USER_INDEXES WHERE TABLE_NAME='EMP_DEPT';
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CREATE-CLUSTER-2.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CREATE-CLUSTER.html
CREATE TABLE dept_10
CLUSTER personnel (department_id)
AS SELECT * FROM employees WHERE department_id = 10;
CREATE TABLE dept_20
CLUSTER personnel (department_id)
AS SELECT * FROM employees WHERE department_id = 20;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CREATE-CLUSTER-3.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CREATE-CLUSTER.html
CREATE CLUSTER language (cust_language VARCHAR2(3))
SIZE 512 HASHKEYS 10
STORAGE (INITIAL 100k next 50k);
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CREATE-CLUSTER-4.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CREATE-CLUSTER.html
CREATE CLUSTER address
(postal_code NUMBER, country_id CHAR(2))
HASHKEYS 20
HASH IS MOD(postal_code + country_id, 101);
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CREATE-CLUSTER-5.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CREATE-CLUSTER.html
CREATE CLUSTER cust_orders (customer_id NUMBER(6))
SIZE 512 SINGLE TABLE HASHKEYS 100;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CREATE-CLUSTER-6.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CREATE-CLUSTER.html
CREATE CLUSTER sales (amount_sold NUMBER, prod_id NUMBER)
HASHKEYS 100000
HASH IS (amount_sold * 10 + prod_id)
SIZE 300
TABLESPACE example
PARTITION BY RANGE (amount_sold)
(PARTITION p1 VALUES LESS THAN (2001),
PARTITION p2 VALUES LESS THAN (4001),
PARTITION p3 VALUES LESS THAN (6001),
PARTITION p4 VALUES LESS THAN (8001),
PARTITION p5 VALUES LESS THAN (MAXVALUE));
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CREATE-CLUSTER-7.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CREATE-CLUSTER.html
CREATE CLUSTER emp_dept (deptno NUMBER(3))
SIZE 600
TABLESPACE USERS
STORAGE (INITIAL 200K
NEXT 300K
MINEXTENTS 2
PCTINCREASE 33);
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CREATE-CLUSTER-8.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CREATE-CLUSTER.html
CREATE TABLE dept (
deptno NUMBER(3) PRIMARY KEY)
CLUSTER emp_dept (deptno);
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CREATE-CLUSTER-9.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CREATE-CLUSTER.html
CREATE TABLE empl (
emplno NUMBER(5) PRIMARY KEY,
emplname VARCHAR2(15) NOT NULL,
deptno NUMBER(3) REFERENCES dept)
CLUSTER emp_dept (deptno);
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CREATE-CONTEXT-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CREATE-CONTEXT.html
CREATE CONTEXT hr_context USING emp_mgmt;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CREATE-CONTEXT-1.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CREATE-CONTEXT.html
CREATE VIEW hr_org_secure_view AS
SELECT * FROM employees
WHERE department_id = SYS_CONTEXT('hr_context', 'department_id');
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CREATE-CONTROLFILE-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CREATE-CONTROLFILE.html
STARTUP NOMOUNT
CREATE CONTROLFILE REUSE DATABASE "demo" NORESETLOGS NOARCHIVELOG
MAXLOGFILES 32
MAXLOGMEMBERS 2
MAXDATAFILES 32
MAXINSTANCES 1
MAXLOGHISTORY 449
LOGFILE
GROUP 1 '/path/oracle/dbs/t_log1.f' SIZE 500K,
GROUP 2 '/path/oracle/dbs/t_log2.f' SIZE 500K
# STANDBY LOGFILE
DATAFILE
'/path/oracle/dbs/t_db1.f',
'/path/oracle/dbs/dbu19i.dbf',
'/path/oracle/dbs/tbs_11.f',
'/path/oracle/dbs/smundo.dbf',
'/path/oracle/dbs/demo.dbf'
CHARACTER SET WE8DEC
;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CREATE-DATABASE-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CREATE-DATABASE.html
CREATE DATABASE sample
CONTROLFILE REUSE
LOGFILE
GROUP 1 ('diskx:log1.log', 'disky:log1.log') SIZE 50K,
GROUP 2 ('diskx:log2.log', 'disky:log2.log') SIZE 50K
MAXLOGFILES 5
MAXLOGHISTORY 100
MAXDATAFILES 10
MAXINSTANCES 2
ARCHIVELOG
CHARACTER SET AL32UTF8
NATIONAL CHARACTER SET AL16UTF16
DATAFILE
'disk1:df1.dbf' AUTOEXTEND ON,
'disk2:df2.dbf' AUTOEXTEND ON NEXT 10M MAXSIZE UNLIMITED
DEFAULT TEMPORARY TABLESPACE temp_ts
UNDO TABLESPACE undo_ts
SET TIME_ZONE = '+02:00';
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CREATE-DATABASE-1.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CREATE-DATABASE.html
CREATE DATABASE newcdb
USER SYS IDENTIFIED BY sys_password
USER SYSTEM IDENTIFIED BY system_password
LOGFILE GROUP 1 ('/u01/logs/my/redo01a.log','/u02/logs/my/redo01b.log')
SIZE 100M BLOCKSIZE 512,
GROUP 2 ('/u01/logs/my/redo02a.log','/u02/logs/my/redo02b.log')
SIZE 100M BLOCKSIZE 512,
GROUP 3 ('/u01/logs/my/redo03a.log','/u02/logs/my/redo03b.log')
SIZE 100M BLOCKSIZE 512
MAXLOGHISTORY 1
MAXLOGFILES 16
MAXLOGMEMBERS 3
MAXDATAFILES 1024
CHARACTER SET AL32UTF8
NATIONAL CHARACTER SET AL16UTF16
EXTENT MANAGEMENT LOCAL
DATAFILE '/u01/app/oracle/oradata/newcdb/system01.dbf'
SIZE 700M REUSE AUTOEXTEND ON NEXT 10240K MAXSIZE UNLIMITED
SYSAUX DATAFILE '/u01/app/oracle/oradata/newcdb/sysaux01.dbf'
SIZE 550M REUSE AUTOEXTEND ON NEXT 10240K MAXSIZE UNLIMITED
DEFAULT TABLESPACE deftbs
DATAFILE '/u01/app/oracle/oradata/newcdb/deftbs01.dbf'
SIZE 500M REUSE AUTOEXTEND ON MAXSIZE UNLIMITED
DEFAULT TEMPORARY TABLESPACE tempts1
TEMPFILE '/u01/app/oracle/oradata/newcdb/temp01.dbf'
SIZE 20M REUSE AUTOEXTEND ON NEXT 640K MAXSIZE UNLIMITED
UNDO TABLESPACE undotbs1
DATAFILE '/u01/app/oracle/oradata/newcdb/undotbs01.dbf'
SIZE 200M REUSE AUTOEXTEND ON NEXT 5120K MAXSIZE UNLIMITED
ENABLE PLUGGABLE DATABASE
SEED
FILE_NAME_CONVERT = ('/u01/app/oracle/oradata/newcdb/',
'/u01/app/oracle/oradata/pdbseed/')
SYSTEM DATAFILES SIZE 125M AUTOEXTEND ON NEXT 10M MAXSIZE UNLIMITED
SYSAUX DATAFILES SIZE 100M
USER_DATA TABLESPACE usertbs
DATAFILE '/u01/app/oracle/oradata/pdbseed/usertbs01.dbf'
SIZE 200M REUSE AUTOEXTEND ON MAXSIZE UNLIMITED;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CREATE-DATABASE-LINK-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CREATE-DATABASE-LINK.html
CREATE PUBLIC DATABASE LINK remote
USING 'remote';
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CREATE-DATABASE-LINK-1.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CREATE-DATABASE-LINK.html
UPDATE employees@remote
SET salary=salary*1.1
WHERE last_name = 'Baer';
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CREATE-DATABASE-LINK-2.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CREATE-DATABASE-LINK.html
CREATE DATABASE LINK local
CONNECT TO hr IDENTIFIED BY password
USING 'local';
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CREATE-DATABASE-LINK-3.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CREATE-DATABASE-LINK.html
SELECT * FROM employees@local;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CREATE-DATABASE-LINK-4.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CREATE-DATABASE-LINK.html
INSERT INTO employees@local
(employee_id, last_name, email, hire_date, job_id)
VALUES (999, 'Claus', 'sclaus@example.com', SYSDATE, 'SH_CLERK');
UPDATE jobs@local SET min_salary = 3000
WHERE job_id = 'SH_CLERK';
DELETE FROM employees@local
WHERE employee_id = 999;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CREATE-DATABASE-LINK-5.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CREATE-DATABASE-LINK.html
SELECT * FROM oe.customers@local;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CREATE-DATABASE-LINK-6.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CREATE-DATABASE-LINK.html
CREATE DATABASE LINK remote.us.example.com
CONNECT TO CURRENT_USER
USING 'remote';
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CREATE-DATABASE-LINK-7.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CREATE-DATABASE-LINK.html
CREATE SYNONYM emp_table
FOR oe.employees@remote.us.example.com;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CREATE-DIMENSION-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CREATE-DIMENSION.html
CREATE DIMENSION customers_dim
LEVEL customer IS (customers.cust_id)
LEVEL city IS (customers.cust_city)
LEVEL state IS (customers.cust_state_province)
LEVEL country IS (countries.country_id)
LEVEL subregion IS (countries.country_subregion)
LEVEL region IS (countries.country_region)
HIERARCHY geog_rollup (
customer CHILD OF
city CHILD OF
state CHILD OF
country CHILD OF
subregion CHILD OF
region
JOIN KEY (customers.country_id) REFERENCES country
)
ATTRIBUTE customer DETERMINES
(cust_first_name, cust_last_name, cust_gender,
cust_marital_status, cust_year_of_birth,
cust_income_level, cust_credit_limit)
ATTRIBUTE country DETERMINES (countries.country_name)
;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CREATE-DIMENSION-1.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CREATE-DIMENSION.html
CREATE DIMENSION customers_dim
LEVEL customer IS (customers.cust_id)
LEVEL city IS (customers.cust_city)
LEVEL state IS (customers.cust_state_province)
LEVEL country IS (countries.country_id)
LEVEL subregion IS (countries.country_subregion)
LEVEL region IS (countries.country_region)
HIERARCHY geog_rollup (
customer CHILD OF
city CHILD OF
state CHILD OF
country CHILD OF
subregion CHILD OF
region
JOIN KEY (customers.country_id) REFERENCES country
)
ATTRIBUTE customer_info LEVEL customer DETERMINES
(cust_first_name, cust_last_name, cust_gender,
cust_marital_status, cust_year_of_birth,
cust_income_level, cust_credit_limit)
ATTRIBUTE country DETERMINES (countries.country_name);
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CREATE-DIMENSION-2.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CREATE-DIMENSION.html
CREATE DIMENSION customers_dim
LEVEL customer IS (customers.cust_id)
LEVEL status IS (customers.cust_marital_status) SKIP WHEN NULL
LEVEL city IS (customers.cust_city)
LEVEL state IS (customers.cust_state_province)
LEVEL country IS (countries.country_id)
LEVEL subregion IS (countries.country_subregion) SKIP WHEN NULL
LEVEL region IS (countries.country_region)
HIERARCHY geog_rollup (
customer CHILD OF
city CHILD OF
state CHILD OF
country CHILD OF
subregion CHILD OF
region
JOIN KEY (customers.country_id) REFERENCES country
)
ATTRIBUTE customer DETERMINES
(cust_first_name, cust_last_name, cust_gender,
cust_marital_status, cust_year_of_birth,
cust_income_level, cust_credit_limit)
ATTRIBUTE country DETERMINES (countries.country_name)
;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CREATE-DIRECTORY-1.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CREATE-DIRECTORY.html
CREATE DIRECTORY mydir AS '/scratch/data/file_data';
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CREATE-DIRECTORY-2.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CREATE-DIRECTORY.html
CREATE DIRECTORY mydir AS '/scratch/../file_data';
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CREATE-DIRECTORY-3.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CREATE-DIRECTORY.html
CREATE DIRECTORY admin AS '/disk1/oracle/admin';
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CREATE-DIRECTORY-4.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CREATE-DIRECTORY.html
CREATE OR REPLACE DIRECTORY bfile_dir AS '/usr/bin/bfile_dir';
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CREATE-DISKGROUP-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CREATE-DISKGROUP.html
CREATE DISKGROUP dgroup_01
EXTERNAL REDUNDANCY
DISK '/devices/disks/c*';
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CREATE-EDITION-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CREATE-EDITION.html
GRANT CREATE ANY EDITION, DROP ANY EDITION to HR;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CREATE-EDITION-1.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CREATE-EDITION.html
CREATE EDITION test_ed;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CREATE-EDITION-2.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CREATE-EDITION.html
SELECT SYS_CONTEXT('userenv', 'current_edition_name') FROM DUAL;
CREATE EDITIONING VIEW e_view AS
SELECT last_name, first_name, email FROM employees;
DESCRIBE e_view
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CREATE-EDITION-3.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CREATE-EDITION.html
ALTER SESSION SET EDITION = TEST_ED;
CREATE OR REPLACE EDITIONING VIEW e_view AS
SELECT last_name, first_name, email, salary FROM employees;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CREATE-EDITION-4.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CREATE-EDITION.html
DESCRIBE e_view
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CREATE-EDITION-5.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CREATE-EDITION.html
ALTER SESSION SET EDITION = ora$base;
DESCRIBE e_view;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CREATE-EDITION-6.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CREATE-EDITION.html
ALTER SESSION SET EDITION = TEST_ED;
DROP VIEW e_view;
ALTER SESSION SET EDITION = ORA$BASE;
DESCRIBE e_view;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CREATE-EDITION-7.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CREATE-EDITION.html
DROP EDITION TEST_ED;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CREATE-FLASHBACK-ARCHIVE-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CREATE-FLASHBACK-ARCHIVE.html
CREATE FLASHBACK ARCHIVE DEFAULT test_archive1
TABLESPACE example
QUOTA 1 M
RETENTION 1 DAY;
CREATE FLASHBACK ARCHIVE test_archive2
TABLESPACE example
QUOTA 1 M
RETENTION 1 DAY;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CREATE-FLASHBACK-ARCHIVE-2.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CREATE-FLASHBACK-ARCHIVE.html
ALTER TABLE oe.customers
FLASHBACK ARCHIVE;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CREATE-FLASHBACK-ARCHIVE-3.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CREATE-FLASHBACK-ARCHIVE.html
ALTER TABLE oe.orders
FLASHBACK ARCHIVE test_archive2;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CREATE-FLASHBACK-ARCHIVE-4.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CREATE-FLASHBACK-ARCHIVE.html
DROP FLASHBACK ARCHIVE test_archive2;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CREATE-HIERARCHY-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CREATE-HIERARCHY.html
CREATE OR REPLACE HIERARCHY time_hier -- Hierarchy name
USING time_attr_dim -- Refers to TIME_ATTR_DIM attribute dimension
(month CHILD OF -- Months in the attribute dimension
quarter CHILD OF
year);
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CREATE-HIERARCHY-1.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CREATE-HIERARCHY.html
CREATE OR REPLACE HIERARCHY product_hier
USING product_attr_dim
(category
CHILD OF department);
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CREATE-HIERARCHY-2.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CREATE-HIERARCHY.html
CREATE OR REPLACE HIERARCHY geography_hier
USING geography_attr_dim
(state_province
CHILD OF country
CHILD OF region);
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CREATE-INDEX-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CREATE-INDEX.html
CREATE MULTIVALUE INDEX mvi_1 ON mytable t
(t.jcol.credit_score.numberOnly());
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CREATE-INDEX-10.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CREATE-INDEX.html
CREATE INDEX area_index ON xwarehouses e
(EXTRACTVALUE(VALUE(e),'/Warehouse/Area'));
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CREATE-INDEX-11.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CREATE-INDEX.html
SELECT e.getClobVal() AS warehouse
FROM xwarehouses e
WHERE EXISTSNODE(VALUE(e),'/Warehouse[Area>50000]') = 1;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CREATE-INDEX-12.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CREATE-INDEX.html
CREATE INDEX upper_ix ON employees (UPPER(last_name));
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CREATE-INDEX-13.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CREATE-INDEX.html
SELECT first_name, last_name
FROM employees WHERE UPPER(last_name) IS NOT NULL
ORDER BY UPPER(last_name);
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CREATE-INDEX-14.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CREATE-INDEX.html
CREATE INDEX income_ix
ON employees(salary + (salary*commission_pct));
SELECT first_name||' '||last_name "Name"
FROM employees
WHERE (salary*commission_pct) + salary > 15000
ORDER BY employee_id;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CREATE-INDEX-15.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CREATE-INDEX.html
CREATE INDEX src_idx ON print_media(text_length(ad_sourcetext));
SELECT product_id FROM print_media
WHERE text_length(ad_sourcetext) < 1000
ORDER BY product_id;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CREATE-INDEX-16.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CREATE-INDEX.html
CREATE TYPE rectangle AS OBJECT
( length NUMBER,
width NUMBER,
MEMBER FUNCTION area RETURN NUMBER DETERMINISTIC
);
CREATE OR REPLACE TYPE BODY rectangle AS
MEMBER FUNCTION area RETURN NUMBER IS
BEGIN
RETURN (length*width);
END;
END;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CREATE-INDEX-17.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CREATE-INDEX.html
CREATE TABLE rect_tab OF rectangle;
CREATE INDEX area_idx ON rect_tab x (x.area());
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CREATE-INDEX-18.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CREATE-INDEX.html
SELECT * FROM rect_tab x WHERE x.area() > 100;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CREATE-INDEX-19.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CREATE-INDEX.html
CREATE UNIQUE INDEX promo_ix ON orders
(CASE WHEN promotion_id =2 THEN customer_id ELSE NULL END,
CASE WHEN promotion_id = 2 THEN promotion_id ELSE NULL END);
INSERT INTO orders (order_id, order_date, customer_id, order_total, promotion_id)
VALUES (2459, systimestamp, 106, 251, 2);
INSERT INTO orders (order_id, order_date, customer_id, order_total, promotion_id)
VALUES (2460, systimestamp+1, 106, 110, 2);
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CREATE-INDEX-20.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CREATE-INDEX.html
CREATE INDEX cost_ix ON sales (amount_sold)
GLOBAL PARTITION BY RANGE (amount_sold)
(PARTITION p1 VALUES LESS THAN (1000),
PARTITION p2 VALUES LESS THAN (2500),
PARTITION p3 VALUES LESS THAN (MAXVALUE));
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CREATE-INDEX-21.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CREATE-INDEX.html
CREATE INDEX cust_last_name_ix ON customers (cust_last_name)
GLOBAL PARTITION BY HASH (cust_last_name)
PARTITIONS 4;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CREATE-INDEX-22.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CREATE-INDEX.html
CREATE INDEX prod_idx ON hash_products(category_id) LOCAL
STORE IN (tbs_01, tbs_02);
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CREATE-INDEX-23.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CREATE-INDEX.html
CREATE INDEX sales_ix ON composite_sales(time_id, prod_id)
STORAGE (INITIAL 1M)
LOCAL
(PARTITION q1_1998,
PARTITION q2_1998,
PARTITION q3_1998,
PARTITION q4_1998,
PARTITION q1_1999,
PARTITION q2_1999,
PARTITION q3_1999,
PARTITION q4_1999,
PARTITION q1_2000,
PARTITION q2_2000
(SUBPARTITION pq2001, SUBPARTITION pq2002,
SUBPARTITION pq2003, SUBPARTITION pq2004,
SUBPARTITION pq2005, SUBPARTITION pq2006,
SUBPARTITION pq2007, SUBPARTITION pq2008),
PARTITION q3_2000
(SUBPARTITION c1 TABLESPACE tbs_02,
SUBPARTITION c2 TABLESPACE tbs_02,
SUBPARTITION c3 TABLESPACE tbs_02,
SUBPARTITION c4 TABLESPACE tbs_02,
SUBPARTITION c5 TABLESPACE tbs_02),
PARTITION q4_2000
(SUBPARTITION pq4001 TABLESPACE tbs_03,
SUBPARTITION pq4002 TABLESPACE tbs_03,
SUBPARTITION pq4003 TABLESPACE tbs_03,
SUBPARTITION pq4004 TABLESPACE tbs_03)
);
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CREATE-INDEX-24.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CREATE-INDEX.html
CREATE BITMAP INDEX product_bm_ix
ON hash_products(list_price)
LOCAL(PARTITION ix_p1 TABLESPACE tbs_01,
PARTITION ix_p2,
PARTITION ix_p3 TABLESPACE tbs_02,
PARTITION ix_p4 TABLESPACE tbs_03)
TABLESPACE tbs_04;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CREATE-INDEX-25.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CREATE-INDEX.html
CREATE TABLE hash_products
( product_id NUMBER(6)
, product_name VARCHAR2(50)
, product_description VARCHAR2(2000)
, category_id NUMBER(2)
, weight_class NUMBER(1)
, warranty_period INTERVAL YEAR TO MONTH
, supplier_id NUMBER(6)
, product_status VARCHAR2(20)
, list_price NUMBER(8,2)
, min_price NUMBER(8,2)
, catalog_url VARCHAR2(50)
, CONSTRAINT pk_product_id PRIMARY KEY (product_id)
, CONSTRAINT product_status_lov_demo
CHECK (product_status in ('orderable'
,'planned'
,'under development'
,'obsolete')
) )
PARTITION BY HASH (product_id)
PARTITIONS 5
STORE IN (example);
CREATE TABLE sales_quota
( product_id NUMBER(6)
, customer_name VARCHAR2(50)
, order_qty NUMBER(6)
,CONSTRAINT u_product_id UNIQUE(product_id)
);
CREATE BITMAP INDEX product_bm_ix
ON hash_products(list_price)
FROM hash_products h, sales_quota s
WHERE h.product_id = s.product_id
LOCAL(PARTITION ix_p1 TABLESPACE example,
PARTITION ix_p2,
PARTITION ix_p3 TABLESPACE example,
PARTITION ix_p4,
PARTITION ix_p5 TABLESPACE example)
TABLESPACE example;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CREATE-INDEX-26.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CREATE-INDEX.html
CREATE UNIQUE INDEX nested_tab_ix
ON textdocs_nestedtab(NESTED_TABLE_ID, document_typ);
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CREATE-INDEX-27.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CREATE-INDEX.html
CREATE INDEX salary_i
ON books (TREAT(author AS employee_t).salary);
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CREATE-INDEX-28.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CREATE-INDEX.html
CREATE INDEX salary_func_i ON persons p
(TREAT(VALUE(p) AS part_time_emp_t).salary);
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CREATE-INDEX-29.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CREATE-INDEX.html
CREATE BITMAP INDEX typeid_i ON books (SYS_TYPEID(author));
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CREATE-INDEX-4.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CREATE-INDEX.html
CREATE INDEX cust_eff_ix ON customers
(NVL(cust_eff_to, TO_DATE('9000-01-01 00:00:00', 'yyyy-mm-dd hh24:mi:ss')));
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CREATE-INDEX-5.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CREATE-INDEX.html
SELECT column_expression
FROM all_ind_expressions
WHERE index_name='CUST_EFF_IX';
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CREATE-INDEX-6.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CREATE-INDEX.html
CREATE INDEX ord_customer_ix
ON orders (customer_id);
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CREATE-INDEX-7.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CREATE-INDEX.html
CREATE INDEX ord_customer_ix_demo
ON orders (customer_id, sales_rep_id)
COMPRESS 1;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CREATE-INDEX-8.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CREATE-INDEX.html
CREATE INDEX ord_customer_ix_demo
ON orders (order_mode)
NOSORT
NOLOGGING;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CREATE-INDEX-9.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CREATE-INDEX.html
CREATE INDEX idx_personnel ON CLUSTER personnel;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CREATE-INDEXTYPE-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CREATE-INDEXTYPE.html
CREATE INDEXTYPE position_indextype
FOR position_between(NUMBER, NUMBER, NUMBER)
USING position_im;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CREATE-INMEMORY-JOIN-GROUP-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CREATE-INMEMORY-JOIN-GROUP.html
CREATE INMEMORY JOIN GROUP prod_id1
(inventories(product_id), order_items(product_id));
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CREATE-INMEMORY-JOIN-GROUP-1.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CREATE-INMEMORY-JOIN-GROUP.html
CREATE INMEMORY JOIN GROUP prod_id2
(inventories(product_id), pm.online_media(product_id));
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CREATE-JAVA-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CREATE-JAVA.html
SELECT LOB FROM CREATE$JAVA$LOB$TABLE
WHERE NAME = 'key_for_BLOB';
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CREATE-JAVA-1.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CREATE-JAVA.html
CREATE JAVA CLASS USING BFILE (java_dir, 'Agent.class')
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CREATE-JAVA-2.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CREATE-JAVA.html
CREATE JAVA SOURCE NAMED "Welcome" AS
public class Welcome {
public static String welcome() {
return "Welcome World"; } }/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CREATE-JAVA-3.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CREATE-JAVA.html
CREATE JAVA RESOURCE NAMED "appText"
USING BFILE (java_dir, 'textBundle.dat')
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CREATE-LOCKDOWN-PROFILE-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CREATE-LOCKDOWN-PROFILE.html
CREATE LOCKDOWN PROFILE hr_prof INCLUDING PRIVATE_DBAAS;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CREATE-MATERIALIZED-VIEW-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CREATE-MATERIALIZED-VIEW.html
CREATE MATERIALIZED VIEW mv1 AS SELECT * FROM hr.employees;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CREATE-MATERIALIZED-VIEW-1.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CREATE-MATERIALIZED-VIEW.html
CREATE MATERIALIZED VIEW foreign_customers
AS SELECT * FROM sh.customers@remote cu
WHERE EXISTS
(SELECT * FROM sh.countries@remote co
WHERE co.country_id = cu.country_id);
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CREATE-MATERIALIZED-VIEW-10.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CREATE-MATERIALIZED-VIEW.html
CREATE MATERIALIZED VIEW my_warranty_orders
AS SELECT w.order_id, w.line_item_id, o.order_date
FROM warranty_orders w, orders o
WHERE o.order_id = o.order_id
AND o.sales_rep_id = 165;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CREATE-MATERIALIZED-VIEW-11.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CREATE-MATERIALIZED-VIEW.html
CREATE MATERIALIZED VIEW MView1 ANNOTATIONS (Title 'Tab1 MV1', ADD Snapshot) AS SELECT * from Table1;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CREATE-MATERIALIZED-VIEW-12.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CREATE-MATERIALIZED-VIEW.html
CREATE MATERIALIZED VIEW MView1(T ANNOTATIONS (Hidden)) ANNOTATIONS (Title 'Tab1 MV1', ADD Snapshot)
AS SELECT * from Table1;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CREATE-MATERIALIZED-VIEW-2.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CREATE-MATERIALIZED-VIEW.html
CREATE MATERIALIZED VIEW LOG ON times
WITH ROWID, SEQUENCE (time_id, calendar_year)
INCLUDING NEW VALUES;
CREATE MATERIALIZED VIEW LOG ON products
WITH ROWID, SEQUENCE (prod_id)
INCLUDING NEW VALUES;
CREATE MATERIALIZED VIEW sales_mv
BUILD IMMEDIATE
REFRESH FAST ON COMMIT
AS SELECT t.calendar_year, p.prod_id,
SUM(s.amount_sold) AS sum_sales
FROM times t, products p, sales s
WHERE t.time_id = s.time_id AND p.prod_id = s.prod_id
GROUP BY t.calendar_year, p.prod_id;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CREATE-MATERIALIZED-VIEW-3.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CREATE-MATERIALIZED-VIEW.html
CREATE MATERIALIZED VIEW sales_by_month_by_state
TABLESPACE example
PARALLEL 4
BUILD IMMEDIATE
REFRESH COMPLETE
ENABLE QUERY REWRITE
AS SELECT t.calendar_month_desc, c.cust_state_province,
SUM(s.amount_sold) AS sum_sales
FROM times t, sales s, customers c
WHERE s.time_id = t.time_id AND s.cust_id = c.cust_id
GROUP BY t.calendar_month_desc, c.cust_state_province;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CREATE-MATERIALIZED-VIEW-4.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CREATE-MATERIALIZED-VIEW.html
CREATE TABLE sales_sum_table
(month VARCHAR2(8), state VARCHAR2(40), sales NUMBER(10,2));
CREATE MATERIALIZED VIEW sales_sum_table
ON PREBUILT TABLE WITH REDUCED PRECISION
ENABLE QUERY REWRITE
AS SELECT t.calendar_month_desc AS month,
c.cust_state_province AS state,
SUM(s.amount_sold) AS sales
FROM times t, customers c, sales s
WHERE s.time_id = t.time_id AND s.cust_id = c.cust_id
GROUP BY t.calendar_month_desc, c.cust_state_province;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CREATE-MATERIALIZED-VIEW-5.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CREATE-MATERIALIZED-VIEW.html
CREATE MATERIALIZED VIEW catalog
REFRESH FAST START WITH SYSDATE NEXT SYSDATE + 1/4096
WITH PRIMARY KEY
AS SELECT * FROM product_information;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CREATE-MATERIALIZED-VIEW-6.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CREATE-MATERIALIZED-VIEW.html
CREATE MATERIALIZED VIEW order_data REFRESH WITH ROWID
AS SELECT * FROM orders;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CREATE-MATERIALIZED-VIEW-7.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CREATE-MATERIALIZED-VIEW.html
CREATE MATERIALIZED VIEW LOG ON employees
WITH PRIMARY KEY
INCLUDING NEW VALUES;
CREATE MATERIALIZED VIEW emp_data
PCTFREE 5 PCTUSED 60
TABLESPACE example
STORAGE (INITIAL 50K)
REFRESH FAST NEXT sysdate + 7
AS SELECT * FROM employees;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CREATE-MATERIALIZED-VIEW-8.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CREATE-MATERIALIZED-VIEW.html
CREATE MATERIALIZED VIEW all_customers
PCTFREE 5 PCTUSED 60
TABLESPACE example
STORAGE (INITIAL 50K)
USING INDEX STORAGE (INITIAL 25K)
REFRESH START WITH ROUND(SYSDATE + 1) + 11/24
NEXT NEXT_DAY(TRUNC(SYSDATE), 'MONDAY') + 15/24
AS SELECT * FROM sh.customers@remote
UNION
SELECT * FROM sh.customers@local;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CREATE-MATERIALIZED-VIEW-9.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CREATE-MATERIALIZED-VIEW.html
CREATE MATERIALIZED VIEW LOG ON inventories
WITH (quantity_on_hand);
CREATE MATERIALIZED VIEW warranty_orders REFRESH FAST AS
SELECT order_id, line_item_id, product_id FROM order_items o
WHERE EXISTS
(SELECT * FROM inventories i WHERE o.product_id = i.product_id
AND i.quantity_on_hand IS NOT NULL)
UNION
SELECT order_id, line_item_id, product_id FROM order_items
WHERE quantity > 5;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CREATE-MATERIALIZED-VIEW-LOG-1.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CREATE-MATERIALIZED-VIEW-LOG.html
CREATE MATERIALIZED VIEW LOG ON customers
PCTFREE 5
TABLESPACE example
STORAGE (INITIAL 10K);
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CREATE-MATERIALIZED-VIEW-LOG-2.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CREATE-MATERIALIZED-VIEW-LOG.html
CREATE MATERIALIZED VIEW LOG ON customers WITH PRIMARY KEY, ROWID;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CREATE-MATERIALIZED-VIEW-LOG-3.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CREATE-MATERIALIZED-VIEW-LOG.html
CREATE MATERIALIZED VIEW LOG ON orders
PCTFREE 5
TABLESPACE example
STORAGE (INITIAL 10K)
PURGE REPEAT INTERVAL '5' DAY;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CREATE-MATERIALIZED-VIEW-LOG-4.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CREATE-MATERIALIZED-VIEW-LOG.html
CREATE MATERIALIZED VIEW LOG ON sales
WITH ROWID, SEQUENCE(amount_sold, time_id, prod_id)
INCLUDING NEW VALUES;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CREATE-MATERIALIZED-VIEW-LOG-5.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CREATE-MATERIALIZED-VIEW-LOG.html
CREATE MATERIALIZED VIEW LOG ON order_items WITH (product_id);
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CREATE-MATERIALIZED-VIEW-LOG-6.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CREATE-MATERIALIZED-VIEW-LOG.html
CREATE MATERIALIZED VIEW LOG ON product_information
WITH ROWID, SEQUENCE (list_price, min_price, category_id), PRIMARY KEY
INCLUDING NEW VALUES;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CREATE-MATERIALIZED-VIEW-LOG-7.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CREATE-MATERIALIZED-VIEW-LOG.html
CREATE MATERIALIZED VIEW products_mv
REFRESH FAST ON COMMIT
AS SELECT SUM(list_price - min_price), category_id
FROM product_information
GROUP BY category_id;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CREATE-MATERIALIZED-VIEW-LOG-8.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CREATE-MATERIALIZED-VIEW-LOG.html
CREATE MATERIALIZED VIEW LOG ON sales
PCTFREE 5
TABLESPACE example
STORAGE (INITIAL 10K)
FOR SYNCHRONOUS REFRESH USING mystage_log;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CREATE-MATERIALIZED-ZONEMAP-4.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CREATE-MATERIALIZED-ZONEMAP.html
CREATE MATERIALIZED ZONEMAP sales_zmap
ON sales(cust_id, prod_id);
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CREATE-MATERIALIZED-ZONEMAP-5.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CREATE-MATERIALIZED-ZONEMAP.html
CREATE MATERIALIZED ZONEMAP sales_zmap
AS SELECT SYS_OP_ZONE_ID(rowid),
MIN(cust_id), MAX(cust_id),
MIN(prod_id), MAX(prod_id)
FROM sales
GROUP BY SYS_OP_ZONE_ID(rowid);
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CREATE-MATERIALIZED-ZONEMAP-6.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CREATE-MATERIALIZED-ZONEMAP.html
CREATE MATERIALIZED ZONEMAP sales_zmap
AS SELECT SYS_OP_ZONE_ID(s.rowid),
MIN(cust_state_province), MAX(cust_state_province),
MIN(cust_city), MAX(cust_city)
FROM sales s
LEFT OUTER JOIN customers c ON s.cust_id = c.cust_id
GROUP BY SYS_OP_ZONE_ID(s.rowid);
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CREATE-MATERIALIZED-ZONEMAP-7.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CREATE-MATERIALIZED-ZONEMAP.html
CREATE MATERIALIZED ZONEMAP sales_zmap
AS SELECT SYS_OP_ZONE_ID(s.rowid),
MIN(prod_category), MAX(prod_category),
MIN(prod_subcategory), MAX(prod_subcategory),
MIN(country_id), MAX(country_id),
MIN(cust_state_province), MAX(cust_state_province),
MIN(cust_city), MAX(cust_city)
FROM sales s
LEFT OUTER JOIN products p ON s.prod_id = p.prod_id
LEFT OUTER JOIN customers c ON s.cust_id = c.cust_id
GROUP BY sys_op_zone_id(s.rowid);
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CREATE-MATERIALIZED-ZONEMAP-8.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CREATE-MATERIALIZED-ZONEMAP.html
CREATE MATERIALIZED ZONEMAP sales_zmap
AS SELECT SYS_OP_ZONE_ID(s.rowid),
MIN(prod_category), MAX(prod_category),
MIN(prod_subcategory), MAX(prod_subcategory),
MIN(country_id), MAX(country_id),
MIN(cust_state_province), MAX(cust_state_province),
MIN(cust_city), MAX(cust_city)
FROM sales s, products p, customers c
WHERE s.prod_id = p.prod_id(+) AND
s.cust_id = c.cust_id(+)
GROUP BY sys_op_zone_id(s.rowid);
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CREATE-OPERATOR-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CREATE-OPERATOR.html
CREATE FUNCTION eq_f(a VARCHAR2, b VARCHAR2) RETURN NUMBER AS
BEGIN
IF a = b THEN RETURN 1;
ELSE RETURN 0;
END IF;
END;
/
CREATE OPERATOR eq_op
BINDING (VARCHAR2, VARCHAR2)
RETURN NUMBER
USING eq_f;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CREATE-OUTLINE-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CREATE-OUTLINE.html
CREATE OUTLINE salaries FOR CATEGORY special
ON SELECT last_name, salary FROM employees;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CREATE-OUTLINE-1.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CREATE-OUTLINE.html
CREATE OR REPLACE PRIVATE OUTLINE my_salaries
FROM salaries;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CREATE-OUTLINE-2.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CREATE-OUTLINE.html
CREATE OR REPLACE OUTLINE public_salaries
FROM PRIVATE my_salaries;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CREATE-PFILE-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CREATE-PFILE.html
CREATE PFILE = 'my_init.ora' FROM SPFILE = 's_params.ora';
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CREATE-PLUGGABLE-DATABASE-10.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CREATE-PLUGGABLE-DATABASE.html
CREATE PLUGGABLE DATABASE newpdb FROM salespdb
FILE_NAME_CONVERT = ('/disk1/oracle/dbs/salespdb/', '/disk1/oracle/dbs/newpdb/')
PATH_PREFIX = '/disk1/oracle/dbs/newpdb';
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CREATE-PLUGGABLE-DATABASE-11.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CREATE-PLUGGABLE-DATABASE.html
CREATE PLUGGABLE DATABASE salespdb
USING '/disk1/usr/salespdb.xml'
SOURCE_FILE_NAME_CONVERT =
('/disk1/oracle/dbs/salespdb/', '/disk2/oracle/dbs/salespdb/')
NOCOPY
STORAGE (MAXSIZE 2G)
TEMPFILE REUSE;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CREATE-PLUGGABLE-DATABASE-3.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CREATE-PLUGGABLE-DATABASE.html
CREATE PLUGGABLE DATABASE CDB1_PDB2_C AS CLONE USING '/tmp/cdb1_pdb2.pdb'
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CREATE-PLUGGABLE-DATABASE-4.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CREATE-PLUGGABLE-DATABASE.html
ALTER PLUGGABLE DATABASE cdb1_pdb3 OPEN
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CREATE-PLUGGABLE-DATABASE-6.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CREATE-PLUGGABLE-DATABASE.html
SELECT partition_name, high_value
FROM dba_tab_partitions
WHERE table_name='MAP' AND table_owner='SYS'
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CREATE-PLUGGABLE-DATABASE-9.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CREATE-PLUGGABLE-DATABASE.html
CREATE PLUGGABLE DATABASE salespdb
ADMIN USER salesadm IDENTIFIED BY password
ROLES = (dba)
DEFAULT TABLESPACE sales
DATAFILE '/disk1/oracle/dbs/salespdb/sales01.dbf' SIZE 250M AUTOEXTEND ON
FILE_NAME_CONVERT = ('/disk1/oracle/dbs/pdbseed/',
'/disk1/oracle/dbs/salespdb/')
STORAGE (MAXSIZE 2G)
PATH_PREFIX = '/disk1/oracle/dbs/salespdb/';
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CREATE-PROFILE-1.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CREATE-PROFILE.html
CREATE MANDATORY PROFILE c##cdb_profile LIMIT PASSWORD_VERIFY_FUNCTION my_mandatory_function
CONTAINER = ALL ;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CREATE-PROFILE-2.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CREATE-PROFILE.html
ALTER SYSTEM SET MANDATORY_USER_PROFILE=c##cdb_profile;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CREATE-PROFILE-4.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CREATE-PROFILE.html
CREATE PROFILE usr_prof LIMIT PASSWORD_ROLLOVER_TIME 1
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CREATE-PROFILE-5.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CREATE-PROFILE.html
CREATE PROFILE new_profile
LIMIT PASSWORD_REUSE_MAX 10
PASSWORD_REUSE_TIME 30;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CREATE-PROFILE-6.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CREATE-PROFILE.html
CREATE PROFILE app_user LIMIT
SESSIONS_PER_USER UNLIMITED
CPU_PER_SESSION UNLIMITED
CPU_PER_CALL 3000
CONNECT_TIME 45
LOGICAL_READS_PER_SESSION DEFAULT
LOGICAL_READS_PER_CALL 1000
PRIVATE_SGA 15K
COMPOSITE_LIMIT 5000000;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CREATE-PROFILE-7.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CREATE-PROFILE.html
CREATE PROFILE app_user2 LIMIT
FAILED_LOGIN_ATTEMPTS 5
PASSWORD_LIFE_TIME 60
PASSWORD_REUSE_TIME 60
PASSWORD_REUSE_MAX 5
PASSWORD_VERIFY_FUNCTION ora12c_verify_function
PASSWORD_LOCK_TIME 1/24
PASSWORD_GRACE_TIME 10
INACTIVE_ACCOUNT_TIME 30;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CREATE-RESTORE-POINT-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CREATE-RESTORE-POINT.html
CREATE RESTORE POINT good_data;
SELECT salary FROM employees WHERE employee_id = 108;
UPDATE employees SET salary = salary*10
WHERE employee_id = 108;
SELECT salary FROM employees
WHERE employee_id = 108;
COMMIT;
FLASHBACK TABLE employees TO RESTORE POINT good_data;
SELECT salary FROM employees
WHERE employee_id = 108;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CREATE-ROLE-1.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CREATE-ROLE.html
CREATE ROLE widget_sales_role IDENTIFIED GLOBALLY AS 'AZURE_ROLE=WidgetManagerGroup';
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CREATE-ROLE-2.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CREATE-ROLE.html
CREATE ROLE dw_manager;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CREATE-ROLE-3.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CREATE-ROLE.html
CREATE ROLE dw_manager
IDENTIFIED BY warehouse;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CREATE-ROLE-4.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CREATE-ROLE.html
CREATE ROLE warehouse_user IDENTIFIED GLOBALLY;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CREATE-ROLE-5.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CREATE-ROLE.html
CREATE ROLE warehouse_user IDENTIFIED EXTERNALLY;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CREATE-ROLE-6.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CREATE-ROLE.html
CREATE ROLE role1 CONTAINER = CURRENT;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CREATE-ROLE-7.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CREATE-ROLE.html
CREATE ROLE c##role1 CONTAINER = ALL;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CREATE-ROLLBACK-SEGMENT-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CREATE-ROLLBACK-SEGMENT.html
CREATE TABLESPACE rbs_ts
DATAFILE 'rbs01.dbf' SIZE 10M
EXTENT MANAGEMENT LOCAL UNIFORM SIZE 100K;
CREATE ROLLBACK SEGMENT rbs_one
TABLESPACE rbs_ts;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CREATE-ROLLBACK-SEGMENT-1.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CREATE-ROLLBACK-SEGMENT.html
CREATE ROLLBACK SEGMENT rbs_one
TABLESPACE rbs_ts
STORAGE
( INITIAL 10K );
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CREATE-SCHEMA-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CREATE-SCHEMA.html
CREATE SCHEMA AUTHORIZATION oe
CREATE TABLE new_product
(color VARCHAR2(10) PRIMARY KEY, quantity NUMBER)
CREATE VIEW new_product_view
AS SELECT color, quantity FROM new_product WHERE color = 'RED'
GRANT select ON new_product_view TO hr;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CREATE-SEQUENCE-2.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CREATE-SEQUENCE.html
SELECT mysequence.nextval FROM DUAL;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CREATE-SEQUENCE-3.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CREATE-SEQUENCE.html
SELECT mysequence.nextval FROM DUAL;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CREATE-SEQUENCE-4.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CREATE-SEQUENCE.html
CREATE SEQUENCE customers_seq
START WITH 1000
INCREMENT BY 1
NOCACHE
NOCYCLE;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CREATE-SPFILE-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CREATE-SPFILE.html
CREATE SPFILE
FROM PFILE = '$ORACLE_HOME/work/t_init1.ora';
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CREATE-SPFILE-1.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CREATE-SPFILE.html
STARTUP
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CREATE-SPFILE-2.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CREATE-SPFILE.html
CREATE SPFILE = 's_params.ora'
FROM PFILE = '$ORACLE_HOME/work/t_init1.ora';
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CREATE-SPFILE-4.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CREATE-SPFILE.html
STARTUP PFILE=new_param.ora
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CREATE-SYNONYM-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CREATE-SYNONYM.html
CREATE SYNONYM offices
FOR hr.locations;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CREATE-SYNONYM-1.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CREATE-SYNONYM.html
CREATE PUBLIC SYNONYM emp_table
FOR hr.employees@remote.us.example.com;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CREATE-SYNONYM-2.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CREATE-SYNONYM.html
CREATE PUBLIC SYNONYM customers FOR oe.customers;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CREATE-SYNONYM-3.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CREATE-SYNONYM.html
SELECT COUNT(*) FROM customers;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CREATE-SYNONYM-4.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CREATE-SYNONYM.html
SELECT COUNT(*) FROM oe.customers;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CREATE-SYNONYM-5.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CREATE-SYNONYM.html
SELECT COUNT(*) FROM customers;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CREATE-TABLE-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CREATE-TABLE.html
create or replace trigger t1_t
before insert or update on t1 for each row
begin
:new.c2 := NULL;
end;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CREATE-TABLE-1.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CREATE-TABLE.html
CREATE IMMUTABLE TABLE trade_ledger (tr_id NUMBER, user_name VARCHAR2(40), tr_value NUMBER)
NO DROP UNTIL 40 DAYS IDLE
NO DELETE UNTIL 100 DAYS AFTER INSERT;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CREATE-TABLE-10.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CREATE-TABLE.html
CREATE TABLE j_purchaseorder
(id VARCHAR2 (32) NOT NULL PRIMARY KEY,
date_loaded TIMESTAMP (6) WITH TIME ZONE,
po_document JSON );
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CREATE-TABLE-11.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CREATE-TABLE.html
CREATE SHARDED TABLE departments
( department_id NUMBER(6)
, department_name VARCHAR2(30) CONSTRAINT dept_name_nn NOT NULL
, manager_id NUMBER(6)
, location_id NUMBER(4)
, CONSTRAINT dept_id_pk PRIMARY KEY(department_id)
)
PARTITION BY DIRECTORY (department_id)
(
PARTITION p_1 TABLESPACE tbs1,
PARTITION p_2 TABLESPACE tbs2
);
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CREATE-TABLE-12.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CREATE-TABLE.html
CREATE TABLE staging_table (col1 number, col2 varchar2(100)) FOR STAGING;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CREATE-TABLE-13.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CREATE-TABLE.html
CREATE TABLE part_staging_table (col1 number, col2 varchar2(100))
PARTITION BY RANGE (col1) (PARTITION p1 VALUES LESS THAN (100), PARTITION pmax VALUES LESS THAN (MAXVALUE))
FOR STAGING;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CREATE-TABLE-14.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CREATE-TABLE.html
CREATE TABLE employees_demo
( employee_id NUMBER(6)
, first_name VARCHAR2(20)
, last_name VARCHAR2(25)
CONSTRAINT emp_last_name_nn_demo NOT NULL
, email VARCHAR2(25)
CONSTRAINT emp_email_nn_demo NOT NULL
, phone_number VARCHAR2(20)
, hire_date DATE DEFAULT SYSDATE
CONSTRAINT emp_hire_date_nn_demo NOT NULL
, job_id VARCHAR2(10)
CONSTRAINT emp_job_nn_demo NOT NULL
, salary NUMBER(8,2)
CONSTRAINT emp_salary_nn_demo NOT NULL
, commission_pct NUMBER(2,2)
, manager_id NUMBER(6)
, department_id NUMBER(4)
, dn VARCHAR2(300)
, CONSTRAINT emp_salary_min_demo
CHECK (salary > 0)
, CONSTRAINT emp_email_uk_demo
UNIQUE (email)
) ;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CREATE-TABLE-15.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CREATE-TABLE.html
CREATE TABLE employees_demo
( employee_id NUMBER(6)
, first_name VARCHAR2(20)
, last_name VARCHAR2(25)
CONSTRAINT emp_last_name_nn_demo NOT NULL
, email VARCHAR2(25)
CONSTRAINT emp_email_nn_demo NOT NULL
, phone_number VARCHAR2(20)
, hire_date DATE DEFAULT SYSDATE
CONSTRAINT emp_hire_date_nn_demo NOT NULL
, job_id VARCHAR2(10)
CONSTRAINT emp_job_nn_demo NOT NULL
, salary NUMBER(8,2)
CONSTRAINT emp_salary_nn_demo NOT NULL
, commission_pct NUMBER(2,2)
, manager_id NUMBER(6)
, department_id NUMBER(4)
, dn VARCHAR2(300)
, CONSTRAINT emp_salary_min_demo
CHECK (salary > 0)
, CONSTRAINT emp_email_uk_demo
UNIQUE (email)
)
TABLESPACE example
STORAGE (INITIAL 8M);
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CREATE-TABLE-16.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CREATE-TABLE.html
CREATE TABLE myemp (employee_id number, last_name varchar2(25),
department_id NUMBER DEFAULT ON NULL 50 NOT NULL);
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CREATE-TABLE-17.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CREATE-TABLE.html
SELECT employee_id, last_name, department_id
FROM employees
WHERE department_id IS NULL;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CREATE-TABLE-18.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CREATE-TABLE.html
INSERT INTO myemp (employee_id, last_name, department_id)
(SELECT employee_id, last_name, department_id from employees);
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CREATE-TABLE-19.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CREATE-TABLE.html
SELECT employee_id, last_name, department_id
FROM myemp
WHERE employee_id = 178;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CREATE-TABLE-20.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CREATE-TABLE.html
CREATE TABLE t1 (id NUMBER GENERATED AS IDENTITY);
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CREATE-TABLE-21.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CREATE-TABLE.html
CREATE TABLE t2 (id NUMBER GENERATED BY DEFAULT AS IDENTITY (START WITH 100 INCREMENT BY 10));
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CREATE-TABLE-22.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CREATE-TABLE.html
CREATE GLOBAL TEMPORARY TABLE today_sales
ON COMMIT PRESERVE ROWS
AS SELECT * FROM orders WHERE order_date = SYSDATE;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CREATE-TABLE-23.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CREATE-TABLE.html
CREATE TABLE later (col1 NUMBER, col2 VARCHAR2(20)) SEGMENT CREATION DEFERRED;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CREATE-TABLE-24.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CREATE-TABLE.html
CREATE TYPE person_t AS OBJECT (name VARCHAR2(100), ssn NUMBER)
NOT FINAL;
/
CREATE TYPE employee_t UNDER person_t
(department_id NUMBER, salary NUMBER) NOT FINAL;
/
CREATE TYPE part_time_emp_t UNDER employee_t (num_hrs NUMBER);
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CREATE-TABLE-25.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CREATE-TABLE.html
CREATE TABLE persons OF person_t;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CREATE-TABLE-26.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CREATE-TABLE.html
CREATE TABLE books (title VARCHAR2(100), author person_t);
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CREATE-TABLE-27.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CREATE-TABLE.html
CREATE TABLE dept_80
PARALLEL
AS SELECT * FROM employees
WHERE department_id = 80;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CREATE-TABLE-28.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CREATE-TABLE.html
CREATE TABLE dept_80
AS SELECT * FROM employees
WHERE department_id = 80;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CREATE-TABLE-29.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CREATE-TABLE.html
CREATE TABLE departments_demo
( department_id NUMBER(4)
, department_name VARCHAR2(30)
CONSTRAINT dept_name_nn NOT NULL
, manager_id NUMBER(6)
, location_id NUMBER(4)
, dn VARCHAR2(300)
) ;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CREATE-TABLE-30.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CREATE-TABLE.html
CREATE TABLE departments_demo
( department_id NUMBER(4) PRIMARY KEY DISABLE
, department_name VARCHAR2(30)
CONSTRAINT dept_name_nn NOT NULL
, manager_id NUMBER(6)
, location_id NUMBER(4)
, dn VARCHAR2(300)
) ;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CREATE-TABLE-31.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CREATE-TABLE.html
CREATE TABLE print_media
( product_id NUMBER(6)
, ad_id NUMBER(6)
, ad_composite BLOB
, ad_sourcetext CLOB
, ad_finaltext CLOB
, ad_fltextn NCLOB
, ad_textdocs_ntab textdoc_tab
, ad_photo BLOB
, ad_graphic BFILE
, ad_header adheader_typ
) NESTED TABLE ad_textdocs_ntab STORE AS textdocs_nestedtab;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CREATE-TABLE-32.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CREATE-TABLE.html
CREATE TYPE phone AS OBJECT (telephone NUMBER);
/
CREATE TYPE phone_list AS TABLE OF phone;
/
CREATE TYPE my_customers AS OBJECT (
cust_name VARCHAR2(25),
phones phone_list);
/
CREATE TYPE customer_list AS TABLE OF my_customers;
/
CREATE TABLE business_contacts (
company_name VARCHAR2(25),
company_reps customer_list)
NESTED TABLE company_reps STORE AS outer_ntab
(NESTED TABLE phones STORE AS inner_ntab);
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CREATE-TABLE-33.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CREATE-TABLE.html
CREATE TYPE phone AS TABLE OF NUMBER;
/
CREATE TYPE phone_list AS TABLE OF phone;
/
CREATE TABLE my_customers (
name VARCHAR2(25),
phone_numbers phone_list)
NESTED TABLE phone_numbers STORE AS outer_ntab
(NESTED TABLE COLUMN_VALUE STORE AS inner_ntab);
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CREATE-TABLE-34.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CREATE-TABLE.html
CREATE TABLE print_media_new
( product_id NUMBER(6)
, ad_id NUMBER(6)
, ad_composite BLOB
, ad_sourcetext CLOB
, ad_finaltext CLOB
, ad_fltextn NCLOB
, ad_textdocs_ntab textdoc_tab
, ad_photo BLOB
, ad_graphic BFILE
, ad_header adheader_typ
) NESTED TABLE ad_textdocs_ntab STORE AS textdocs_nestedtab_new
LOB (ad_sourcetext, ad_finaltext) STORE AS
(TABLESPACE example
STORAGE (INITIAL 6144)
CHUNK 4000
NOCACHE LOGGING);
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CREATE-TABLE-35.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CREATE-TABLE.html
CREATE TABLE countries_demo
( country_id CHAR(2)
CONSTRAINT country_id_nn_demo NOT NULL
, country_name VARCHAR2(40)
, currency_name VARCHAR2(25)
, currency_symbol VARCHAR2(3)
, region VARCHAR2(15)
, CONSTRAINT country_c_id_pk_demo
PRIMARY KEY (country_id ) )
ORGANIZATION INDEX
INCLUDING country_name
PCTTHRESHOLD 2
STORAGE
( INITIAL 4K )
OVERFLOW
STORAGE
( INITIAL 4K );
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CREATE-TABLE-36.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CREATE-TABLE.html
CREATE TABLE dept_external (
deptno NUMBER(6),
dname VARCHAR2(20),
loc VARCHAR2(25)
)
ORGANIZATION EXTERNAL
(TYPE oracle_loader
DEFAULT DIRECTORY admin
ACCESS PARAMETERS
(
RECORDS DELIMITED BY newline
BADFILE 'ulcase1.bad'
DISCARDFILE 'ulcase1.dis'
LOGFILE 'ulcase1.log'
SKIP 20
FIELDS TERMINATED BY "," OPTIONALLY ENCLOSED BY '"'
(
deptno INTEGER EXTERNAL(6),
dname CHAR(20),
loc CHAR(25)
)
)
LOCATION ('ulcase1.ctl')
)
REJECT LIMIT UNLIMITED;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CREATE-TABLE-37.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CREATE-TABLE.html
CREATE TABLE xwarehouses OF XMLTYPE;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CREATE-TABLE-38.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CREATE-TABLE.html
CREATE TABLE xwarehouses OF XMLTYPE
XMLSCHEMA "http://www.example.com/xwarehouses.xsd"
ELEMENT "Warehouse";
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CREATE-TABLE-39.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CREATE-TABLE.html
CREATE TABLE xwarehouses (
warehouse_id NUMBER,
warehouse_spec XMLTYPE)
XMLTYPE warehouse_spec STORE AS CLOB
(TABLESPACE example
STORAGE (INITIAL 6144)
CHUNK 4000
NOCACHE LOGGING);
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CREATE-TABLE-40.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CREATE-TABLE.html
CREATE TABLE xwarehouses (
warehouse_id NUMBER,
warehouse_spec XMLTYPE)
XMLTYPE warehouse_spec STORE AS OBJECT RELATIONAL
XMLSCHEMA "http://www.example.com/xwarehouses.xsd"
ELEMENT "Warehouse";
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CREATE-TABLE-41.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CREATE-TABLE.html
CREATE TABLE xwarehouses (
warehouse_id NUMBER,
warehouse_spec XMLTYPE)
XMLTYPE warehouse_spec STORE AS SECUREFILE CLOB
(TABLESPACE auto_seg_ts
STORAGE (INITIAL 6144)
CACHE);
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CREATE-TABLE-42.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CREATE-TABLE.html
CREATE TABLE range_sales
( prod_id NUMBER(6)
, cust_id NUMBER
, time_id DATE
, channel_id CHAR(1)
, promo_id NUMBER(6)
, quantity_sold NUMBER(3)
, amount_sold NUMBER(10,2)
)
PARTITION BY RANGE (time_id)
(PARTITION SALES_Q1_1998 VALUES LESS THAN (TO_DATE('01-APR-1998','DD-MON-YYYY')),
PARTITION SALES_Q2_1998 VALUES LESS THAN (TO_DATE('01-JUL-1998','DD-MON-YYYY')),
PARTITION SALES_Q3_1998 VALUES LESS THAN (TO_DATE('01-OCT-1998','DD-MON-YYYY')),
PARTITION SALES_Q4_1998 VALUES LESS THAN (TO_DATE('01-JAN-1999','DD-MON-YYYY')),
PARTITION SALES_Q1_1999 VALUES LESS THAN (TO_DATE('01-APR-1999','DD-MON-YYYY')),
PARTITION SALES_Q2_1999 VALUES LESS THAN (TO_DATE('01-JUL-1999','DD-MON-YYYY')),
PARTITION SALES_Q3_1999 VALUES LESS THAN (TO_DATE('01-OCT-1999','DD-MON-YYYY')),
PARTITION SALES_Q4_1999 VALUES LESS THAN (TO_DATE('01-JAN-2000','DD-MON-YYYY')),
PARTITION SALES_Q1_2000 VALUES LESS THAN (TO_DATE('01-APR-2000','DD-MON-YYYY')),
PARTITION SALES_Q2_2000 VALUES LESS THAN (TO_DATE('01-JUL-2000','DD-MON-YYYY')),
PARTITION SALES_Q3_2000 VALUES LESS THAN (TO_DATE('01-OCT-2000','DD-MON-YYYY')),
PARTITION SALES_Q4_2000 VALUES LESS THAN (MAXVALUE))
;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CREATE-TABLE-43.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CREATE-TABLE.html
CREATE TABLE empl_h
(
employee_id NUMBER(6) PRIMARY KEY,
first_name VARCHAR2(20),
last_name VARCHAR2(25),
email VARCHAR2(25),
phone_number VARCHAR2(20),
hire_date DATE DEFAULT SYSDATE,
job_id VARCHAR2(10),
salary NUMBER(8, 2),
part_name VARCHAR2(25)
) PARTITION BY RANGE (hire_date) (
PARTITION hire_q1 VALUES less than(to_date('01-APR-2014', 'DD-MON-YYYY')),
PARTITION hire_q2 VALUES less than(to_date('01-JUL-2014', 'DD-MON-YYYY')),
PARTITION hire_q3 VALUES less than(to_date('01-OCT-2014', 'DD-MON-YYYY')),
PARTITION hire_q4 VALUES less than(to_date('01-JAN-2015', 'DD-MON-YYYY'))
);
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CREATE-TABLE-44.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CREATE-TABLE.html
INSERT INTO empl_h (employee_id, first_name, last_name, email, phone_number, hire_date, job_id, salary, Part_name)
VALUES (1, 'Jane', 'Doe', 'example.com', '415.555.0100', '10-Feb-2014', '1001', 5001,'HIRE_Q1');
INSERT INTO empl_h (employee_id, first_name, last_name, email, phone_number, hire_date, job_id, salary, Part_name)
VALUES (2, 'John', 'Doe', 'example.net', '415.555.0101', '10-Apr-2014', '1002', 7001,'HIRE_Q2');
INSERT INTO empl_h (employee_id, first_name, last_name, email, phone_number, hire_date, job_id, salary, Part_name)
VALUES (3, 'Isabelle', 'Owl', 'example.org', '415.555.0102', '10-Sep-2014', '1003', 10001,'HIRE_Q3');
INSERT INTO empl_h (employee_id, first_name, last_name, email, phone_number, hire_date, job_id, salary, Part_name)
VALUES (4, 'Smith', 'Jones', 'example.in', '415.555.0103', '10-Dec-2014', '1004', 12001,'HIRE_Q4');
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CREATE-TABLE-45.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CREATE-TABLE.html
SELECT PARTITION_NAME FROM USER_TAB_PARTITIONS WHERE TABLE_NAME = 'EMPL_H';
SELECT TABLE_NAME, PARTITIONING_TYPE, STATUS FROM USER_PART_TABLES WHERE TABLE_NAME = 'EMPL_H';
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CREATE-TABLE-46.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CREATE-TABLE.html
CREATE TABLE parts (p_name) AS SELECT PARTITION_NAME FROM USER_TAB_PARTITIONS WHERE TABLE_NAME = 'EMPL_H';
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CREATE-TABLE-47.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CREATE-TABLE.html
select * from parts;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CREATE-TABLE-48.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CREATE-TABLE.html
select E.HIRE_DATE,E.JOB_ID,P.p_name from empl_h E, parts P where E.Part_name = P.p_name;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CREATE-TABLE-49.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CREATE-TABLE.html
CREATE TABLE customers_demo (
customer_id number(6),
cust_first_name varchar2(20),
cust_last_name varchar2(20),
credit_limit number(9,2))
PARTITION BY RANGE (credit_limit)
INTERVAL (1000)
(PARTITION p1 VALUES LESS THAN (5001));
INSERT INTO customers_demo
(customer_id, cust_first_name, cust_last_name, credit_limit)
(select customer_id, cust_first_name, cust_last_name, credit_limit
from customers);
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CREATE-TABLE-5.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CREATE-TABLE.html
CREATE BLOCKCHAIN TABLE bank_ledger (bank VARCHAR2(128), account_no NUMBER, deposit_date DATE, deposit_amount NUMBER)
NO DROP UNTIL 31 DAYS IDLE
NO DELETE LOCKED
HASHING USING SHA2_512 WITH ROW VERSION ACCOUNT_NO (bank, account_no) VERSION V2;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CREATE-TABLE-50.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CREATE-TABLE.html
SELECT partition_name, high_value FROM user_tab_partitions WHERE table_name = 'CUSTOMERS_DEMO';
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CREATE-TABLE-51.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CREATE-TABLE.html
INSERT INTO customers_demo
VALUES (699, 'Fred', 'Flintstone', 5500);
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CREATE-TABLE-52.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CREATE-TABLE.html
SELECT partition_name, high_value FROM user_tab_partitions
WHERE table_name = 'CUSTOMERS_DEMO'
ORDER BY partition_name;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CREATE-TABLE-53.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CREATE-TABLE.html
CREATE TABLE list_customers
( customer_id NUMBER(6)
, cust_first_name VARCHAR2(20)
, cust_last_name VARCHAR2(20)
, cust_address CUST_ADDRESS_TYP
, nls_territory VARCHAR2(30)
, cust_email VARCHAR2(40))
PARTITION BY LIST (nls_territory) (
PARTITION asia VALUES ('CHINA', 'THAILAND'),
PARTITION europe VALUES ('GERMANY', 'ITALY', 'SWITZERLAND'),
PARTITION west VALUES ('AMERICA'),
PARTITION east VALUES ('INDIA'),
PARTITION rest VALUES (DEFAULT));
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CREATE-TABLE-54.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CREATE-TABLE.html
CREATE TABLE print_media_demo
( product_id NUMBER(6)
, ad_id NUMBER(6)
, ad_composite BLOB
, ad_sourcetext CLOB
, ad_finaltext CLOB
, ad_fltextn NCLOB
, ad_textdocs_ntab textdoc_tab
, ad_photo BLOB
, ad_graphic BFILE
, ad_header adheader_typ
) NESTED TABLE ad_textdocs_ntab STORE AS textdocs_nestedtab_demo
LOB (ad_composite, ad_photo, ad_finaltext)
STORE AS(STORAGE (INITIAL 20M))
PARTITION BY RANGE (product_id)
(PARTITION p1 VALUES LESS THAN (3000) TABLESPACE tbs_01
LOB (ad_composite, ad_photo)
STORE AS (TABLESPACE tbs_02 STORAGE (INITIAL 10M))
NESTED TABLE ad_textdocs_ntab STORE AS nt_p1 (TABLESPACE example),
PARTITION P2 VALUES LESS THAN (MAXVALUE)
LOB (ad_composite, ad_finaltext)
STORE AS SECUREFILE (TABLESPACE auto_seg_ts)
NESTED TABLE ad_textdocs_ntab STORE AS nt_p2
)
TABLESPACE tbs_03;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CREATE-TABLE-55.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CREATE-TABLE.html
CREATE TABLE hash_products
( product_id NUMBER(6) PRIMARY KEY
, product_name VARCHAR2(50)
, product_description VARCHAR2(2000)
, category_id NUMBER(2)
, weight_class NUMBER(1)
, warranty_period INTERVAL YEAR TO MONTH
, supplier_id NUMBER(6)
, product_status VARCHAR2(20)
, list_price NUMBER(8,2)
, min_price NUMBER(8,2)
, catalog_url VARCHAR2(50)
, CONSTRAINT product_status_lov_demo
CHECK (product_status in ('orderable'
,'planned'
,'under development'
,'obsolete')
) )
PARTITION BY HASH (product_id)
PARTITIONS 4
STORE IN (tbs_01, tbs_02, tbs_03, tbs_04);
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CREATE-TABLE-56.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CREATE-TABLE.html
CREATE TABLE part_order_items (
order_id NUMBER(12) PRIMARY KEY,
line_item_id NUMBER(3),
product_id NUMBER(6) NOT NULL,
unit_price NUMBER(8,2),
quantity NUMBER(8),
CONSTRAINT product_id_fk
FOREIGN KEY (product_id) REFERENCES hash_products(product_id))
PARTITION BY REFERENCE (product_id_fk);
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CREATE-TABLE-57.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CREATE-TABLE.html
CREATE TABLE composite_sales
( prod_id NUMBER(6)
, cust_id NUMBER
, time_id DATE
, channel_id CHAR(1)
, promo_id NUMBER(6)
, quantity_sold NUMBER(3)
, amount_sold NUMBER(10,2)
)
PARTITION BY RANGE (time_id)
SUBPARTITION BY HASH (channel_id)
(PARTITION SALES_Q1_1998 VALUES LESS THAN (TO_DATE('01-APR-1998','DD-MON-YYYY')),
PARTITION SALES_Q2_1998 VALUES LESS THAN (TO_DATE('01-JUL-1998','DD-MON-YYYY')),
PARTITION SALES_Q3_1998 VALUES LESS THAN (TO_DATE('01-OCT-1998','DD-MON-YYYY')),
PARTITION SALES_Q4_1998 VALUES LESS THAN (TO_DATE('01-JAN-1999','DD-MON-YYYY')),
PARTITION SALES_Q1_1999 VALUES LESS THAN (TO_DATE('01-APR-1999','DD-MON-YYYY')),
PARTITION SALES_Q2_1999 VALUES LESS THAN (TO_DATE('01-JUL-1999','DD-MON-YYYY')),
PARTITION SALES_Q3_1999 VALUES LESS THAN (TO_DATE('01-OCT-1999','DD-MON-YYYY')),
PARTITION SALES_Q4_1999 VALUES LESS THAN (TO_DATE('01-JAN-2000','DD-MON-YYYY')),
PARTITION SALES_Q1_2000 VALUES LESS THAN (TO_DATE('01-APR-2000','DD-MON-YYYY')),
PARTITION SALES_Q2_2000 VALUES LESS THAN (TO_DATE('01-JUL-2000','DD-MON-YYYY'))
SUBPARTITIONS 8,
PARTITION SALES_Q3_2000 VALUES LESS THAN (TO_DATE('01-OCT-2000','DD-MON-YYYY'))
(SUBPARTITION ch_c,
SUBPARTITION ch_i,
SUBPARTITION ch_p,
SUBPARTITION ch_s,
SUBPARTITION ch_t),
PARTITION SALES_Q4_2000 VALUES LESS THAN (MAXVALUE)
SUBPARTITIONS 4)
;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CREATE-TABLE-58.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CREATE-TABLE.html
CREATE TABLE customers_part (
customer_id NUMBER(6),
cust_first_name VARCHAR2(20),
cust_last_name VARCHAR2(20),
nls_territory VARCHAR2(30),
credit_limit NUMBER(9,2))
PARTITION BY RANGE (credit_limit)
SUBPARTITION BY LIST (nls_territory)
SUBPARTITION TEMPLATE
(SUBPARTITION east VALUES
('CHINA', 'JAPAN', 'INDIA', 'THAILAND'),
SUBPARTITION west VALUES
('AMERICA', 'GERMANY', 'ITALY', 'SWITZERLAND'),
SUBPARTITION other VALUES (DEFAULT))
(PARTITION p1 VALUES LESS THAN (1000),
PARTITION p2 VALUES LESS THAN (2500),
PARTITION p3 VALUES LESS THAN (MAXVALUE));
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CREATE-TABLE-59.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CREATE-TABLE.html
CREATE TYPE department_typ AS OBJECT
( d_name VARCHAR2(100),
d_address VARCHAR2(200) );
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CREATE-TABLE-6.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CREATE-TABLE.html
CREATE BLOCKCHAIN TABLE bank_ledger (bank VARCHAR2(128), account_no NUMBER, deposit_date DATE, deposit_amount NUMBER)
NO DROP UNTIL 31 DAYS IDLE
NO DELETE LOCKED
HASHING USING SHA2_512 WITH ROW VERSION AND USER CHAIN bank_accounts (bank, account_no) VERSION V2;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CREATE-TABLE-60.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CREATE-TABLE.html
CREATE TABLE departments_obj_t OF department_typ;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CREATE-TABLE-61.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CREATE-TABLE.html
CREATE OR REPLACE TYPE salesrep_typ AS OBJECT
( repId NUMBER,
repName VARCHAR2(64));
CREATE TABLE salesreps OF salesrep_typ;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CREATE-TABLE-62.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CREATE-TABLE.html
CREATE TYPE employees_typ AS OBJECT
(e_no NUMBER, e_address CHAR(30));
/
CREATE TABLE employees_obj_t OF employees_typ (e_no PRIMARY KEY)
OBJECT IDENTIFIER IS PRIMARY KEY;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CREATE-TABLE-63.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CREATE-TABLE.html
CREATE TABLE departments_t
(d_no NUMBER,
mgr_ref REF employees_typ SCOPE IS employees_obj_t);
CREATE TABLE departments_t (
d_no NUMBER,
mgr_ref REF employees_typ
CONSTRAINT mgr_in_emp REFERENCES employees_obj_t);
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CREATE-TABLE-64.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CREATE-TABLE.html
CREATE TYPE address_t AS OBJECT
( hno NUMBER,
street VARCHAR2(40),
city VARCHAR2(20),
zip VARCHAR2(5),
phone VARCHAR2(10) );
/
CREATE TYPE person AS OBJECT
( name VARCHAR2(40),
dateofbirth DATE,
homeaddress address_t,
manager REF person );
/
CREATE TABLE persons OF person
( homeaddress NOT NULL,
UNIQUE (homeaddress.phone),
CHECK (homeaddress.zip IS NOT NULL),
CHECK (homeaddress.city <> 'San Francisco') );
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CREATE-TABLE-65.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CREATE-TABLE.html
CREATE TABLE t1 (T NUMBER) ANNOTATIONS(Operations 'Sort', Operations 'Group', Hidden);
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CREATE-TABLE-66.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CREATE-TABLE.html
CREATE TABLE t1 (T NUMBER) ANNOTATIONS (ADD Hidden);
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CREATE-TABLE-67.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CREATE-TABLE.html
CREATE TABLE t1 (T NUMBER ANNOTATIONS(Operations 'Sort' , Hidden) );
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CREATE-TABLE-69.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CREATE-TABLE.html
CREATE DOMAIN dn1 AS NUMBER;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CREATE-TABLE-7.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CREATE-TABLE.html
CREATE BLOCKCHAIN TABLE bank_ledger (bank VARCHAR2(128), deposit_date DATE, deposit_amount NUMBER)
NO DROP UNTIL 31 DAYS IDLE
NO DELETE LOCKED
HASHING USING SHA2_512 VERSION V2;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CREATE-TABLE-70.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CREATE-TABLE.html
CREATE DOMAIN dn2 AS (c1 AS NUMBER NOT NULL, c2 as NUMBER DEFAULT 1);
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CREATE-TABLE-71.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CREATE-TABLE.html
CREATE DOMAIN dm1 AS
(ann AS NUMBER NOT NULL ,
bnnpos AS NUMBER NOT NULL CONSTRAINT CHECK (bnnpos > 0),
c AS VARCHAR2(10) DEFAULT 'abc',
ddon AS NUMBER DEFAULT ON NULL 10)
CONSTRAINT CHECK (ann+ddon < = 100)
CONSTRAINT CHECK (length(c) > bnnpos);
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CREATE-TABLE-72.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CREATE-TABLE.html
CREATE TABLE tm1 (c1 NUMBER, c2 NUMBER, c3 VARCHAR2(15),c4 NUMBER, c5 NUMBER,
c6 NUMBER, c7 NUMBER, DOMAIN dm1 (c1, c2, c3, c4),
DOMAIN dn2(c5, c6), DOMAIN dn1(c7));
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CREATE-TABLE-73.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CREATE-TABLE.html
CREATE TABLE t1 OF XMLTYPE
XMLTYPE STORE AS TRANSPORTABLE BINARY XML;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CREATE-TABLE-74.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CREATE-TABLE.html
CREATE TABLE t2 (id NUMBER, doc XMLTYPE)
XMLTYPE doc STORE AS TRANSPORTABLE BINARY XML;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CREATE-TABLE-75.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CREATE-TABLE.html
ALTER TABLE t3 ADD (doc XMLTYPE)
XMLTYPE doc STORE AS TRANSPORTABLE BINARY XML;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CREATE-TABLE-8.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CREATE-TABLE.html
CREATE TABLE mydoc(id NUMBER, docCreationTime DATE, doc CLOB, json_doc JSON) INMEMORY TEXT(DOC, JSON_DOC)
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CREATE-TABLE-9.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CREATE-TABLE.html
CREATE TABLE mydoc(id NUMBER, docCreationTime DATE, doc CLOB, json_doc JSON) INMEMORY PRIORITY CRITICAL
INMEMORY TEXT(DOC, JSON_DOC)
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CREATE-TABLESPACE-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CREATE-TABLESPACE.html
CREATE BIGFILE TABLESPACE sh_lwp1 DATAFILE sh_lwp1.df SIZE 10M BLOCKSIZE 8K
LOST WRITE PROTECTION;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CREATE-TABLESPACE-1.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CREATE-TABLESPACE.html
CREATE BIGFILE TABLESPACE bigtbs_01
DATAFILE 'bigtbs_f1.dbf'
SIZE 20M AUTOEXTEND ON;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CREATE-TABLESPACE-10.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CREATE-TABLESPACE.html
CREATE TABLESPACE lmt1 DATAFILE 'lmt_file2.dbf' SIZE 100m REUSE
EXTENT MANAGEMENT LOCAL UNIFORM SIZE 1M;
CREATE TABLE lmt_table1 (col1 NUMBER, col2 VARCHAR2(20))
TABLESPACE lmt1 STORAGE (INITIAL 2m);
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CREATE-TABLESPACE-11.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CREATE-TABLESPACE.html
CREATE TABLESPACE lmt2 DATAFILE 'lmt_file3.dbf' SIZE 100m REUSE
EXTENT MANAGEMENT LOCAL;
CREATE TABLE lmt_table2 (col1 NUMBER, col2 VARCHAR2(20))
TABLESPACE lmt2 STORAGE (INITIAL 2m MAXSIZE 100m);
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CREATE-TABLESPACE-12.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CREATE-TABLESPACE.html
ALTER SYSTEM SET ENCRYPTION WALLET OPEN IDENTIFIED BY "wallet_password";
CREATE TABLESPACE encrypt_ts
DATAFILE '$ORACLE_HOME/dbs/encrypt_df.dbf' SIZE 1M
ENCRYPTION USING 'AES256' ENCRYPT;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CREATE-TABLESPACE-14.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CREATE-TABLESPACE.html
CREATE TABLESPACE auto_seg_ts DATAFILE 'file_2.dbf' SIZE 1M
EXTENT MANAGEMENT LOCAL
SEGMENT SPACE MANAGEMENT AUTO;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CREATE-TABLESPACE-15.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CREATE-TABLESPACE.html
ALTER SYSTEM SET DB_CREATE_FILE_DEST = '$ORACLE_HOME/rdbms/dbs';
CREATE TABLESPACE omf_ts1;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CREATE-TABLESPACE-16.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CREATE-TABLESPACE.html
CREATE TABLESPACE omf_ts2 DATAFILE AUTOEXTEND OFF;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CREATE-TABLESPACE-2.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CREATE-TABLESPACE.html
CREATE UNDO TABLESPACE undots1
DATAFILE 'undotbs_1a.dbf'
SIZE 10M AUTOEXTEND ON
RETENTION GUARANTEE;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CREATE-TABLESPACE-3.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CREATE-TABLESPACE.html
CREATE TEMPORARY TABLESPACE temp_demo
TEMPFILE 'temp01.dbf' SIZE 5M AUTOEXTEND ON;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CREATE-TABLESPACE-4.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CREATE-TABLESPACE.html
ALTER SYSTEM SET DB_CREATE_FILE_DEST = '$ORACLE_HOME/rdbms/dbs';
CREATE TEMPORARY TABLESPACE tbs_05;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CREATE-TABLESPACE-5.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CREATE-TABLESPACE.html
CREATE TEMPORARY TABLESPACE tbs_temp_02
TEMPFILE 'temp02.dbf' SIZE 5M AUTOEXTEND ON
TABLESPACE GROUP tbs_grp_01;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CREATE-TABLESPACE-6.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CREATE-TABLESPACE.html
CREATE TABLESPACE tbs_01
DATAFILE 'tbs_f2.dbf' SIZE 40M
ONLINE;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CREATE-TABLESPACE-7.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CREATE-TABLESPACE.html
CREATE TABLESPACE tbs_03
DATAFILE 'tbs_f03.dbf' SIZE 20M
LOGGING;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CREATE-TABLESPACE-8.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CREATE-TABLESPACE.html
CREATE TABLESPACE tbs_02
DATAFILE 'diskb:tbs_f5.dbf' SIZE 500K REUSE
AUTOEXTEND ON NEXT 500K MAXSIZE 100M;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CREATE-TABLESPACE-9.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CREATE-TABLESPACE.html
CREATE TABLESPACE tbs_04 DATAFILE 'file_1.dbf' SIZE 10M
EXTENT MANAGEMENT LOCAL UNIFORM SIZE 128K;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CREATE-TABLESPACE-SET-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CREATE-TABLESPACE-SET.html
CREATE TABLESPACE SET ts1
IN SHARDSPACE sgr1
USING TEMPLATE
( DATAFILE SIZE 100m
EXTENT MANAGEMENT LOCAL
SEGMENT SPACE MANAGEMENT AUTO
);
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CREATE-USER-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CREATE-USER.html
CREATE USER jsmith IDENTIFIED EXTERNALLY AS "CN=foo,DNQ=123,SERIAL=234";
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CREATE-USER-1.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CREATE-USER.html
CREATE USER tjones IDENTIFIED EXTERNALLY AS "CN=foo,dnQualifier=123,SERIALNUMER=234";
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CREATE-USER-2.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CREATE-USER.html
CREATE USER peter_fitch IDENTIFIED GLOBALLY AS 'AZURE_USER=peter.fitch@example.com';
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CREATE-USER-3.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CREATE-USER.html
CREATE USER dba_azure IDENTIFIED GLOBALLY AS 'AZURE_ROLE=AZURE_DBA';
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CREATE-USER-4.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CREATE-USER.html
CREATE USER u1 IDENTIFIED BY p1 PROFILE prof1 ;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CREATE-USER-5.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CREATE-USER.html
CREATE USER sidney
IDENTIFIED BY out_standing1
DEFAULT TABLESPACE example
QUOTA 10M ON example
TEMPORARY TABLESPACE temp
QUOTA 5M ON system
PROFILE app_user
PASSWORD EXPIRE;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CREATE-USER-6.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CREATE-USER.html
CREATE USER app_user1
IDENTIFIED EXTERNALLY
DEFAULT TABLESPACE example
QUOTA 5M ON example
PROFILE app_user;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CREATE-USER-7.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CREATE-USER.html
CREATE USER ops$external_user
IDENTIFIED EXTERNALLY
DEFAULT TABLESPACE example
QUOTA 5M ON example
PROFILE app_user;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CREATE-USER-8.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CREATE-USER.html
CREATE USER global_user
IDENTIFIED GLOBALLY AS 'CN=analyst, OU=division1, O=oracle, C=US'
DEFAULT TABLESPACE example
QUOTA 5M ON example;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CREATE-USER-9.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CREATE-USER.html
CREATE USER c##comm_user
IDENTIFIED BY comm_pwd
DEFAULT TABLESPACE example
QUOTA 20M ON example
TEMPORARY TABLESPACE temp_tbs;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CREATE-VIEW-1.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CREATE-VIEW.html
CREATE VIEW emp_view AS
SELECT last_name, salary*12 annual_salary
FROM employees
WHERE department_id = 20;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CREATE-VIEW-10.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CREATE-VIEW.html
CREATE VIEW customer_ro (name, language, credit)
AS SELECT cust_last_name, nls_language, credit_limit
FROM customers
WITH READ ONLY;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CREATE-VIEW-11.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CREATE-VIEW.html
CREATE TYPE inventory_typ
OID '82A4AF6A4CD4656DE034080020E0EE3D'
AS OBJECT
( product_id NUMBER(6)
, warehouse warehouse_typ
, quantity_on_hand NUMBER(8)
) ;
/
CREATE OR REPLACE VIEW oc_inventories OF inventory_typ
WITH OBJECT OID (product_id)
AS SELECT i.product_id,
warehouse_typ(w.warehouse_id, w.warehouse_name, w.location_id),
i.quantity_on_hand
FROM inventories i, warehouses w
WHERE i.warehouse_id=w.warehouse_id;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CREATE-VIEW-12.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CREATE-VIEW.html
CREATE VIEW warehouse_view AS
SELECT VALUE(p) AS warehouse_xml
FROM xwarehouses p;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CREATE-VIEW-13.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CREATE-VIEW.html
SELECT e.warehouse_xml.getclobval()
FROM warehouse_view e
WHERE EXISTSNODE(warehouse_xml, '//Docks') =1;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CREATE-VIEW-14.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CREATE-VIEW.html
CREATE TABLE warehouse_table
(
WarehouseID NUMBER,
Area NUMBER,
Docks NUMBER,
DockType VARCHAR2(100),
WaterAccess VARCHAR2(10),
RailAccess VARCHAR2(10),
Parking VARCHAR2(20),
VClearance NUMBER
);
INSERT INTO warehouse_table
VALUES(5, 103000,3,'Side Load','false','true','Lot',15);
CREATE VIEW warehouse_view OF XMLTYPE
XMLSCHEMA "http://www.example.com/xwarehouses.xsd"
ELEMENT "Warehouse"
WITH OBJECT ID
(extract(OBJECT_VALUE, '/Warehouse/Area/text()').getnumberval())
AS SELECT XMLELEMENT("Warehouse",
XMLFOREST(WarehouseID as "Building",
area as "Area",
docks as "Docks",
docktype as "DockType",
wateraccess as "WaterAccess",
railaccess as "RailAccess",
parking as "Parking",
VClearance as "VClearance"))
FROM warehouse_table;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CREATE-VIEW-15.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CREATE-VIEW.html
SELECT VALUE(e) FROM warehouse_view e;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CREATE-VIEW-2.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CREATE-VIEW.html
CREATE EDITIONING VIEW ed_orders_view (o_id, o_date, o_status)
AS SELECT order_id, order_date, order_status FROM orders
WITH READ ONLY;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CREATE-VIEW-3.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CREATE-VIEW.html
CREATE VIEW emp_sal (emp_id, last_name,
email UNIQUE RELY DISABLE NOVALIDATE,
CONSTRAINT id_pk PRIMARY KEY (emp_id) RELY DISABLE NOVALIDATE)
AS SELECT employee_id, last_name, email FROM employees;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CREATE-VIEW-4.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CREATE-VIEW.html
CREATE VIEW clerk AS
SELECT employee_id, last_name, department_id, job_id
FROM employees
WHERE job_id = 'PU_CLERK'
or job_id = 'SH_CLERK'
or job_id = 'ST_CLERK';
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CREATE-VIEW-5.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CREATE-VIEW.html
UPDATE clerk SET job_id = 'PU_MAN' WHERE employee_id = 118;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CREATE-VIEW-6.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CREATE-VIEW.html
CREATE VIEW clerk AS
SELECT employee_id, last_name, department_id, job_id
FROM employees
WHERE job_id = 'PU_CLERK'
or job_id = 'SH_CLERK'
or job_id = 'ST_CLERK'
WITH CHECK OPTION;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CREATE-VIEW-7.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CREATE-VIEW.html
CREATE VIEW locations_view AS
SELECT d.department_id, d.department_name, l.location_id, l.city
FROM departments d, locations l
WHERE d.location_id = l.location_id;
SELECT column_name, updatable
FROM user_updatable_columns
WHERE table_name = 'LOCATIONS_VIEW'
ORDER BY column_name, updatable;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CREATE-VIEW-8.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CREATE-VIEW.html
INSERT INTO locations_view VALUES
(999, 'Entertainment', 87, 'Roma');
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CREATE-VIEW-9.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CREATE-VIEW.html
INSERT INTO locations_view (department_id, department_name)
VALUES (999, 'Entertainment');
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CUBE_TABLE-1.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CUBE_TABLE.html
SELECT dim_key, level_name, long_description, channel_total_id tot_id,
channel_channel_id chan_id, channel_long_description chan_desc,
total_long_description tot_desc
FROM TABLE(CUBE_TABLE('global.channel'));
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CUBE_TABLE-2.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CUBE_TABLE.html
SELECT sales, units, cost, time, customer, product, channel
FROM TABLE(CUBE_TABLE('global.units_cube HIERARCHY customer market HIERARCHY time calendar'))
WHERE rownum < 20;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CUME_DIST-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CUME_DIST.html
SELECT CUME_DIST(15500, .05) WITHIN GROUP
(ORDER BY salary, commission_pct) "Cume-Dist of 15500"
FROM employees;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CUME_DIST-1.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CUME_DIST.html
SELECT job_id, last_name, salary, CUME_DIST()
OVER (PARTITION BY job_id ORDER BY salary) AS cume_dist
FROM employees
WHERE job_id LIKE 'PU%'
ORDER BY job_id, last_name, salary, cume_dist;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CURRENT_DATE-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CURRENT_DATE.html
ALTER SESSION SET TIME_ZONE = '-5:0';
ALTER SESSION SET NLS_DATE_FORMAT = 'DD-MON-YYYY HH24:MI:SS';
SELECT SESSIONTIMEZONE, CURRENT_DATE FROM DUAL;
ALTER SESSION SET TIME_ZONE = '-8:0';
SELECT SESSIONTIMEZONE, CURRENT_DATE FROM DUAL;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CURRENT_TIMESTAMP-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CURRENT_TIMESTAMP.html
ALTER SESSION SET TIME_ZONE = '-5:0';
ALTER SESSION SET NLS_DATE_FORMAT = 'DD-MON-YYYY HH24:MI:SS';
SELECT SESSIONTIMEZONE, CURRENT_TIMESTAMP FROM DUAL;
ALTER SESSION SET TIME_ZONE = '-8:0';
SELECT SESSIONTIMEZONE, CURRENT_TIMESTAMP FROM DUAL;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CURRENT_TIMESTAMP-1.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CURRENT_TIMESTAMP.html
CREATE TABLE current_test (col1 TIMESTAMP WITH TIME ZONE);
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CURRENT_TIMESTAMP-2.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CURRENT_TIMESTAMP.html
INSERT INTO current_test VALUES
(TO_TIMESTAMP_TZ(CURRENT_TIMESTAMP, 'DD-MON-RR HH.MI.SSXFF PM'));
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CURRENT_TIMESTAMP-3.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CURRENT_TIMESTAMP.html
INSERT INTO current_test VALUES
(TO_TIMESTAMP_TZ(CURRENT_TIMESTAMP, 'DD-MON-RR HH.MI.SSXFF PM TZH:TZM'));
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CURSOR-Expressions-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CURSOR-Expressions.html
SELECT department_name, CURSOR(SELECT salary, commission_pct
FROM employees e
WHERE e.department_id = d.department_id)
FROM departments d
ORDER BY department_name;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CURSOR-Expressions-1.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CURSOR-Expressions.html
CREATE FUNCTION f(cur SYS_REFCURSOR, mgr_hiredate DATE)
RETURN NUMBER IS
emp_hiredate DATE;
before number :=0;
after number:=0;
begin
loop
fetch cur into emp_hiredate;
exit when cur%NOTFOUND;
if emp_hiredate > mgr_hiredate then
after:=after+1;
else
before:=before+1;
end if;
end loop;
close cur;
if before > after then
return 1;
else
return 0;
end if;
end;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CURSOR-Expressions-2.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CURSOR-Expressions.html
SELECT e1.last_name FROM employees e1
WHERE f(
CURSOR(SELECT e2.hire_date FROM employees e2
WHERE e1.employee_id = e2.manager_id),
e1.hire_date) = 1
ORDER BY last_name;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/CV-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CV.html
SELECT country, prod, year, s
FROM sales_view_ref
MODEL
PARTITION BY (country)
DIMENSION BY (prod, year)
MEASURES (sale s)
IGNORE NAV
UNIQUE DIMENSION
RULES UPSERT SEQUENTIAL ORDER
(
s[FOR prod IN ('Mouse Pad', 'Standard Mouse'), 2001] =
s[CV( ), 1999] + s[CV( ), 2000]
)
ORDER BY country, prod, year;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/Comments-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/Comments.html
SELECT last_name, employee_id, salary + NVL(commission_pct, 0),
job_id, e.department_id
/* Select all employees whose compensation is
greater than that of Pataballa.*/
FROM employees e, departments d
/*The DEPARTMENTS table is used to get the department name.*/
WHERE e.department_id = d.department_id
AND salary + NVL(commission_pct,0) > /* Subquery: */
(SELECT salary + NVL(commission_pct,0)
/* total compensation is salary + commission_pct */
FROM employees
WHERE last_name = 'Pataballa')
ORDER BY last_name, employee_id;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/Comments-1.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/Comments.html
CREATE VIEW v AS
SELECT e.last_name, e.department_id, d.location_id
FROM employees e, departments d
WHERE e.department_id = d.department_id;
CREATE TABLE t AS
SELECT * from employees
WHERE employee_id < 200;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/Comments-10.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/Comments.html
SELECT /*+ DYNAMIC_SAMPLING(e 1) */ count(*)
FROM employees e;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/Comments-12.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/Comments.html
SELECT /*+ FIRST_ROWS(10) */ employee_id, last_name, salary, job_id
FROM employees
WHERE department_id = 20;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/Comments-13.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/Comments.html
SELECT /*+ FULL(e) */ employee_id, last_name
FROM hr.employees e
WHERE last_name LIKE :b1;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/Comments-15.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/Comments.html
SELECT /*+ INDEX (employees emp_department_ix)*/ employee_id, department_id
FROM employees
WHERE department_id > 50;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/Comments-16.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/Comments.html
SELECT /*+ INDEX_COMBINE(e emp_manager_ix emp_department_ix) */ *
FROM employees e
WHERE manager_id = 108
OR department_id = 110;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/Comments-17.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/Comments.html
SELECT /*+ INDEX_DESC(e emp_name_ix) */ *
FROM employees e;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/Comments-18.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/Comments.html
SELECT /*+ INDEX_FFS(e emp_name_ix) */ first_name
FROM employees e;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/Comments-19.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/Comments.html
SELECT /*+ INDEX_JOIN(e emp_manager_ix emp_department_ix) */ department_id
FROM employees e
WHERE manager_id < 110
AND department_id < 50;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/Comments-2.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/Comments.html
EXPLAIN PLAN
SET STATEMENT_ID = 'Test 1'
INTO plan_table FOR
(SELECT /*+ LEADING(v.e v.d t) */ *
FROM t, v
WHERE t.department_id = v.department_id);
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/Comments-20.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/Comments.html
SELECT /*+ INDEX_SS(e emp_name_ix) */ last_name
FROM employees e
WHERE first_name = 'Steven';
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/Comments-21.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/Comments.html
SELECT /*+ INDEX_SS_DESC(e emp_name_ix) */ last_name
FROM employees e
WHERE first_name = 'Steven';
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/Comments-22.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/Comments.html
SELECT /*+ LEADING(e j) */ *
FROM employees e, departments d, job_history j
WHERE e.department_id = d.department_id
AND e.hire_date = j.start_date;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/Comments-23.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/Comments.html
SELECT /*+ MERGE(v) */ e1.last_name, e1.salary, v.avg_salary
FROM employees e1,
(SELECT department_id, avg(salary) avg_salary
FROM employees e2
GROUP BY department_id) v
WHERE e1.department_id = v.department_id
AND e1.salary > v.avg_salary
ORDER BY e1.last_name;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/Comments-24.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/Comments.html
SELECT /*+ FULL(hr_emp) NOCACHE(hr_emp) */ last_name
FROM employees hr_emp;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/Comments-25.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/Comments.html
SELECT /*+ NO_EXPAND */ *
FROM employees e, departments d
WHERE e.manager_id = 108
OR d.department_id = 110;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/Comments-26.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/Comments.html
SELECT /*+ NO_INDEX(employees emp_empid) */ employee_id
FROM employees
WHERE employee_id > 200;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/Comments-27.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/Comments.html
SELECT /*+ NO_INDEX_FFS(items item_order_ix) */ order_id
FROM order_items items;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/Comments-28.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/Comments.html
SELECT /*+ NO_MERGE(seattle_dept) */ e1.last_name, seattle_dept.department_name
FROM employees e1,
(SELECT location_id, department_id, department_name
FROM departments
WHERE location_id = 1700) seattle_dept
WHERE e1.department_id = seattle_dept.department_id;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/Comments-29.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/Comments.html
ALTER TABLE employees PARALLEL 8;
SELECT /*+ NO_PARALLEL(hr_emp) */ last_name
FROM employees hr_emp;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/Comments-3.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/Comments.html
SELECT id, LPAD(' ',2*(LEVEL-1))||operation operation, options, object_name, object_alias
FROM plan_table
START WITH id = 0 AND statement_id = 'Test 1'
CONNECT BY PRIOR id = parent_id AND statement_id = 'Test 1'
ORDER BY id;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/Comments-30.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/Comments.html
SELECT /*+ NO_MERGE(v) NO_PUSH_PRED(v) */ *
FROM employees e,
(SELECT manager_id
FROM employees) v
WHERE e.manager_id = v.manager_id(+)
AND e.employee_id = 100;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/Comments-31.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/Comments.html
SELECT /*+ NO_QUERY_TRANSFORMATION */ employee_id, last_name
FROM (SELECT * FROM employees e) v
WHERE v.last_name = 'Smith';
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/Comments-32.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/Comments.html
SELECT /*+ NO_REWRITE */ sum(s.amount_sold) AS dollars
FROM sales s, times t
WHERE s.time_id = t.time_id
GROUP BY t.calendar_month_desc;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/Comments-33.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/Comments.html
SELECT /*+ NO_STATEMENT_QUEUING */ emp.last_name, dpt.department_name
FROM employees emp, departments dpt
WHERE emp.department_id = dpt.department_id;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/Comments-34.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/Comments.html
SELECT /*+ NO_USE_BAND(e1 e2) */
e1.last_name
|| ' has salary between 100 less and 100 more than '
|| e2.last_name AS "SALARY COMPARISON"
FROM employees e1, employees e2
WHERE e1.salary BETWEEN e2.salary - 100 AND e2.salary + 100;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/Comments-35.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/Comments.html
SELECT /*+ NO_USE_HASH(e d) */ *
FROM employees e, departments d
WHERE e.department_id = d.department_id;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/Comments-36.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/Comments.html
SELECT /*+ NO_USE_MERGE(e d) */ *
FROM employees e, departments d
WHERE e.department_id = d.department_id
ORDER BY d.department_id;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/Comments-37.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/Comments.html
SELECT /*+ NO_USE_NL(l h) */ *
FROM orders h, order_items l
WHERE l.order_id = h.order_id
AND l.order_id > 2400;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/Comments-38.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/Comments.html
SELECT /*+NO_XML_QUERY_REWRITE*/ XMLQUERY('' RETURNING CONTENT)
FROM DUAL;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/Comments-39.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/Comments.html
SELECT /*+NO_XMLINDEX_REWRITE*/ count(*)
FROM warehouses
WHERE existsNode(warehouse_spec, '/Warehouse/Building') = 1;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/Comments-4.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/Comments.html
EXPLAIN PLAN
SET STATEMENT_ID = 'Test 2'
INTO plan_table FOR
(SELECT /*+ LEADING(E@SEL$2 D@SEL$2 T@SEL$1) */ *
FROM t, v
WHERE t.department_id = v.department_id);
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/Comments-41.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/Comments.html
SELECT /*+ ORDERED */ o.order_id, c.customer_id, l.unit_price * l.quantity
FROM customers c, order_items l, orders o
WHERE c.cust_last_name = 'Taylor'
AND o.customer_id = c.customer_id
AND o.order_id = l.order_id;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/Comments-42.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/Comments.html
SELECT /*+ PARALLEL */ last_name
FROM employees;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/Comments-43.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/Comments.html
SELECT /*+ PARALLEL (AUTO) */ last_name
FROM employees;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/Comments-44.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/Comments.html
CREATE TABLE parallel_table (col1 number, col2 VARCHAR2(10)) PARALLEL 5;
SELECT /*+ PARALLEL (MANUAL) */ col2
FROM parallel_table;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/Comments-45.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/Comments.html
SELECT /*+ FULL(hr_emp) PARALLEL(hr_emp, 5) */ last_name
FROM employees hr_emp;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/Comments-46.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/Comments.html
SELECT /*+ FULL(hr_emp) PARALLEL(hr_emp, DEFAULT) */ last_name
FROM employees hr_emp;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/Comments-48.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/Comments.html
INSERT /*+ APPEND PARALLEL(target_table, 16) PQ_DISTRIBUTE(target_table, NONE) */
INTO target_table
SELECT * FROM source_table;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/Comments-49.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/Comments.html
CREATE /*+ PQ_DISTRIBUTE(target_table, PARTITION) */ TABLE target_table
NOLOGGING PARALLEL 16
PARTITION BY HASH (l_orderkey) PARTITIONS 512
AS SELECT * FROM source_table;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/Comments-5.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/Comments.html
SELECT id, LPAD(' ',2*(LEVEL-1))||operation operation, options,
object_name, object_alias
FROM plan_table
START WITH id = 0 AND statement_id = 'Test 2'
CONNECT BY PRIOR id = parent_id AND statement_id = 'Test 2'
ORDER BY id;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/Comments-50.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/Comments.html
SELECT /*+ORDERED PQ_DISTRIBUTE(s HASH, HASH) USE_HASH (s)*/ column_list
FROM r,s
WHERE r.c=s.c;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/Comments-51.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/Comments.html
SELECT /*+ORDERED PQ_DISTRIBUTE(s BROADCAST, NONE) USE_HASH (s) */ column_list
FROM r,s
WHERE r.c=s.c;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/Comments-52.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/Comments.html
SELECT /*+ NO_MERGE(v) PUSH_PRED(v) */ *
FROM employees e,
(SELECT manager_id
FROM employees) v
WHERE e.manager_id = v.manager_id(+)
AND e.employee_id = 100;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/Comments-53.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/Comments.html
SELECT /*+ QB_NAME(qb) FULL(@qb e) */ employee_id, last_name
FROM employees e
WHERE last_name = 'Smith';
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/Comments-56.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/Comments.html
SELECT /*+ STAR_TRANSFORMATION */ s.time_id, s.prod_id, s.channel_id
FROM sales s, times t, products p, channels c
WHERE s.time_id = t.time_id
AND s.prod_id = p.prod_id
AND s.channel_id = c.channel_id
AND c.channel_desc = 'Tele Sales';
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/Comments-57.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/Comments.html
SELECT /*+ STATEMENT_QUEUING */ emp.last_name, dpt.department_name
FROM employees emp, departments dpt
WHERE emp.department_id = dpt.department_id;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/Comments-58.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/Comments.html
SELECT /*+ USE_BAND(e1 e2) */
e1.last_name
|| ' has salary between 100 less and 100 more than '
|| e2.last_name AS "SALARY COMPARISON"
FROM employees e1, employees e2
WHERE e1.salary BETWEEN e2.salary - 100 AND e2.salary + 100;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/Comments-59.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/Comments.html
SELECT /*+ USE_CONCAT */ *
FROM employees e
WHERE manager_id = 108
OR department_id = 110;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/Comments-6.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/Comments.html
SELECT /*+ ALL_ROWS */ employee_id, last_name, salary, job_id
FROM employees
WHERE employee_id = 107;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/Comments-60.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/Comments.html
SELECT /*+ USE_HASH(l h) */ *
FROM orders h, order_items l
WHERE l.order_id = h.order_id
AND l.order_id > 2400;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/Comments-61.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/Comments.html
SELECT /*+ USE_MERGE(employees departments) */ *
FROM employees, departments
WHERE employees.department_id = departments.department_id;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/Comments-62.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/Comments.html
SELECT /*+ USE_NL(l h) */ h.customer_id, l.unit_price * l.quantity
FROM orders h, order_items l
WHERE l.order_id = h.order_id;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/Comments-63.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/Comments.html
select /*+ LEADING(t2) USE_NL(t1) */ sum(t1.a),sum(t2.a)
from t1 , t2
where t1.b = t2.b;
select * from table(dbms_xplan.display_cursor()) ;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/Comments-64.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/Comments.html
SELECT /*+ USE_NL_WITH_INDEX(l item_product_ix) */ *
FROM orders h, order_items l
WHERE l.order_id = h.order_id
AND l.order_id > 2400;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/Comments-7.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/Comments.html
SELECT /*+ FULL (hr_emp) CACHE(hr_emp) */ last_name
FROM employees hr_emp;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/Comments-8.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/Comments.html
SELECT /*+ CONTAINERS(DEFAULT_PDB_HINT='NO_PARALLEL') */
(CASE WHEN COUNT(*) < 10000
THEN 'Less than 10,000'
ELSE '10,000 or more' END) "Number of Tables"
FROM CONTAINERS(DBA_TABLES);
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/Comments-9.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/Comments.html
SELECT /*+ DRIVING_SITE(departments) */ *
FROM employees, departments@rsite
WHERE employees.department_id = departments.department_id;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/Comparison-Conditions-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/Comparison-Conditions.html
SELECT *
FROM employees
WHERE salary = 2500
ORDER BY employee_id;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/Comparison-Conditions-1.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/Comparison-Conditions.html
SELECT *
FROM employees
WHERE salary != 2500
ORDER BY employee_id;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/Comparison-Conditions-2.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/Comparison-Conditions.html
SELECT * FROM employees
WHERE salary > 2500
ORDER BY employee_id;
SELECT * FROM employees
WHERE salary < 2500
ORDER BY employee_id;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/Comparison-Conditions-3.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/Comparison-Conditions.html
SELECT * FROM employees
WHERE salary >= 2500
ORDER BY employee_id;
SELECT * FROM employees
WHERE salary <= 2500
ORDER BY employee_id;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/Comparison-Conditions-4.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/Comparison-Conditions.html
SELECT * FROM employees
WHERE salary = ANY
(SELECT salary
FROM employees
WHERE department_id = 30)
ORDER BY employee_id;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/Comparison-Conditions-5.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/Comparison-Conditions.html
SELECT * FROM employees
WHERE salary >=
ALL (1400, 3000)
ORDER BY employee_id;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/Concatenation-Operator-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/Concatenation-Operator.html
SELECT 'Name is ' || last_name
FROM employees
ORDER BY last_name;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/Concatenation-Operator-1.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/Concatenation-Operator.html
CREATE TABLE tab1 (col1 VARCHAR2(6), col2 CHAR(6),
col3 VARCHAR2(6), col4 CHAR(6));
INSERT INTO tab1 (col1, col2, col3, col4)
VALUES ('abc', 'def ', 'ghi ', 'jkl');
SELECT col1 || col2 || col3 || col4 "Concatenation"
FROM tab1;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/DBTIMEZONE-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/DBTIMEZONE.html
SELECT DBTIMEZONE
FROM DUAL;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/DECODE-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/DECODE.html
SELECT product_id,
DECODE (warehouse_id, 1, 'Southlake',
2, 'San Francisco',
3, 'New Jersey',
4, 'Seattle',
'Non domestic') "Location"
FROM inventories
WHERE product_id < 1775
ORDER BY product_id, "Location";
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/DECOMPOSE-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/DECOMPOSE.html
SELECT DECOMPOSE ('Châteaux')
FROM DUAL;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/DELETE-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/DELETE.html
DELETE FROM t
FROM s
WHERE t.t1 = s.s1;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/DELETE-1.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/DELETE.html
DELETE FROM product_descriptions
WHERE language_id = 'AR';
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/DELETE-10.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/DELETE.html
DELETE (SELECT * FROM product_price_history) WHERE currency_code = 'EUR';
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/DELETE-11.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/DELETE.html
DELETE product_price_history pp
WHERE (product_id, currency_code, effective_from_date)
IN (SELECT product_id, currency_code, Max(effective_from_date)
FROM product_price_history
GROUP BY product_id, currency_code);
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/DELETE-12.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/DELETE.html
DELETE product_price_history partition (p1);
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/DELETE-13.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/DELETE.html
SELECT * FROM product_price_history;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/DELETE-14.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/DELETE.html
DELETE product_price_history;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/DELETE-2.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/DELETE.html
DELETE FROM employees
WHERE job_id = 'SA_REP'
AND commission_pct < .2;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/DELETE-3.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/DELETE.html
DELETE FROM (SELECT * FROM employees)
WHERE job_id = 'SA_REP'
AND commission_pct < .2;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/DELETE-4.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/DELETE.html
DELETE FROM hr.locations@remote
WHERE location_id > 3000;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/DELETE-5.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/DELETE.html
DELETE FROM sales PARTITION (sales_q1_1998)
WHERE amount_sold > 1000;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/DELETE-6.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/DELETE.html
DELETE FROM employees
WHERE job_id = 'SA_REP'
AND hire_date + TO_YMINTERVAL('01-00') < SYSDATE
RETURNING salary INTO :bnd1;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/DELETE-7.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/DELETE.html
CREATE TABLE product_price_history (
product_id INTEGER NOT NULL,
price INTEGER NOT NULL,
currency_code VARCHAR2(3 CHAR) NOT NULL,
effective_from_date DATE NOT NULL,
effective_to_date DATE,
CONSTRAINT product_price_history_pk
PRIMARY KEY (product_id, currency_code, effective_from_date)
) PARTITION BY RANGE (effective_from_date) (
PARTITION p0 VALUES less than (DATE'2015-01-02'),
PARTITION p1 VALUES less than (DATE'2015-01-03'),
PARTITION p2 VALUES less than (DATE'2015-01-04')
);
INSERT INTO product_price_history
WITH prices AS (
SELECT 1, 100, 'USD', DATE'2015-01-01', DATE'2015-01-02'
FROM dual UNION ALL
SELECT 1, 60, 'GBP', DATE'2015-01-01', DATE'2015-01-02'
FROM dual UNION ALL
SELECT 1, 110, 'EUR', DATE'2015-01-01', DATE'2015-01-02'
FROM dual UNION ALL
SELECT 1, 101, 'USD', DATE'2015-01-02', DATE'2015-01-03'
FROM dual UNION ALL
SELECT 1, 62, 'GBP', DATE'2015-01-02', DATE'2015-01-03'
FROM dual UNION ALL
SELECT 1, 109, 'EUR', DATE'2015-01-02', DATE'2015-01-03'
FROM dual UNION ALL
SELECT 1, 105, 'USD', DATE'2015-01-03', NULL
FROM dual UNION ALL
SELECT 1, 61, 'GBP', DATE'2015-01-03', NULL
FROM dual UNION ALL
SELECT 1, 107, 'EUR', DATE'2015-01-03', NULL
FROM dual UNION ALL
SELECT 2, 30, 'USD', DATE'2015-01-01', DATE'2015-01-03'
FROM dual UNION ALL
SELECT 2, 33, 'USD', DATE'2015-01-03', NULL
FROM dual UNION ALL
SELECT 3, 100, 'GBP', DATE'2015-01-03', NULL
FROM dual
)
SELECT *
FROM prices;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/DELETE-8.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/DELETE.html
DELETE FROM product_price_history WHERE product_id = 3;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/DENSE_RANK-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/DENSE_RANK.html
SELECT DENSE_RANK(15500, .05) WITHIN GROUP
(ORDER BY salary DESC, commission_pct) "Dense Rank"
FROM employees;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/DENSE_RANK-1.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/DENSE_RANK.html
SELECT department_id, last_name, salary,
DENSE_RANK() OVER (PARTITION BY department_id ORDER BY salary) DENSE_RANK
FROM employees WHERE department_id = 60
ORDER BY DENSE_RANK, last_name;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/DEPTH-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/DEPTH.html
SELECT PATH(1), DEPTH(2)
FROM RESOURCE_VIEW
WHERE UNDER_PATH(res, '/sys/schemas/OE', 1)=1
AND UNDER_PATH(res, '/sys/schemas/OE', 2)=1;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/DEREF-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/DEREF.html
INSERT INTO address_table VALUES
('1 First', 'G45 EU8', 'Paris', 'CA', 'US');
INSERT INTO customer_addresses
SELECT 999, REF(a) FROM address_table a;
SELECT address
FROM customer_addresses
ORDER BY address;
SELECT DEREF(address)
FROM customer_addresses;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/DISASSOCIATE-STATISTICS-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/DISASSOCIATE-STATISTICS.html
DISASSOCIATE STATISTICS FROM PACKAGES hr.emp_mgmt;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/DROP-ANALYTIC-VIEW-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/DROP-ANALYTIC-VIEW.html
DROP ANALYTIC VIEW sales_av;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/DROP-ATTRIBUTE-DIMENSION-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/DROP-ATTRIBUTE-DIMENSION.html
DROP ATTRIBUTE DIMENSION product_attr_dim;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/DROP-AUDIT-POLICY-Unified-Auditing-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/DROP-AUDIT-POLICY-Unified-Auditing.html
DROP AUDIT POLICY table_pol;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/DROP-CLUSTER-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/DROP-CLUSTER.html
DROP CLUSTER language;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/DROP-CLUSTER-1.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/DROP-CLUSTER.html
DROP CLUSTER personnel
INCLUDING TABLES
CASCADE CONSTRAINTS;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/DROP-CONTEXT-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/DROP-CONTEXT.html
DROP CONTEXT hr_context;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/DROP-DATABASE-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/DROP-DATABASE.html
STARTUP MOUNT
ALTER SYSTEM ENABLE RESTRICTED SESSION;
DROP DATABASE
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/DROP-DATABASE-LINK-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/DROP-DATABASE-LINK.html
DROP PUBLIC DATABASE LINK remote;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/DROP-DIMENSION-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/DROP-DIMENSION.html
DROP DIMENSION customers_dim;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/DROP-DIRECTORY-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/DROP-DIRECTORY.html
DROP DIRECTORY bfile_dir;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/DROP-DISKGROUP-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/DROP-DISKGROUP.html
DROP DISKGROUP dgroup_01 INCLUDING CONTENTS;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/DROP-FUNCTION-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/DROP-FUNCTION.html
DROP FUNCTION oe.SecondMax;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/DROP-HIERARCHY-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/DROP-HIERARCHY.html
DROP HIERARCHY product_hier;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/DROP-INDEX-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/DROP-INDEX.html
DROP INDEX ord_customer_ix_demo;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/DROP-INDEXTYPE-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/DROP-INDEXTYPE.html
DROP INDEXTYPE position_indextype FORCE;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/DROP-INMEMORY-JOIN-GROUP-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/DROP-INMEMORY-JOIN-GROUP.html
DROP INMEMORY JOIN GROUP prod_id1;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/DROP-JAVA-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/DROP-JAVA.html
DROP JAVA CLASS "Agent";
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/DROP-LIBRARY-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/DROP-LIBRARY.html
DROP LIBRARY ext_lib;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/DROP-LOCKDOWN-PROFILE-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/DROP-LOCKDOWN-PROFILE.html
DROP LOCKDOWN PROFILE hr_prof;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/DROP-MATERIALIZED-VIEW-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/DROP-MATERIALIZED-VIEW.html
DROP MATERIALIZED VIEW emp_data;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/DROP-MATERIALIZED-VIEW-1.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/DROP-MATERIALIZED-VIEW.html
DROP MATERIALIZED VIEW sales_by_month_by_state;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/DROP-MATERIALIZED-VIEW-LOG-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/DROP-MATERIALIZED-VIEW-LOG.html
DROP MATERIALIZED VIEW LOG ON customers;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/DROP-MATERIALIZED-ZONEMAP-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/DROP-MATERIALIZED-ZONEMAP.html
DROP MATERIALIZED ZONEMAP sales_zmap;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/DROP-OPERATOR-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/DROP-OPERATOR.html
DROP OPERATOR eq_op;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/DROP-OUTLINE-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/DROP-OUTLINE.html
DROP OUTLINE salaries;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/DROP-PACKAGE-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/DROP-PACKAGE.html
DROP PACKAGE emp_mgmt;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/DROP-PLUGGABLE-DATABASE-1.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/DROP-PLUGGABLE-DATABASE.html
DROP PLUGGABLE DATABASE pdb1
INCLUDING DATAFILES;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/DROP-PROCEDURE-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/DROP-PROCEDURE.html
DROP PROCEDURE hr.remove_emp;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/DROP-PROFILE-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/DROP-PROFILE.html
DROP PROFILE app_user CASCADE;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/DROP-RESTORE-POINT-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/DROP-RESTORE-POINT.html
DROP RESTORE POINT good_data;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/DROP-ROLE-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/DROP-ROLE.html
DROP ROLE dw_manager;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/DROP-ROLLBACK-SEGMENT-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/DROP-ROLLBACK-SEGMENT.html
DROP ROLLBACK SEGMENT rbs_one;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/DROP-SEQUENCE-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/DROP-SEQUENCE.html
DROP SEQUENCE oe.customers_seq;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/DROP-SYNONYM-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/DROP-SYNONYM.html
DROP PUBLIC SYNONYM customers;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/DROP-TABLE-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/DROP-TABLE.html
DROP TABLE list_customers PURGE;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/DROP-TABLESPACE-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/DROP-TABLESPACE.html
DROP TABLESPACE tbs_01
INCLUDING CONTENTS
CASCADE CONSTRAINTS;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/DROP-TABLESPACE-3.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/DROP-TABLESPACE.html
DROP TABLESPACE tbs_02
INCLUDING CONTENTS AND DATAFILES;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/DROP-TABLESPACE-SET-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/DROP-TABLESPACE-SET.html
DROP TABLESPACE SET ts1;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/DROP-TRIGGER-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/DROP-TRIGGER.html
DROP TRIGGER hr.salary_check;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/DROP-TYPE-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/DROP-TYPE.html
DROP TYPE person_t FORCE;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/DROP-TYPE-BODY-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/DROP-TYPE-BODY.html
DROP TYPE BODY data_typ1;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/DROP-USER-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/DROP-USER.html
DROP USER sidney;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/DROP-USER-1.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/DROP-USER.html
DROP USER sidney CASCADE;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/DROP-VIEW-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/DROP-VIEW.html
DROP VIEW emp_view;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/DUMP-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/DUMP.html
SELECT DUMP('abc', 1016)
FROM DUAL;
SELECT DUMP(last_name, 8, 3, 2) "OCTAL"
FROM employees
WHERE last_name = 'Hunold'
ORDER BY employee_id;
SELECT DUMP(last_name, 10, 3, 2) "ASCII"
FROM employees
WHERE last_name = 'Hunold'
ORDER BY employee_id;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/Data-Type-Comparison-Rules-2.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/Data-Type-Comparison-Rules.html
SELECT salary + '10'
FROM employees;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/Data-Type-Comparison-Rules-3.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/Data-Type-Comparison-Rules.html
SELECT last_name
FROM employees
WHERE employee_id = '200';
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/Data-Type-Comparison-Rules-4.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/Data-Type-Comparison-Rules.html
SELECT last_name
FROM employees
WHERE hire_date = '24-JUN-06';
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/Data-Types-11.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/Data-Types.html
SELECT TO_DATE('31-AUG-2004','DD-MON-YYYY') + TO_YMINTERVAL('0-1')
FROM DUAL;
SELECT TO_DATE('29-FEB-2004','DD-MON-YYYY') + TO_YMINTERVAL('1-0')
FROM DUAL;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/Data-Types-12.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/Data-Types.html
SELECT TO_DATE('29-FEB-2004', 'DD-MON-YYYY') + TO_YMINTERVAL('4-0')
FROM DUAL;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/Data-Types-13.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/Data-Types.html
SELECT order_id, order_date + INTERVAL '30' DAY AS "Due Date"
FROM orders
ORDER BY order_id, "Due Date";
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/Data-Types-14.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/Data-Types.html
SELECT job_name,
SUM( cpu_used )
FROM DBA_SCHEDULER_JOB_RUN_DETAILS
GROUP BY job_name
HAVING SUM ( cpu_used ) > interval '5' minute;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/Data-Types-15.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/Data-Types.html
CREATE TABLE time_table
(start_time TIMESTAMP,
duration_1 INTERVAL DAY (6) TO SECOND (5),
duration_2 INTERVAL YEAR TO MONTH);
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/Data-Types-16.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/Data-Types.html
SELECT last_name, EXTRACT(YEAR FROM (SYSDATE - hire_date) YEAR TO MONTH)
|| ' years '
|| EXTRACT(MONTH FROM (SYSDATE - hire_date) YEAR TO MONTH)
|| ' months' "Interval"
FROM employees;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/Data-Types-17.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/Data-Types.html
CREATE TABLE j_purchaseorder
(id VARCHAR2 (32) NOT NULL PRIMARY KEY,
date_loaded TIMESTAMP (6) WITH TIME ZONE,
po_document JSON (OBJECT));
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/Data-Types-18.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/Data-Types.html
CREATE TABLE example (id NUMBER, c1 BOOLEAN, c2 BOOL);
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/Data-Types-19.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/Data-Types.html
INSERT INTO example VALUES (1, TRUE, NULL);
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/Data-Types-20.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/Data-Types.html
INSERT INTO example VALUES (2, FALSE, true);
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/Data-Types-21.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/Data-Types.html
CREATE TABLE example (id NUMBER, c1 BOOLEAN, c2 BOOL);
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/Data-Types-22.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/Data-Types.html
INSERT INTO example VALUES (1, TRUE, NULL);
INSERT INTO example VALUES (2, FALSE, true);
INSERT INTO example VALUES (3, 0, 'off');
INSERT INTO example VALUES (4, 'no', 'yes');
INSERT INTO example VALUES (5, 'f', 't' );
INSERT INTO example VALUES (6, false, true);
INSERT INTO example VALUES (7, 'on', 'off');
INSERT INTO example VALUES (8, -3.14, 1);
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/Data-Types-23.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/Data-Types.html
SELECT * FROM example;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/Data-Types-24.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/Data-Types.html
SELECT * FROM example WHERE c1 = c2;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/Data-Types-25.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/Data-Types.html
SELECT * FROM example e1
WHERE c1 >= ALL (SELECT c2 FROM example e2 WHERE e2.id > e1.id);
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/Data-Types-26.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/Data-Types.html
SELECT * FROM example WHERE NOT c2;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/Data-Types-27.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/Data-Types.html
SELECT * FROM example WHERE c1 AND c2;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/Data-Types-28.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/Data-Types.html
SELECT * FROM example WHERE c1 AND TRUE;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/Data-Types-29.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/Data-Types.html
SELECT * FROM example WHERE c1 OR c2;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/Data-Types-3.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/Data-Types.html
CREATE TABLE test (col1 NUMBER(5,2), col2 FLOAT(5));
INSERT INTO test VALUES (1.23, 1.23);
INSERT INTO test VALUES (7.89, 7.89);
INSERT INTO test VALUES (12.79, 12.79);
INSERT INTO test VALUES (123.45, 123.45);
SELECT * FROM test;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/Data-Types-30.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/Data-Types.html
SELECT * FROM example WHERE NOT c2;
SELECT * FROM example WHERE c1 AND c2;
SELECT * FROM example WHERE c1 AND TRUE;
SELECT * FROM example WHERE c1 OR c2;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/Data-Types-31.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/Data-Types.html
SELECT * FROM example WHERE c2 IS NULL;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/Data-Types-32.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/Data-Types.html
CREATE TABLE t (v VECTOR);
CREATE TABLE t (v VECTOR(*, *));
CREATE TABLE t (v VECTOR(100));
CREATE TABLE t (v VECTOR(100, *));
CREATE TABLE t (v VECTOR(*, FLOAT32));
CREATE TABLE t (v VECTOR(100, FLOAT32));
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/Data-Types-33.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/Data-Types.html
CREATE TABLE my_vect_tab (
v1 VECTOR(3, FLOAT32),
v2 VECTOR(2, FLOAT64),
v3 VECTOR(1, INT8),
v4 VECTOR(1, *),
v5 VECTOR(*, FLOAT32),
v6 VECTOR(*, *),
v7 VECTOR
);
DESC my_vect_tab;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/Data-Types-34.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/Data-Types.html
CREATE TABLE my_vectors (id NUMBER, embedding VECTOR);
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/Data-Types-35.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/Data-Types.html
CREATE TABLE my_vectors (id NUMBER, embedding VECTOR(768, INT8)) ;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/Data-Types-36.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/Data-Types.html
SELECT o.customer_ref.cust_email
FROM oc_orders o
WHERE o.customer_ref IS NOT DANGLING;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/Data-Types-4.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/Data-Types.html
SELECT TO_DATE('2009', 'YYYY')
FROM DUAL;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/Data-Types-40.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/Data-Types.html
CREATE TYPE SDO_GEOMETRY AS OBJECT
(sgo_gtype NUMBER,
sdo_srid NUMBER,
sdo_point SDO_POINT_TYPE,
sdo_elem_info SDO_ELEM_INFO_ARRAY,
sdo_ordinates SDO_ORDINATE_ARRAY);
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/Data-Types-41.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/Data-Types.html
CREATE TYPE SDO_TOPO_GEOMETRY AS OBJECT
(tg_type NUMBER,
tg_id NUMBER,
tg_layer_id NUMBER,
topology_id NUMBER);
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/Data-Types-42.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/Data-Types.html
CREATE TYPE SDO_GEORASTER AS OBJECT
(rasterType NUMBER,
spatialExtent SDO_GEOMETRY,
rasterDataTable VARCHAR2(32),
rasterID NUMBER,
metadata XMLType);
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/Data-Types-5.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/Data-Types.html
SELECT TO_CHAR(TO_DATE('01-01-2009', 'MM-DD-YYYY'),'J')
FROM DUAL;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/Datetime-Expressions-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/Datetime-Expressions.html
SELECT FROM_TZ(CAST(TO_DATE('1999-12-01 11:00:00',
'YYYY-MM-DD HH:MI:SS') AS TIMESTAMP), 'America/New_York')
AT TIME ZONE 'America/Los_Angeles' "West Coast Time"
FROM DUAL;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/EMPTY_BLOB-EMPTY_CLOB-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/EMPTY_BLOB-EMPTY_CLOB.html
UPDATE print_media
SET ad_photo = EMPTY_BLOB();
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/EXISTS-Condition-1.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/EXISTS-Condition.html
SELECT department_id
FROM departments d
WHERE EXISTS
(SELECT * FROM employees e
WHERE d.department_id
= e.department_id)
ORDER BY department_id;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/EXISTSNODE-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/EXISTSNODE.html
SELECT warehouse_id, warehouse_name
FROM warehouses
WHERE EXISTSNODE(warehouse_spec, '/Warehouse/Docks') = 1
ORDER BY warehouse_id;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/EXP-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/EXP.html
SELECT EXP(4) "e to the 4th power"
FROM DUAL;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/EXPLAIN-PLAN-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/EXPLAIN-PLAN.html
EXPLAIN PLAN
SET STATEMENT_ID = 'Raise in Tokyo'
INTO plan_table
FOR UPDATE employees
SET salary = salary * 1.10
WHERE department_id =
(SELECT department_id FROM departments
WHERE location_id = 1700);
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/EXPLAIN-PLAN-1.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/EXPLAIN-PLAN.html
SELECT id, LPAD(' ',2*(LEVEL-1))||operation operation, options,
object_name, object_alias, position
FROM plan_table
START WITH id = 0 AND statement_id = 'Raise in Tokyo'
CONNECT BY PRIOR id = parent_id AND statement_id = 'Raise in Tokyo'
ORDER BY id;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/EXPLAIN-PLAN-3.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/EXPLAIN-PLAN.html
EXPLAIN PLAN FOR
SELECT * FROM sales
WHERE time_id BETWEEN :h AND '01-OCT-2000';
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/EXPLAIN-PLAN-4.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/EXPLAIN-PLAN.html
SELECT operation, options, partition_start, partition_stop,
partition_id
FROM plan_table;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/EXTRACT-XML-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/EXTRACT-XML.html
SELECT warehouse_name,
EXTRACT(warehouse_spec, '/Warehouse/Docks') "Number of Docks"
FROM warehouses
WHERE warehouse_spec IS NOT NULL
ORDER BY warehouse_name;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/EXTRACT-datetime-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/EXTRACT-datetime.html
SELECT EXTRACT(month FROM order_date) "Month", COUNT(order_date) "No. of Orders"
FROM orders
GROUP BY EXTRACT(month FROM order_date)
ORDER BY "No. of Orders" DESC, "Month";
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/EXTRACT-datetime-1.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/EXTRACT-datetime.html
SELECT EXTRACT(YEAR FROM DATE '1998-03-07')
FROM DUAL;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/EXTRACT-datetime-2.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/EXTRACT-datetime.html
SELECT last_name, employee_id, hire_date
FROM employees
WHERE EXTRACT(YEAR FROM hire_date) > 2007
ORDER BY hire_date;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/EXTRACT-datetime-3.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/EXTRACT-datetime.html
SELECT EXTRACT(TIMEZONE_REGION FROM TIMESTAMP '1999-01-01 10:00:00 -08:00')
FROM DUAL;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/EXTRACTVALUE-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/EXTRACTVALUE.html
SELECT warehouse_name, EXTRACTVALUE(e.warehouse_spec, '/Warehouse/Docks') "Docks"
FROM warehouses e
WHERE warehouse_spec IS NOT NULL
ORDER BY warehouse_name;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/Expression-Lists-1.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/Expression-Lists.html
SELECT * FROM employees
WHERE (first_name, last_name, email) IN
(('Guy', 'Himuro', 'GHIMURO'),('Karen', 'Colmenares', 'KCOLMENA'))
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/Expression-Lists-2.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/Expression-Lists.html
SELECT department_id, MIN(salary) min, MAX(salary) max FROM employees
GROUP BY department_id, salary
ORDER BY department_id, min, max;
SELECT department_id, MIN(salary) min, MAX(salary) max FROM employees
GROUP BY (department_id, salary)
ORDER BY department_id, min, max;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/Expression-Lists-3.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/Expression-Lists.html
SELECT
prod_category, prod_subcategory, country_id, cust_city, count(*)
FROM products, sales, customers
WHERE sales.prod_id = products.prod_id
AND sales.cust_id=customers.cust_id
AND sales.time_id = '01-oct-00'
AND customers.cust_year_of_birth BETWEEN 1960 and 1970
GROUP BY GROUPING SETS
(
(prod_category, prod_subcategory, country_id, cust_city),
(prod_category, prod_subcategory, country_id),
(prod_category, prod_subcategory),
country_id
)
ORDER BY prod_category, prod_subcategory, country_id, cust_city;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/FEATURE_COMPARE-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/FEATURE_COMPARE.html
SELECT 1-FEATURE_COMPARE(esa_wiki_mod USING 'There are several PGA tour golfers from South Africa' text AND USING 'Nick Price won the 2002 Mastercard Colonial Open' text) similarity FROM DUAL;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/FEATURE_COMPARE-1.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/FEATURE_COMPARE.html
SELECT 1-FEATURE_COMPARE(esa_wiki_mod USING 'There are several PGA tour golfers from South Africa' text AND USING 'John Elway played quarterback for the Denver Broncos' text) similarity FROM DUAL;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/FEATURE_DETAILS-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/FEATURE_DETAILS.html
SELECT S.feature_id fid, value val,
FEATURE_DETAILS(nmf_sh_sample, S.feature_id, 5 using T.*) det
FROM
(SELECT v.*, FEATURE_SET(nmf_sh_sample, 3 USING *) fset
FROM mining_data_apply_v v
WHERE cust_id = 100002) T,
TABLE(T.fset) S
ORDER BY 2 DESC;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/FEATURE_DETAILS-1.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/FEATURE_DETAILS.html
SELECT feature_id, value
FROM (
SELECT cust_id, feature_set(INTO 6 USING *) OVER () fset
FROM mining_data_apply_v),
TABLE (fset)
WHERE cust_id = 100001
ORDER BY feature_id;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/FEATURE_ID-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/FEATURE_ID.html
SELECT FEATURE_ID(nmf_sh_sample USING *) AS feat, COUNT(*) AS cnt
FROM nmf_sh_sample_apply_prepared
GROUP BY FEATURE_ID(nmf_sh_sample USING *)
ORDER BY cnt DESC, feat DESC;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/FEATURE_SET-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/FEATURE_SET.html
WITH
feat_tab AS (
SELECT F.feature_id fid,
A.attribute_name attr,
TO_CHAR(A.attribute_value) val,
A.coefficient coeff
FROM TABLE(DBMS_DATA_MINING.GET_MODEL_DETAILS_NMF('nmf_sh_sample')) F,
TABLE(F.attribute_set) A
WHERE A.coefficient > 0.25
),
feat AS (
SELECT fid,
CAST(COLLECT(Featattr(attr, val, coeff))
AS Featattrs) f_attrs
FROM feat_tab
GROUP BY fid
),
cust_10_features AS (
SELECT T.cust_id, S.feature_id, S.value
FROM (SELECT cust_id, FEATURE_SET(nmf_sh_sample, 10 USING *) pset
FROM nmf_sh_sample_apply_prepared
WHERE cust_id = 100002) T,
TABLE(T.pset) S
)
SELECT A.value, A.feature_id fid,
B.attr, B.val, B.coeff
FROM cust_10_features A,
(SELECT T.fid, F.*
FROM feat T,
TABLE(T.f_attrs) F) B
WHERE A.feature_id = B.fid
ORDER BY A.value DESC, A.feature_id ASC, coeff DESC, attr ASC, val ASC;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/FEATURE_VALUE-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/FEATURE_VALUE.html
SELECT *
FROM (SELECT cust_id, FEATURE_VALUE(nmf_sh_sample, 3 USING *) match_quality
FROM nmf_sh_sample_apply_prepared
ORDER BY match_quality DESC)
WHERE ROWNUM < 11;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/FIRST-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/FIRST.html
SELECT department_id,
MIN(salary) KEEP (DENSE_RANK FIRST ORDER BY commission_pct) "Worst",
MAX(salary) KEEP (DENSE_RANK LAST ORDER BY commission_pct) "Best"
FROM employees
GROUP BY department_id
ORDER BY department_id;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/FIRST-1.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/FIRST.html
SELECT last_name, department_id, salary,
MIN(salary) KEEP (DENSE_RANK FIRST ORDER BY commission_pct)
OVER (PARTITION BY department_id) "Worst",
MAX(salary) KEEP (DENSE_RANK LAST ORDER BY commission_pct)
OVER (PARTITION BY department_id) "Best"
FROM employees
ORDER BY department_id, salary, last_name;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/FIRST_VALUE-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/FIRST_VALUE.html
SELECT employee_id, last_name, salary, hire_date,
FIRST_VALUE(last_name)
OVER (ORDER BY salary ASC ROWS UNBOUNDED PRECEDING) AS fv
FROM (SELECT * FROM employees
WHERE department_id = 90
ORDER BY hire_date);
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/FIRST_VALUE-1.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/FIRST_VALUE.html
SELECT employee_id, last_name, salary, hire_date,
FIRST_VALUE(last_name)
OVER (ORDER BY salary ASC ROWS UNBOUNDED PRECEDING) AS fv
FROM (SELECT * FROM employees
WHERE department_id = 90
ORDER by hire_date DESC);
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/FIRST_VALUE-2.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/FIRST_VALUE.html
SELECT employee_id, last_name, salary, hire_date,
FIRST_VALUE(last_name)
OVER (ORDER BY salary ASC, employee_id ROWS UNBOUNDED PRECEDING) AS fv
FROM (SELECT * FROM employees
WHERE department_id = 90
ORDER BY hire_date);
SELECT employee_id, last_name, salary, hire_date,
FIRST_VALUE(last_name)
OVER (ORDER BY salary ASC, employee_id ROWS UNBOUNDED PRECEDING) AS fv
FROM (SELECT * FROM employees
WHERE department_id = 90
ORDER BY hire_date DESC);
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/FIRST_VALUE-3.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/FIRST_VALUE.html
SELECT employee_id, last_name, salary, hire_date,
FIRST_VALUE(last_name)
OVER (ORDER BY salary ASC RANGE UNBOUNDED PRECEDING) AS fv
FROM (SELECT * FROM employees
WHERE department_id = 90
ORDER BY hire_date);
SELECT employee_id, last_name, salary, hire_date,
FIRST_VALUE(last_name)
OVER (ORDER BY salary ASC RANGE UNBOUNDED PRECEDING) AS fv
FROM (SELECT * FROM employees
WHERE department_id = 90
ORDER BY hire_date DESC);
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/FLASHBACK-DATABASE-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/FLASHBACK-DATABASE.html
STARTUP MOUNT
ALTER DATABASE FLASHBACK ON;
ALTER DATABASE OPEN;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/FLASHBACK-DATABASE-1.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/FLASHBACK-DATABASE.html
SHUTDOWN DATABASE
STARTUP MOUNT
FLASHBACK DATABASE TO TIMESTAMP SYSDATE-1;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/FLASHBACK-TABLE-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/FLASHBACK-TABLE.html
SELECT * FROM RECYCLEBIN;
SELECT * FROM USER_RECYCLEBIN;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/FLASHBACK-TABLE-1.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/FLASHBACK-TABLE.html
CREATE TABLE employees_test
AS SELECT * FROM employees;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/FLASHBACK-TABLE-10.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/FLASHBACK-TABLE.html
SELECT object_name, droptime FROM user_recyclebin
WHERE original_name = 'PRINT_MEDIA';
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/FLASHBACK-TABLE-2.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/FLASHBACK-TABLE.html
SELECT salary
FROM employees_test
WHERE salary < 2500;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/FLASHBACK-TABLE-3.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/FLASHBACK-TABLE.html
ALTER TABLE employees_test
ENABLE ROW MOVEMENT;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/FLASHBACK-TABLE-4.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/FLASHBACK-TABLE.html
UPDATE employees_test
SET salary = salary * 1.1
WHERE salary < 2500;
COMMIT;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/FLASHBACK-TABLE-5.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/FLASHBACK-TABLE.html
SELECT salary
FROM employees_test
WHERE salary < 2500;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/FLASHBACK-TABLE-6.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/FLASHBACK-TABLE.html
FLASHBACK TABLE employees_test
TO TIMESTAMP (SYSTIMESTAMP - INTERVAL '1' minute);
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/FLASHBACK-TABLE-7.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/FLASHBACK-TABLE.html
SELECT salary
FROM employees_test
WHERE salary < 2500;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/FLASHBACK-TABLE-8.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/FLASHBACK-TABLE.html
FLASHBACK TABLE print_media TO BEFORE DROP;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/FLASHBACK-TABLE-9.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/FLASHBACK-TABLE.html
FLASHBACK TABLE print_media TO BEFORE DROP RENAME TO print_media_old;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/FLOOR-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/FLOOR.html
SELECT FLOOR(15.7) "Floor"
FROM DUAL;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/FROM_TZ-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/FROM_TZ.html
SELECT FROM_TZ(TIMESTAMP '2000-03-28 08:00:00', '3:00')
FROM DUAL;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/Floating-Point-Conditions-1.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/Floating-Point-Conditions.html
SELECT COUNT(*) FROM employees
WHERE commission_pct IS NOT NAN;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/Floating-Point-Conditions-3.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/Floating-Point-Conditions.html
SELECT last_name FROM employees
WHERE salary IS NOT INFINITE;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/Format-Models-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/Format-Models.html
SELECT TO_CHAR(number, 'fmt')
FROM DUAL;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/Format-Models-47.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/Format-Models.html
SELECT TO_CHAR(TO_DATE('0207','MM/YY'), 'MM/YY') FROM DUAL;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/Format-Models-48.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/Format-Models.html
SELECT TO_CHAR(TO_DATE('0207', 'fxmm/yy'), 'mm/yy') FROM DUAL;
SELECT TO_CHAR(TO_DATE('0207', 'fxmm/yy'), 'mm/yy') FROM DUAL;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/Format-Models-49.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/Format-Models.html
SELECT TO_CHAR (TO_DATE('02#07','MM/YY'), 'MM/YY') FROM DUAL;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/Format-Models-50.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/Format-Models.html
SELECT TO_CHAR(TO_DATE('27-OCT-98', 'DD-MON-RR'), 'YYYY') "Year" FROM DUAL;
SELECT TO_CHAR(TO_DATE('27-OCT-17', 'DD-MON-RR'), 'YYYY') "Year" FROM DUAL;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/Format-Models-51.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/Format-Models.html
SELECT TO_CHAR(TO_DATE('27-OCT-98', 'DD-MON-RR'), 'YYYY') "Year" FROM DUAL;
SELECT TO_CHAR(TO_DATE('27-OCT-17', 'DD-MON-RR'), 'YYYY') "Year" FROM DUAL;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/Format-Models-52.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/Format-Models.html
SELECT TO_CHAR(SYSDATE, 'fmDDTH') || ' of ' ||
TO_CHAR(SYSDATE, 'fmMonth') || ', ' ||
TO_CHAR(SYSDATE, 'YYYY') "Ides"
FROM DUAL;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/Format-Models-53.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/Format-Models.html
SELECT TO_CHAR(SYSDATE, 'DDTH') || ' of ' ||
TO_CHAR(SYSDATE, 'Month') || ', ' ||
TO_CHAR(SYSDATE, 'YYYY') "Ides"
FROM DUAL;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/Format-Models-54.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/Format-Models.html
SELECT TO_CHAR(SYSDATE, 'fmDay') || '''s Special' "Menu"
FROM DUAL;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/Format-Models-56.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/Format-Models.html
SELECT last_name employee, TO_CHAR(salary, '$99,990.99')
FROM employees
WHERE department_id = 80;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/Format-Models-57.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/Format-Models.html
SELECT last_name employee, TO_CHAR(hire_date,'fmMonth DD, YYYY') hiredate
FROM employees
WHERE department_id = 20;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/Format-Models-58.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/Format-Models.html
UPDATE employees
SET hire_date = TO_DATE('2008 05 20','YYYY MM DD')
WHERE last_name = 'Hunold';
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/GRANT-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/GRANT.html
GRANT CREATE SESSION
TO hr;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/GRANT-1.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/GRANT.html
GRANT CREATE SESSION
TO hr, newuser IDENTIFIED BY password1, password2;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/GRANT-10.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/GRANT.html
GRANT SELECT, UPDATE
ON emp_view TO PUBLIC;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/GRANT-11.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/GRANT.html
GRANT SELECT
ON oe.customers_seq TO hr;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/GRANT-12.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/GRANT.html
SELECT oe.customers_seq.NEXTVAL
FROM DUAL;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/GRANT-13.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/GRANT.html
GRANT REFERENCES (employee_id),
UPDATE (employee_id, salary, commission_pct)
ON hr.employees
TO oe;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/GRANT-14.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/GRANT.html
CREATE TABLE dependent
(dependno NUMBER,
dependname VARCHAR2(10),
employee NUMBER
CONSTRAINT in_emp REFERENCES hr.employees(employee_id) );
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/GRANT-2.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/GRANT.html
GRANT
CREATE ANY MATERIALIZED VIEW
, ALTER ANY MATERIALIZED VIEW
, DROP ANY MATERIALIZED VIEW
, QUERY REWRITE
, GLOBAL QUERY REWRITE
TO dw_manager
WITH ADMIN OPTION;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/GRANT-3.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/GRANT.html
GRANT dw_manager
TO sh
WITH ADMIN OPTION;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/GRANT-4.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/GRANT.html
GRANT dw_manager
TO sh
WITH DELEGATE OPTION;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/GRANT-5.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/GRANT.html
GRANT SELECT ON sh.sales TO warehouse_user;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/GRANT-6.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/GRANT.html
GRANT warehouse_user TO dw_manager;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/GRANT-7.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/GRANT.html
GRANT INHERIT PRIVILEGES ON USER sh TO hr;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/GRANT-8.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/GRANT.html
GRANT READ ON DIRECTORY bfile_dir TO hr
WITH GRANT OPTION;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/GRANT-9.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/GRANT.html
GRANT ALL ON bonuses TO hr
WITH GRANT OPTION;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/GREATEST-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/GREATEST.html
SELECT GREATEST('HARRY', 'HARRIOT', 'HAROLD') "Greatest"
FROM DUAL;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/GREATEST-1.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/GREATEST.html
SELECT GREATEST (1, '3.925', '2.4') "Greatest"
FROM DUAL;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/GROUPING-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/GROUPING.html
SELECT
DECODE(GROUPING(department_name), 1, 'ALL DEPARTMENTS', department_name)
AS department,
DECODE(GROUPING(job_id), 1, 'All Jobs', job_id) AS job,
COUNT(*) "Total Empl",
AVG(salary) * 12 "Average Sal"
FROM employees e, departments d
WHERE d.department_id = e.department_id
GROUP BY ROLLUP (department_name, job_id)
ORDER BY department, job;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/GROUPING_ID-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/GROUPING_ID.html
SELECT channel_id, promo_id, sum(amount_sold) s_sales,
GROUPING(channel_id) gc,
GROUPING(promo_id) gp,
GROUPING_ID(channel_id, promo_id) gcp,
GROUPING_ID(promo_id, channel_id) gpc
FROM sales
WHERE promo_id > 496
GROUP BY CUBE(channel_id, promo_id)
ORDER BY channel_id, promo_id, s_sales, gc;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/GROUP_ID-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/GROUP_ID.html
SELECT co.country_region, co.country_subregion,
SUM(s.amount_sold) "Revenue", GROUP_ID() g
FROM sales s, customers c, countries co
WHERE s.cust_id = c.cust_id
AND c.country_id = co.country_id
AND s.time_id = '1-JAN-00'
AND co.country_region IN ('Americas', 'Europe')
GROUP BY GROUPING SETS ( (co.country_region, co.country_subregion),
(co.country_region, co.country_subregion) )
ORDER BY co.country_region, co.country_subregion, "Revenue", g;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/Graphic-Syntax-Diagrams-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/Graphic-Syntax-Diagrams.html
DROP LIBRARY hq_lib;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/Graphic-Syntax-Diagrams-2.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/Graphic-Syntax-Diagrams.html
ALTER JAVA SOURCE jsource_1 COMPILE;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/HEXTORAW-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/HEXTORAW.html
CREATE TABLE test (raw_col RAW(10));
INSERT INTO test VALUES (HEXTORAW('7D'));
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/HEXTORAW-1.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/HEXTORAW.html
SELECT UTL_RAW.CAST_TO_VARCHAR2(HEXTORAW('4041424344'))
FROM DUAL;
@ABCD
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/Hierarchical-Queries-2.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/Hierarchical-Queries.html
SELECT employee_id, last_name, manager_id
FROM employees
CONNECT BY PRIOR employee_id = manager_id;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/Hierarchical-Queries-3.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/Hierarchical-Queries.html
SELECT employee_id, last_name, manager_id, LEVEL
FROM employees
CONNECT BY PRIOR employee_id = manager_id;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/Hierarchical-Queries-4.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/Hierarchical-Queries.html
SELECT last_name, employee_id, manager_id, LEVEL
FROM employees
START WITH employee_id = 100
CONNECT BY PRIOR employee_id = manager_id
ORDER SIBLINGS BY last_name;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/Hierarchical-Queries-5.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/Hierarchical-Queries.html
UPDATE employees SET manager_id = 145
WHERE employee_id = 100;
SELECT last_name "Employee",
LEVEL, SYS_CONNECT_BY_PATH(last_name, '/') "Path"
FROM employees
WHERE level <= 3 AND department_id = 80
START WITH last_name = 'King'
CONNECT BY PRIOR employee_id = manager_id AND LEVEL <= 4;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/Hierarchical-Queries-6.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/Hierarchical-Queries.html
SELECT last_name "Employee", CONNECT_BY_ISCYCLE "Cycle",
LEVEL, SYS_CONNECT_BY_PATH(last_name, '/') "Path"
FROM employees
WHERE level <= 3 AND department_id = 80
START WITH last_name = 'King'
CONNECT BY NOCYCLE PRIOR employee_id = manager_id AND LEVEL <= 4
ORDER BY "Employee", "Cycle", LEVEL, "Path";
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/Hierarchical-Queries-7.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/Hierarchical-Queries.html
SELECT LTRIM(SYS_CONNECT_BY_PATH (warehouse_id,','),',') FROM
(SELECT ROWNUM r, warehouse_id FROM warehouses)
WHERE CONNECT_BY_ISLEAF = 1
START WITH r = 1
CONNECT BY r = PRIOR r + 1
ORDER BY warehouse_id;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/Hierarchical-Queries-8.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/Hierarchical-Queries.html
SELECT last_name "Employee", CONNECT_BY_ROOT last_name "Manager",
LEVEL-1 "Pathlen", SYS_CONNECT_BY_PATH(last_name, '/') "Path"
FROM employees
WHERE LEVEL > 1 and department_id = 110
CONNECT BY PRIOR employee_id = manager_id
ORDER BY "Employee", "Manager", "Pathlen", "Path";
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/Hierarchical-Queries-9.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/Hierarchical-Queries.html
SELECT name, SUM(salary) "Total_Salary" FROM (
SELECT CONNECT_BY_ROOT last_name as name, Salary
FROM employees
WHERE department_id = 110
CONNECT BY PRIOR employee_id = manager_id)
GROUP BY name
ORDER BY name, "Total_Salary";
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/Hierarchical-Query-Pseudocolumns-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/Hierarchical-Query-Pseudocolumns.html
SELECT last_name "Employee", CONNECT_BY_ISLEAF "IsLeaf",
LEVEL, SYS_CONNECT_BY_PATH(last_name, '/') "Path"
FROM employees
WHERE LEVEL <= 3 AND department_id = 80
START WITH employee_id = 100
CONNECT BY PRIOR employee_id = manager_id AND LEVEL <= 4
ORDER BY "Employee", "IsLeaf";
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/IN-Condition-1.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/IN-Condition.html
SELECT * FROM employees
WHERE job_id IN
('PU_CLERK','SH_CLERK')
ORDER BY employee_id;
SELECT * FROM employees
WHERE salary IN
(SELECT salary
FROM employees
WHERE department_id =30)
ORDER BY employee_id;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/IN-Condition-3.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/IN-Condition.html
SELECT * FROM employees
WHERE salary NOT IN
(SELECT salary
FROM employees
WHERE department_id = 30)
ORDER BY employee_id;
SELECT * FROM employees
WHERE job_id NOT IN
('PU_CLERK', 'SH_CLERK')
ORDER BY employee_id;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/IN-Condition-4.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/IN-Condition.html
SELECT 'True' FROM employees
WHERE department_id NOT IN (10, 20);
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/IN-Condition-5.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/IN-Condition.html
SELECT 'True' FROM employees
WHERE department_id NOT IN (10, 20, NULL);
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/IN-Condition-7.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/IN-Condition.html
SELECT 'True' FROM employees
WHERE department_id NOT IN (SELECT 0 FROM DUAL WHERE 1=2);
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/IN-Condition-8.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/IN-Condition.html
SELECT employee_id, last_name FROM employees
WHERE (employee_id, LEVEL)
IN (SELECT employee_id, 2 FROM employees)
START WITH employee_id = 2
CONNECT BY PRIOR employee_id = manager_id;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/IN-Condition-9.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/IN-Condition.html
SELECT v.employee_id, v.last_name, v.lev FROM
(SELECT employee_id, last_name, LEVEL lev
FROM employees v
START WITH employee_id = 100
CONNECT BY PRIOR employee_id = manager_id) v
WHERE (v.employee_id, v.lev) IN
(SELECT employee_id, 2 FROM employees);
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/INITCAP-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/INITCAP.html
SELECT INITCAP('the soap') "Capitals"
FROM DUAL;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/INSERT-10.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/INSERT.html
CREATE TABLE raises (emp_id NUMBER, sal NUMBER
CONSTRAINT check_sal CHECK(sal > 8000));
EXECUTE DBMS_ERRLOG.CREATE_ERROR_LOG('raises', 'errlog');
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/INSERT-11.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/INSERT.html
INSERT INTO raises
SELECT employee_id, salary*1.1 FROM employees
WHERE commission_pct > .2
LOG ERRORS INTO errlog ('my_bad') REJECT LIMIT 10;
SELECT ORA_ERR_MESG$, ORA_ERR_TAG$, emp_id, sal FROM errlog;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/INSERT-12.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/INSERT.html
INSERT INTO employees@remote
VALUES (8002, 'Juan', 'Fernandez', 'juanf@example.com', NULL,
TO_DATE('04-OCT-1992', 'DD-MON-YYYY'), 'SH_CLERK', 3000,
NULL, 121, 20);
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/INSERT-13.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/INSERT.html
INSERT INTO departments
VALUES (departments_seq.nextval, 'Entertainment', 162, 1400);
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/INSERT-14.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/INSERT.html
INSERT INTO employees
(employee_id, last_name, email, hire_date, job_id, salary)
VALUES
(employees_seq.nextval, 'Doe', 'john.doe@example.com',
SYSDATE, 'SH_CLERK', 2400)
RETURNING salary*12, job_id INTO :bnd1, :bnd2;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/INSERT-15.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/INSERT.html
INSERT INTO persons VALUES (person_t('Bob', 1234));
INSERT INTO persons VALUES (employee_t('Joe', 32456, 12, 100000));
INSERT INTO persons VALUES (
part_time_emp_t('Tim', 5678, 13, 1000, 20));
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/INSERT-16.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/INSERT.html
INSERT INTO books VALUES (
'An Autobiography', person_t('Bob', 1234));
INSERT INTO books VALUES (
'Business Rules', employee_t('Joe', 3456, 12, 10000));
INSERT INTO books VALUES (
'Mixing School and Work',
part_time_emp_t('Tim', 5678, 13, 1000, 20));
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/INSERT-17.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/INSERT.html
CREATE TABLE long_tab (pic_id NUMBER, long_pics LONG RAW);
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/INSERT-18.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/INSERT.html
CREATE TABLE lob_tab (pic_id NUMBER, lob_pics BLOB);
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/INSERT-19.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/INSERT.html
INSERT INTO lob_tab
SELECT pic_id, TO_LOB(long_pics) FROM long_tab;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/INSERT-20.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/INSERT.html
ALTER TABLE long_tab DROP COLUMN long_pics;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/INSERT-21.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/INSERT.html
SELECT * FROM sales_input_table;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/INSERT-24.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/INSERT.html
INSERT ALL
INTO sales (prod_id, cust_id, time_id, amount)
VALUES (product_id, customer_id, weekly_start_date, sales_sun)
INTO sales (prod_id, cust_id, time_id, amount)
VALUES (product_id, customer_id, weekly_start_date+1, sales_mon)
INTO sales (prod_id, cust_id, time_id, amount)
VALUES (product_id, customer_id, weekly_start_date+2, sales_tue)
INTO sales (prod_id, cust_id, time_id, amount)
VALUES (product_id, customer_id, weekly_start_date+3, sales_wed)
INTO sales (prod_id, cust_id, time_id, amount)
VALUES (product_id, customer_id, weekly_start_date+4, sales_thu)
INTO sales (prod_id, cust_id, time_id, amount)
VALUES (product_id, customer_id, weekly_start_date+5, sales_fri)
INTO sales (prod_id, cust_id, time_id, amount)
VALUES (product_id, customer_id, weekly_start_date+6, sales_sat)
SELECT product_id, customer_id, weekly_start_date, sales_sun,
sales_mon, sales_tue, sales_wed, sales_thu, sales_fri, sales_sat
FROM sales_input_table;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/INSERT-25.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/INSERT.html
SELECT * FROM sales
ORDER BY prod_id, cust_id, time_id;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/INSERT-26.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/INSERT.html
CREATE TABLE small_orders
(order_id NUMBER(12) NOT NULL,
customer_id NUMBER(6) NOT NULL,
order_total NUMBER(8,2),
sales_rep_id NUMBER(6)
);
CREATE TABLE medium_orders AS SELECT * FROM small_orders;
CREATE TABLE large_orders AS SELECT * FROM small_orders;
CREATE TABLE special_orders
(order_id NUMBER(12) NOT NULL,
customer_id NUMBER(6) NOT NULL,
order_total NUMBER(8,2),
sales_rep_id NUMBER(6),
credit_limit NUMBER(9,2),
cust_email VARCHAR2(40)
);
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/INSERT-27.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/INSERT.html
INSERT ALL
WHEN order_total <= 100000 THEN
INTO small_orders
WHEN order_total > 1000000 AND order_total <= 200000 THEN
INTO medium_orders
WHEN order_total > 200000 THEN
INTO large_orders
SELECT order_id, order_total, sales_rep_id, customer_id
FROM orders;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/INSERT-28.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/INSERT.html
INSERT ALL
WHEN order_total <= 100000 THEN
INTO small_orders
WHEN order_total > 100000 AND order_total <= 200000 THEN
INTO medium_orders
ELSE
INTO large_orders
SELECT order_id, order_total, sales_rep_id, customer_id
FROM orders;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/INSERT-29.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/INSERT.html
INSERT ALL
WHEN ottl <= 100000 THEN
INTO small_orders
VALUES(oid, ottl, sid, cid)
WHEN ottl > 100000 and ottl <= 200000 THEN
INTO medium_orders
VALUES(oid, ottl, sid, cid)
WHEN ottl > 200000 THEN
into large_orders
VALUES(oid, ottl, sid, cid)
WHEN ottl > 290000 THEN
INTO special_orders
SELECT o.order_id oid, o.customer_id cid, o.order_total ottl,
o.sales_rep_id sid, c.credit_limit cl, c.cust_email cem
FROM orders o, customers c
WHERE o.customer_id = c.customer_id;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/INSERT-30.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/INSERT.html
INSERT FIRST
WHEN ottl <= 100000 THEN
INTO small_orders
VALUES(oid, ottl, sid, cid)
WHEN ottl > 100000 and ottl <= 200000 THEN
INTO medium_orders
VALUES(oid, ottl, sid, cid)
WHEN ottl > 290000 THEN
INTO special_orders
WHEN ottl > 200000 THEN
INTO large_orders
VALUES(oid, ottl, sid, cid)
SELECT o.order_id oid, o.customer_id cid, o.order_total ottl,
o.sales_rep_id sid, c.credit_limit cl, c.cust_email cem
FROM orders o, customers c
WHERE o.customer_id = c.customer_id;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/INSERT-31.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/INSERT.html
CREATE TABLE people (
person_id INTEGER NOT NULL PRIMARY KEY,
given_name VARCHAR2(100) NOT NULL,
family_name VARCHAR2(100) NOT NULL,
title VARCHAR2(20),
birth_date DATE
);
CREATE TABLE patients (
patient_id INTEGER NOT NULL PRIMARY KEY REFERENCES people (person_id),
last_admission_date DATE
);
CREATE TABLE staff (
staff_id INTEGER NOT NULL PRIMARY KEY REFERENCES people (person_id),
hired_date DATE
);
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/INSERT-32.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/INSERT.html
INSERT INTO people
VALUES (1, 'Dave', 'Badger', 'Mr', date'1960-05-01');
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/INSERT-33.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/INSERT.html
INSERT INTO people
VALUES (2, 'Simon', 'Fox', 'Mr');
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/INSERT-34.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/INSERT.html
INSERT INTO people (person_id, given_name, family_name, title)
VALUES (2, 'Simon', 'Fox', 'Mr');
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/INSERT-35.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/INSERT.html
INSERT INTO people (person_id, given_name, family_name, title)
VALUES (3, 'Dave', 'Frog', (SELECT 'Mr' FROM dual));
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/INSERT-36.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/INSERT.html
INSERT INTO people (person_id, given_name, family_name, title)
WITH names AS (
SELECT 4, 'Ruth', 'Fox', 'Mrs' FROM dual UNION ALL
SELECT 5, 'Isabelle', 'Squirrel', 'Miss' FROM dual UNION ALL
SELECT 6, 'Justin', 'Frog', 'Master' FROM dual UNION ALL
SELECT 7, 'Lisa', 'Owl', 'Dr' FROM dual
)
SELECT * FROM names;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/INSERT-37.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/INSERT.html
ROLLBACK;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/INSERT-38.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/INSERT.html
INSERT INTO people (person_id, given_name, family_name, title)
WITH names AS (
SELECT 4, 'Ruth', 'Fox' family_name, 'Mrs' FROM dual UNION ALL
SELECT 5, 'Isabelle', 'Squirrel' family_name, 'Miss' FROM dual UNION ALL
SELECT 6, 'Justin', 'Frog' family_name, 'Master' FROM dual UNION ALL
SELECT 7, 'Lisa', 'Owl' family_name, 'Dr' FROM dual
)
SELECT * FROM names
WHERE family_name LIKE 'F%';
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/INSERT-39.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/INSERT.html
ROLLBACK;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/INSERT-40.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/INSERT.html
INSERT ALL
/* Every one is a person */
INTO people (person_id, given_name, family_name, title)
VALUES (id, given_name, family_name, title)
INTO patients (patient_id, last_admission_date)
VALUES (id, admission_date)
INTO staff (staff_id, hired_date)
VALUES (id, hired_date)
WITH names AS (
SELECT 4 id, 'Ruth' given_name, 'Fox' family_name, 'Mrs' title,
NULL hired_date, DATE'2009-12-31' admission_date
FROM dual UNION ALL
SELECT 5 id, 'Isabelle' given_name, 'Squirrel' family_name, 'Miss' title ,
NULL hired_date, DATE'2014-01-01' admission_date
FROM dual UNION ALL
SELECT 6 id, 'Justin' given_name, 'Frog' family_name, 'Master' title,
NULL hired_date, DATE'2015-04-22' admission_date
FROM dual UNION ALL
SELECT 7 id, 'Lisa' given_name, 'Owl' family_name, 'Dr' title,
DATE'2015-01-01' hired_date, NULL admission_date
FROM dual
)
SELECT * FROM names;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/INSERT-41.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/INSERT.html
ROLLBACK;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/INSERT-42.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/INSERT.html
INSERT ALL
/* Everyone is a person, so insert all rows into people */
WHEN 1=1 THEN
INTO people (person_id, given_name, family_name, title)
VALUES (id, given_name, family_name, title)
/* Only people with an admission date are patients */
WHEN admission_date IS NOT NULL THEN
INTO patients (patient_id, last_admission_date)
VALUES (id, admission_date)
/* Only people with a hired date are staff */
WHEN hired_date IS NOT NULL THEN
INTO staff (staff_id, hired_date)
VALUES (id, hired_date)
WITH names AS (
SELECT 4 id, 'Ruth' given_name, 'Fox' family_name, 'Mrs' title,
NULL hired_date, DATE'2009-12-31' admission_date
FROM dual UNION ALL
SELECT 5 id, 'Isabelle' given_name, 'Squirrel' family_name, 'Miss' title ,
NULL hired_date, DATE'2014-01-01' admission_date
FROM dual UNION ALL
SELECT 6 id, 'Justin' given_name, 'Frog' family_name, 'Master' title,
NULL hired_date, DATE'2015-04-22' admission_date
FROM dual UNION ALL
SELECT 7 id, 'Lisa' given_name, 'Owl' family_name, 'Dr' title,
DATE'2015-01-01' hired_date, NULL admission_date
FROM dual
)
SELECT * FROM names;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/INSERT-5.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/INSERT.html
INSERT INTO departments
VALUES (280, 'Recreation', 121, 1700);
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/INSERT-6.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/INSERT.html
INSERT INTO departments
VALUES (280, 'Recreation', DEFAULT, 1700);
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/INSERT-7.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/INSERT.html
INSERT INTO employees (employee_id, last_name, email,
hire_date, job_id, salary, commission_pct)
VALUES (207, 'Gregory', 'pgregory@example.com',
sysdate, 'PU_CLERK', 1.2E3, NULL);
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/INSERT-8.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/INSERT.html
INSERT INTO
(SELECT employee_id, last_name, email, hire_date, job_id,
salary, commission_pct FROM employees)
VALUES (207, 'Gregory', 'pgregory@example.com',
sysdate, 'PU_CLERK', 1.2E3, NULL);
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/INSERT-9.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/INSERT.html
INSERT INTO bonuses
SELECT employee_id, salary*1.1
FROM employees
WHERE commission_pct > 0.25;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/INSTR-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/INSTR.html
SELECT INSTR('CORPORATE FLOOR','OR', 3, 2) "Instring"
FROM DUAL;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/INSTR-1.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/INSTR.html
SELECT INSTR('CORPORATE FLOOR','OR', -3, 2) "Reversed Instring"
FROM DUAL;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/INSTR-2.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/INSTR.html
SELECT INSTRB('CORPORATE FLOOR','OR',5,2) "Instring in bytes"
FROM DUAL;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/IS-OF-type-Condition-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/IS-OF-type-Condition.html
SELECT * FROM persons p
WHERE VALUE(p) IS OF TYPE (employee_t);
SELECT * FROM persons p
WHERE VALUE(p) IS OF (ONLY part_time_emp_t);
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ITERATION_NUMBER-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ITERATION_NUMBER.html
SELECT country, prod, year, s
FROM sales_view_ref
MODEL
PARTITION BY (country)
DIMENSION BY (prod, year)
MEASURES (sale s)
IGNORE NAV
UNIQUE DIMENSION
RULES UPSERT SEQUENTIAL ORDER ITERATE(2)
(
s['Mouse Pad', 2001 + ITERATION_NUMBER] =
s['Mouse Pad', 1998 + ITERATION_NUMBER]
)
ORDER BY country, prod, year;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/Interval-Expressions-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/Interval-Expressions.html
SELECT (SYSTIMESTAMP - order_date) DAY(9) TO SECOND FROM orders
WHERE order_id = 2458;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/JSON-Object-Access-Expressions-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/JSON-Object-Access-Expressions.html
SELECT po.po_document.PONumber.number()
FROM j_purchaseorder po;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/JSON-Object-Access-Expressions-1.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/JSON-Object-Access-Expressions.html
SELECT po.po_document.ShippingInstructions.Phone
FROM j_purchaseorder po;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/JSON-Object-Access-Expressions-2.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/JSON-Object-Access-Expressions.html
SELECT po.po_document.LineItems.Part.Description
FROM j_purchaseorder po;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/JSON_ARRAY-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/JSON_ARRAY.html
SELECT JSON_ARRAY (
JSON_OBJECT('percentage' VALUE .50),
JSON_ARRAY(1,2,3),
100,
'California',
null
NULL ON NULL
) "JSON Array Example"
FROM DUAL;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/JSON_ARRAYAGG-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/JSON_ARRAYAGG.html
CREATE TABLE id_table (id NUMBER);
INSERT INTO id_table VALUES(624);
INSERT INTO id_table VALUES(null);
INSERT INTO id_table VALUES(925);
INSERT INTO id_table VALUES(585);
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/JSON_ARRAYAGG-1.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/JSON_ARRAYAGG.html
SELECT JSON_ARRAYAGG(id ORDER BY id RETURNING VARCHAR2(100)) ID_NUMBERS
FROM id_table;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/JSON_DATAGUIDE-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/JSON_DATAGUIDE.html
SELECT EXTRACT(YEAR FROM date_loaded) YEAR,
JSON_DATAGUIDE(po_document) "DATA GUIDE"
FROM j_purchaseorder
GROUP BY extract(YEAR FROM date_loaded)
ORDER BY extract(YEAR FROM date_loaded) DESC;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/JSON_OBJECT-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/JSON_OBJECT.html
SELECT JSON_OBJECT(
'name' : first_name || ' ' || last_name,
'email' : email,
'phone' : phone_number,
'hire_date' : hire_date
)
FROM employees
WHERE employee_id = 140;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/JSON_OBJECT-1.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/JSON_OBJECT.html
SELECT JSON_OBJECT(*)
FROM employees
WHERE employee_id = 140;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/JSON_OBJECT-10.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/JSON_OBJECT.html
SELECT JSON_OBJECT(
'first_name' VALUE first_name,
'last_name' VALUE last_name,
'email' VALUE email,
'hire_date' VALUE hire_date
)
FROM employees
WHERE employee_id = 140;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/JSON_OBJECT-11.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/JSON_OBJECT.html
SELECT JSON_OBJECT(first_name, last_name, email, hire_date)
FROM employees
WHERE employee_id = 140;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/JSON_OBJECT-3.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/JSON_OBJECT.html
SELECT JSON_OBJECT('NAME' VALUE first_name, d.*)
FROM employees e, departments d
WHERE e.department_id = d.department_id
AND e.employee_id =140
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/JSON_OBJECT-4.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/JSON_OBJECT.html
SELECT JSON_ARRAYAGG(JSON_OBJECT(*))
FROM departments
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/JSON_OBJECT-9.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/JSON_OBJECT.html
SELECT JSON_OBJECT (
KEY 'deptno' VALUE d.department_id,
KEY 'deptname' VALUE d.department_name
) "Department Objects"
FROM departments d
ORDER BY d.department_id;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/JSON_OBJECTAGG-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/JSON_OBJECTAGG.html
SELECT JSON_OBJECTAGG(KEY department_name VALUE department_id) "Department Numbers"
FROM departments
WHERE department_id <= 30;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/JSON_QUERY-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/JSON_QUERY.html
SELECT JSON_QUERY('{a:100, b:200, c:300}', '$') AS value
FROM DUAL;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/JSON_QUERY-1.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/JSON_QUERY.html
SELECT JSON_QUERY('{a:100, b:200, c:300}', '$.a' WITH WRAPPER) AS value
FROM DUAL;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/JSON_QUERY-10.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/JSON_QUERY.html
SELECT JSON_QUERY('[{"a":100},{"b":200},{"c":300}]', '$[*]'
RETURNING VARCHAR2(100) WITH CONDITIONAL WRAPPER) AS value
FROM DUAL;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/JSON_QUERY-11.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/JSON_QUERY.html
SELECT JSON_QUERY('[{"a":100},{"b":200},{"c":300}]', '$[3]'
EMPTY ON ERROR) AS value
FROM DUAL;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/JSON_QUERY-2.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/JSON_QUERY.html
SELECT JSON_QUERY('{a:100, b:200, c:300}', '$.*' WITH WRAPPER) AS value
FROM DUAL;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/JSON_QUERY-3.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/JSON_QUERY.html
SELECT JSON_QUERY('[0,1,2,3,4]', '$') AS value
FROM DUAL;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/JSON_QUERY-4.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/JSON_QUERY.html
SELECT JSON_QUERY('[0,1,2,3,4]', '$' WITH WRAPPER) AS value
FROM DUAL;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/JSON_QUERY-5.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/JSON_QUERY.html
SELECT JSON_QUERY('[0,1,2,3,4]', '$[*]' WITH WRAPPER) AS value
FROM DUAL;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/JSON_QUERY-6.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/JSON_QUERY.html
SELECT JSON_QUERY('[0,1,2,3,4,5,6,7,8]', '$[0, 3 to 5, 7]' WITH WRAPPER) AS value
FROM DUAL;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/JSON_QUERY-7.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/JSON_QUERY.html
SELECT JSON_QUERY('[0,1,2,3,4]', '$[3]' WITH WRAPPER) AS value
FROM DUAL;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/JSON_QUERY-8.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/JSON_QUERY.html
SELECT JSON_QUERY('[{a:100},{b:200},{c:300}]', '$[0]'
WITH CONDITIONAL WRAPPER) AS value
FROM DUAL;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/JSON_QUERY-9.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/JSON_QUERY.html
SELECT JSON_QUERY('[{"a":100},{"b":200},{"c":300}]', '$[*]'
WITH CONDITIONAL WRAPPER) AS value
FROM DUAL;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/JSON_SERIALIZE-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/JSON_SERIALIZE.html
SELECT JSON_SERIALIZE('{price:20, currency:" €"}' ASCII PRETTY ORDERED) from dual;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/JSON_TABLE-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/JSON_TABLE.html
SELECT t.*
FROM j_purchaseOrder
NESTED po_document COLUMNS(PONumber, Reference, Requestor) t;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/JSON_TABLE-1.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/JSON_TABLE.html
SELECT t.*
FROM j_purchaseOrder LEFT OUTER JOIN
JSON_TABLE(po_document COLUMNS(PONumber, Reference, Requestor)) t ON 1=1;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/JSON_TABLE-10.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/JSON_TABLE.html
SELECT requestor
FROM j_purchaseorder,
JSON_TABLE(po_document, '$'
COLUMNS
(requestor VARCHAR2(32) PATH '$.Requestor',
has_zip VARCHAR2(5) EXISTS PATH '$.ShippingInstructions.Address.zipCode'))
WHERE (has_zip = 'true');
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/JSON_TABLE-11.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/JSON_TABLE.html
SELECT *
FROM JSON_TABLE('[1,2,["a","b"]]', '$'
COLUMNS (outer_value_0 NUMBER PATH '$[0]',
outer_value_1 NUMBER PATH '$[1]',
outer_value_2 VARCHAR2(20) FORMAT JSON PATH '$[2]'));
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/JSON_TABLE-12.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/JSON_TABLE.html
SELECT *
FROM JSON_TABLE('[1,2,["a","b"]]', '$'
COLUMNS (outer_value_0 NUMBER PATH '$[0]',
outer_value_1 NUMBER PATH '$[1]',
NESTED PATH '$[2]'
COLUMNS (nested_value_0 VARCHAR2(1) PATH '$[0]',
nested_value_1 VARCHAR2(1) PATH '$[1]')));
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/JSON_TABLE-13.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/JSON_TABLE.html
SELECT *
FROM JSON_TABLE('{a:100, b:200, c:{d:300, e:400}}', '$'
COLUMNS (outer_value_0 NUMBER PATH '$.a',
outer_value_1 NUMBER PATH '$.b',
NESTED PATH '$.c'
COLUMNS (nested_value_0 NUMBER PATH '$.d',
nested_value_1 NUMBER PATH '$.e')));
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/JSON_TABLE-14.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/JSON_TABLE.html
SELECT jt.*
FROM j_purchaseorder,
JSON_TABLE(po_document, '$'
COLUMNS
(requestor VARCHAR2(32) PATH '$.Requestor',
NESTED PATH '$.ShippingInstructions.Phone[*]'
COLUMNS (phone_type VARCHAR2(32) PATH '$.type',
phone_num VARCHAR2(20) PATH '$.number')))
AS jt;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/JSON_TABLE-15.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/JSON_TABLE.html
SELECT c.*
FROM customer t,
JSON_TABLE(t.json COLUMNS(
id, name, phone, address,
NESTED orders[*] COLUMNS(
updated, status,
NESTED lineitems[*] COLUMNS(
description, quantity NUMBER, price NUMBER
)
)
)) c;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/JSON_TABLE-16.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/JSON_TABLE.html
SELECT c.*
FROM customer t,
JSON_TABLE(t.json, '$' COLUMNS(
id PATH '$.id',
name PATH '$.name',
phone PATH '$.phone',
address PATH '$.address',
NESTED PATH '$.orders[*]' COLUMNS(
updated PATH '$.updated',
status PATH '$.status',
NESTED PATH '$.lineitems[*]' COLUMNS(
description PATH '$.description',
quantity NUMBER PATH '$.quantity',
price NUMBER PATH '$.price'
)
)
)) c;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/JSON_TABLE-2.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/JSON_TABLE.html
SELECT *
FROM j_purchaseOrder
NESTED po_document.LineItems[*]
COLUMNS(ItemNumber, Quantity NUMBER);
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/JSON_TABLE-4.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/JSON_TABLE.html
CREATE TABLE j_purchaseorder
(id RAW (16) NOT NULL,
date_loaded TIMESTAMP(6) WITH TIME ZONE,
po_document CLOB CONSTRAINT ensure_json CHECK (po_document IS JSON));
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/JSON_TABLE-5.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/JSON_TABLE.html
INSERT INTO j_purchaseorder
VALUES (
SYS_GUID(),
SYSTIMESTAMP,
'{"PONumber" : 1600,
"Reference" : "ABULL-20140421",
"Requestor" : "Alexis Bull",
"User" : "ABULL",
"CostCenter" : "A50",
"ShippingInstructions" : {"name" : "Alexis Bull",
"Address": {"street" : "200 Sporting Green",
"city" : "South San Francisco",
"state" : "CA",
"zipCode" : 99236,
"country" : "United States of America"},
"Phone" : [{"type" : "Office", "number" : "909-555-7307"},
{"type" : "Mobile", "number" : "415-555-1234"}]},
"Special Instructions" : null,
"AllowPartialShipment" : true,
"LineItems" : [{"ItemNumber" : 1,
"Part" : {"Description" : "One Magic Christmas",
"UnitPrice" : 19.95,
"UPCCode" : 13131092899},
"Quantity" : 9.0},
{"ItemNumber" : 2,
"Part" : {"Description" : "Lethal Weapon",
"UnitPrice" : 19.95,
"UPCCode" : 85391628927},
"Quantity" : 5.0}]}');
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/JSON_TABLE-6.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/JSON_TABLE.html
SELECT jt.phones
FROM j_purchaseorder,
JSON_TABLE(po_document, '$.ShippingInstructions'
COLUMNS
(phones VARCHAR2(100) FORMAT JSON PATH '$.Phone')) AS jt;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/JSON_TABLE-8.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/JSON_TABLE.html
SELECT jt.*
FROM j_purchaseorder,
JSON_TABLE(po_document, '$.ShippingInstructions.Phone[*]'
COLUMNS (row_number FOR ORDINALITY,
phone_type VARCHAR2(10) PATH '$.type',
phone_num VARCHAR2(20) PATH '$.number'))
AS jt;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/JSON_TABLE-9.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/JSON_TABLE.html
SELECT requestor, has_zip
FROM j_purchaseorder,
JSON_TABLE(po_document, '$'
COLUMNS
(requestor VARCHAR2(32) PATH '$.Requestor',
has_zip VARCHAR2(5) EXISTS PATH '$.ShippingInstructions.Address.zipCode'));
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/JSON_TRANSFORM-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/JSON_TRANSFORM.html
UPDATE t SET jcol = JSON_TRANSFORM(jcol, SET '$.lastUpdated' = SYSTIMESTAMP)
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/JSON_TRANSFORM-1.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/JSON_TRANSFORM.html
SELECT JSON_TRANSFORM (jcol, REMOVE '$.ssn') FROM t WHERE …
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/JSON_VALUE-10.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/JSON_VALUE.html
SELECT JSON_VALUE('[{a:100}, {b:200}, {c:300}]', '$[*].c') AS value
FROM DUAL;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/JSON_VALUE-11.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/JSON_VALUE.html
SELECT JSON_VALUE('{firstname:"John"}', '$.lastname') AS "Last Name"
FROM DUAL;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/JSON_VALUE-12.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/JSON_VALUE.html
SELECT JSON_VALUE('{firstname:"John"}', '$.lastname'
DEFAULT 'No last name found' ON ERROR) AS "Last Name"
FROM DUAL;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/JSON_VALUE-3.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/JSON_VALUE.html
SELECT JSON_VALUE('{a:100}', '$.a') AS value
FROM DUAL;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/JSON_VALUE-4.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/JSON_VALUE.html
SELECT JSON_VALUE('{a:100}', '$.a' RETURNING NUMBER) AS value
FROM DUAL;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/JSON_VALUE-5.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/JSON_VALUE.html
SELECT JSON_VALUE('{a:{b:100}}', '$.a.b') AS value
FROM DUAL;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/JSON_VALUE-6.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/JSON_VALUE.html
SELECT JSON_VALUE('{a:{b:100}, c:{d:200}, e:{f:300}}', '$.*.d') AS value
FROM DUAL;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/JSON_VALUE-7.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/JSON_VALUE.html
SELECT JSON_VALUE('[0, 1, 2, 3]', '$[0]') AS value
FROM DUAL;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/JSON_VALUE-8.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/JSON_VALUE.html
SELECT JSON_VALUE('{a:[5, 10, 15, 20]}', '$.a[2]') AS value
FROM DUAL;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/JSON_VALUE-9.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/JSON_VALUE.html
SELECT JSON_VALUE('[{a:100}, {a:200}, {a:300}]', '$[1].a') AS value
FROM DUAL;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/Joins-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/Joins.html
SELECT employee_id, manager_id
FROM employees
WHERE employees.manager_id(+) = employees.employee_id;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/Joins-1.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/Joins.html
SELECT e1.employee_id, e1.manager_id, e2.employee_id
FROM employees e1, employees e2
WHERE e1.manager_id(+) = e2.employee_id
ORDER BY e1.employee_id, e1.manager_id, e2.employee_id;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/Joins-3.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/Joins.html
SELECT * FROM A, B, D
WHERE A.c1 = B.c2(+) and D.c3 = B.c4(+);
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/LAG-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/LAG.html
SELECT hire_date, last_name, salary,
LAG(salary, 1, 0) OVER (ORDER BY hire_date) AS prev_sal
FROM employees
WHERE job_id = 'PU_CLERK'
ORDER BY hire_date;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/LAST_DAY-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/LAST_DAY.html
SELECT SYSDATE,
LAST_DAY(SYSDATE) "Last",
LAST_DAY(SYSDATE) - SYSDATE "Days Left"
FROM DUAL;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/LAST_DAY-1.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/LAST_DAY.html
SELECT last_name, hire_date,
TO_CHAR(ADD_MONTHS(LAST_DAY(hire_date), 5)) "Eval Date"
FROM employees
ORDER BY last_name, hire_date;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/LAST_VALUE-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/LAST_VALUE.html
SELECT employee_id, last_name, salary, hire_date,
LAST_VALUE(hire_date)
OVER (ORDER BY salary DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED
FOLLOWING) AS lv
FROM (SELECT * FROM employees
WHERE department_id = 90
ORDER BY hire_date);
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/LAST_VALUE-1.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/LAST_VALUE.html
SELECT employee_id, last_name, salary, hire_date,
LAST_VALUE(hire_date)
OVER (ORDER BY salary DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED
FOLLOWING) AS lv
FROM (SELECT * FROM employees
WHERE department_id = 90
ORDER BY hire_date DESC);
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/LAST_VALUE-2.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/LAST_VALUE.html
SELECT employee_id, last_name, salary, hire_date,
LAST_VALUE(hire_date)
OVER (ORDER BY salary DESC, employee_id ROWS BETWEEN UNBOUNDED PRECEDING
AND UNBOUNDED FOLLOWING) AS lv
FROM (SELECT * FROM employees
WHERE department_id = 90
ORDER BY hire_date);
SELECT employee_id, last_name, salary, hire_date,
LAST_VALUE(hire_date)
OVER (ORDER BY salary DESC, employee_id ROWS BETWEEN UNBOUNDED PRECEDING
AND UNBOUNDED FOLLOWING) AS lv
FROM (SELECT * FROM employees
WHERE department_id = 90
ORDER BY hire_date DESC);
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/LAST_VALUE-3.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/LAST_VALUE.html
SELECT employee_id, last_name, salary, hire_date,
LAST_VALUE(hire_date)
OVER (ORDER BY salary DESC RANGE BETWEEN UNBOUNDED PRECEDING AND
UNBOUNDED FOLLOWING) AS lv
FROM (SELECT * FROM employees
WHERE department_id = 90
ORDER BY hire_date);
SELECT employee_id, last_name, salary, hire_date,
LAST_VALUE(hire_date)
OVER (ORDER BY salary DESC RANGE BETWEEN UNBOUNDED PRECEDING AND
UNBOUNDED FOLLOWING) AS lv
FROM (SELECT * FROM employees
WHERE department_id = 90
ORDER BY hire_date DESC);
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/LEAD-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/LEAD.html
SELECT hire_date, last_name,
LEAD(hire_date, 1) OVER (ORDER BY hire_date) AS "NextHired"
FROM employees
WHERE department_id = 30
ORDER BY hire_date;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/LEAST-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/LEAST.html
SELECT LEAST('HARRY','HARRIOT','HAROLD') "Least"
FROM DUAL;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/LEAST-1.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/LEAST.html
SELECT LEAST (1, '2.1', '.000832') "Least"
FROM DUAL;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/LENGTH-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/LENGTH.html
SELECT LENGTH('CANDIDE') "Length in characters"
FROM DUAL;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/LENGTH-1.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/LENGTH.html
SELECT LENGTHB ('CANDIDE') "Length in bytes"
FROM DUAL;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/LISTAGG-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/LISTAGG.html
SELECT LISTAGG(last_name, '; ')
WITHIN GROUP (ORDER BY hire_date, last_name) "Emp_list",
MIN(hire_date) "Earliest"
FROM employees
WHERE department_id = 30;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/LISTAGG-1.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/LISTAGG.html
SELECT department_id "Dept.",
LISTAGG(last_name, '; ') WITHIN GROUP (ORDER BY hire_date) "Employees"
FROM employees
GROUP BY department_id
ORDER BY department_id;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/LISTAGG-2.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/LISTAGG.html
SELECT department_id "Dept.",
LISTAGG(last_name, '; ' ON OVERFLOW TRUNCATE '...')
WITHIN GROUP (ORDER BY hire_date) "Employees"
FROM employees
GROUP BY department_id
ORDER BY department_id;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/LISTAGG-3.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/LISTAGG.html
SELECT department_id "Dept", hire_date "Date", last_name "Name",
LISTAGG(last_name, '; ') WITHIN GROUP (ORDER BY hire_date, last_name)
OVER (PARTITION BY department_id) as "Emp_list"
FROM employees
WHERE hire_date < '01-SEP-2003'
ORDER BY "Dept", "Date", "Name";
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/LN-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/LN.html
SELECT LN(95) "Natural log of 95"
FROM DUAL;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/LNNVL-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/LNNVL.html
SELECT COUNT(*)
FROM employees
WHERE commission_pct < .2;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/LNNVL-1.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/LNNVL.html
SELECT COUNT(*)
FROM employees
WHERE LNNVL(commission_pct >= .2);
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/LOCALTIMESTAMP-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/LOCALTIMESTAMP.html
ALTER SESSION SET TIME_ZONE = '-5:00';
SELECT CURRENT_TIMESTAMP, LOCALTIMESTAMP FROM DUAL;
ALTER SESSION SET TIME_ZONE = '-8:00';
SELECT CURRENT_TIMESTAMP, LOCALTIMESTAMP FROM DUAL;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/LOCALTIMESTAMP-1.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/LOCALTIMESTAMP.html
CREATE TABLE local_test (col1 TIMESTAMP WITH LOCAL TIME ZONE);
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/LOCALTIMESTAMP-2.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/LOCALTIMESTAMP.html
INSERT INTO local_test
VALUES (TO_TIMESTAMP(LOCALTIMESTAMP, 'DD-MON-RR HH.MI.SSXFF'));
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/LOCALTIMESTAMP-3.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/LOCALTIMESTAMP.html
INSERT INTO local_test
VALUES (TO_TIMESTAMP(LOCALTIMESTAMP, 'DD-MON-RR HH.MI.SSXFF PM'));
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/LOCK-TABLE-1.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/LOCK-TABLE.html
LOCK TABLE employees
IN EXCLUSIVE MODE
NOWAIT;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/LOCK-TABLE-2.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/LOCK-TABLE.html
LOCK TABLE employees@remote
IN SHARE MODE;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/LOG-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/LOG.html
SELECT LOG(10,100) "Log base 10 of 100"
FROM DUAL;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/LOWER-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/LOWER.html
SELECT LOWER('MR. SCOTT MCMILLAN') "Lowercase"
FROM DUAL;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/LPAD-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/LPAD.html
SELECT LPAD('Page 1',15,'*.') "LPAD example"
FROM DUAL;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/LTRIM-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/LTRIM.html
SELECT LTRIM('<=====>BROWNING<=====>', '<>=') "LTRIM Example"
FROM DUAL;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/Lexical-Conventions-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/Lexical-Conventions.html
SELECT last_name,salary*12,MONTHS_BETWEEN(SYSDATE,hire_date)
FROM employees
WHERE department_id = 30
ORDER BY last_name;
SELECT last_name,
salary * 12,
MONTHS_BETWEEN( SYSDATE, hire_date )
FROM employees
WHERE department_id=30
ORDER BY last_name;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/Literals-10.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/Literals.html
SELECT COUNT(*)
FROM employees
WHERE salary < BINARY_FLOAT_INFINITY;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/Literals-11.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/Literals.html
SELECT COUNT(*)
FROM employees
WHERE TO_BINARY_FLOAT(commission_pct)
!= BINARY_FLOAT_NAN;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/Literals-12.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/Literals.html
SELECT COUNT(*)
FROM employees
WHERE salary < BINARY_DOUBLE_INFINITY;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/Literals-15.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/Literals.html
INSERT INTO my_table VALUES (1, SYSDATE);
INSERT INTO my_table VALUES (2, TRUNC(SYSDATE));
SELECT *
FROM my_table;
SELECT *
FROM my_table
WHERE datecol > TO_DATE('02-OCT-02', 'DD-MON-YY');
SELECT *
FROM my_table
WHERE datecol = TO_DATE('03-OCT-02','DD-MON-YY');
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/Literals-16.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/Literals.html
SELECT *
FROM my_table
WHERE datecol = DATE '2002-10-03';
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/Literals-17.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/Literals.html
SELECT *
FROM my_table
WHERE TRUNC(datecol) = DATE '2002-10-03';
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/Literals-18.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/Literals.html
INSERT INTO my_table
VALUES (3, TO_DATE('3-OCT-2002','DD-MON-YYYY'));
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/Literals-19.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/Literals.html
INSERT INTO my_table
VALUES (4, '03-OCT-02');
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/Literals-20.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/Literals.html
INSERT INTO my_table
VALUES (5, TRUNC(SYSDATE));
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/Literals-27.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/Literals.html
SELECT TIMESTAMP '2009-10-29 01:30:00' AT TIME ZONE 'US/Pacific'
FROM DUAL;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/Literals-3.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/Literals.html
ALTER SESSION SET NLS_NUMERIC_CHARACTERS=',.';
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/Literals-4.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/Literals.html
SELECT 2 * 1.23, 3 * '2,34' FROM DUAL;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/Literals-5.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/Literals.html
SELECT 2 * 1,23 FROM DUAL;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/Literals-6.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/Literals.html
SELECT 3 * '2.34' FROM DUAL;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/Literals-9.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/Literals.html
SELECT COUNT(*)
FROM employees
WHERE TO_BINARY_FLOAT(commission_pct)
!= BINARY_FLOAT_NAN;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/Logical-Conditions-1.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/Logical-Conditions.html
SELECT *
FROM employees
WHERE NOT (job_id IS NULL)
ORDER BY employee_id;
SELECT *
FROM employees
WHERE NOT
(salary BETWEEN 1000 AND 2000)
ORDER BY employee_id;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/Logical-Conditions-3.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/Logical-Conditions.html
SELECT *
FROM employees
WHERE job_id = 'PU_CLERK'
AND department_id = 30
ORDER BY employee_id;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/Logical-Conditions-5.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/Logical-Conditions.html
SELECT *
FROM employees
WHERE job_id = 'PU_CLERK'
OR department_id = 10
ORDER BY employee_id;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/Logical-Conditions-6.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/Logical-Conditions.html
SELECT * FROM employees
WHERE hire_date < TO_DATE('01-JAN-2004', 'DD-MON-YYYY')
AND salary > 2500
ORDER BY employee_id;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/Logical-Conditions-7.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/Logical-Conditions.html
SELECT employee_id FROM employees
WHERE commission_pct = .4 OR salary > 20000
ORDER BY employee_id;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/MAKE_REF-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/MAKE_REF.html
SELECT MAKE_REF (oc_inventories, 3003)
FROM DUAL;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/MAX-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/MAX.html
SELECT MAX(salary) "Maximum"
FROM employees;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/MAX-1.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/MAX.html
SELECT manager_id, last_name, salary,
MAX(salary) OVER (PARTITION BY manager_id) AS mgr_max
FROM employees
ORDER BY manager_id, last_name, salary;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/MAX-2.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/MAX.html
SELECT manager_id, last_name, salary
FROM (SELECT manager_id, last_name, salary,
MAX(salary) OVER (PARTITION BY manager_id) AS rmax_sal
FROM employees)
WHERE salary = rmax_sal
ORDER BY manager_id, last_name, salary;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/MEDIAN-1.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/MEDIAN.html
SELECT department_id, MEDIAN(salary)
FROM employees
GROUP BY department_id
ORDER BY department_id;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/MEDIAN-2.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/MEDIAN.html
SELECT manager_id, employee_id, salary,
MEDIAN(salary) OVER (PARTITION BY manager_id) "Median by Mgr"
FROM employees
WHERE department_id > 60
ORDER BY manager_id, employee_id;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/MERGE-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/MERGE.html
CREATE TABLE bonuses (employee_id NUMBER, bonus NUMBER DEFAULT 100);
INSERT INTO bonuses(employee_id)
(SELECT e.employee_id FROM hr.employees e, oe.orders o
WHERE e.employee_id = o.sales_rep_id
GROUP BY e.employee_id);
SELECT * FROM bonuses ORDER BY employee_id;
MERGE INTO bonuses D
USING (SELECT employee_id, salary, department_id FROM hr.employees
WHERE department_id = 80) S
ON (D.employee_id = S.employee_id)
WHEN MATCHED THEN UPDATE SET D.bonus = D.bonus + S.salary*.01
DELETE WHERE (S.salary > 8000)
WHEN NOT MATCHED THEN INSERT (D.employee_id, D.bonus)
VALUES (S.employee_id, S.salary*.01)
WHERE (S.salary <= 8000);
SELECT * FROM bonuses ORDER BY employee_id;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/MERGE-1.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/MERGE.html
CREATE TABLE people_source (
person_id INTEGER NOT NULL PRIMARY KEY,
first_name VARCHAR2(20) NOT NULL,
last_name VARCHAR2(20) NOT NULL,
title VARCHAR2(10) NOT NULL
);
CREATE TABLE people_target (
person_id INTEGER NOT NULL PRIMARY KEY,
first_name VARCHAR2(20) NOT NULL,
last_name VARCHAR2(20) NOT NULL,
title VARCHAR2(10) NOT NULL
);
INSERT INTO people_target VALUES (1, 'John', 'Smith', 'Mr');
INSERT INTO people_target VALUES (2, 'alice', 'jones', 'Mrs');
INSERT INTO people_source VALUES (2, 'Alice', 'Jones', 'Mrs.');
INSERT INTO people_source VALUES (3, 'Jane', 'Doe', 'Miss');
INSERT INTO people_source VALUES (4, 'Dave', 'Brown', 'Mr');
COMMIT;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/MERGE-10.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/MERGE.html
var person_id NUMBER;
var first_name VARCHAR2(20);
var last_name VARCHAR2(20);
var title VARCHAR2(10);
exec :person_id := 3;
exec :first_name := 'Gerald';
exec :last_name := 'Walker';
exec :title := 'Mr';
MERGE INTO people_target
ON (person_id = :person_id)
WHEN MATCHED THEN UPDATE
SET first_name = :first_name,
last_name = :last_name,
title = :title
WHEN NOT MATCHED THEN INSERT
(person_id, first_name, last_name, title)
VALUES (:person_id, :first_name, :last_name, :title);
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/MERGE-11.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/MERGE.html
SELECT * FROM people_target;
ROLLBACK;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/MERGE-12.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/MERGE.html
var person_id NUMBER;
var first_name VARCHAR2(20);
var last_name VARCHAR2(20);
var title VARCHAR2(10);
exec :person_id := 2;
exec :first_name := 'Alice';
exec :last_name := 'Jones';
exec :title := 'Mrs';
MERGE INTO people_target
ON (person_id = :person_id)
WHEN MATCHED THEN UPDATE
SET first_name = :first_name,
last_name = :last_name,
title = :title
WHEN NOT MATCHED THEN INSERT
(person_id, first_name, last_name, title)
VALUES (:person_id, :first_name, :last_name, :title);
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/MERGE-13.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/MERGE.html
SELECT * FROM people_target;
ROLLBACK;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/MERGE-2.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/MERGE.html
MERGE INTO people_target pt
USING people_source ps
ON (pt.person_id = ps.person_id)
WHEN MATCHED THEN UPDATE
SET pt.first_name = ps.first_name,
pt.last_name = ps.last_name,
pt.title = ps.title;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/MERGE-3.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/MERGE.html
SELECT * FROM people_target;
ROLLBACK;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/MERGE-4.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/MERGE.html
MERGE INTO people_target pt
USING people_source ps
ON (pt.person_id = ps.person_id)
WHEN NOT MATCHED THEN INSERT
(pt.person_id, pt.first_name, pt.last_name, pt.title)
VALUES (ps.person_id, ps.first_name, ps.last_name, ps.title);
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/MERGE-5.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/MERGE.html
SELECT * FROM people_target;
ROLLBACK;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/MERGE-6.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/MERGE.html
MERGE INTO people_target pt
USING people_source ps
ON (pt.person_id = ps.person_id)
WHEN MATCHED THEN UPDATE
SET pt.first_name = ps.first_name,
pt.last_name = ps.last_name,
pt.title = ps.title
WHEN NOT MATCHED THEN INSERT
(pt.person_id, pt.first_name, pt.last_name, pt.title)
VALUES (ps.person_id, ps.first_name, ps.last_name, ps.title);
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/MERGE-7.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/MERGE.html
SELECT * FROM people_target;
ROLLBACK;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/MERGE-8.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/MERGE.html
MERGE INTO people_target pt
USING people_source ps
ON (pt.person_id = ps.person_id)
WHEN MATCHED THEN UPDATE
SET pt.first_name = ps.first_name,
pt.last_name = ps.last_name,
pt.title = ps.title
DELETE where pt.title = 'Mrs.'
WHEN NOT MATCHED THEN INSERT
(pt.person_id, pt.first_name, pt.last_name, pt.title)
VALUES (ps.person_id, ps.first_name, ps.last_name, ps.title)
WHERE ps.title = 'Mr';
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/MERGE-9.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/MERGE.html
SELECT * FROM people_target;
ROLLBACK;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/MIN-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/MIN.html
SELECT MIN(hire_date) "Earliest"
FROM employees;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/MIN-1.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/MIN.html
SELECT manager_id, last_name, hire_date, salary,
MIN(salary) OVER(PARTITION BY manager_id ORDER BY hire_date
RANGE UNBOUNDED PRECEDING) AS p_cmin
FROM employees
ORDER BY manager_id, last_name, hire_date, salary;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/MOD-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/MOD.html
SELECT MOD(11,4) "Modulus"
FROM DUAL;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/MONTHS_BETWEEN-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/MONTHS_BETWEEN.html
SELECT MONTHS_BETWEEN
(TO_DATE('02-02-1995','MM-DD-YYYY'),
TO_DATE('01-01-1995','MM-DD-YYYY') ) "Months"
FROM DUAL;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/Model-Conditions-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/Model-Conditions.html
SELECT country, prod, year, s
FROM sales_view_ref
MODEL
PARTITION BY (country)
DIMENSION BY (prod, year)
MEASURES (sale s)
IGNORE NAV
UNIQUE DIMENSION
RULES UPSERT SEQUENTIAL ORDER
(
s[ANY, 2000] = 0
)
ORDER BY country, prod, year;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/Model-Conditions-1.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/Model-Conditions.html
SELECT country, prod, year, s
FROM sales_view_ref
MODEL
PARTITION BY (country)
DIMENSION BY (prod, year)
MEASURES (sale s)
IGNORE NAV
UNIQUE DIMENSION
RULES UPSERT SEQUENTIAL ORDER
(
s['Mouse Pad', 2000] =
CASE WHEN s['Mouse Pad', 1999] IS PRESENT
THEN s['Mouse Pad', 1999]
ELSE 0
END
)
ORDER BY country, prod, year;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/Model-Expressions-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/Model-Expressions.html
SELECT country,prod,year,s
FROM sales_view_ref
MODEL
PARTITION BY (country)
DIMENSION BY (prod, year)
MEASURES (sale s)
IGNORE NAV
UNIQUE DIMENSION
RULES UPSERT SEQUENTIAL ORDER
(
s[prod='Mouse Pad', year=2000] =
s['Mouse Pad', 1998] + s['Mouse Pad', 1999],
s['Standard Mouse', 2001] = s['Standard Mouse', 2000]
)
ORDER BY country, prod, year;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/Multiset-Conditions-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/Multiset-Conditions.html
SELECT customer_id, cust_address_ntab
FROM customers_demo
WHERE cust_address_ntab IS A SET
ORDER BY customer_id;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/Multiset-Conditions-1.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/Multiset-Conditions.html
SELECT product_id, TO_CHAR(ad_finaltext) AS text
FROM print_media
WHERE ad_textdocs_ntab IS NOT EMPTY
ORDER BY product_id, text;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/Multiset-Conditions-2.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/Multiset-Conditions.html
SELECT customer_id, cust_address_ntab
FROM customers_demo
WHERE cust_address_typ('8768 N State Rd 37', 47404,
'Bloomington', 'IN', 'US')
MEMBER OF cust_address_ntab
ORDER BY customer_id;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/Multiset-Conditions-3.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/Multiset-Conditions.html
SELECT customer_id, cust_address_ntab
FROM customers_demo
WHERE cust_address_ntab SUBMULTISET OF cust_address2_ntab
ORDER BY customer_id;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/Multiset-Operators-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/Multiset-Operators.html
CREATE TABLE customers_demo AS
SELECT * FROM customers;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/Multiset-Operators-1.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/Multiset-Operators.html
CREATE TYPE cust_address_tab_typ AS
TABLE OF cust_address_typ;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/Multiset-Operators-2.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/Multiset-Operators.html
ALTER TABLE customers_demo
ADD (cust_address_ntab cust_address_tab_typ,
cust_address2_ntab cust_address_tab_typ)
NESTED TABLE cust_address_ntab STORE AS cust_address_ntab_store
NESTED TABLE cust_address2_ntab STORE AS cust_address2_ntab_store;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/Multiset-Operators-3.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/Multiset-Operators.html
UPDATE customers_demo cd
SET cust_address_ntab =
CAST(MULTISET(SELECT cust_address
FROM customers c
WHERE c.customer_id =
cd.customer_id) as cust_address_tab_typ);
UPDATE customers_demo cd
SET cust_address2_ntab =
CAST(MULTISET(SELECT cust_address
FROM customers c
WHERE c.customer_id =
cd.customer_id) as cust_address_tab_typ);
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/Multiset-Operators-4.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/Multiset-Operators.html
SELECT customer_id, cust_address_ntab
MULTISET EXCEPT DISTINCT cust_address2_ntab multiset_except
FROM customers_demo
ORDER BY customer_id;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/Multiset-Operators-5.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/Multiset-Operators.html
SELECT customer_id, cust_address_ntab
MULTISET INTERSECT DISTINCT cust_address2_ntab multiset_intersect
FROM customers_demo
ORDER BY customer_id;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/Multiset-Operators-6.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/Multiset-Operators.html
SELECT customer_id, cust_address_ntab
MULTISET UNION cust_address2_ntab multiset_union
FROM customers_demo
ORDER BY customer_id;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/NANVL-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/NANVL.html
INSERT INTO float_point_demo
VALUES (0,'NaN','NaN');
SELECT *
FROM float_point_demo;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/NANVL-1.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/NANVL.html
SELECT bin_float, NANVL(bin_float,0)
FROM float_point_demo;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/NCHR-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/NCHR.html
SELECT NCHR(187)
FROM DUAL;
SELECT CHR(187 USING NCHAR_CS)
FROM DUAL;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/NEW_TIME-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/NEW_TIME.html
ALTER SESSION SET NLS_DATE_FORMAT = 'DD-MON-YYYY HH24:MI:SS';
SELECT NEW_TIME(TO_DATE('11-10-09 01:23:45', 'MM-DD-YY HH24:MI:SS'), 'AST', 'PST')
"New Date and Time"
FROM DUAL;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/NEXT_DAY-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/NEXT_DAY.html
SELECT NEXT_DAY('15-OCT-2009','TUESDAY') "NEXT DAY"
FROM DUAL;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/NLSSORT-1.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/NLSSORT.html
CREATE TABLE test (name VARCHAR2(15));
INSERT INTO test VALUES ('Gaardiner');
INSERT INTO test VALUES ('Gaberd');
INSERT INTO test VALUES ('Gaasten');
SELECT *
FROM test
ORDER BY name;
SELECT *
FROM test
ORDER BY NLSSORT(name, 'NLS_SORT = XDanish');
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/NLSSORT-2.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/NLSSORT.html
SELECT *
FROM test
WHERE name > 'Gaberd'
ORDER BY name;
SELECT *
FROM test
WHERE NLSSORT(name, 'NLS_SORT = XDanish') >
NLSSORT('Gaberd', 'NLS_SORT = XDanish')
ORDER BY name;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/NLSSORT-3.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/NLSSORT.html
ALTER SESSION SET NLS_COMP = 'LINGUISTIC';
ALTER SESSION SET NLS_SORT = 'XDanish';
SELECT *
FROM test
WHERE name > 'Gaberd'
ORDER BY name;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/NLS_CHARSET_DECL_LEN-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/NLS_CHARSET_DECL_LEN.html
SELECT NLS_CHARSET_DECL_LEN(200, nls_charset_id('ja16eucfixed'))
FROM DUAL;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/NLS_CHARSET_ID-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/NLS_CHARSET_ID.html
SELECT NLS_CHARSET_ID('ja16euc')
FROM DUAL;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/NLS_CHARSET_NAME-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/NLS_CHARSET_NAME.html
SELECT NLS_CHARSET_NAME(2)
FROM DUAL;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/NLS_COLLATION_ID-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/NLS_COLLATION_ID.html
SELECT NLS_COLLATION_ID('BINARY_CI')
FROM DUAL;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/NLS_COLLATION_NAME-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/NLS_COLLATION_NAME.html
SELECT NLS_COLLATION_NAME(81919)
FROM DUAL;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/NLS_COLLATION_NAME-1.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/NLS_COLLATION_NAME.html
SELECT NLS_COLLATION_NAME(208897,'S')
FROM DUAL;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/NLS_COLLATION_NAME-2.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/NLS_COLLATION_NAME.html
SELECT NLS_COLLATION_NAME(208897,'L')
FROM DUAL;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/NLS_INITCAP-1.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/NLS_INITCAP.html
SELECT NLS_INITCAP('ijsland') "InitCap"
FROM DUAL;
SELECT NLS_INITCAP('ijsland', 'NLS_SORT = XDutch') "InitCap"
FROM DUAL;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/NLS_LOWER-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/NLS_LOWER.html
SELECT NLS_LOWER('NOKTASINDA', 'NLS_SORT = XTurkish') "Lowercase"
FROM DUAL;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/NLS_UPPER-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/NLS_UPPER.html
SELECT NLS_UPPER('große') "Uppercase"
FROM DUAL;
SELECT NLS_UPPER('große', 'NLS_SORT = XGerman') "Uppercase"
FROM DUAL;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/NOAUDIT-Traditional-Auditing-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/NOAUDIT-Traditional-Auditing.html
NOAUDIT ROLE;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/NOAUDIT-Traditional-Auditing-1.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/NOAUDIT-Traditional-Auditing.html
NOAUDIT SELECT TABLE BY hr;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/NOAUDIT-Traditional-Auditing-2.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/NOAUDIT-Traditional-Auditing.html
NOAUDIT DELETE ANY TABLE;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/NOAUDIT-Traditional-Auditing-3.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/NOAUDIT-Traditional-Auditing.html
NOAUDIT SELECT
ON hr.employees;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/NOAUDIT-Traditional-Auditing-4.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/NOAUDIT-Traditional-Auditing.html
NOAUDIT SELECT
ON hr.employees
WHENEVER SUCCESSFUL;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/NOAUDIT-Unified-Auditing-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/NOAUDIT-Unified-Auditing.html
NOAUDIT POLICY table_pol;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/NOAUDIT-Unified-Auditing-1.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/NOAUDIT-Unified-Auditing.html
SELECT *
FROM audit_unified_enabled_policies
WHERE policy_name = 'TABLE_POL';
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/NOAUDIT-Unified-Auditing-2.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/NOAUDIT-Unified-Auditing.html
SELECT policy_name, enabled_option, entity_name
FROM audit_unified_enabled_policies
WHERE policy_name = 'DML_POL'
ORDER BY entity_name;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/NOAUDIT-Unified-Auditing-3.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/NOAUDIT-Unified-Auditing.html
NOAUDIT POLICY dml_pol BY hr;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/NOAUDIT-Unified-Auditing-4.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/NOAUDIT-Unified-Auditing.html
SELECT policy_name, enabled_option, entity_name
FROM audit_unified_enabled_policies
WHERE policy_name = 'DML_POL';
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/NOAUDIT-Unified-Auditing-5.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/NOAUDIT-Unified-Auditing.html
NOAUDIT POLICY dml_pol BY sh;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/NOAUDIT-Unified-Auditing-6.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/NOAUDIT-Unified-Auditing.html
SELECT *
FROM audit_unified_enabled_policies
WHERE policy_name = 'DML_POL';
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/NOAUDIT-Unified-Auditing-7.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/NOAUDIT-Unified-Auditing.html
NOAUDIT CONTEXT NAMESPACE userenv
ATTRIBUTES current_user, db_name
BY hr;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/NTH_VALUE-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/NTH_VALUE.html
SELECT prod_id, channel_id, MIN(amount_sold),
NTH_VALUE(MIN(amount_sold), 2) OVER (PARTITION BY prod_id ORDER BY channel_id
ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) nv
FROM sales
WHERE prod_id BETWEEN 13 and 16
GROUP BY prod_id, channel_id;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/NTILE-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/NTILE.html
SELECT last_name, salary, NTILE(4) OVER (ORDER BY salary DESC) AS quartile
FROM employees
WHERE department_id = 100
ORDER BY last_name, salary, quartile;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/NULLIF-1.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/NULLIF.html
SELECT e.last_name, NULLIF(j.job_id, e.job_id) "Old Job ID"
FROM employees e, job_history j
WHERE e.employee_id = j.employee_id
ORDER BY last_name, "Old Job ID";
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/NUMTODSINTERVAL-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/NUMTODSINTERVAL.html
SELECT manager_id, last_name, hire_date,
COUNT(*) OVER (PARTITION BY manager_id ORDER BY hire_date
RANGE NUMTODSINTERVAL(100, 'day') PRECEDING) AS t_count
FROM employees
ORDER BY last_name, hire_date;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/NUMTOYMINTERVAL-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/NUMTOYMINTERVAL.html
SELECT last_name, hire_date, salary,
SUM(salary) OVER (ORDER BY hire_date
RANGE NUMTOYMINTERVAL(1,'year') PRECEDING) AS t_sal
FROM employees
ORDER BY last_name, hire_date;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/NVL-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/NVL.html
SELECT last_name, NVL(TO_CHAR(commission_pct), 'Not Applicable') commission
FROM employees
WHERE last_name LIKE 'B%'
ORDER BY last_name;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/NVL2-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/NVL2.html
SELECT last_name, salary,
NVL2(commission_pct, salary + (salary * commission_pct), salary) income
FROM employees
WHERE last_name like 'B%'
ORDER BY last_name;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/Null-Conditions-1.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/Null-Conditions.html
SELECT last_name
FROM employees
WHERE commission_pct
IS NULL
ORDER BY last_name;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ORA_DM_PARTITION_NAME-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ORA_DM_PARTITION_NAME.html
SELECT prediction(mymodel using *) pred, ora_dm_partition_name(mymodel USING *) pname FROM customers;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ORA_HASH-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ORA_HASH.html
SELECT SUM(amount_sold)
FROM sales
WHERE ORA_HASH(CONCAT(cust_id, prod_id), 99, 5) = 0;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ORA_INVOKING_USER-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ORA_INVOKING_USER.html
SELECT ORA_INVOKING_USER FROM DUAL;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ORA_INVOKING_USERID-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ORA_INVOKING_USERID.html
SELECT ORA_INVOKING_USERID FROM DUAL;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ORA_ROWSCN-Pseudocolumn-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ORA_ROWSCN-Pseudocolumn.html
SELECT ORA_ROWSCN, last_name
FROM employees
WHERE employee_id = 188;
SELECT SCN_TO_TIMESTAMP(ORA_ROWSCN), last_name
FROM employees
WHERE employee_id = 188;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/Object-Access-Expressions-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/Object-Access-Expressions.html
CREATE TABLE short_orders (
sales_rep VARCHAR2(25), item order_item_typ);
UPDATE short_orders s SET sales_rep = 'Unassigned';
SELECT o.item.line_item_id, o.item.quantity FROM short_orders o;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/PERCENTILE_CONT-1.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/PERCENTILE_CONT.html
SELECT department_id,
PERCENTILE_CONT(0.5) WITHIN GROUP (ORDER BY salary DESC) "Median cont",
PERCENTILE_DISC(0.5) WITHIN GROUP (ORDER BY salary DESC) "Median disc"
FROM employees
GROUP BY department_id
ORDER BY department_id;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/PERCENTILE_CONT-2.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/PERCENTILE_CONT.html
SELECT last_name, salary, department_id,
PERCENTILE_CONT(0.5) WITHIN GROUP (ORDER BY salary DESC)
OVER (PARTITION BY department_id) "Percentile_Cont",
PERCENT_RANK()
OVER (PARTITION BY department_id ORDER BY salary DESC) "Percent_Rank"
FROM employees
WHERE department_id IN (30, 60)
ORDER BY last_name, salary, department_id;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/PERCENTILE_DISC-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/PERCENTILE_DISC.html
SELECT last_name, salary, department_id,
PERCENTILE_DISC(0.5) WITHIN GROUP (ORDER BY salary DESC)
OVER (PARTITION BY department_id) "Percentile_Disc",
CUME_DIST() OVER (PARTITION BY department_id
ORDER BY salary DESC) "Cume_Dist"
FROM employees
WHERE department_id in (30, 60)
ORDER BY last_name, salary, department_id;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/PERCENT_RANK-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/PERCENT_RANK.html
SELECT PERCENT_RANK(15000, .05) WITHIN GROUP
(ORDER BY salary, commission_pct) "Percent-Rank"
FROM employees;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/PERCENT_RANK-1.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/PERCENT_RANK.html
SELECT department_id, last_name, salary, PERCENT_RANK()
OVER (PARTITION BY department_id ORDER BY salary DESC) AS pr
FROM employees
ORDER BY pr, salary, last_name;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/POWER-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/POWER.html
SELECT POWER(3,2) "Raised"
FROM DUAL;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/POWERMULTISET-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/POWERMULTISET.html
CREATE TYPE cust_address_tab_tab_typ
AS TABLE OF cust_address_tab_typ;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/POWERMULTISET-1.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/POWERMULTISET.html
SELECT CAST(POWERMULTISET(cust_address_ntab) AS cust_address_tab_tab_typ)
FROM customers_demo;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/POWERMULTISET_BY_CARDINALITY-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/POWERMULTISET_BY_CARDINALITY.html
CREATE TYPE cust_address_tab_tab_typ
AS TABLE OF cust_address_tab_typ;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/POWERMULTISET_BY_CARDINALITY-1.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/POWERMULTISET_BY_CARDINALITY.html
UPDATE customers_demo
SET cust_address_ntab = cust_address_ntab MULTISET UNION cust_address_ntab;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/POWERMULTISET_BY_CARDINALITY-2.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/POWERMULTISET_BY_CARDINALITY.html
SELECT CAST(POWERMULTISET_BY_CARDINALITY(cust_address_ntab, 2)
AS cust_address_tab_tab_typ)
FROM customers_demo;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/PREDICTION-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/PREDICTION.html
SELECT cust_gender, COUNT(*) AS cnt, ROUND(AVG(age)) AS avg_age
FROM mining_data_apply_v
WHERE PREDICTION(dt_sh_clas_sample COST MODEL
USING cust_marital_status, education, household_size) = 1
GROUP BY cust_gender
ORDER BY cust_gender;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/PREDICTION-2.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/PREDICTION.html
SELECT cust_id, age, pred_age, age-pred_age age_diff, pred_det FROM
(SELECT cust_id, age, pred_age, pred_det,
RANK() OVER (ORDER BY ABS(age-pred_age) desc) rnk FROM
(SELECT cust_id, age,
PREDICTION(FOR age USING *) OVER () pred_age,
PREDICTION_DETAILS(FOR age ABS USING *) OVER () pred_det
FROM mining_data_apply_v))
WHERE rnk <= 3;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/PREDICTION_BOUNDS-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/PREDICTION_BOUNDS.html
SELECT count(cust_id) cust_count, cust_marital_status
FROM (SELECT cust_id, cust_marital_status
FROM mining_data_apply_v
WHERE PREDICTION_BOUNDS(glmr_sh_regr_sample,0.98 USING *).LOWER > 24 AND
PREDICTION_BOUNDS(glmr_sh_regr_sample,0.98 USING *).UPPER < 46)
GROUP BY cust_marital_status;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/PREDICTION_COST-2.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/PREDICTION_COST.html
SELECT cust_id
FROM (SELECT cust_id,rank()
OVER (ORDER BY PREDICTION_COST(DT_SH_Clas_sample, 1 COST MODEL USING *)
ASC, cust_id) rnk
FROM mining_data_apply_v
WHERE country_name = 'Italy')
WHERE rnk <= 10
ORDER BY rnk;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/PREDICTION_DETAILS-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/PREDICTION_DETAILS.html
SELECT PREDICTION_DETAILS(svmr_sh_regr_sample, null, 3 USING *) prediction_details
FROM mining_data_apply_v
WHERE cust_id = 100001;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/PREDICTION_DETAILS-1.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/PREDICTION_DETAILS.html
SELECT cust_id, age, pred_age, age-pred_age age_diff, pred_det
FROM (SELECT cust_id, age, pred_age, pred_det,
RANK() OVER (ORDER BY ABS(age-pred_age) DESC) rnk
FROM (SELECT cust_id, age,
PREDICTION(FOR age USING *) OVER () pred_age,
PREDICTION_DETAILS(FOR age ABS USING *) OVER () pred_det
FROM mining_data_apply_v))
WHERE rnk <= 5;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/PREDICTION_PROBABILITY-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/PREDICTION_PROBABILITY.html
SELECT cust_id FROM (
SELECT cust_id
FROM mining_data_apply_v
WHERE country_name = 'Italy'
ORDER BY PREDICTION_PROBABILITY(DT_SH_Clas_sample, 1 USING *)
DESC, cust_id)
WHERE rownum < 11;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/PREDICTION_PROBABILITY-1.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/PREDICTION_PROBABILITY.html
SELECT cust_id, cust_marital_status, rank_anom, anom_det FROM
(SELECT cust_id, cust_marital_status, anom_det,
rank() OVER (PARTITION BY CUST_MARITAL_STATUS
ORDER BY ANOM_PROB DESC,cust_id) rank_anom FROM
(SELECT cust_id, cust_marital_status,
PREDICTION_PROBABILITY(OF ANOMALY, 0 USING *)
OVER (PARTITION BY CUST_MARITAL_STATUS) anom_prob,
PREDICTION_DETAILS(OF ANOMALY, 0, 3 USING *)
OVER (PARTITION BY CUST_MARITAL_STATUS) anom_det
FROM mining_data_one_class_v
))
WHERE rank_anom < 3 order by 2, 3;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/PREDICTION_SET-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/PREDICTION_SET.html
SELECT T.cust_id, S.prediction, S.probability, S.cost
FROM (SELECT cust_id,
PREDICTION_SET(dt_sh_clas_sample COST MODEL USING *) pset
FROM mining_data_apply_v
WHERE cust_id < 100006) T,
TABLE(T.pset) S
ORDER BY cust_id, S.prediction;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/PRESENTNNV-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/PRESENTNNV.html
SELECT country, prod, year, s
FROM sales_view_ref
MODEL
PARTITION BY (country)
DIMENSION BY (prod, year)
MEASURES (sale s)
IGNORE NAV
UNIQUE DIMENSION
RULES UPSERT SEQUENTIAL ORDER
( s['Mouse Pad', 2002] =
PRESENTNNV(s['Mouse Pad', 2002], s['Mouse Pad', 2002], 10)
)
ORDER BY country, prod, year;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/PRESENTV-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/PRESENTV.html
SELECT country, prod, year, s
FROM sales_view_ref
MODEL
PARTITION BY (country)
DIMENSION BY (prod, year)
MEASURES (sale s)
IGNORE NAV
UNIQUE DIMENSION
RULES UPSERT SEQUENTIAL ORDER
(
s['Mouse Pad', 2001] =
PRESENTV(s['Mouse Pad', 2000], s['Mouse Pad', 2000], 0)
)
ORDER BY country, prod, year;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/PREVIOUS-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/PREVIOUS.html
SELECT dim_col, cur_val, num_of_iterations
FROM (SELECT 1 AS dim_col, 10 AS cur_val FROM dual)
MODEL
DIMENSION BY (dim_col)
MEASURES (cur_val, 0 num_of_iterations)
IGNORE NAV
UNIQUE DIMENSION
RULES ITERATE (1000) UNTIL (PREVIOUS(cur_val[1]) - cur_val[1] < 1)
(
cur_val[1] = cur_val[1]/2,
num_of_iterations[1] = num_of_iterations[1] + 1
);
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/PURGE-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/PURGE.html
SELECT * FROM RECYCLEBIN;
SELECT * FROM USER_RECYCLEBIN;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/PURGE-1.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/PURGE.html
PURGE TABLE test;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/PURGE-2.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/PURGE.html
PURGE TABLE RB$$33750$TABLE$0;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/PURGE-3.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/PURGE.html
PURGE RECYCLEBIN;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/Pattern-matching-Conditions-1.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/Pattern-matching-Conditions.html
SELECT last_name
FROM employees
WHERE last_name
LIKE '%A\_B%' ESCAPE '\'
ORDER BY last_name;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/Pattern-matching-Conditions-10.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/Pattern-matching-Conditions.html
CREATE TABLE ducks (f CHAR(6), v VARCHAR2(6));
INSERT INTO ducks VALUES ('DUCK', 'DUCK');
SELECT '*'||f||'*' "char",
'*'||v||'*' "varchar"
FROM ducks;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/Pattern-matching-Conditions-11.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/Pattern-matching-Conditions.html
SELECT first_name, last_name
FROM employees
WHERE REGEXP_LIKE (first_name, '^Ste(v|ph)en$')
ORDER BY first_name, last_name;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/Pattern-matching-Conditions-12.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/Pattern-matching-Conditions.html
SELECT last_name
FROM employees
WHERE REGEXP_LIKE (last_name, '([aeiou])\1', 'i')
ORDER BY last_name;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/Pattern-matching-Conditions-2.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/Pattern-matching-Conditions.html
SELECT salary
FROM employees
WHERE last_name LIKE 'R%'
ORDER BY salary;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/Pattern-matching-Conditions-3.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/Pattern-matching-Conditions.html
SELECT salary
FROM employees
WHERE last_name = 'R%'
ORDER BY salary;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/Pattern-matching-Conditions-4.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/Pattern-matching-Conditions.html
SELECT salary
FROM employees
WHERE 'SM%' LIKE last_name
ORDER BY salary;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/Pattern-matching-Conditions-9.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/Pattern-matching-Conditions.html
SELECT last_name
FROM employees
WHERE last_name LIKE '%A\_B%' ESCAPE '\'
ORDER BY last_name;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/RANK-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/RANK.html
SELECT RANK(15500, .05) WITHIN GROUP
(ORDER BY salary, commission_pct) "Rank"
FROM employees;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/RANK-1.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/RANK.html
SELECT RANK(15500) WITHIN GROUP
(ORDER BY salary DESC) "Rank of 15500"
FROM employees;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/RANK-2.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/RANK.html
SELECT department_id, last_name, salary,
RANK() OVER (PARTITION BY department_id ORDER BY salary) RANK
FROM employees WHERE department_id = 60
ORDER BY RANK, last_name;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/RATIO_TO_REPORT-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/RATIO_TO_REPORT.html
SELECT last_name, salary, RATIO_TO_REPORT(salary) OVER () AS rr
FROM employees
WHERE job_id = 'PU_CLERK'
ORDER BY last_name, salary, rr;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/RAWTOHEX-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/RAWTOHEX.html
SELECT RAWTOHEX(raw_column) "Graphics"
FROM graphics;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/RAWTONHEX-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/RAWTONHEX.html
SELECT RAWTONHEX(raw_column),
DUMP ( RAWTONHEX (raw_column) ) "DUMP"
FROM graphics;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/REF-1.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/REF.html
CREATE TABLE addresses OF cust_address_typ;
INSERT INTO addresses VALUES (
'123 First Street', '4GF H1J', 'Our Town', 'Ourcounty', 'US');
SELECT REF(e) FROM addresses e;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/REFTOHEX-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/REFTOHEX.html
CREATE TABLE warehouse_table OF warehouse_typ
(PRIMARY KEY (warehouse_id));
CREATE TABLE location_table
(location_number NUMBER, building REF warehouse_typ
SCOPE IS warehouse_table);
INSERT INTO warehouse_table VALUES (1, 'Downtown', 99);
INSERT INTO location_table SELECT 10, REF(w) FROM warehouse_table w;
SELECT REFTOHEX(building) FROM location_table;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/REGEXP_COUNT-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/REGEXP_COUNT.html
SELECT REGEXP_COUNT('123123123123123', '(12)3', 1, 'i') REGEXP_COUNT
FROM DUAL;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/REGEXP_COUNT-1.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/REGEXP_COUNT.html
SELECT REGEXP_COUNT('123123123123', '123', 3, 'i') COUNT FROM DUAL;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/REGEXP_COUNT-10.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/REGEXP_COUNT.html
select regexp_count('ABC123', '[A-Z][0-9]{2}') Char_num_like_A12_anywhere,
regexp_count('A1B2C34', '[A-Z][0-9]{2}') Char_num_like_A12_anywhere from dual;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/REGEXP_COUNT-11.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/REGEXP_COUNT.html
select regexp_count('ABC12D3', '([A-Z][0-9]){2}') Char_num_within_2_places,
regexp_count('A1B2C3', '([A-Z][0-9]){2}') Char_num_within_2_places from dual;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/REGEXP_COUNT-12.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/REGEXP_COUNT.html
CREATE TABLE regexp_temp(empName varchar2(20));
INSERT INTO regexp_temp (empName) VALUES ('John Doe');
INSERT INTO regexp_temp (empName) VALUES ('Jane Doe');
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/REGEXP_COUNT-13.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/REGEXP_COUNT.html
SELECT empName, REGEXP_COUNT(empName, 'e', 1, 'c') "CASE_SENSITIVE_E" From regexp_temp;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/REGEXP_COUNT-14.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/REGEXP_COUNT.html
SELECT empName, REGEXP_COUNT(empName, 'o', 1, 'c') "CASE_SENSITIVE_O" From regexp_temp;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/REGEXP_COUNT-15.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/REGEXP_COUNT.html
SELECT empName, REGEXP_COUNT(empName, 'E', 1, 'i') "CASE_INSENSITIVE_E" From regexp_temp;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/REGEXP_COUNT-16.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/REGEXP_COUNT.html
SELECT empName, REGEXP_COUNT(empName, 'do', 1, 'i') "CASE_INSENSITIVE_STRING" From regexp_temp;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/REGEXP_COUNT-17.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/REGEXP_COUNT.html
SELECT empName, REGEXP_COUNT(empName, 'an', 1, 'c') "CASE_SENSITIVE_STRING" From regexp_temp;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/REGEXP_COUNT-2.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/REGEXP_COUNT.html
select regexp_count('ABC123', '[A-Z]'), regexp_count('A1B2C3', '[A-Z]') from dual;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/REGEXP_COUNT-3.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/REGEXP_COUNT.html
select regexp_count('ABC123', '[A-Z][0-9]'), regexp_count('A1B2C3', '[A-Z][0-9]') from dual;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/REGEXP_COUNT-4.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/REGEXP_COUNT.html
select regexp_count('ABC123', '[A-Z][0-9]'), regexp_count('A1B2C3', '[A-Z][0-9]') from dual;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/REGEXP_COUNT-5.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/REGEXP_COUNT.html
select regexp_count('ABC123', '[A-Z][0-9]{2}'), regexp_count('A1B2C3', '[A-Z][0-9]{2}') from dual;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/REGEXP_COUNT-6.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/REGEXP_COUNT.html
select regexp_count('ABC123', '([A-Z][0-9]){2}'), regexp_count('A1B2C3', '([A-Z][0-9]){2}') from dual;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/REGEXP_COUNT-7.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/REGEXP_COUNT.html
select regexp_count('ABC123', '[A-Z]') Match_char_ABC_count,
regexp_count('A1B2C3', '[A-Z]') Match_char_ABC_count from dual;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/REGEXP_COUNT-8.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/REGEXP_COUNT.html
select regexp_count('ABC123', '[A-Z][0-9]') Match_string_C1_count,
regexp_count('A1B2C3', '[A-Z][0-9]') Match_strings_A1_B2_C3_count from dual;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/REGEXP_COUNT-9.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/REGEXP_COUNT.html
select regexp_count('ABC123A5', '^[A-Z][0-9]') Char_num_like_A1_at_start,
regexp_count('A1B2C3', '^[A-Z][0-9]') Char_num_like_A1_at_start from dual;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/REGEXP_INSTR-1.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/REGEXP_INSTR.html
SELECT
REGEXP_INSTR('500 Oracle Parkway, Redwood Shores, CA',
'[^ ]+', 1, 6) "REGEXP_INSTR"
FROM DUAL;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/REGEXP_INSTR-2.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/REGEXP_INSTR.html
SELECT
REGEXP_INSTR('500 Oracle Parkway, Redwood Shores, CA',
'[s|r|p][[:alpha:]]{6}', 3, 2, 1, 'i') "REGEXP_INSTR"
FROM DUAL;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/REGEXP_INSTR-3.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/REGEXP_INSTR.html
SELECT REGEXP_INSTR('1234567890', '(123)(4(56)(78))', 1, 1, 0, 'i', 1)
"REGEXP_INSTR" FROM DUAL;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/REGEXP_INSTR-4.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/REGEXP_INSTR.html
SELECT REGEXP_INSTR('1234567890', '(123)(4(56)(78))', 1, 1, 0, 'i', 2)
"REGEXP_INSTR" FROM DUAL;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/REGEXP_INSTR-5.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/REGEXP_INSTR.html
SELECT REGEXP_INSTR('1234567890', '(123)(4(56)(78))', 1, 1, 0, 'i', 4)
"REGEXP_INSTR" FROM DUAL;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/REGEXP_INSTR-6.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/REGEXP_INSTR.html
CREATE TABLE regexp_temp(empName varchar2(20), emailID varchar2(20));
INSERT INTO regexp_temp (empName, emailID) VALUES ('John Doe', 'johndoe@example.com');
INSERT INTO regexp_temp (empName, emailID) VALUES ('Jane Doe', 'janedoe');
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/REGEXP_INSTR-7.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/REGEXP_INSTR.html
SELECT emailID, REGEXP_INSTR(emailID, '\w+@\w+(\.\w+)+') "IS_A_VALID_EMAIL" FROM regexp_temp;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/REGEXP_REPLACE-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/REGEXP_REPLACE.html
SELECT
REGEXP_REPLACE(phone_number,
'([[:digit:]]{3})\.([[:digit:]]{3})\.([[:digit:]]{4})',
'(\1) \2-\3') "REGEXP_REPLACE"
FROM employees
ORDER BY "REGEXP_REPLACE";
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/REGEXP_REPLACE-1.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/REGEXP_REPLACE.html
SELECT
REGEXP_REPLACE(country_name, '(.)', '\1 ') "REGEXP_REPLACE"
FROM countries;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/REGEXP_REPLACE-10.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/REGEXP_REPLACE.html
WITH strings as (
SELECT 'AddressLine1' s FROM dual union all
SELECT 'ZipCode' s FROM dual union all
SELECT 'Country' s FROM dual
)
SELECT s "STRING",
lower(regexp_replace(s, '([A-Z0-9])', '_\1', 2)) "MODIFIED_STRING"
FROM strings;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/REGEXP_REPLACE-11.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/REGEXP_REPLACE.html
WITH date_strings AS (
SELECT '2015-01-01' d from dual union all
SELECT '2000-12-31' d from dual union all
SELECT '900-01-01' d from dual
)
SELECT d "STRING",
regexp_replace(d, '([[:digit:]]+)-([[:digit:]]{2})-([[:digit:]]{2})', '\3.\2.\1') "MODIFIED_STRING"
FROM date_strings;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/REGEXP_REPLACE-12.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/REGEXP_REPLACE.html
WITH strings as (
SELECT 'NEW YORK' s FROM dual union all
SELECT 'New York' s FROM dual union all
SELECT 'new york' s FROM dual
)
SELECT s "STRING",
regexp_replace(s, '[a-z]', '1', 1, 0, 'i') "CASE_INSENSITIVE",
regexp_replace(s, '[a-z]', '1', 1, 0, 'c') "CASE_SENSITIVE",
regexp_replace(s, '[a-zA-Z]', '1', 1, 0, 'c') "CASE_SENSITIVE_MATCHING"
FROM strings;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/REGEXP_REPLACE-2.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/REGEXP_REPLACE.html
SELECT
REGEXP_REPLACE('500 Oracle Parkway, Redwood Shores, CA',
'( ){2,}', ' ') "REGEXP_REPLACE"
FROM DUAL;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/REGEXP_REPLACE-3.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/REGEXP_REPLACE.html
CREATE TABLE regexp_temp(empName varchar2(20), emailID varchar2(20));
INSERT INTO regexp_temp (empName, emailID) VALUES ('John Doe', 'johndoe@example.com');
INSERT INTO regexp_temp (empName, emailID) VALUES ('Jane Doe', 'janedoe@example.com');
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/REGEXP_REPLACE-4.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/REGEXP_REPLACE.html
SELECT empName, REGEXP_REPLACE (empName, 'Jane', 'John') "STRING_REPLACE" FROM regexp_temp;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/REGEXP_REPLACE-5.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/REGEXP_REPLACE.html
SELECT empName, REGEXP_REPLACE (empName, 'Jane', 'John') "STRING_REPLACE" FROM regexp_temp;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/REGEXP_REPLACE-6.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/REGEXP_REPLACE.html
WITH strings AS (
SELECT 'abc123' s FROM dual union all
SELECT '123abc' s FROM dual union all
SELECT 'a1b2c3' s FROM dual
)
SELECT s "STRING", regexp_replace(s, '[0-9]', '') "MODIFIED_STRING"
FROM strings;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/REGEXP_REPLACE-7.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/REGEXP_REPLACE.html
WITH strings AS (
SELECT 'abc123' s from DUAL union all
SELECT '123abc' s from DUAL union all
SELECT 'a1b2c3' s from DUAL
)
SELECT s "STRING", REGEXP_REPLACE(s, '[0-9]', '', 1, 1) "MODIFIED_STRING"
FROM strings;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/REGEXP_REPLACE-8.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/REGEXP_REPLACE.html
WITH strings AS (
SELECT 'abc123' s from DUAL union all
SELECT '123abc' s from DUAL union all
SELECT 'a1b2c3' s from DUAL
)
SELECT s "STRING", REGEXP_REPLACE(s, '[0-9]', '', 1, 2) "MODIFIED_STRING"
FROM strings;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/REGEXP_REPLACE-9.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/REGEXP_REPLACE.html
WITH strings AS (
SELECT 'Hello World' s FROM dual union all
SELECT 'Hello World' s FROM dual union all
SELECT 'Hello, World !' s FROM dual
)
SELECT s "STRING", regexp_replace(s, ' {2,}', ' ') "MODIFIED_STRING"
FROM strings;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/REGEXP_SUBSTR-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/REGEXP_SUBSTR.html
SELECT
REGEXP_SUBSTR('500 Oracle Parkway, Redwood Shores, CA',
',[^,]+,') "REGEXPR_SUBSTR"
FROM DUAL;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/REGEXP_SUBSTR-1.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/REGEXP_SUBSTR.html
SELECT
REGEXP_SUBSTR('http://www.example.com/products',
'http://([[:alnum:]]+\.?){3,4}/?') "REGEXP_SUBSTR"
FROM DUAL;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/REGEXP_SUBSTR-2.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/REGEXP_SUBSTR.html
SELECT REGEXP_SUBSTR('1234567890', '(123)(4(56)(78))', 1, 1, 'i', 1)
"REGEXP_SUBSTR" FROM DUAL;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/REGEXP_SUBSTR-3.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/REGEXP_SUBSTR.html
SELECT REGEXP_SUBSTR('1234567890', '(123)(4(56)(78))', 1, 1, 'i', 4)
"REGEXP_SUBSTR" FROM DUAL;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/REGEXP_SUBSTR-4.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/REGEXP_SUBSTR.html
CREATE TABLE regexp_temp(empName varchar2(20), emailID varchar2(20));
INSERT INTO regexp_temp (empName, emailID) VALUES ('John Doe', 'johndoe@example.com');
INSERT INTO regexp_temp (empName, emailID) VALUES ('Jane Doe', 'janedoe');
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/REGEXP_SUBSTR-5.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/REGEXP_SUBSTR.html
SELECT empName, REGEXP_SUBSTR(emailID, '[[:alnum:]]+\@[[:alnum:]]+\.[[:alnum:]]+') "Valid Email" FROM regexp_temp;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/REGEXP_SUBSTR-6.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/REGEXP_SUBSTR.html
SELECT empName, REGEXP_SUBSTR(emailID, '[[:alnum:]]+\@[[:alnum:]]+\.[[:alnum:]]+') "Valid Email", REGEXP_INSTR(emailID, '\w+@\w+(\.\w+)+') "FIELD_WITH_VALID_EMAIL" FROM regexp_temp;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/REGEXP_SUBSTR-7.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/REGEXP_SUBSTR.html
with strings as (
select 'ABC123' str from dual union all
select 'A1B2C3' str from dual union all
select '123ABC' str from dual union all
select '1A2B3C' str from dual
)
select regexp_substr(str, '[0-9]') First_Occurrence_of_Number,
regexp_substr(str, '[0-9].*') Num_Followed_by_String,
regexp_substr(str, '[A-Z][0-9]') Letter_Followed_by_String
from strings;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/REGEXP_SUBSTR-8.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/REGEXP_SUBSTR.html
with strings as (
select 'LHRJFK/010315/JOHNDOE' str from dual union all
select 'CDGLAX/050515/JANEDOE' str from dual union all
select 'LAXCDG/220515/JOHNDOE' str from dual union all
select 'SFOJFK/010615/JANEDOE' str from dual
)
SELECT regexp_substr(str, '[A-Z]{6}') String_of_6_characters,
regexp_substr(str, '[0-9]+') First_Matching_Numbers,
regexp_substr(str, '[A-Z].*$') Letter_by_other_characters,
regexp_substr(str, '/[A-Z].*$') Slash_letter_and_characters
FROM strings;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/REGR_-Linear-Regression-Functions-10.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/REGR_-Linear-Regression-Functions.html
SELECT job_id,
REGR_COUNT(SYSDATE-hire_date, salary) count
FROM employees
WHERE department_id in (30, 50)
GROUP BY job_id
ORDER BY job_id, count;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/REGR_-Linear-Regression-Functions-11.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/REGR_-Linear-Regression-Functions.html
SELECT job_id,
REGR_R2(SYSDATE-hire_date, salary) Regr_R2
FROM employees
WHERE department_id in (80, 50)
GROUP by job_id
ORDER BY job_id, Regr_R2;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/REGR_-Linear-Regression-Functions-12.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/REGR_-Linear-Regression-Functions.html
SELECT job_id,
REGR_AVGY(SYSDATE-hire_date, salary) avgy,
REGR_AVGX(SYSDATE-hire_date, salary) avgx
FROM employees
WHERE department_id in (30,50)
GROUP BY job_id
ORDER BY job_id, avgy, avgx;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/REGR_-Linear-Regression-Functions-13.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/REGR_-Linear-Regression-Functions.html
SELECT job_id,
REGR_SXY(SYSDATE-hire_date, salary) regr_sxy,
REGR_SXX(SYSDATE-hire_date, salary) regr_sxx,
REGR_SYY(SYSDATE-hire_date, salary) regr_syy
FROM employees
WHERE department_id in (80, 50)
GROUP BY job_id
ORDER BY job_id;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/REGR_-Linear-Regression-Functions-8.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/REGR_-Linear-Regression-Functions.html
SELECT job_id, employee_id ID, salary,
REGR_SLOPE(SYSDATE-hire_date, salary)
OVER (PARTITION BY job_id) slope,
REGR_INTERCEPT(SYSDATE-hire_date, salary)
OVER (PARTITION BY job_id) intcpt,
REGR_R2(SYSDATE-hire_date, salary)
OVER (PARTITION BY job_id) rsqr,
REGR_COUNT(SYSDATE-hire_date, salary)
OVER (PARTITION BY job_id) count,
REGR_AVGX(SYSDATE-hire_date, salary)
OVER (PARTITION BY job_id) avgx,
REGR_AVGY(SYSDATE-hire_date, salary)
OVER (PARTITION BY job_id) avgy
FROM employees
WHERE department_id in (50, 80)
ORDER BY job_id, employee_id;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/REGR_-Linear-Regression-Functions-9.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/REGR_-Linear-Regression-Functions.html
SELECT job_id,
REGR_SLOPE(SYSDATE-hire_date, salary) slope,
REGR_INTERCEPT(SYSDATE-hire_date, salary) intercept
FROM employees
WHERE department_id in (50,80)
GROUP BY job_id
ORDER BY job_id;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/REMAINDER-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/REMAINDER.html
SELECT bin_float, bin_double, REMAINDER(bin_float, bin_double)
FROM float_point_demo;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/RENAME-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/RENAME.html
RENAME departments_new TO emp_departments;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/RENAME-1.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/RENAME.html
CREATE TABLE temporary
(employee_id, start_date, end_date, job_id, dept_id)
AS SELECT
employee_id, start_date, end_date, job_id, department_id
FROM job_history;
DROP TABLE job_history;
RENAME temporary TO job_history;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/REPLACE-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/REPLACE.html
SELECT REPLACE('JACK and JUE','J','BL') "Changes"
FROM DUAL;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/REVOKE-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/REVOKE.html
REVOKE DROP ANY TABLE
FROM hr, oe;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/REVOKE-1.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/REVOKE.html
REVOKE dw_manager
FROM sh;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/REVOKE-10.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/REVOKE.html
REVOKE INHERIT PRIVILEGES ON USER sh FROM hr;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/REVOKE-11.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/REVOKE.html
GRANT SELECT
ON hr.departments_seq TO oe;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/REVOKE-12.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/REVOKE.html
REVOKE SELECT
ON hr.departments_seq FROM oe;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/REVOKE-13.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/REVOKE.html
GRANT REFERENCES, UPDATE
ON hr.employees TO oe;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/REVOKE-14.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/REVOKE.html
CREATE TABLE dependent
(dependno NUMBER,
dependname VARCHAR2(10),
employee NUMBER
CONSTRAINT in_emp REFERENCES hr.employees(employee_id) );
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/REVOKE-15.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/REVOKE.html
REVOKE REFERENCES
ON hr.employees
FROM oe
CASCADE CONSTRAINTS;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/REVOKE-16.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/REVOKE.html
REVOKE READ ON DIRECTORY bfile_dir FROM hr;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/REVOKE-17.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/REVOKE.html
CONNECT hr
GRANT UPDATE ON employees TO oe WITH GRANT OPTION;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/REVOKE-18.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/REVOKE.html
CONNECT oe
GRANT UPDATE ON hr.employees TO pm;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/REVOKE-19.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/REVOKE.html
CONNECT sh
REVOKE UPDATE ON hr.employees FROM oe;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/REVOKE-2.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/REVOKE.html
REVOKE CREATE TABLESPACE
FROM dw_manager;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/REVOKE-3.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/REVOKE.html
REVOKE dw_user
FROM dw_manager;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/REVOKE-4.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/REVOKE.html
GRANT ALL
ON orders TO hr;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/REVOKE-5.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/REVOKE.html
REVOKE DELETE
ON orders FROM hr;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/REVOKE-6.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/REVOKE.html
REVOKE ALL
ON orders FROM hr;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/REVOKE-7.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/REVOKE.html
GRANT SELECT, UPDATE
ON emp_details_view TO public;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/REVOKE-8.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/REVOKE.html
REVOKE UPDATE
ON emp_details_view FROM public;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/REVOKE-9.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/REVOKE.html
GRANT INHERIT PRIVILEGES ON USER sh TO hr;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ROLLBACK-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ROLLBACK.html
ROLLBACK;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ROLLBACK-1.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ROLLBACK.html
ROLLBACK TO SAVEPOINT banda_sal;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ROLLBACK-2.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ROLLBACK.html
ROLLBACK WORK
FORCE '25.32.87';
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ROUND-date-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ROUND-date.html
SELECT ROUND (TO_DATE ('27-OCT-00'),'YEAR')
"New Year" FROM DUAL;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ROUND-number-1.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ROUND-number.html
SELECT ROUND(15.193,1) "Round" FROM DUAL;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ROUND-number-2.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ROUND-number.html
SELECT ROUND(15.193,-1) "Round" FROM DUAL;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ROUND_TIES_TO_EVEN-number-1.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ROUND_TIES_TO_EVEN-number.html
SELECT ROUND_TIES_TO_EVEN(45.177,-1) "ROUND_EVEN" FROM DUAL;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ROWID-Pseudocolumn-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ROWID-Pseudocolumn.html
SELECT ROWID, last_name
FROM employees
WHERE department_id = 20;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ROWIDTOCHAR-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ROWIDTOCHAR.html
SELECT ROWID FROM employees
WHERE ROWIDTOCHAR(ROWID) LIKE '%JAAB%'
ORDER BY ROWID;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ROWIDTONCHAR-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ROWIDTONCHAR.html
SELECT LENGTHB( ROWIDTONCHAR(ROWID) ) Length, ROWIDTONCHAR(ROWID)
FROM employees
ORDER BY length;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ROWNUM-Pseudocolumn-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ROWNUM-Pseudocolumn.html
SELECT *
FROM employees
WHERE ROWNUM < 11;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ROWNUM-Pseudocolumn-1.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ROWNUM-Pseudocolumn.html
SELECT *
FROM employees
WHERE ROWNUM < 11
ORDER BY last_name;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ROWNUM-Pseudocolumn-2.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ROWNUM-Pseudocolumn.html
SELECT *
FROM (SELECT * FROM employees ORDER BY employee_id)
WHERE ROWNUM < 11;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ROWNUM-Pseudocolumn-3.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ROWNUM-Pseudocolumn.html
SELECT *
FROM employees
WHERE ROWNUM > 1;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ROWNUM-Pseudocolumn-4.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ROWNUM-Pseudocolumn.html
UPDATE my_table
SET column1 = ROWNUM;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ROW_NUMBER-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ROW_NUMBER.html
SELECT department_id, first_name, last_name, salary
FROM
(
SELECT
department_id, first_name, last_name, salary,
ROW_NUMBER() OVER (PARTITION BY department_id ORDER BY salary desc) rn
FROM employees
)
WHERE rn <= 3
ORDER BY department_id, salary DESC, last_name;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ROW_NUMBER-1.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ROW_NUMBER.html
SELECT sales_2000.channel_desc, sales_2000.prod_name,
sales_2000.amt amt_2000, top_5_prods_1999_year.amt amt_1999,
sales_2000.amt - top_5_prods_1999_year.amt amt_diff
FROM
/* The first subquery finds the 5 top-selling products per channel in year 1999. */
(SELECT channel_desc, prod_name, amt
FROM
(
SELECT channel_desc, prod_name, sum(amount_sold) amt,
ROW_NUMBER () OVER (PARTITION BY channel_desc
ORDER BY SUM(amount_sold) DESC) rn
FROM sales, times, channels, products
WHERE sales.time_id = times.time_id
AND times.calendar_year = 1999
AND channels.channel_id = sales.channel_id
AND products.prod_id = sales.prod_id
GROUP BY channel_desc, prod_name
)
WHERE rn <= 5
) top_5_prods_1999_year,
/* The next subquery finds sales per product and per channel in 2000. */
(SELECT channel_desc, prod_name, sum(amount_sold) amt
FROM sales, times, channels, products
WHERE sales.time_id = times.time_id
AND times.calendar_year = 2000
AND channels.channel_id = sales.channel_id
AND products.prod_id = sales.prod_id
GROUP BY channel_desc, prod_name
) sales_2000
WHERE sales_2000.channel_desc = top_5_prods_1999_year.channel_desc
AND sales_2000.prod_name = top_5_prods_1999_year.prod_name
ORDER BY sales_2000.channel_desc, sales_2000.prod_name
;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/RPAD-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/RPAD.html
SELECT last_name, RPAD(' ', salary/1000/1, '*') "Salary"
FROM employees
WHERE department_id = 80
ORDER BY last_name, "Salary";
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/RTRIM-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/RTRIM.html
SELECT RTRIM('<=====>BROWNING<=====>', '<>=') "RTRIM Example"
FROM DUAL;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/SAVEPOINT-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/SAVEPOINT.html
UPDATE employees
SET salary = 7000
WHERE last_name = 'Banda';
SAVEPOINT banda_sal;
UPDATE employees
SET salary = 12000
WHERE last_name = 'Greene';
SAVEPOINT greene_sal;
SELECT SUM(salary) FROM employees;
ROLLBACK TO SAVEPOINT banda_sal;
UPDATE employees
SET salary = 11000
WHERE last_name = 'Greene';
COMMIT;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/SCN_TO_TIMESTAMP-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/SCN_TO_TIMESTAMP.html
SELECT SCN_TO_TIMESTAMP(ORA_ROWSCN) FROM employees
WHERE employee_id = 188;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/SCN_TO_TIMESTAMP-1.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/SCN_TO_TIMESTAMP.html
SELECT salary FROM employees WHERE employee_id = 188;
UPDATE employees SET salary = salary*10 WHERE employee_id = 188;
COMMIT;
SELECT salary FROM employees WHERE employee_id = 188;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/SCN_TO_TIMESTAMP-2.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/SCN_TO_TIMESTAMP.html
SELECT SCN_TO_TIMESTAMP(ORA_ROWSCN) FROM employees
WHERE employee_id = 188;
FLASHBACK TABLE employees TO TIMESTAMP
TO_TIMESTAMP('28-AUG-03 01.00.00.000000000 PM');
SELECT salary FROM employees WHERE employee_id = 188;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/SELECT-10.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/SELECT.html
SELECT
ename, mgr,
FIRST_VALUE(sal) OVER w AS "first",
LAST_VALUE(sal) OVER w AS "last",
NTH_VALUE(sal, 2) OVER w AS "second",
NTH_VALUE(sal, 4) OVER w AS "fourth"
FROM emp
WINDOW w AS (PARTITION BY deptno ORDER BY sal ROWS UNBOUNDED PRECEDING);
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/SELECT-100.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/SELECT.html
UPDATE TABLE(SELECT h.people FROM hr_info h
WHERE h.department_id = 280) p
SET p.salary = p.salary + 100;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/SELECT-101.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/SELECT.html
DELETE TABLE(SELECT h.people FROM hr_info h
WHERE h.department_id = 280) p
WHERE p.salary > 1700;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/SELECT-102.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/SELECT.html
SELECT t1.department_id, t2.* FROM hr_info t1, TABLE(t1.people) t2
WHERE t2.department_id = t1.department_id;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/SELECT-103.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/SELECT.html
SELECT t1.department_id, t2.*
FROM hr_info t1, TABLE(CAST(MULTISET(
SELECT t3.last_name, t3.department_id, t3.salary
FROM people t3
WHERE t3.department_id = t1.department_id)
AS people_tab_typ)) t2;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/SELECT-105.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/SELECT.html
SELECT LPAD(' ',2*(LEVEL-1)) || last_name org_chart,
employee_id, manager_id, job_id
FROM employees
START WITH job_id = 'AD_VP'
CONNECT BY PRIOR employee_id = manager_id;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/SELECT-106.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/SELECT.html
SELECT LPAD(' ',2*(LEVEL-1)) || last_name org_chart,
employee_id, manager_id, job_id
FROM employees
WHERE job_id != 'FI_MGR'
START WITH job_id = 'AD_VP'
CONNECT BY PRIOR employee_id = manager_id;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/SELECT-107.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/SELECT.html
SELECT LPAD(' ',2*(LEVEL-1)) || last_name org_chart,
employee_id, manager_id, job_id
FROM employees
START WITH job_id = 'AD_PRES'
CONNECT BY PRIOR employee_id = manager_id AND LEVEL <= 2;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/SELECT-108.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/SELECT.html
SELECT last_name, department_name
FROM employees@remote, departments
WHERE employees.department_id = departments.department_id;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/SELECT-109.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/SELECT.html
UPDATE table1 t_alias1
SET column =
(SELECT expr
FROM table2 t_alias2
WHERE t_alias1.column = t_alias2.column);
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/SELECT-11.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/SELECT.html
SELECT docID FROM vec_table
ORDER BY VECTOR_DISTANCE(data, :query_vec)
FETCH APPROX FIRST 20 ROWS ONLY;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/SELECT-110.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/SELECT.html
SELECT department_id, last_name, salary
FROM employees x
WHERE salary > (SELECT AVG(salary)
FROM employees
WHERE x.department_id = department_id)
ORDER BY department_id;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/SELECT-111.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/SELECT.html
SELECT CURRENT_DATE FROM DUAL;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/SELECT-112.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/SELECT.html
SELECT CURRENT_DATE;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/SELECT-113.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/SELECT.html
SELECT employees_seq.nextval
FROM DUAL;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/SELECT-114.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/SELECT.html
SELECT employees_seq.currval
FROM DUAL;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/SELECT-115.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/SELECT.html
CREATE TABLE Ticker (SYMBOL VARCHAR2(10), tstamp DATE, price NUMBER);
INSERT INTO Ticker VALUES('ACME', '01-Apr-11', 12);
INSERT INTO Ticker VALUES('ACME', '02-Apr-11', 17);
INSERT INTO Ticker VALUES('ACME', '03-Apr-11', 19);
INSERT INTO Ticker VALUES('ACME', '04-Apr-11', 21);
INSERT INTO Ticker VALUES('ACME', '05-Apr-11', 25);
INSERT INTO Ticker VALUES('ACME', '06-Apr-11', 12);
INSERT INTO Ticker VALUES('ACME', '07-Apr-11', 15);
INSERT INTO Ticker VALUES('ACME', '08-Apr-11', 20);
INSERT INTO Ticker VALUES('ACME', '09-Apr-11', 24);
INSERT INTO Ticker VALUES('ACME', '10-Apr-11', 25);
INSERT INTO Ticker VALUES('ACME', '11-Apr-11', 19);
INSERT INTO Ticker VALUES('ACME', '12-Apr-11', 15);
INSERT INTO Ticker VALUES('ACME', '13-Apr-11', 25);
INSERT INTO Ticker VALUES('ACME', '14-Apr-11', 25);
INSERT INTO Ticker VALUES('ACME', '15-Apr-11', 14);
INSERT INTO Ticker VALUES('ACME', '16-Apr-11', 12);
INSERT INTO Ticker VALUES('ACME', '17-Apr-11', 14);
INSERT INTO Ticker VALUES('ACME', '18-Apr-11', 24);
INSERT INTO Ticker VALUES('ACME', '19-Apr-11', 23);
INSERT INTO Ticker VALUES('ACME', '20-Apr-11', 22);
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/SELECT-116.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/SELECT.html
SELECT *
FROM Ticker MATCH_RECOGNIZE (
PARTITION BY symbol
ORDER BY tstamp
MEASURES STRT.tstamp AS start_tstamp,
LAST(DOWN.tstamp) AS bottom_tstamp,
LAST(UP.tstamp) AS end_tstamp
ONE ROW PER MATCH
AFTER MATCH SKIP TO LAST UP
PATTERN (STRT DOWN+ UP+)
DEFINE
DOWN AS DOWN.price < PREV(DOWN.price),
UP AS UP.price > PREV(UP.price)
) MR
ORDER BY MR.symbol, MR.start_tstamp;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/SELECT-117.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/SELECT.html
SELECT deptno, ename FROM emp
ORDER BY sal DESC
FETCH FIRST 2 PARTITIONS BY deptno, 3 ROWS ONLY;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/SELECT-118.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/SELECT.html
CREATE TABLE chunk_table (
doc_id NUMBER,
chunk_id NUMBER,
data_vec VECTOR
);
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/SELECT-12.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/SELECT.html
SELECT employee_id FROM (SELECT * FROM employees)
FOR UPDATE OF employee_id;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/SELECT-13.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/SELECT.html
SELECT employee_id FROM (SELECT employee_id+1 AS employee_id FROM employees)
FOR UPDATE;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/SELECT-14.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/SELECT.html
SELECT employee_id FROM (SELECT employee_id+1 AS employee_id FROM employees)
FOR UPDATE OF employee_id;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/SELECT-15.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/SELECT.html
SELECT avgsal
FROM (SELECT AVG(salary) AS avgsal FROM employees GROUP BY job_id)
FOR UPDATE;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/SELECT-17.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/SELECT.html
create or replace function greet(name varchar2 default 'World')
return varchar2 SQL_MACRO(Scalar) is
begin
return q'{ 'Hello, ' || name || '!' }';
end;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/SELECT-18.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/SELECT.html
SELECT greet ('World') from dual;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/SELECT-19.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/SELECT.html
SELECT greet ('Bob') from dual;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/SELECT-20.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/SELECT.html
create or replace function split_part(string varchar2,
delimiter varchar2,
position pls_integer)
return varchar2 SQL_MACRO(Scalar) is
begin
return q'{
regexp_substr(replace(string, delimiter||delimiter, delimiter||' '||delimiter),
'[^'||delimiter||']+', 1, position, 'imx')
}';
end;
/
SELECT split_part( sysdate, '-', 2) month from dual;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/SELECT-21.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/SELECT.html
create or replace function budget(job varchar2) return varchar2 SQL_MACRO is
begin
return q'{
select deptno, sum(sal) budget
from emp
where job = budget.job
group by deptno
}';
end;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/SELECT-22.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/SELECT.html
SELECT * FROM budget ('MANAGER');
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/SELECT-23.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/SELECT.html
WITH
FUNCTION get_domain(url VARCHAR2) RETURN VARCHAR2 IS
pos BINARY_INTEGER;
len BINARY_INTEGER;
BEGIN
pos := INSTR(url, 'www.');
len := INSTR(SUBSTR(url, pos + 4), '.') - 1;
RETURN SUBSTR(url, pos + 4, len);
END;
SELECT DISTINCT get_domain(catalog_url)
FROM product_information;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/SELECT-24.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/SELECT.html
WITH
dept_costs AS (
SELECT department_name, SUM(salary) dept_total
FROM employees e, departments d
WHERE e.department_id = d.department_id
GROUP BY department_name),
avg_cost AS (
SELECT SUM(dept_total)/COUNT(*) avg
FROM dept_costs)
SELECT * FROM dept_costs
WHERE dept_total >
(SELECT avg FROM avg_cost)
ORDER BY department_name;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/SELECT-25.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/SELECT.html
WITH
reports_to_101 (eid, emp_last, mgr_id, reportLevel) AS
(
SELECT employee_id, last_name, manager_id, 0 reportLevel
FROM employees
WHERE employee_id = 101
UNION ALL
SELECT e.employee_id, e.last_name, e.manager_id, reportLevel+1
FROM reports_to_101 r, employees e
WHERE r.eid = e.manager_id
)
SELECT eid, emp_last, mgr_id, reportLevel
FROM reports_to_101
ORDER BY reportLevel, eid;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/SELECT-26.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/SELECT.html
WITH
reports_to_101 (eid, emp_last, mgr_id, reportLevel, mgr_list) AS
(
SELECT employee_id, last_name, manager_id, 0 reportLevel,
CAST(manager_id AS VARCHAR2(2000))
FROM employees
WHERE employee_id = 101
UNION ALL
SELECT e.employee_id, e.last_name, e.manager_id, reportLevel+1,
CAST(mgr_list || ',' || manager_id AS VARCHAR2(2000))
FROM reports_to_101 r, employees e
WHERE r.eid = e.manager_id
)
SELECT eid, emp_last, mgr_id, reportLevel, mgr_list
FROM reports_to_101
ORDER BY reportLevel, eid;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/SELECT-27.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/SELECT.html
WITH
reports_to_101 (eid, emp_last, mgr_id, reportLevel) AS
(
SELECT employee_id, last_name, manager_id, 0 reportLevel
FROM employees
WHERE employee_id = 101
UNION ALL
SELECT e.employee_id, e.last_name, e.manager_id, reportLevel+1
FROM reports_to_101 r, employees e
WHERE r.eid = e.manager_id
)
SELECT eid, emp_last, mgr_id, reportLevel
FROM reports_to_101
WHERE reportLevel <= 1
ORDER BY reportLevel, eid;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/SELECT-28.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/SELECT.html
WITH
org_chart (eid, emp_last, mgr_id, reportLevel, salary, job_id) AS
(
SELECT employee_id, last_name, manager_id, 0 reportLevel, salary, job_id
FROM employees
WHERE manager_id is null
UNION ALL
SELECT e.employee_id, e.last_name, e.manager_id,
r.reportLevel+1 reportLevel, e.salary, e.job_id
FROM org_chart r, employees e
WHERE r.eid = e.manager_id
)
SEARCH DEPTH FIRST BY emp_last SET order1
SELECT lpad(' ',2*reportLevel)||emp_last emp_name, eid, mgr_id, salary, job_id
FROM org_chart
ORDER BY order1;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/SELECT-29.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/SELECT.html
WITH
dup_hiredate (eid, emp_last, mgr_id, reportLevel, hire_date, job_id) AS
(
SELECT employee_id, last_name, manager_id, 0 reportLevel, hire_date, job_id
FROM employees
WHERE manager_id is null
UNION ALL
SELECT e.employee_id, e.last_name, e.manager_id,
r.reportLevel+1 reportLevel, e.hire_date, e.job_id
FROM dup_hiredate r, employees e
WHERE r.eid = e.manager_id
)
SEARCH DEPTH FIRST BY hire_date SET order1
CYCLE hire_date SET is_cycle TO 'Y' DEFAULT 'N'
SELECT lpad(' ',2*reportLevel)||emp_last emp_name, eid, mgr_id,
hire_date, job_id, is_cycle
FROM dup_hiredate
ORDER BY order1;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/SELECT-30.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/SELECT.html
WITH
emp_count (eid, emp_last, mgr_id, mgrLevel, salary, cnt_employees) AS
(
SELECT employee_id, last_name, manager_id, 0 mgrLevel, salary, 0 cnt_employees
FROM employees
UNION ALL
SELECT e.employee_id, e.last_name, e.manager_id,
r.mgrLevel+1 mgrLevel, e.salary, 1 cnt_employees
FROM emp_count r, employees e
WHERE e.employee_id = r.mgr_id
)
SEARCH DEPTH FIRST BY emp_last SET order1
SELECT emp_last, eid, mgr_id, salary, sum(cnt_employees), max(mgrLevel) mgrLevel
FROM emp_count
GROUP BY emp_last, eid, mgr_id, salary
HAVING max(mgrLevel) > 0
ORDER BY mgr_id NULLS FIRST, emp_last;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/SELECT-31.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/SELECT.html
SELECT time_hier.member_name as TIME,
sales,
units
FROM
sales_av HIERARCHIES(time_hier)
WHERE time_hier.level_name = 'YEAR'
ORDER BY time_hier.hier_order;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/SELECT-33.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/SELECT.html
WITH
my_av ANALYTIC VIEW AS (
USING sales_av HIERARCHIES (time_hier)
ADD MEASURES (
lag_sales AS (LAG(sales) OVER (HIERARCHY time_hier OFFSET 1))
)
)
SELECT time_hier.member_name time, sales, lag_sales
FROM my_av HIERARCHIES (time_hier)
WHERE time_hier.level_name = 'YEAR'
ORDER BY time_hier.hier_order;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/SELECT-35.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/SELECT.html
WITH
my_av ANALYTIC VIEW AS (
USING sales_av HIERARCHIES (time_hier)
FILTER FACT (
time_hier TO quarter_of_year IN (1, 2)
AND year_name IN ('CY2011', 'CY2012')
)
)
SELECT time_hier.member_name time, sales
FROM my_av HIERARCHIES (time_hier)
WHERE time_hier.level_name IN ('YEAR', 'QUARTER')
ORDER BY time_hier.hier_order;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/SELECT-37.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/SELECT.html
SELECT time_hier.member_name time, sales, lag_sales
FROM
ANALYTIC VIEW (
USING sales_av HIERARCHIES (time_hier)
ADD MEASURES (
lag_sales AS (LAG(sales) OVER (HIERARCHY time_hier OFFSET 1))
)
)
WHERE time_hier.level_name = 'YEAR'
ORDER BY time_hier.hier_order;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/SELECT-39.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/SELECT.html
SELECT *
FROM employees
WHERE department_id = 30
ORDER BY last_name;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/SELECT-4.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/SELECT.html
SELECT *
FROM ( VALUES (1,'SCOTT'),
(2,'SMITH'),
(3,'JOHN' )
) t1 (employee_id, first_name);
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/SELECT-40.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/SELECT.html
SELECT last_name, job_id, salary, department_id
FROM employees
WHERE NOT (job_id = 'PU_CLERK' AND department_id = 30)
ORDER BY last_name;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/SELECT-41.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/SELECT.html
SELECT a.department_id "Department",
a.num_emp/b.total_count "%_Employees",
a.sal_sum/b.total_sal "%_Salary"
FROM
(SELECT department_id, COUNT(*) num_emp, SUM(salary) sal_sum
FROM employees
GROUP BY department_id) a,
(SELECT COUNT(*) total_count, SUM(salary) total_sal
FROM employees) b
ORDER BY a.department_id;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/SELECT-42.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/SELECT.html
SELECT * FROM sales PARTITION (sales_q2_2000) s
WHERE s.amount_sold > 1500
ORDER BY cust_id, time_id, channel_id;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/SELECT-43.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/SELECT.html
SELECT * FROM orders
WHERE order_date < TO_DATE('2006-06-15', 'YYYY-MM-DD');
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/SELECT-44.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/SELECT.html
SELECT COUNT(*) * 10 FROM orders SAMPLE (10);
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/SELECT-45.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/SELECT.html
SELECT COUNT(*) * 10 FROM orders SAMPLE (10);
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/SELECT-46.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/SELECT.html
SELECT COUNT(*) * 10 FROM orders SAMPLE(10) SEED (1);
SELECT COUNT(*) * 10 FROM orders SAMPLE(10) SEED(4);
SELECT COUNT(*) * 10 FROM orders SAMPLE(10) SEED (1);
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/SELECT-47.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/SELECT.html
SELECT salary FROM employees
WHERE last_name = 'Chung';
UPDATE employees SET salary = 4000
WHERE last_name = 'Chung';
SELECT salary FROM employees
WHERE last_name = 'Chung';
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/SELECT-48.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/SELECT.html
SELECT salary FROM employees
AS OF TIMESTAMP (SYSTIMESTAMP - INTERVAL '1' MINUTE)
WHERE last_name = 'Chung';
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/SELECT-49.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/SELECT.html
SELECT salary FROM employees
VERSIONS BETWEEN TIMESTAMP
SYSTIMESTAMP - INTERVAL '10' MINUTE AND
SYSTIMESTAMP - INTERVAL '1' MINUTE
WHERE last_name = 'Chung';
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/SELECT-5.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/SELECT.html
WITH X(foo, bar, baz) AS (
VALUES (0, 1, 2), (3, 4, 5), (6, 7, 8) ) SELECT * FROM X;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/SELECT-50.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/SELECT.html
UPDATE employees SET salary =
(SELECT salary FROM employees
AS OF TIMESTAMP (SYSTIMESTAMP - INTERVAL '2' MINUTE)
WHERE last_name = 'Chung')
WHERE last_name = 'Chung';
SELECT salary FROM employees
WHERE last_name = 'Chung';
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/SELECT-51.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/SELECT.html
SELECT department_id, MIN(salary), MAX (salary)
FROM employees
GROUP BY department_id
ORDER BY department_id;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/SELECT-52.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/SELECT.html
SELECT department_id, MIN(salary), MAX (salary)
FROM employees
WHERE job_id = 'PU_CLERK'
GROUP BY department_id
ORDER BY department_id;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/SELECT-53.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/SELECT.html
SELECT TRUNC(hire_date, 'YYYY') year_hired, COUNT(*)
FROM employees
GROUP BY year_hired
ORDER BY year_hired;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/SELECT-54.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/SELECT.html
SELECT TRUNC(hire_date, 'YYYY') hire_date, COUNT(*)
FROM employees
GROUP BY hire_date
ORDER BY hire_date;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/SELECT-55.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/SELECT.html
SELECT DECODE(GROUPING(department_name), 1, 'All Departments',
department_name) AS department_name,
DECODE(GROUPING(job_id), 1, 'All Jobs', job_id) AS job_id,
COUNT(*) "Total Empl", AVG(salary) * 12 "Average Sal"
FROM employees e, departments d
WHERE d.department_id = e.department_id
GROUP BY CUBE (department_name, job_id)
ORDER BY department_name, job_id;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/SELECT-56.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/SELECT.html
SELECT channel_desc, calendar_month_desc, co.country_id,
TO_CHAR(sum(amount_sold) , '9,999,999,999') SALES$
FROM sales, customers, times, channels, countries co
WHERE sales.time_id=times.time_id
AND sales.cust_id=customers.cust_id
AND sales.channel_id= channels.channel_id
AND customers.country_id = co.country_id
AND channels.channel_desc IN ('Direct Sales', 'Internet')
AND times.calendar_month_desc IN ('2000-09', '2000-10')
AND co.country_iso_code IN ('UK', 'US')
GROUP BY GROUPING SETS(
(channel_desc, calendar_month_desc, co.country_id),
(channel_desc, co.country_id),
(calendar_month_desc, co.country_id) );
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/SELECT-57.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/SELECT.html
SELECT last_name, employee_id, manager_id FROM employees
CONNECT BY employee_id = manager_id
ORDER BY last_name;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/SELECT-58.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/SELECT.html
SELECT last_name, employee_id, manager_id FROM employees
CONNECT BY PRIOR employee_id = manager_id
AND salary > commission_pct
ORDER BY last_name;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/SELECT-59.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/SELECT.html
SELECT department_id, MIN(salary), MAX (salary)
FROM employees
GROUP BY department_id
HAVING MIN(salary) < 5000
ORDER BY department_id;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/SELECT-60.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/SELECT.html
SELECT department_id, manager_id
FROM employees
GROUP BY department_id, manager_id HAVING (department_id, manager_id) IN
(SELECT department_id, manager_id FROM employees x
WHERE x.department_id = employees.department_id)
ORDER BY department_id;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/SELECT-61.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/SELECT.html
SELECT *
FROM employees
WHERE job_id = 'PU_CLERK'
ORDER BY salary DESC;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/SELECT-62.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/SELECT.html
SELECT last_name, department_id, salary
FROM employees
ORDER BY department_id ASC, salary DESC, last_name;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/SELECT-63.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/SELECT.html
SELECT last_name, department_id, salary
FROM employees
ORDER BY 2 ASC, 3 DESC, 1;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/SELECT-64.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/SELECT.html
CREATE OR REPLACE VIEW sales_view_ref AS
SELECT country_name country,
prod_name prod,
calendar_year year,
SUM(amount_sold) sale,
COUNT(amount_sold) cnt
FROM sales,times,customers,countries,products
WHERE sales.time_id = times.time_id
AND sales.prod_id = products.prod_id
AND sales.cust_id = customers.cust_id
AND customers.country_id = countries.country_id
AND ( customers.country_id = 52779
OR customers.country_id = 52776 )
AND ( prod_name = 'Standard Mouse'
OR prod_name = 'Mouse Pad' )
GROUP BY country_name,prod_name,calendar_year;
SELECT country, prod, year, sale
FROM sales_view_ref
ORDER BY country, prod, year;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/SELECT-65.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/SELECT.html
SELECT country,prod,year,s
FROM sales_view_ref
MODEL
PARTITION BY (country)
DIMENSION BY (prod, year)
MEASURES (sale s)
IGNORE NAV
UNIQUE DIMENSION
RULES UPSERT SEQUENTIAL ORDER
(
s[prod='Mouse Pad', year=2001] =
s['Mouse Pad', 1999] + s['Mouse Pad', 2000],
s['Standard Mouse', 2002] = s['Standard Mouse', 2001]
)
ORDER BY country, prod, year;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/SELECT-66.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/SELECT.html
SELECT country, year, sale, csum
FROM
(SELECT country, year, SUM(sale) sale
FROM sales_view_ref
GROUP BY country, year
)
MODEL DIMENSION BY (country, year)
MEASURES (sale, 0 csum)
RULES (csum[any, any]=
SUM(sale) OVER (PARTITION BY country
ORDER BY year
ROWS UNBOUNDED PRECEDING)
)
ORDER BY country, year;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/SELECT-67.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/SELECT.html
SELECT employee_id, last_name
FROM employees
ORDER BY employee_id
FETCH FIRST 5 ROWS ONLY;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/SELECT-68.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/SELECT.html
SELECT employee_id, last_name
FROM employees
ORDER BY employee_id
OFFSET 5 ROWS FETCH NEXT 5 ROWS ONLY;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/SELECT-69.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/SELECT.html
SELECT employee_id, last_name, salary
FROM employees
ORDER BY salary
FETCH FIRST 5 PERCENT ROWS ONLY;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/SELECT-70.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/SELECT.html
SELECT employee_id, last_name, salary
FROM employees
ORDER BY salary
FETCH FIRST 5 PERCENT ROWS WITH TIES;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/SELECT-71.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/SELECT.html
SELECT e.employee_id, e.salary, e.commission_pct
FROM employees e, departments d
WHERE job_id = 'SA_REP'
AND e.department_id = d.department_id
AND location_id = 2500
ORDER BY e.employee_id
FOR UPDATE;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/SELECT-72.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/SELECT.html
SELECT e.employee_id, e.salary, e.commission_pct
FROM employees e JOIN departments d
USING (department_id)
WHERE job_id = 'SA_REP'
AND location_id = 2500
ORDER BY e.employee_id
FOR UPDATE OF e.salary;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/SELECT-73.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/SELECT.html
INSERT INTO (SELECT department_id, department_name, location_id
FROM departments WHERE location_id < 2000)
VALUES (9999, 'Entertainment', 2500);
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/SELECT-74.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/SELECT.html
INSERT INTO (SELECT department_id, department_name, location_id
FROM departments WHERE location_id < 2000 WITH CHECK OPTION)
VALUES (9999, 'Entertainment', 2500);
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/SELECT-75.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/SELECT.html
CREATE TABLE pivot_table AS
SELECT * FROM
(SELECT EXTRACT(YEAR FROM order_date) year, order_mode, order_total FROM orders)
PIVOT
(SUM(order_total) FOR order_mode IN ('direct' AS Store, 'online' AS Internet));
SELECT * FROM pivot_table ORDER BY year;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/SELECT-76.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/SELECT.html
SELECT * FROM pivot_table
UNPIVOT (yearly_total FOR order_mode IN (store AS 'direct',
internet AS 'online'))
ORDER BY year, order_mode;
SELECT * FROM pivot_table
UNPIVOT INCLUDE NULLS
(yearly_total FOR order_mode IN (store AS 'direct', internet AS 'online'))
ORDER BY year, order_mode;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/SELECT-77.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/SELECT.html
SELECT last_name, job_id, departments.department_id, department_name
FROM employees, departments
WHERE employees.department_id = departments.department_id
ORDER BY last_name, job_id;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/SELECT-79.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/SELECT.html
SELECT last_name, job_id, departments.department_id, department_name
FROM employees, departments
WHERE employees.department_id = departments.department_id
AND job_id = 'SA_MAN'
ORDER BY last_name;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/SELECT-80.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/SELECT.html
SELECT last_name, department_id FROM employees
WHERE department_id =
(SELECT department_id FROM employees
WHERE last_name = 'Lorentz')
ORDER BY last_name, department_id;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/SELECT-81.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/SELECT.html
UPDATE employees
SET salary = salary * 1.1
WHERE employee_id IN (SELECT employee_id FROM job_history);
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/SELECT-82.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/SELECT.html
CREATE TABLE new_departments
(department_id, department_name, location_id)
AS SELECT department_id, department_name, location_id
FROM departments;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/SELECT-83.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/SELECT.html
SELECT e1.last_name||' works for '||e2.last_name
"Employees and Their Managers"
FROM employees e1, employees e2
WHERE e1.manager_id = e2.employee_id
AND e1.last_name LIKE 'R%'
ORDER BY e1.last_name;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/SELECT-85.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/SELECT.html
SELECT d.department_id, e.last_name
FROM departments d LEFT OUTER JOIN employees e
ON d.department_id = e.department_id
ORDER BY d.department_id, e.last_name;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/SELECT-86.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/SELECT.html
SELECT d.department_id, e.last_name
FROM departments d, employees e
WHERE d.department_id = e.department_id(+)
ORDER BY d.department_id, e.last_name;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/SELECT-87.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/SELECT.html
SELECT d.department_id, e.last_name
FROM departments d RIGHT OUTER JOIN employees e
ON d.department_id = e.department_id
ORDER BY d.department_id, e.last_name;
Grant
Zeuss
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/SELECT-88.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/SELECT.html
SELECT d.department_id as d_dept_id, e.department_id as e_dept_id,
e.last_name
FROM departments d FULL OUTER JOIN employees e
ON d.department_id = e.department_id
ORDER BY d.department_id, e.last_name;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/SELECT-89.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/SELECT.html
SELECT department_id AS d_e_dept_id, e.last_name
FROM departments d FULL OUTER JOIN employees e
USING (department_id)
ORDER BY department_id, e.last_name;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/SELECT-90.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/SELECT.html
CREATE TABLE inventory (time_id DATE,
product VARCHAR2(10),
quantity NUMBER);
INSERT INTO inventory VALUES (TO_DATE('01/04/01', 'DD/MM/YY'), 'bottle', 10);
INSERT INTO inventory VALUES (TO_DATE('06/04/01', 'DD/MM/YY'), 'bottle', 10);
INSERT INTO inventory VALUES (TO_DATE('01/04/01', 'DD/MM/YY'), 'can', 10);
INSERT INTO inventory VALUES (TO_DATE('04/04/01', 'DD/MM/YY'), 'can', 10);
SELECT times.time_id, product, quantity FROM inventory
PARTITION BY (product)
RIGHT OUTER JOIN times ON (times.time_id = inventory.time_id)
WHERE times.time_id BETWEEN TO_DATE('01/04/01', 'DD/MM/YY')
AND TO_DATE('06/04/01', 'DD/MM/YY')
ORDER BY 2,1;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/SELECT-91.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/SELECT.html
SELECT time_id, product, LAST_VALUE(quantity IGNORE NULLS)
OVER (PARTITION BY product ORDER BY time_id) quantity
FROM ( SELECT times.time_id, product, quantity
FROM inventory PARTITION BY (product)
RIGHT OUTER JOIN times ON (times.time_id = inventory.time_id)
WHERE times.time_id BETWEEN TO_DATE('01/04/01', 'DD/MM/YY')
AND TO_DATE('06/04/01', 'DD/MM/YY'))
ORDER BY 2,1;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/SELECT-92.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/SELECT.html
SELECT department_name FROM hr.departments d
WHERE NOT EXISTS (SELECT asdf FROM hr.employees e
WHERE e.department_id = d.department_id
AND e.salary >= 10000)
ORDER BY department_name;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/SELECT-93.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/SELECT.html
SELECT * FROM departments
WHERE EXISTS
(SELECT * FROM employees
WHERE departments.department_id = employees.department_id
AND employees.salary > 2500)
ORDER BY department_name;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/SELECT-94.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/SELECT.html
SELECT d.department_name, v.employee_id, v.last_name
FROM departments d CROSS APPLY (SELECT * FROM employees e
WHERE e.department_id = d.department_id) v
WHERE d.department_name IN ('Marketing', 'Operations', 'Public Relations')
ORDER BY d.department_name, v.employee_id;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/SELECT-95.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/SELECT.html
SELECT d.department_name, v.employee_id, v.last_name
FROM departments d OUTER APPLY (SELECT * FROM employees e
WHERE e.department_id = d.department_id) v
WHERE d.department_name IN ('Marketing', 'Operations', 'Public Relations')
ORDER by d.department_name, v.employee_id;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/SELECT-96.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/SELECT.html
SELECT department_name,
(SELECT last_name FROM
(SELECT last_name FROM hr.employees e
WHERE e.department_id = d.department_id
ORDER BY e.salary DESC, e.employee_id ASC)
WHERE ROWNUM = 1) highest_paid
FROM hr.departments d;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/SELECT-97.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/SELECT.html
SELECT d.department_name, e2.last_name, e2.first_name, e2.salary, e2.email
FROM hr.departments d,
LATERAL (SELECT * FROM
(SELECT * FROM hr.employees e
WHERE e.department_id = d.department_id
ORDER BY e.salary DESC, e.employee_id ASC)
WHERE ROWNUM = 1) e2;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/SELECT-98.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/SELECT.html
CREATE TYPE people_typ AS OBJECT (
last_name VARCHAR2(25),
department_id NUMBER(4),
salary NUMBER(8,2));
/
CREATE TYPE people_tab_typ AS TABLE OF people_typ;
/
CREATE TABLE hr_info (
department_id NUMBER(4),
location_id NUMBER(4),
manager_id NUMBER(6),
people people_tab_typ)
NESTED TABLE people STORE AS people_stor_tab;
INSERT INTO hr_info VALUES (280, 1800, 999, people_tab_typ());
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/SELECT-99.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/SELECT.html
INSERT INTO TABLE(SELECT h.people FROM hr_info h
WHERE h.department_id = 280)
VALUES ('Smith', 280, 1750);
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/SESSIONTIMEZONE-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/SESSIONTIMEZONE.html
SELECT SESSIONTIMEZONE FROM DUAL;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/SET-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/SET.html
SELECT customer_id, SET(cust_address_ntab) address
FROM customers_demo
ORDER BY customer_id;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/SET-CONSTRAINTS-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/SET-CONSTRAINTS.html
SET CONSTRAINTS ALL IMMEDIATE;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/SET-CONSTRAINTS-1.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/SET-CONSTRAINTS.html
SET CONSTRAINTS emp_job_nn, emp_salary_min,
hr.jhist_dept_fk@remote DEFERRED;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/SET-ROLE-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/SET-ROLE.html
SET ROLE dw_manager IDENTIFIED BY password;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/SET-ROLE-1.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/SET-ROLE.html
SET ROLE ALL;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/SET-ROLE-2.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/SET-ROLE.html
SET ROLE ALL EXCEPT dw_manager;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/SET-ROLE-3.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/SET-ROLE.html
SET ROLE NONE;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/SET-TRANSACTION-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/SET-TRANSACTION.html
COMMIT;
SET TRANSACTION READ ONLY NAME 'West Coast';
SELECT product_id, quantity_on_hand, 'San Francisco' location
FROM inventories
WHERE warehouse_id = 2
ORDER BY product_id;
SELECT product_id, quantity_on_hand, 'Seattle' location
FROM inventories
WHERE warehouse_id = 4
ORDER BY product_id;
COMMIT;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/SIGN-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/SIGN.html
SELECT SIGN(-15) "Sign" FROM DUAL;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/SIN-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/SIN.html
SELECT SIN(30 * 3.14159265359/180)
"Sine of 30 degrees" FROM DUAL;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/SINH-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/SINH.html
SELECT SINH(1) "Hyperbolic sine of 1" FROM DUAL;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/SOUNDEX-1.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/SOUNDEX.html
SELECT last_name, first_name
FROM hr.employees
WHERE SOUNDEX(last_name)
= SOUNDEX('SMYTHE')
ORDER BY last_name, first_name;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/SQL-JSON-Conditions-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/SQL-JSON-Conditions.html
CREATE TABLE tab (jcol JSON VALIDATE '{"type" : "object"}');
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/SQL-JSON-Conditions-1.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/SQL-JSON-Conditions.html
CREATE TABLE tab (jcol JSON CONSTRAINT jchk
CHECK (jcol IS JSON VALIDATE '{"type" : "object"}'));
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/SQL-JSON-Conditions-10.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/SQL-JSON-Conditions.html
INSERT INTO jsontab1(jschd) VALUES (json('"a json string"'));
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/SQL-JSON-Conditions-11.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/SQL-JSON-Conditions.html
ALTER TABLE jsontab1
ADD jschd JSON CONSTRAINT jschdsv
CHECK (jschd IS JSON VALIDATE USING '{"type":"string"}');
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/SQL-JSON-Conditions-13.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/SQL-JSON-Conditions.html
SELECT COUNT(1) FROM jsontab1 WHERE j IS JSON
VALIDATE
'{"type" : "object",
"properties" : {
"id" : {
"type" : "number"
}
}
}';
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/SQL-JSON-Conditions-14.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/SQL-JSON-Conditions.html
CREATE TABLE t (col1 VARCHAR2(100));
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/SQL-JSON-Conditions-15.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/SQL-JSON-Conditions.html
INSERT INTO t VALUES ( '[ "LIT192", "CS141", "HIS160" ]' );
INSERT INTO t VALUES ( '{ "Name": "John" }' );
INSERT INTO t VALUES ( '{ "Grade Values" : { A : 4.0, B : 3.0, C : 2.0 } }');
INSERT INTO t VALUES ( '{ "isEnrolled" : true }' );
INSERT INTO t VALUES ( '{ "isMatriculated" : False }' );
INSERT INTO t VALUES (NULL);
INSERT INTO t VALUES ('This is not well-formed JSON data');
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/SQL-JSON-Conditions-16.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/SQL-JSON-Conditions.html
SELECT col1
FROM t
WHERE col1 IS JSON;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/SQL-JSON-Conditions-17.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/SQL-JSON-Conditions.html
SELECT col1
FROM t
WHERE col1 IS JSON STRICT;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/SQL-JSON-Conditions-18.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/SQL-JSON-Conditions.html
SELECT col1
FROM t
WHERE col1 IS NOT JSON STRICT AND col1 IS JSON LAX;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/SQL-JSON-Conditions-19.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/SQL-JSON-Conditions.html
CREATE TABLE t (col1 VARCHAR2(100));
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/SQL-JSON-Conditions-20.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/SQL-JSON-Conditions.html
INSERT INTO t VALUES ('{a:100, b:200, c:300}');
INSERT INTO t VALUES ('{a:100, a:200, b:300}');
INSERT INTO t VALUES ('{a:100, b : {a:100, c:300}}');
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/SQL-JSON-Conditions-21.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/SQL-JSON-Conditions.html
SELECT col1 FROM t
WHERE col1 IS JSON WITH UNIQUE KEYS;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/SQL-JSON-Conditions-22.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/SQL-JSON-Conditions.html
SELECT col1 FROM t
WHERE col1 IS JSON WITHOUT UNIQUE KEYS;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/SQL-JSON-Conditions-23.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/SQL-JSON-Conditions.html
CREATE TABLE j_purchaseorder
(id RAW (16) NOT NULL,
date_loaded TIMESTAMP(6) WITH TIME ZONE,
po_document CLOB CONSTRAINT ensure_json CHECK (po_document IS JSON));
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/SQL-JSON-Conditions-28.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/SQL-JSON-Conditions.html
CREATE TABLE t (name VARCHAR2(100));
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/SQL-JSON-Conditions-29.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/SQL-JSON-Conditions.html
INSERT INTO t VALUES ('[{first:"John"}, {middle:"Mark"}, {last:"Smith"}]');
INSERT INTO t VALUES ('[{first:"Mary"}, {last:"Jones"}]');
INSERT INTO t VALUES ('[{first:"Jeff"}, {last:"Williams"}]');
INSERT INTO t VALUES ('[{first:"Jean"}, {middle:"Anne"}, {last:"Brown"}]');
INSERT INTO t VALUES (NULL);
INSERT INTO t VALUES ('This is not well-formed JSON data');
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/SQL-JSON-Conditions-3.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/SQL-JSON-Conditions.html
CREATE TABLE jtab(jcol JSON DOMAIN jd);
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/SQL-JSON-Conditions-30.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/SQL-JSON-Conditions.html
SELECT name FROM t
WHERE JSON_EXISTS(name, '$[0].first');
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/SQL-JSON-Conditions-31.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/SQL-JSON-Conditions.html
SELECT name FROM t
WHERE JSON_EXISTS(name, '$[1].middle');
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/SQL-JSON-Conditions-32.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/SQL-JSON-Conditions.html
SELECT name FROM t
WHERE JSON_EXISTS(name, '$[1].middle' TRUE ON ERROR);
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/SQL-JSON-Conditions-33.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/SQL-JSON-Conditions.html
SELECT name FROM t
WHERE JSON_EXISTS(name, '$[*].last');
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/SQL-JSON-Conditions-34.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/SQL-JSON-Conditions.html
SELECT name FROM t
WHERE JSON_EXISTS(name, '$[1]?(@.middle == $var1)' PASSING 'Anne' as "var1");
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/SQL-JSON-Conditions-35.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/SQL-JSON-Conditions.html
CREATE TABLE families (family_doc VARCHAR2(200));
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/SQL-JSON-Conditions-36.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/SQL-JSON-Conditions.html
CREATE INDEX ix
ON families(family_doc)
INDEXTYPE IS CTXSYS.CONTEXT
PARAMETERS ('SECTION GROUP CTXSYS.JSON_SECTION_GROUP SYNC (ON COMMIT)');
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/SQL-JSON-Conditions-37.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/SQL-JSON-Conditions.html
INSERT INTO families
VALUES ('{family : {id:10, ages:[40,38,12], address : {street : "10 Main Street"}}}');
INSERT INTO families
VALUES ('{family : {id:11, ages:[42,40,10,5], address : {street : "200 East Street", apt : 20}}}');
INSERT INTO families
VALUES ('{family : {id:12, ages:[25,23], address : {street : "300 Oak Street", apt : 10}}}');
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/SQL-JSON-Conditions-38.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/SQL-JSON-Conditions.html
COMMIT;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/SQL-JSON-Conditions-39.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/SQL-JSON-Conditions.html
SELECT family_doc FROM families
WHERE JSON_TEXTCONTAINS(family_doc, '$', '10');
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/SQL-JSON-Conditions-40.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/SQL-JSON-Conditions.html
SELECT family_doc FROM families
where json_textcontains(family_doc, '$.family.id', '10');
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/SQL-JSON-Conditions-41.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/SQL-JSON-Conditions.html
SELECT family_doc FROM families
WHERE JSON_TEXTCONTAINS(family_doc, '$.family.ages', '10');
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/SQL-JSON-Conditions-42.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/SQL-JSON-Conditions.html
SELECT family_doc FROM families
WHERE JSON_TEXTCONTAINS(family_doc, '$.family.address', '10');
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/SQL-JSON-Conditions-43.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/SQL-JSON-Conditions.html
SELECT family_doc FROM families
WHERE JSON_TEXTCONTAINS(family_doc, '$.family.address.apt', '10');
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/SQL-JSON-Conditions-5.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/SQL-JSON-Conditions.html
CREATE TABLE jtab (
id NUMBER(9) PRIMARY KEY,
jcol JSON CHECK(jcol IS JSON VALIDATE CAST USING '{
"type": "object",
"properties": {
"firstName": {
"extendedType": "string",
"maxLength": 50
},
"birthDate" : {
"extendedType": "date"
}
},
"required": ["firstName", "birthDate"]
}'
)
);
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/SQL-JSON-Conditions-7.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/SQL-JSON-Conditions.html
CREATE TABLE jsontab1(
id NUMBER(4),
j JSON CONSTRAINT jt1isj CHECK (j IS JSON VALIDATE USING
'{
"type":"object",
"minProperties": 2
}')
);
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/SQL-JSON-Conditions-8.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/SQL-JSON-Conditions.html
INSERT INTO jsontab1(j) VALUES ('["a", "b"]');
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/SQL-JSON-Conditions-9.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/SQL-JSON-Conditions.html
INSERT INTO jsontab1(j) VALUES ('{"a": "a", "b": "b"}');
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/SQRT-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/SQRT.html
SELECT SQRT(26) "Square root" FROM DUAL;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/STATS_BINOMIAL_TEST-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/STATS_BINOMIAL_TEST.html
SELECT AVG(DECODE(cust_gender, 'M', 1, 0)) real_proportion,
STATS_BINOMIAL_TEST
(cust_gender, 'M', 0.68, 'EXACT_PROB') exact,
STATS_BINOMIAL_TEST
(cust_gender, 'M', 0.68, 'ONE_SIDED_PROB_OR_LESS') prob_or_less
FROM sh.customers;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/STATS_CROSSTAB-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/STATS_CROSSTAB.html
SELECT STATS_CROSSTAB
(cust_gender, cust_income_level, 'CHISQ_OBS') chi_squared,
STATS_CROSSTAB
(cust_gender, cust_income_level, 'CHISQ_SIG') p_value,
STATS_CROSSTAB
(cust_gender, cust_income_level, 'PHI_COEFFICIENT') phi_coefficient
FROM sh.customers;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/STATS_F_TEST-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/STATS_F_TEST.html
SELECT VARIANCE(DECODE(cust_gender, 'M', cust_credit_limit, null)) var_men,
VARIANCE(DECODE(cust_gender, 'F', cust_credit_limit, null)) var_women,
STATS_F_TEST(cust_gender, cust_credit_limit, 'STATISTIC', 'F') f_statistic,
STATS_F_TEST(cust_gender, cust_credit_limit) two_sided_p_value
FROM sh.customers;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/STATS_KS_TEST-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/STATS_KS_TEST.html
SELECT stats_ks_test(cust_gender, amount_sold, 'STATISTIC') ks_statistic,
stats_ks_test(cust_gender, amount_sold) p_value
FROM sh.customers c, sh.sales s
WHERE c.cust_id = s.cust_id;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/STATS_MODE-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/STATS_MODE.html
SELECT x FROM (SELECT x, COUNT(x) AS cnt1
FROM t GROUP BY x)
WHERE cnt1 =
(SELECT MAX(cnt2) FROM (SELECT COUNT(x) AS cnt2 FROM t GROUP BY x));
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/STATS_MODE-1.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/STATS_MODE.html
SELECT department_id, STATS_MODE(salary) FROM employees
GROUP BY department_id
ORDER BY department_id, stats_mode(salary);
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/STATS_MODE-2.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/STATS_MODE.html
SELECT commission_pct FROM
(SELECT commission_pct, COUNT(commission_pct) AS cnt1 FROM employees
GROUP BY commission_pct)
WHERE cnt1 =
(SELECT MAX (cnt2) FROM
(SELECT COUNT(commission_pct) AS cnt2
FROM employees GROUP BY commission_pct))
ORDER BY commission_pct;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/STATS_MW_TEST-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/STATS_MW_TEST.html
SELECT STATS_MW_TEST
(cust_gender, amount_sold, 'STATISTIC') z_statistic,
STATS_MW_TEST
(cust_gender, amount_sold, 'ONE_SIDED_SIG', 'F') one_sided_p_value
FROM sh.customers c, sh.sales s
WHERE c.cust_id = s.cust_id;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/STATS_ONE_WAY_ANOVA-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/STATS_ONE_WAY_ANOVA.html
SELECT cust_gender,
STATS_ONE_WAY_ANOVA(cust_income_level, amount_sold, 'F_RATIO') f_ratio,
STATS_ONE_WAY_ANOVA(cust_income_level, amount_sold, 'SIG') p_value
FROM sh.customers c, sh.sales s
WHERE c.cust_id = s.cust_id
GROUP BY cust_gender
ORDER BY cust_gender;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/STATS_T_TEST_-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/STATS_T_TEST_.html
SELECT AVG(prod_list_price) group_mean,
STATS_T_TEST_ONE(prod_list_price, 60, 'STATISTIC') t_observed,
STATS_T_TEST_ONE(prod_list_price, 60) two_sided_p_value
FROM sh.products;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/STATS_T_TEST_-1.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/STATS_T_TEST_.html
SELECT SUBSTR(cust_income_level, 1, 22) income_level,
AVG(DECODE(cust_gender, 'M', amount_sold, null)) sold_to_men,
AVG(DECODE(cust_gender, 'F', amount_sold, null)) sold_to_women,
STATS_T_TEST_INDEP(cust_gender, amount_sold, 'STATISTIC', 'F') t_observed,
STATS_T_TEST_INDEP(cust_gender, amount_sold) two_sided_p_value
FROM sh.customers c, sh.sales s
WHERE c.cust_id = s.cust_id
GROUP BY ROLLUP(cust_income_level)
ORDER BY income_level, sold_to_men, sold_to_women, t_observed;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/STATS_T_TEST_-2.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/STATS_T_TEST_.html
SELECT SUBSTR(cust_income_level, 1, 22) income_level,
AVG(DECODE(cust_gender, 'M', amount_sold, null)) sold_to_men,
AVG(DECODE(cust_gender, 'F', amount_sold, null)) sold_to_women,
STATS_T_TEST_INDEPU(cust_gender, amount_sold, 'STATISTIC', 'F') t_observed,
STATS_T_TEST_INDEPU(cust_gender, amount_sold) two_sided_p_value
FROM sh.customers c, sh.sales s
WHERE c.cust_id = s.cust_id
GROUP BY ROLLUP(cust_income_level)
ORDER BY income_level, sold_to_men, sold_to_women, t_observed;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/STDDEV-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/STDDEV.html
SELECT STDDEV(salary) "Deviation"
FROM employees;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/STDDEV-1.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/STDDEV.html
SELECT last_name, salary,
STDDEV(salary) OVER (ORDER BY hire_date) "StdDev"
FROM employees
WHERE department_id = 30
ORDER BY last_name, salary, "StdDev";
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/STDDEV_POP-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/STDDEV_POP.html
SELECT STDDEV_POP(amount_sold) "Pop",
STDDEV_SAMP(amount_sold) "Samp"
FROM sales;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/STDDEV_POP-1.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/STDDEV_POP.html
SELECT department_id, last_name, salary,
STDDEV_POP(salary) OVER (PARTITION BY department_id) AS pop_std
FROM employees
ORDER BY department_id, last_name, salary, pop_std;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/STDDEV_SAMP-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/STDDEV_SAMP.html
SELECT department_id, last_name, hire_date, salary,
STDDEV_SAMP(salary) OVER (PARTITION BY department_id
ORDER BY hire_date
ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) AS cum_sdev
FROM employees
ORDER BY department_id, last_name, hire_date, salary, cum_sdev;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/SUBSTR-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/SUBSTR.html
SELECT SUBSTR('ABCDEFG',3,4) "Substring"
FROM DUAL;
SELECT SUBSTR('ABCDEFG',-5,4) "Substring"
FROM DUAL;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/SUBSTR-1.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/SUBSTR.html
SELECT SUBSTRB('ABCDEFG',5,4.2) "Substring with bytes"
FROM DUAL;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/SUM-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/SUM.html
SELECT SUM(salary) "Total"
FROM employees;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/SUM-1.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/SUM.html
SELECT manager_id, last_name, salary,
SUM(salary) OVER (PARTITION BY manager_id ORDER BY salary
RANGE UNBOUNDED PRECEDING) l_csum
FROM employees
ORDER BY manager_id, last_name, salary, l_csum;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/SYSDATE-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/SYSDATE.html
SELECT TO_CHAR
(SYSDATE, 'MM-DD-YYYY HH24:MI:SS') "NOW"
FROM DUAL;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/SYSTIMESTAMP-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/SYSTIMESTAMP.html
SELECT SYSTIMESTAMP FROM DUAL;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/SYSTIMESTAMP-1.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/SYSTIMESTAMP.html
SELECT TO_CHAR(SYSTIMESTAMP, 'SSSSS.FF') FROM DUAL;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/SYSTIMESTAMP-2.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/SYSTIMESTAMP.html
SELECT SYSTIMESTAMP AT TIME ZONE 'UTC' FROM DUAL;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/SYS_CONNECT_BY_PATH-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/SYS_CONNECT_BY_PATH.html
SELECT LPAD(' ', 2*level-1)||SYS_CONNECT_BY_PATH(last_name, '/') "Path"
FROM employees
START WITH last_name = 'Kochhar'
CONNECT BY PRIOR employee_id = manager_id;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/SYS_CONTEXT-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/SYS_CONTEXT.html
CONNECT OE
SELECT SYS_CONTEXT ('USERENV', 'SESSION_USER')
FROM DUAL;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/SYS_CONTEXT-1.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/SYS_CONTEXT.html
CONNECT OE
SELECT role FROM session_roles;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/SYS_CONTEXT-2.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/SYS_CONTEXT.html
SELECT SYS_CONTEXT ('hr_apps', 'group_no') "User Group"
FROM DUAL;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/SYS_DBURIGEN-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/SYS_DBURIGEN.html
SELECT SYS_DBURIGEN(employee_id, email)
FROM employees
WHERE employee_id = 206;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/SYS_EXTRACT_UTC-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/SYS_EXTRACT_UTC.html
SELECT SYS_EXTRACT_UTC(TIMESTAMP '2000-03-28 11:30:00.00 -08:00')
FROM DUAL;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/SYS_GUID-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/SYS_GUID.html
ALTER TABLE locations ADD (uid_col RAW(16));
UPDATE locations SET uid_col = SYS_GUID();
SELECT location_id, uid_col FROM locations
ORDER BY location_id, uid_col;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/SYS_OP_ZONE_ID-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/SYS_OP_ZONE_ID.html
CREATE MATERIALIZED ZONEMAP sales_zmap
AS
SELECT SYS_OP_ZONE_ID(rowid), MIN(time_id), MAX(time_id)
FROM sales
GROUP BY SYS_OP_ZONE_ID(rowid);
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/SYS_OP_ZONE_ID-1.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/SYS_OP_ZONE_ID.html
CREATE MATERIALIZED ZONEMAP sales_zmap
SCALE 8
AS
SELECT SYS_OP_ZONE_ID(rowid), MIN(time_id), MAX(time_id)
FROM sales
GROUP BY SYS_OP_ZONE_ID(rowid);
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/SYS_OP_ZONE_ID-2.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/SYS_OP_ZONE_ID.html
CREATE MATERIALIZED ZONEMAP sales_zmap
SCALE 8
AS
SELECT SYS_OP_ZONE_ID(rowid,12), MIN(time_id), MAX(time_id)
FROM sales
GROUP BY SYS_OP_ZONE_ID(rowid,12);
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/SYS_OP_ZONE_ID-3.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/SYS_OP_ZONE_ID.html
CREATE MATERIALIZED ZONEMAP sales_zmap
AS
SELECT SYS_OP_ZONE_ID(s.rowid),
MIN(prod_category), MAX(prod_category),
MIN(country_id), MAX(country_id)
FROM sales s, products p, customers c
WHERE s.prod_id = p.prod_id(+) AND
s.cust_id = c.cust_id(+)
GROUP BY SYS_OP_ZONE_ID(s.rowid);
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/SYS_TYPEID-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/SYS_TYPEID.html
SELECT name, SYS_TYPEID(VALUE(p)) "Type_id" FROM persons p;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/SYS_TYPEID-1.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/SYS_TYPEID.html
SELECT b.title, b.author.name, SYS_TYPEID(author)
"Type_ID" FROM books b;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/SYS_XMLAGG-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/SYS_XMLAGG.html
SELECT SYS_XMLAGG(SYS_XMLGEN(last_name)) XMLAGG
FROM employees
WHERE last_name LIKE 'R%'
ORDER BY xmlagg;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/SYS_XMLGEN-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/SYS_XMLGEN.html
SELECT SYS_XMLGEN(email)
FROM employees
WHERE employee_id = 205;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/Sequence-Pseudocolumns-3.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/Sequence-Pseudocolumns.html
SELECT employees_seq.nextval
FROM DUAL;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/Sequence-Pseudocolumns-4.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/Sequence-Pseudocolumns.html
INSERT INTO employees
VALUES (employees_seq.nextval, 'John', 'Doe', 'jdoe', '555-1212',
TO_DATE(SYSDATE), 'PU_CLERK', 2500, null, null, 30);
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/Sequence-Pseudocolumns-5.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/Sequence-Pseudocolumns.html
INSERT INTO orders (order_id, order_date, customer_id)
VALUES (orders_seq.nextval, TO_DATE(SYSDATE), 106);
INSERT INTO order_items (order_id, line_item_id, product_id)
VALUES (orders_seq.currval, 1, 2359);
INSERT INTO order_items (order_id, line_item_id, product_id)
VALUES (orders_seq.currval, 2, 3290);
INSERT INTO order_items (order_id, line_item_id, product_id)
VALUES (orders_seq.currval, 3, 2381);
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/Syntax-for-Schema-Objects-and-Parts-in-SQL-Statements-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/Syntax-for-Schema-Objects-and-Parts-in-SQL-Statements.html
INSERT INTO departments
VALUES (280, 'ENTERTAINMENT_CLERK', 206, 1700);
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/Syntax-for-Schema-Objects-and-Parts-in-SQL-Statements-2.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/Syntax-for-Schema-Objects-and-Parts-in-SQL-Statements.html
DROP TABLE hr.employees;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/Syntax-for-Schema-Objects-and-Parts-in-SQL-Statements-3.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/Syntax-for-Schema-Objects-and-Parts-in-SQL-Statements.html
CREATE VIEW Q1_2000_sales AS
SELECT *
FROM sales PARTITION (SALES_Q1_2000);
DELETE FROM Q1_2000_sales
WHERE amount_sold < 0;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/Syntax-for-Schema-Objects-and-Parts-in-SQL-Statements-4.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/Syntax-for-Schema-Objects-and-Parts-in-SQL-Statements.html
CREATE TYPE cust_address_typ
OID '82A4AF6A4CD1656DE034080020E0EE3D'
AS OBJECT
(street_address VARCHAR2(40),
postal_code VARCHAR2(10),
city VARCHAR2(30),
state_province VARCHAR2(10),
country_id CHAR(2));
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/Syntax-for-Schema-Objects-and-Parts-in-SQL-Statements-5.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/Syntax-for-Schema-Objects-and-Parts-in-SQL-Statements.html
SELECT c.cust_address.postal_code
FROM customers c;
UPDATE customers c
SET c.cust_address.postal_code = '14621-2604'
WHERE c.cust_address.city = 'Rochester'
AND c.cust_address.state_province = 'NY';
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/Syntax-for-Schema-Objects-and-Parts-in-SQL-Statements-6.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/Syntax-for-Schema-Objects-and-Parts-in-SQL-Statements.html
SELECT TREAT(VALUE(c) AS catalog_typ).getCatalogName() "Catalog Type"
FROM categories_tab c
WHERE category_id = 90;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/TAN-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/TAN.html
SELECT TAN(135 * 3.14159265359/180)
"Tangent of 135 degrees" FROM DUAL;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/TANH-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/TANH.html
SELECT TANH(.5) "Hyperbolic tangent of .5"
FROM DUAL;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/TIMESTAMP_TO_SCN-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/TIMESTAMP_TO_SCN.html
INSERT INTO orders (order_id, order_date, customer_id, order_total)
VALUES (5000, SYSTIMESTAMP, 188, 2345);
COMMIT;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/TO_BINARY_DOUBLE-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/TO_BINARY_DOUBLE.html
CREATE TABLE float_point_demo
(dec_num NUMBER(10,2), bin_double BINARY_DOUBLE, bin_float BINARY_FLOAT);
INSERT INTO float_point_demo
VALUES (1234.56,1234.56,1234.56);
SELECT * FROM float_point_demo;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/TO_BINARY_DOUBLE-1.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/TO_BINARY_DOUBLE.html
SELECT dec_num, TO_BINARY_DOUBLE(dec_num)
FROM float_point_demo;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/TO_BINARY_DOUBLE-2.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/TO_BINARY_DOUBLE.html
SELECT DUMP(dec_num) "Decimal",
DUMP(bin_double) "Double"
FROM float_point_demo;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/TO_BINARY_DOUBLE-3.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/TO_BINARY_DOUBLE.html
SELECT TO_BINARY_DOUBLE('2oo' DEFAULT 0 ON CONVERSION ERROR) "Value"
FROM DUAL;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/TO_BINARY_FLOAT-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/TO_BINARY_FLOAT.html
SELECT dec_num, TO_BINARY_FLOAT(dec_num)
FROM float_point_demo;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/TO_BINARY_FLOAT-1.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/TO_BINARY_FLOAT.html
SELECT TO_BINARY_FLOAT('2oo' DEFAULT 0 ON CONVERSION ERROR) "Value"
FROM DUAL;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/TO_BLOB-bfile-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/TO_BLOB-bfile.html
SELECT TO_BLOB(media_col, 'JPEG') FROM media_tab;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/TO_BLOB-raw-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/TO_BLOB-raw.html
SELECT TO_BLOB(raw_column) blob FROM raw_table;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/TO_CHAR-bfile-blob-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/TO_CHAR-bfile-blob.html
SELECT TO_CHAR(media_col, 873) FROM media_tab;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/TO_CHAR-character-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/TO_CHAR-character.html
SELECT TO_CHAR('01110') FROM DUAL;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/TO_CHAR-character-1.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/TO_CHAR-character.html
SELECT TO_CHAR(ad_sourcetext) FROM print_media
WHERE product_id = 2268;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/TO_CHAR-character-2.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/TO_CHAR-character.html
CREATE TABLE empl_temp
(
employee_id NUMBER(6),
first_name VARCHAR2(20),
last_name VARCHAR2(25),
email VARCHAR2(25),
hire_date DATE DEFAULT SYSDATE,
job_id VARCHAR2(10),
clob_column CLOB
);
INSERT INTO empl_temp
VALUES(111,'John','Doe','example.com','10-JAN-2015','1001','Experienced Employee');
INSERT INTO empl_temp
VALUES(112,'John','Smith','example.com','12-JAN-2015','1002','Junior Employee');
INSERT INTO empl_temp
VALUES(113,'Johnnie','Smith','example.com','12-JAN-2014','1002','Mid-Career Employee');
INSERT INTO empl_temp
VALUES(115,'Jane','Doe','example.com','15-JAN-2015','1005','Executive Employee');
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/TO_CHAR-character-3.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/TO_CHAR-character.html
SELECT To_char(clob_column) "CLOB_TO_CHAR"
FROM empl_temp
WHERE employee_id IN ( 111, 112, 115 );
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/TO_CHAR-datetime-1.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/TO_CHAR-datetime.html
CREATE TABLE date_tab (
ts_col TIMESTAMP,
tsltz_col TIMESTAMP WITH LOCAL TIME ZONE,
tstz_col TIMESTAMP WITH TIME ZONE);
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/TO_CHAR-datetime-10.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/TO_CHAR-datetime.html
CREATE TABLE empl_temp
(
employee_id NUMBER(6),
first_name VARCHAR2(20),
last_name VARCHAR2(25),
email VARCHAR2(25),
hire_date DATE DEFAULT SYSDATE,
job_id VARCHAR2(10),
clob_column CLOB
);
INSERT INTO empl_temp
VALUES(111,'John','Doe','example.com','10-JAN-2015','1001','Experienced Employee');
INSERT INTO empl_temp
VALUES(112,'John','Smith','example.com','12-JAN-2015','1002','Junior Employee');
INSERT INTO empl_temp
VALUES(113,'Johnnie','Smith','example.com','12-JAN-2014','1002','Mid-Career Employee');
INSERT INTO empl_temp
VALUES(115,'Jane','Doe','example.com','15-JAN-2015','1005','Executive Employee');
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/TO_CHAR-datetime-11.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/TO_CHAR-datetime.html
SELECT hire_date "Default",
TO_CHAR(hire_date,'DS') "Short",
TO_CHAR(hire_date,'DL') "Long"FROM empl_temp
WHERE employee_id IN (111, 112, 115);
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/TO_CHAR-datetime-2.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/TO_CHAR-datetime.html
ALTER SESSION SET TIME_ZONE = '-8:00';
INSERT INTO date_tab VALUES (
TIMESTAMP'1999-12-01 10:00:00',
TIMESTAMP'1999-12-01 10:00:00',
TIMESTAMP'1999-12-01 10:00:00');
INSERT INTO date_tab VALUES (
TIMESTAMP'1999-12-02 10:00:00 -8:00',
TIMESTAMP'1999-12-02 10:00:00 -8:00',
TIMESTAMP'1999-12-02 10:00:00 -8:00');
SELECT TO_CHAR(ts_col, 'DD-MON-YYYY HH24:MI:SSxFF') AS ts_date,
TO_CHAR(tstz_col, 'DD-MON-YYYY HH24:MI:SSxFF TZH:TZM') AS tstz_date
FROM date_tab
ORDER BY ts_date, tstz_date;
SELECT SESSIONTIMEZONE,
TO_CHAR(tsltz_col, 'DD-MON-YYYY HH24:MI:SSxFF') AS tsltz
FROM date_tab
ORDER BY sessiontimezone, tsltz;
ALTER SESSION SET TIME_ZONE = '-5:00';
SELECT TO_CHAR(ts_col, 'DD-MON-YYYY HH24:MI:SSxFF') AS ts_col,
TO_CHAR(tstz_col, 'DD-MON-YYYY HH24:MI:SSxFF TZH:TZM') AS tstz_col
FROM date_tab
ORDER BY ts_col, tstz_col;
SELECT SESSIONTIMEZONE,
TO_CHAR(tsltz_col, 'DD-MON-YYYY HH24:MI:SSxFF') AS tsltz_col
FROM date_tab
ORDER BY sessiontimezone, tsltz_col;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/TO_CHAR-datetime-3.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/TO_CHAR-datetime.html
SELECT TO_CHAR(INTERVAL '123-2' YEAR(3) TO MONTH) FROM DUAL;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/TO_CHAR-datetime-4.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/TO_CHAR-datetime.html
WITH dates AS (
SELECT date'2015-01-01' d FROM dual union
SELECT date'2015-01-10' d FROM dual union
SELECT date'2015-02-01' d FROM dual
)
SELECT d "Original Date",
to_char(d, 'dd-mm-yyyy') "Day-Month-Year",
to_char(d, 'hh24:mi') "Time in 24-hr format",
to_char(d, 'iw-iyyy') "ISO Year and Week of Year"
FROM dates;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/TO_CHAR-datetime-5.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/TO_CHAR-datetime.html
WITH dates AS (
SELECT date'2015-01-01' d FROM dual union
SELECT date'2015-01-10' d FROM dual union
SELECT date'2015-02-01' d FROM dual union
SELECT timestamp'2015-03-03 23:44:32' d FROM dual union
SELECT timestamp'2015-04-11 12:34:56' d FROM dual
)
SELECT d "Original Date",
to_char(d, 'dd-mm-yyyy') "Day-Month-Year",
to_char(d, 'hh24:mi') "Time in 24-hr format",
to_char(d, 'iw-iyyy') "ISO Year and Week of Year",
to_char(d, 'Month') "Month Name",
to_char(d, 'Year') "Year"
FROM dates;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/TO_CHAR-datetime-6.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/TO_CHAR-datetime.html
WITH dates AS (
SELECT date'2015-01-01' d FROM dual union
SELECT date'2015-01-10' d FROM dual union
SELECT date'2015-02-01' d FROM dual union
SELECT timestamp'2015-03-03 23:44:32' d FROM dual union
SELECT timestamp'2015-04-11 12:34:56' d FROM dual
)
SELECT extract(minute from d) minutes,
extract(hour from d) hours,
extract(day from d) days,
extract(month from d) months,
extract(year from d) years
FROM dates;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/TO_CHAR-datetime-7.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/TO_CHAR-datetime.html
WITH nums AS (
SELECT 10 n FROM dual union
SELECT 9.99 n FROM dual union
SELECT 1000000 n FROM dual --one million
)
SELECT n "Input Number N",
to_char(n),
to_char(n, '9,999,999.99') "Number with Commas",
to_char(n, '0,000,000.000') "Zero-padded Number",
to_char(n, '9.9EEEE') "Scientific Notation"
FROM nums;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/TO_CHAR-datetime-8.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/TO_CHAR-datetime.html
WITH nums AS (
SELECT 10 n FROM dual union
SELECT 9.99 n FROM dual union
SELECT .99 n FROM dual union
SELECT 1000000 n FROM dual --one million
)
SELECT n "Input Number N",
to_char(n),
to_char(n, '9,999,999.99') "Number with Commas",
to_char(n, '0,000,000.000') "Zero_padded Number",
to_char(n, '9.9EEEE') "Scientific Notation",
to_char(n, '$9,999,990.00') Monetary,
to_char(n, 'X') "Hexadecimal Value"
FROM nums;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/TO_CHAR-datetime-9.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/TO_CHAR-datetime.html
WITH nums AS (
SELECT 10 n FROM dual union
SELECT 9.99 n FROM dual union
SELECT .99 n FROM dual union
SELECT 1000000 n FROM dual --one million
)
SELECT n "Input Number N",
to_char(n),
to_char(n, '9,999,999.99') "Number with Commas",
to_char(n, '0,000,000.000') "Zero_padded Number",
to_char(n, '9.9EEEE') "Scientific Notation",
to_char(n, '$9,999,990.00') Monetary,
to_char(n, 'XXXXXX') "Hexadecimal Value"
FROM nums;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/TO_CHAR-number-1.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/TO_CHAR-number.html
SELECT TO_CHAR('01110' + 1) FROM DUAL;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/TO_CHAR-number-2.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/TO_CHAR-number.html
SELECT TO_CHAR(-10000,'L99G999D99MI') "Amount"
FROM DUAL;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/TO_CHAR-number-3.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/TO_CHAR-number.html
SELECT TO_CHAR(-10000,'L99G999D99MI',
'NLS_NUMERIC_CHARACTERS = '',.''
NLS_CURRENCY = ''AusDollars'' ') "Amount"
FROM DUAL;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/TO_CHAR-number-4.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/TO_CHAR-number.html
SELECT TO_CHAR(-10000,'99G999D99C',
'NLS_NUMERIC_CHARACTERS = '',.''
NLS_ISO_CURRENCY=POLAND') "Amount"
FROM DUAL;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/TO_CHAR-number-5.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/TO_CHAR-number.html
CREATE TABLE empl_temp
(
employee_id NUMBER(6),
first_name VARCHAR2(20),
last_name VARCHAR2(25),
email VARCHAR2(25),
hire_date DATE DEFAULT SYSDATE,
job_id VARCHAR2(10),
clob_column CLOB
);
INSERT INTO empl_temp
VALUES(111,'John','Doe','example.com','10-JAN-2015','1001','Experienced Employee');
INSERT INTO empl_temp
VALUES(112,'John','Smith','example.com','12-JAN-2015','1002','Junior Employee');
INSERT INTO empl_temp
VALUES(113,'Johnnie','Smith','example.com','12-JAN-2014','1002','Mid-Career Employee');
INSERT INTO empl_temp
VALUES(115,'Jane','Doe','example.com','15-JAN-2015','1005','Executive Employee');
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/TO_CHAR-number-6.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/TO_CHAR-number.html
SELECT To_char(employee_id) "NUM_TO_CHAR"
FROM empl_temp
WHERE employee_id IN ( 111, 112, 113, 115 );
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/TO_CLOB-bfile-blob-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/TO_CLOB-bfile-blob.html
SELECT TO_CLOB(docu, 873, 'text/xml') FROM media_tab;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/TO_CLOB-character-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/TO_CLOB-character.html
UPDATE PRINT_MEDIA
SET AD_FINALTEXT = TO_CLOB (AD_FLTEXTN);
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/TO_DATE-1.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/TO_DATE.html
SELECT TO_DATE(
'January 15, 1989, 11:00 A.M.',
'Month dd, YYYY, HH:MI A.M.',
'NLS_DATE_LANGUAGE = American')
FROM DUAL;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/TO_DATE-2.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/TO_DATE.html
ALTER SESSION SET NLS_TERRITORY = 'KOREAN';
SELECT TO_DATE(
'January 15, 1989, 11:00 A.M.',
'Month dd, YYYY, HH:MI A.M.',
'NLS_DATE_LANGUAGE = American')
FROM DUAL;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/TO_DATE-3.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/TO_DATE.html
SELECT TO_DATE('Febuary 15, 2016, 11:00 A.M.'
DEFAULT 'January 01, 2016 12:00 A.M.' ON CONVERSION ERROR,
'Month dd, YYYY, HH:MI A.M.') "Value"
FROM DUAL;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/TO_DSINTERVAL-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/TO_DSINTERVAL.html
SELECT employee_id, last_name FROM employees
WHERE hire_date + TO_DSINTERVAL('100 00:00:00')
<= DATE '2002-11-01'
ORDER BY employee_id;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/TO_DSINTERVAL-1.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/TO_DSINTERVAL.html
SELECT TO_CHAR(TIMESTAMP '2009-01-01 00:00:00' + TO_DSINTERVAL('P100DT05H'),
'YYYY-MM-DD HH24:MI:SS') "Time Stamp"
FROM DUAL;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/TO_DSINTERVAL-2.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/TO_DSINTERVAL.html
SELECT TO_DSINTERVAL('1o 1:02:10'
DEFAULT '10 8:00:00' ON CONVERSION ERROR) "Value"
FROM DUAL;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/TO_MULTI_BYTE-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/TO_MULTI_BYTE.html
SELECT dump(TO_MULTI_BYTE( 'A')) FROM DUAL;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/TO_NCHAR-character-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/TO_NCHAR-character.html
SELECT TO_NCHAR(cust_last_name) FROM customers
WHERE customer_id=103;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/TO_NCHAR-datetime-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/TO_NCHAR-datetime.html
SELECT TO_NCHAR(ORDER_DATE) AS order_date
FROM ORDERS
WHERE ORDER_STATUS > 9
ORDER BY order_date;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/TO_NCHAR-number-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/TO_NCHAR-number.html
SELECT TO_NCHAR(customer_id) "NCHAR_Customer_ID" FROM orders
WHERE order_status > 9
ORDER BY "NCHAR_Customer_ID";
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/TO_NCLOB-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/TO_NCLOB.html
INSERT INTO print_media (product_id, ad_id, ad_fltextn)
VALUES (3502, 31001,
TO_NCLOB('Placeholder for new product description'));
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/TO_NUMBER-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/TO_NUMBER.html
UPDATE employees SET salary = salary +
TO_NUMBER('100.00', '9G999D99')
WHERE last_name = 'Perkins';
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/TO_NUMBER-1.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/TO_NUMBER.html
SELECT TO_NUMBER('-AusDollars100','L9G999D99',
' NLS_NUMERIC_CHARACTERS = '',.''
NLS_CURRENCY = ''AusDollars''
') "Amount"
FROM DUAL;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/TO_NUMBER-2.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/TO_NUMBER.html
SELECT TO_NUMBER('2,00' DEFAULT 0 ON CONVERSION ERROR) "Value"
FROM DUAL;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/TO_SINGLE_BYTE-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/TO_SINGLE_BYTE.html
SELECT TO_SINGLE_BYTE( CHR(15711393)) FROM DUAL;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/TO_TIMESTAMP-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/TO_TIMESTAMP.html
SELECT TO_TIMESTAMP ('10-Sep-02 14:10:10.123000', 'DD-Mon-RR HH24:MI:SS.FF')
FROM DUAL;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/TO_TIMESTAMP-1.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/TO_TIMESTAMP.html
SELECT TO_TIMESTAMP ('10-Sept-02 14:10:10.123000'
DEFAULT NULL ON CONVERSION ERROR,
'DD-Mon-RR HH24:MI:SS.FF',
'NLS_DATE_LANGUAGE = American') "Value"
FROM DUAL;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/TO_TIMESTAMP_TZ-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/TO_TIMESTAMP_TZ.html
SELECT TO_TIMESTAMP_TZ('1999-12-01 11:00:00 -8:00',
'YYYY-MM-DD HH:MI:SS TZH:TZM') FROM DUAL;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/TO_TIMESTAMP_TZ-1.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/TO_TIMESTAMP_TZ.html
SELECT order_id, line_item_id,
CAST(NULL AS TIMESTAMP WITH LOCAL TIME ZONE) order_date
FROM order_items
UNION
SELECT order_id, to_number(null), order_date
FROM orders;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/TO_TIMESTAMP_TZ-2.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/TO_TIMESTAMP_TZ.html
SELECT TO_TIMESTAMP_TZ('1999-13-01 11:00:00 -8:00'
DEFAULT NULL ON CONVERSION ERROR,
'YYYY-MM-DD HH:MI:SS TZH:TZM') "Value"
FROM DUAL;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/TO_UTC_TIMESTAMP_TZ-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/TO_UTC_TIMESTAMP_TZ.html
SELECT TO_UTC_TIMESTAMP_TZ('1998-01-01') FROM DUAL;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/TO_UTC_TIMESTAMP_TZ-1.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/TO_UTC_TIMESTAMP_TZ.html
SELECT TO_UTC_TIMESTAMP_TZ('2000-01-02T12:34:56.789') FROM DUAL;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/TO_UTC_TIMESTAMP_TZ-2.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/TO_UTC_TIMESTAMP_TZ.html
SELECT TO_UTC_TIMESTAMP_TZ('2016-05-05T00:00:00.000Z') FROM DUAL;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/TO_UTC_TIMESTAMP_TZ-3.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/TO_UTC_TIMESTAMP_TZ.html
SELECT TO_UTC_TIMESTAMP_TZ('2016-05-05T02:04:35.4678Z') FROM DUAL;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/TO_YMINTERVAL-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/TO_YMINTERVAL.html
SELECT hire_date, hire_date + TO_YMINTERVAL('01-02') "14 months"
FROM employees;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/TO_YMINTERVAL-1.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/TO_YMINTERVAL.html
SELECT hire_date, hire_date + TO_YMINTERVAL('P1Y2M') FROM employees;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/TO_YMINTERVAL-2.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/TO_YMINTERVAL.html
SELECT TO_YMINTERVAL('1x-02'
DEFAULT '00-00' ON CONVERSION ERROR) "Value"
FROM DUAL;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/TRANSLATE-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/TRANSLATE.html
SELECT TRANSLATE('SQL*Plus User''s Guide', ' */''', '___') FROM DUAL;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/TRANSLATE-USING-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/TRANSLATE-USING.html
CREATE TABLE translate_tab (char_col VARCHAR2(100),
nchar_col NVARCHAR2(50));
INSERT INTO translate_tab
SELECT NULL, translated_name
FROM product_descriptions
WHERE product_id = 3501;
SELECT * FROM translate_tab;
UPDATE translate_tab
SET char_col = TRANSLATE (nchar_col USING CHAR_CS);
SELECT * FROM translate_tab;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/TREAT-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/TREAT.html
SELECT name, TREAT(VALUE(p) AS employee_t).salary salary
FROM persons p;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/TRIM-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/TRIM.html
SELECT employee_id,
TO_CHAR(TRIM(LEADING 0 FROM hire_date))
FROM employees
WHERE department_id = 60
ORDER BY employee_id;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/TRUNC-date-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/TRUNC-date.html
SELECT TRUNC(TO_DATE('27-OCT-92','DD-MON-YY'), 'YEAR')
"New Year" FROM DUAL;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/TRUNC-date-1.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/TRUNC-date.html
WITH dates AS (
SELECT date'2015-01-01' d FROM dual union
SELECT date'2015-01-10' d FROM dual union
SELECT date'2015-02-01' d FROM dual union
SELECT timestamp'2015-03-03 23:45:00' d FROM dual union
SELECT timestamp'2015-04-11 12:34:56' d FROM dual
)
SELECT d "Original Date",
trunc(d) "Nearest Day, Time Removed",
trunc(d, 'ww') "Nearest Week",
trunc(d, 'iw') "Start of Week",
trunc(d, 'mm') "Start of Month",
trunc(d, 'year') "Start of Year"
FROM dates;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/TRUNC-date-2.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/TRUNC-date.html
WITH dates AS (
SELECT date'2015-01-01' d FROM dual union
SELECT date'2015-01-10' d FROM dual union
SELECT date'2015-02-01' d FROM dual union
SELECT timestamp'2015-03-03 23:45:00' d FROM dual union
SELECT timestamp'2015-04-11 12:34:56' d FROM dual
)
SELECT d "Original Date",
trunc(d) "Date with Time Removed",
to_char(trunc(d, 'mi'), 'dd-mon-yyyy hh24:mi') "Nearest Minute",
trunc(d, 'iw') "Start of Week",
trunc(d, 'mm') "Start of Month",
trunc(d, 'year') "Start of Year"
FROM dates;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/TRUNC-date-3.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/TRUNC-date.html
ALTER SESSION SET nls_date_format = 'dd-mon-yyyy hh24:mi';
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/TRUNC-date-4.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/TRUNC-date.html
WITH dates AS (
SELECT date'2015-01-01' d FROM dual union
SELECT date'2015-01-10' d FROM dual union
SELECT date'2015-02-01' d FROM dual union
SELECT timestamp'2015-03-03 23:44:32' d FROM dual union
SELECT timestamp'2015-04-11 12:34:56' d FROM dual
)
SELECT d "Original Date",
trunc(d) "Date, time removed",
to_char(trunc(d, 'mi'), 'dd-mon-yyyy hh24:mi') "Nearest Minute",
trunc(d, 'iw') "Start of Week",
trunc(d, 'mm') "Start of Month",
trunc(d, 'year') "Start of Year"
FROM dates;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/TRUNC-number-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/TRUNC-number.html
SELECT TRUNC(15.79,1) "Truncate" FROM DUAL;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/TRUNCATE-CLUSTER-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/TRUNCATE-CLUSTER.html
TRUNCATE CLUSTER personnel REUSE STORAGE;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/TRUNCATE-TABLE-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/TRUNCATE-TABLE.html
TRUNCATE TABLE employees_demo;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/TRUNCATE-TABLE-1.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/TRUNCATE-TABLE.html
TRUNCATE TABLE sales_demo PRESERVE MATERIALIZED VIEW LOG;
TRUNCATE TABLE orders_demo;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/TZ_OFFSET-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/TZ_OFFSET.html
SELECT TZ_OFFSET('US/Eastern') FROM DUAL;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/The-UNION-ALL-INTERSECT-MINUS-Operators-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/The-UNION-ALL-INTERSECT-MINUS-Operators.html
SELECT 3 FROM DUAL
INTERSECT
SELECT 3f FROM DUAL;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/The-UNION-ALL-INTERSECT-MINUS-Operators-1.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/The-UNION-ALL-INTERSECT-MINUS-Operators.html
SELECT TO_BINARY_FLOAT(3) FROM DUAL
INTERSECT
SELECT 3f FROM DUAL;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/The-UNION-ALL-INTERSECT-MINUS-Operators-2.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/The-UNION-ALL-INTERSECT-MINUS-Operators.html
SELECT '3' FROM DUAL
INTERSECT
SELECT 3f FROM DUAL;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/The-UNION-ALL-INTERSECT-MINUS-Operators-3.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/The-UNION-ALL-INTERSECT-MINUS-Operators.html
SELECT location_id, department_name "Department",
TO_CHAR(NULL) "Warehouse" FROM departments
UNION
SELECT location_id, TO_CHAR(NULL) "Department", warehouse_name
FROM warehouses;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/The-UNION-ALL-INTERSECT-MINUS-Operators-4.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/The-UNION-ALL-INTERSECT-MINUS-Operators.html
SELECT product_id FROM order_items
UNION
SELECT product_id FROM inventories
ORDER BY product_id;
SELECT location_id FROM locations
UNION ALL
SELECT location_id FROM departments
ORDER BY location_id;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/The-UNION-ALL-INTERSECT-MINUS-Operators-5.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/The-UNION-ALL-INTERSECT-MINUS-Operators.html
SELECT product_id FROM inventories
INTERSECT
SELECT product_id FROM order_items
ORDER BY product_id;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/The-UNION-ALL-INTERSECT-MINUS-Operators-6.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/The-UNION-ALL-INTERSECT-MINUS-Operators.html
SELECT product_id FROM inventories
MINUS
SELECT product_id FROM order_items
ORDER BY product_id;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/The-UNION-ALL-INTERSECT-MINUS-Operators-7.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/The-UNION-ALL-INTERSECT-MINUS-Operators.html
SELECT product_id FROM inventories
EXCEPT
SELECT product_id FROM order_items
ORDER BY product_id;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/Type-Constructor-Expressions-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/Type-Constructor-Expressions.html
CREATE TYPE address_book_t AS TABLE OF cust_address_typ;
DECLARE
myaddr cust_address_typ := cust_address_typ(
'500 Oracle Parkway', 94065, 'Redwood Shores', 'CA','USA');
alladdr address_book_t := address_book_t();
BEGIN
INSERT INTO customers VALUES (
666999, 'Joe', 'Smith', myaddr, NULL, NULL, NULL, NULL,
NULL, NULL, NULL, NULL, NULL, NULL, NULL);
END;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/Type-Constructor-Expressions-1.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/Type-Constructor-Expressions.html
CREATE TABLE warehouse_tab OF warehouse_typ;
INSERT INTO warehouse_tab
VALUES (warehouse_typ(101, 'new_wh', 201));
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/UID-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/UID.html
SELECT UID FROM DUAL;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/UNISTR-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/UNISTR.html
SELECT UNISTR('abc\00e5\00f1\00f6') FROM DUAL;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/UPDATE-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/UPDATE.html
UPDATE employees e
SET e.salary = j.max_salary
FROM jobs j
WHERE j.job_id = e.job_id;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/UPDATE-1.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/UPDATE.html
UPDATE employees
SET commission_pct = NULL
WHERE job_id = 'SH_CLERK';
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/UPDATE-2.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/UPDATE.html
UPDATE employees SET
job_id = 'SA_MAN', salary = salary + 1000, department_id = 120
WHERE first_name||' '||last_name = 'Douglas Grant';
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/UPDATE-3.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/UPDATE.html
UPDATE employees@remote
SET salary = salary*1.1
WHERE last_name = 'Baer';
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/UPDATE-4.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/UPDATE.html
UPDATE employees a
SET department_id =
(SELECT department_id
FROM departments
WHERE location_id = '2100'),
(salary, commission_pct) =
(SELECT 1.1*AVG(salary), 1.5*AVG(commission_pct)
FROM employees b
WHERE a.department_id = b.department_id)
WHERE department_id IN
(SELECT department_id
FROM departments
WHERE location_id = 2900
OR location_id = 2700);
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/UPDATE-5.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/UPDATE.html
UPDATE sales PARTITION (sales_q1_1999) s
SET s.promo_id = 494
WHERE amount_sold > 1000;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/UPDATE-6.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/UPDATE.html
CREATE TABLE people_demo1 OF people_typ;
CREATE TABLE people_demo2 OF people_typ;
UPDATE people_demo1 p SET VALUE(p) =
(SELECT VALUE(q) FROM people_demo2 q
WHERE p.department_id = q.department_id)
WHERE p.department_id = 10;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/UPDATE-7.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/UPDATE.html
UPDATE employees
SET job_id ='SA_MAN', salary = salary + 1000, department_id = 140
WHERE last_name = 'Jones'
RETURNING salary*0.25, last_name, department_id
INTO :bnd1, :bnd2, :bnd3;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/UPDATE-8.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/UPDATE.html
UPDATE employees
SET salary = salary * 1.1
WHERE department_id = 100
RETURNING SUM(salary) INTO :bnd1;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/UPDATE-9.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/UPDATE.html
UPDATE hr.employees e
SET e.salary = j.max_salary
FROM hr.jobs j
WHERE e.job_id = j.job_id;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/UPPER-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/UPPER.html
SELECT UPPER(last_name) "Uppercase"
FROM employees;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/USER-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/USER.html
SELECT USER, UID FROM DUAL;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/USERENV-1.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/USERENV.html
SELECT USERENV('LANGUAGE') "Language" FROM DUAL;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/Unnesting-of-Nested-Subqueries-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/Unnesting-of-Nested-Subqueries.html
SELECT C.cust_last_name, C.country_id
FROM customers C
WHERE EXISTS (SELECT 1
FROM sales S
WHERE S.quantity_sold > 1000 and
S.cust_id = C.cust_id);
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/Unnesting-of-Nested-Subqueries-1.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/Unnesting-of-Nested-Subqueries.html
SELECT C.cust_last_name, C.country_id
FROM customers C
WHERE C.cust_id =ANY (SELECT S.cust_id
FROM sales S
WHERE S.quantity_sold > 1000);
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/Unnesting-of-Nested-Subqueries-2.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/Unnesting-of-Nested-Subqueries.html
SELECT C.cust_last_name, C.country_id
FROM customers C
WHERE NOT EXISTS (SELECT 1
FROM sales S, products P
WHERE P.prod_id = S.prod_id and
P.prod_min_price > 90 and
S.cust_id = C.cust_id);
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/Using-Extensible-Indexing-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/Using-Extensible-Indexing.html
SELECT last_name, salary FROM
(SELECT last_name, DENSE_RANK() OVER
(ORDER BY salary DESC) rank_val, salary FROM employees)
WHERE rank_val BETWEEN 10 AND 20;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/Using-Extensible-Indexing-1.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/Using-Extensible-Indexing.html
CREATE OR REPLACE TYPE position_im AUTHID CURRENT_USER AS OBJECT
(
curnum NUMBER,
howmany NUMBER,
lower_bound NUMBER,
upper_bound NUMBER,
/* lower_bound and upper_bound are used for the
index-based functional implementation */
STATIC FUNCTION ODCIGETINTERFACES(ifclist OUT SYS.ODCIOBJECTLIST) RETURN NUMBER,
STATIC FUNCTION ODCIINDEXCREATE
(ia SYS.ODCIINDEXINFO, parms VARCHAR2, env SYS.ODCIEnv) RETURN NUMBER,
STATIC FUNCTION ODCIINDEXTRUNCATE (ia SYS.ODCIINDEXINFO,
env SYS.ODCIEnv) RETURN NUMBER,
STATIC FUNCTION ODCIINDEXDROP(ia SYS.ODCIINDEXINFO,
env SYS.ODCIEnv) RETURN NUMBER,
STATIC FUNCTION ODCIINDEXINSERT(ia SYS.ODCIINDEXINFO, rid ROWID,
newval NUMBER, env SYS.ODCIEnv) RETURN NUMBER,
STATIC FUNCTION ODCIINDEXDELETE(ia SYS.ODCIINDEXINFO, rid ROWID, oldval NUMBER,
env SYS.ODCIEnv) RETURN NUMBER,
STATIC FUNCTION ODCIINDEXUPDATE(ia SYS.ODCIINDEXINFO, rid ROWID, oldval NUMBER,
newval NUMBER, env SYS.ODCIEnv) RETURN NUMBER,
STATIC FUNCTION ODCIINDEXSTART(SCTX IN OUT position_im, ia SYS.ODCIINDEXINFO,
op SYS.ODCIPREDINFO, qi SYS.ODCIQUERYINFO,
strt NUMBER, stop NUMBER, lower_pos NUMBER,
upper_pos NUMBER, env SYS.ODCIEnv) RETURN NUMBER,
MEMBER FUNCTION ODCIINDEXFETCH(SELF IN OUT position_im, nrows NUMBER,
rids OUT SYS.ODCIRIDLIST, env SYS.ODCIEnv)
RETURN NUMBER,
MEMBER FUNCTION ODCIINDEXCLOSE(env SYS.ODCIEnv) RETURN NUMBER
);
/
CREATE OR REPLACE TYPE BODY position_im
IS
STATIC FUNCTION ODCIGETINTERFACES(ifclist OUT SYS.ODCIOBJECTLIST)
RETURN NUMBER IS
BEGIN
ifclist := SYS.ODCIOBJECTLIST(SYS.ODCIOBJECT('SYS','ODCIINDEX2'));
RETURN ODCICONST.SUCCESS;
END ODCIGETINTERFACES;
STATIC FUNCTION ODCIINDEXCREATE (ia SYS.ODCIINDEXINFO, parms VARCHAR2, env SYS.ODCIEnv) RETURN
NUMBER
IS
stmt VARCHAR2(2000);
BEGIN
/* Construct the SQL statement */
stmt := 'Create Table ' || ia.INDEXSCHEMA || '.' || ia.INDEXNAME ||
'_STORAGE_TAB' || '(col_val, base_rowid, constraint pk PRIMARY KEY ' ||
'(col_val, base_rowid)) ORGANIZATION INDEX AS SELECT ' ||
ia.INDEXCOLS(1).COLNAME || ', ROWID FROM ' ||
ia.INDEXCOLS(1).TABLESCHEMA || '.' || ia.INDEXCOLS(1).TABLENAME;
EXECUTE IMMEDIATE stmt;
RETURN ODCICONST.SUCCESS;
END;
STATIC FUNCTION ODCIINDEXDROP(ia SYS.ODCIINDEXINFO, env SYS.ODCIEnv) RETURN NUMBER IS
stmt VARCHAR2(2000);
BEGIN
/* Construct the SQL statement */
stmt := 'DROP TABLE ' || ia.INDEXSCHEMA || '.' || ia.INDEXNAME ||
'_STORAGE_TAB';
/* Execute the statement */
EXECUTE IMMEDIATE stmt;
RETURN ODCICONST.SUCCESS;
END;
STATIC FUNCTION ODCIINDEXTRUNCATE(ia SYS.ODCIINDEXINFO, env SYS.ODCIEnv) RETURN NUMBER IS
stmt VARCHAR2(2000);
BEGIN
/* Construct the SQL statement */
stmt := 'TRUNCATE TABLE ' || ia.INDEXSCHEMA || '.' || ia.INDEXNAME || '_STORAGE_TAB';
EXECUTE IMMEDIATE stmt;
RETURN ODCICONST.SUCCESS;
END;
STATIC FUNCTION ODCIINDEXINSERT(ia SYS.ODCIINDEXINFO, rid ROWID,
newval NUMBER, env SYS.ODCIEnv) RETURN NUMBER IS
stmt VARCHAR2(2000);
BEGIN
/* Construct the SQL statement */
stmt := 'INSERT INTO ' || ia.INDEXSCHEMA || '.' || ia.INDEXNAME ||
'_STORAGE_TAB VALUES (''' || newval || ''' , ''' || rid || ''' )';
/* Execute the SQL statement */
EXECUTE IMMEDIATE stmt;
RETURN ODCICONST.SUCCESS;
END;
STATIC FUNCTION ODCIINDEXDELETE(ia SYS.ODCIINDEXINFO, rid ROWID, oldval NUMBER,
env SYS.ODCIEnv)
RETURN NUMBER IS
stmt VARCHAR2(2000);
BEGIN
/* Construct the SQL statement */
stmt := 'DELETE FROM ' || ia.INDEXSCHEMA || '.' || ia.INDEXNAME ||
'_STORAGE_TAB WHERE col_val = ''' || oldval || ''' AND base_rowid = ''' || rid || '''';
/* Execute the statement */
EXECUTE IMMEDIATE stmt;
RETURN ODCICONST.SUCCESS;
END;
STATIC FUNCTION ODCIINDEXUPDATE(ia SYS.ODCIINDEXINFO, rid ROWID, oldval NUMBER,
newval NUMBER, env SYS.ODCIEnv) RETURN NUMBER IS
stmt VARCHAR2(2000);
BEGIN
/* Construct the SQL statement */
stmt := 'UPDATE ' || ia.INDEXSCHEMA || '.' || ia.INDEXNAME ||
'_STORAGE_TAB SET col_val = ''' || newval || ''' WHERE f2 = '''|| rid ||'''';
/* Execute the statement */
EXECUTE IMMEDIATE stmt;
RETURN ODCICONST.SUCCESS;
END;
STATIC FUNCTION ODCIINDEXSTART(SCTX IN OUT position_im, ia SYS.ODCIINDEXINFO,
op SYS.ODCIPREDINFO, qi SYS.ODCIQUERYINFO,
strt NUMBER, stop NUMBER, lower_pos NUMBER,
upper_pos NUMBER, env SYS.ODCIEnv) RETURN NUMBER IS
rid VARCHAR2(5072);
storage_tab_name VARCHAR2(65);
lower_bound_stmt VARCHAR2(2000);
upper_bound_stmt VARCHAR2(2000);
range_query_stmt VARCHAR2(2000);
lower_bound NUMBER;
upper_bound NUMBER;
cnum INTEGER;
nrows INTEGER;
BEGIN
/* Take care of some error cases.
The only predicates in which position operator can appear are
op() = 1 OR
op() = 0 OR
op() between 0 and 1
*/
IF (((strt != 1) AND (strt != 0)) OR
((stop != 1) AND (stop != 0)) OR
((strt = 1) AND (stop = 0))) THEN
RAISE_APPLICATION_ERROR(-20101,
'incorrect predicate for position_between operator');
END IF;
IF (lower_pos > upper_pos) THEN
RAISE_APPLICATION_ERROR(-20101, 'Upper Position must be greater than or
equal to Lower Position');
END IF;
IF (lower_pos <= 0) THEN
RAISE_APPLICATION_ERROR(-20101, 'Both Positions must be greater than zero');
END IF;
storage_tab_name := ia.INDEXSCHEMA || '.' || ia.INDEXNAME ||
'_STORAGE_TAB';
upper_bound_stmt := 'Select MIN(col_val) FROM (Select /*+ INDEX_DESC(' ||
storage_tab_name || ') */ DISTINCT ' ||
'col_val FROM ' || storage_tab_name || ' ORDER BY ' ||
'col_val DESC) WHERE rownum <= ' || lower_pos;
EXECUTE IMMEDIATE upper_bound_stmt INTO upper_bound;
IF (lower_pos != upper_pos) THEN
lower_bound_stmt := 'Select MIN(col_val) FROM (Select /*+ INDEX_DESC(' ||
storage_tab_name || ') */ DISTINCT ' ||
'col_val FROM ' || storage_tab_name ||
' WHERE col_val < ' || upper_bound || ' ORDER BY ' ||
'col_val DESC) WHERE rownum <= ' ||
(upper_pos - lower_pos);
EXECUTE IMMEDIATE lower_bound_stmt INTO lower_bound;
ELSE
lower_bound := upper_bound;
END IF;
IF (lower_bound IS NULL) THEN
lower_bound := upper_bound;
END IF;
range_query_stmt := 'Select base_rowid FROM ' || storage_tab_name ||
' WHERE col_val BETWEEN ' || lower_bound || ' AND ' ||
upper_bound;
cnum := DBMS_SQL.OPEN_CURSOR;
DBMS_SQL.PARSE(cnum, range_query_stmt, DBMS_SQL.NATIVE);
/* set context as the cursor number */
SCTX := position_im(cnum, 0, 0, 0);
/* return success */
RETURN ODCICONST.SUCCESS;
END;
MEMBER FUNCTION ODCIINDEXFETCH(SELF IN OUT position_im, nrows NUMBER,
rids OUT SYS.ODCIRIDLIST, env SYS.ODCIEnv)
RETURN NUMBER IS
cnum INTEGER;
rid_tab DBMS_SQL.Varchar2_table;
rlist SYS.ODCIRIDLIST := SYS.ODCIRIDLIST();
i INTEGER;
d INTEGER;
BEGIN
cnum := SELF.curnum;
IF self.howmany = 0 THEN
dbms_sql.define_array(cnum, 1, rid_tab, nrows, 1);
d := DBMS_SQL.EXECUTE(cnum);
END IF;
d := DBMS_SQL.FETCH_ROWS(cnum);
IF d = nrows THEN
rlist.extend(d);
ELSE
rlist.extend(d+1);
END IF;
DBMS_SQL.COLUMN_VALUE(cnum, 1, rid_tab);
for i in 1..d loop
rlist(i) := rid_tab(i+SELF.howmany);
end loop;
SELF.howmany := SELF.howmany + d;
rids := rlist;
RETURN ODCICONST.SUCCESS;
END;
MEMBER FUNCTION ODCIINDEXCLOSE(env SYS.ODCIEnv) RETURN NUMBER IS
cnum INTEGER;
BEGIN
cnum := SELF.curnum;
DBMS_SQL.CLOSE_CURSOR(cnum);
RETURN ODCICONST.SUCCESS;
END;
END;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/Using-Extensible-Indexing-2.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/Using-Extensible-Indexing.html
CREATE OR REPLACE FUNCTION function_for_position_between
(col NUMBER, lower_pos NUMBER, upper_pos NUMBER,
indexctx IN SYS.ODCIIndexCtx,
scanctx IN OUT position_im,
scanflg IN NUMBER)
RETURN NUMBER AS
rid ROWID;
storage_tab_name VARCHAR2(65);
lower_bound_stmt VARCHAR2(2000);
upper_bound_stmt VARCHAR2(2000);
col_val_stmt VARCHAR2(2000);
lower_bound NUMBER;
upper_bound NUMBER;
column_value NUMBER;
BEGIN
IF (indexctx.IndexInfo IS NOT NULL) THEN
storage_tab_name := indexctx.IndexInfo.INDEXSCHEMA || '.' ||
indexctx.IndexInfo.INDEXNAME || '_STORAGE_TAB';
IF (scanctx IS NULL) THEN
/* This is the first call. Open a cursor for future calls.
First, do some error checking
*/
IF (lower_pos > upper_pos) THEN
RAISE_APPLICATION_ERROR(-20101,
'Upper Position must be greater than or equal to Lower Position');
END IF;
IF (lower_pos <= 0) THEN
RAISE_APPLICATION_ERROR(-20101,
'Both Positions must be greater than zero');
END IF;
/* Obtain the upper and lower value bounds for the range we're interested in.
*/
upper_bound_stmt := 'Select MIN(col_val) FROM (Select /*+ INDEX_DESC(' ||
storage_tab_name || ') */ DISTINCT ' ||
'col_val FROM ' || storage_tab_name || ' ORDER BY ' ||
'col_val DESC) WHERE rownum <= ' || lower_pos;
EXECUTE IMMEDIATE upper_bound_stmt INTO upper_bound;
IF (lower_pos != upper_pos) THEN
lower_bound_stmt := 'Select MIN(col_val) FROM (Select /*+ INDEX_DESC(' ||
storage_tab_name || ') */ DISTINCT ' ||
'col_val FROM ' || storage_tab_name ||
' WHERE col_val < ' || upper_bound || ' ORDER BY ' ||
'col_val DESC) WHERE rownum <= ' ||
(upper_pos - lower_pos);
EXECUTE IMMEDIATE lower_bound_stmt INTO lower_bound;
ELSE
lower_bound := upper_bound;
END IF;
IF (lower_bound IS NULL) THEN
lower_bound := upper_bound;
END IF;
/* Store the lower and upper bounds for future function invocations for
the positions.
*/
scanctx := position_im(0, 0, lower_bound, upper_bound);
END IF;
/* Fetch the column value corresponding to the rowid, and see if it falls
within the determined range.
*/
col_val_stmt := 'Select col_val FROM ' || storage_tab_name ||
' WHERE base_rowid = ''' || indexctx.Rid || '''';
EXECUTE IMMEDIATE col_val_stmt INTO column_value;
IF (column_value <= scanctx.upper_bound AND
column_value >= scanctx.lower_bound AND
scanflg = ODCICONST.RegularCall) THEN
RETURN 1;
ELSE
RETURN 0;
END IF;
ELSE
RAISE_APPLICATION_ERROR(-20101, 'A column that has a domain index of' ||
'Position indextype must be the first argument');
END IF;
END;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/Using-Extensible-Indexing-3.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/Using-Extensible-Indexing.html
CREATE OR REPLACE OPERATOR position_between
BINDING (NUMBER, NUMBER, NUMBER) RETURN NUMBER
WITH INDEX CONTEXT, SCAN CONTEXT position_im
USING function_for_position_between;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/Using-Extensible-Indexing-4.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/Using-Extensible-Indexing.html
CREATE INDEXTYPE position_indextype
FOR position_between(NUMBER, NUMBER, NUMBER)
USING position_im;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/Using-Extensible-Indexing-6.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/Using-Extensible-Indexing.html
CREATE INDEX salary_index ON employees(salary)
INDEXTYPE IS position_indextype;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/Using-Extensible-Indexing-8.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/Using-Extensible-Indexing.html
SELECT last_name, salary FROM employees
WHERE position_between(salary, 10, 20)=1
ORDER BY salary DESC, last_name;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/Using-XML-in-SQL-Statements-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/Using-XML-in-SQL-Statements.html
CREATE TABLE xwarehouses OF XMLTYPE
XMLTYPE STORE AS CLOB;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/Using-XML-in-SQL-Statements-1.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/Using-XML-in-SQL-Statements.html
INSERT INTO xwarehouses VALUES
(xmltype('
1
Southlake, Texas
Owned
25000
2
Rear load
true
N
Street
10
'));
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/Using-XML-in-SQL-Statements-2.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/Using-XML-in-SQL-Statements.html
SELECT e.getClobVal() FROM xwarehouses e;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/Using-XML-in-SQL-Statements-3.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/Using-XML-in-SQL-Statements.html
begin
dbms_xmlschema.registerSchema(
'http://www.example.com/xwarehouses.xsd',
'
',
TRUE, TRUE, FALSE, FALSE);
end;
/
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/Using-XML-in-SQL-Statements-4.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/Using-XML-in-SQL-Statements.html
CREATE TABLE xwarehouses OF XMLTYPE
XMLSCHEMA "http://www.example.com/xwarehouses.xsd"
ELEMENT "Warehouse";
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/Using-XML-in-SQL-Statements-5.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/Using-XML-in-SQL-Statements.html
INSERT INTO xwarehouses VALUES( xmltype.createxml('
1
Southlake, Texas
Owned
25000
2
Rear load
true
false
Street
10
'));
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/Using-XML-in-SQL-Statements-6.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/Using-XML-in-SQL-Statements.html
ALTER TABLE xwarehouses ADD (PRIMARY KEY(XMLDATA."WarehouseId"));
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/Using-XML-in-SQL-Statements-7.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/Using-XML-in-SQL-Statements.html
SELECT * FROM xwarehouses x
WHERE EXISTSNODE(VALUE(x), '/Warehouse[WarehouseId="1"]',
'xmlns:who="http://www.example.com/xwarehouses.xsd"') = 1;
SELECT * FROM xwarehouses x
WHERE EXTRACTVALUE(VALUE(x), '/Warehouse/WarehouseId',
'xmlns:who="http://www.example.com/xwarehouses.xsd"') = 1;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/Using-XML-in-SQL-Statements-8.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/Using-XML-in-SQL-Statements.html
CREATE TABLE xwarehouses (
warehouse_id NUMBER,
warehouse_spec XMLTYPE)
XMLTYPE warehouse_spec STORE AS CLOB
(TABLESPACE example
STORAGE (INITIAL 6144)
CHUNK 4000
NOCACHE LOGGING);
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/Using-XML-in-SQL-Statements-9.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/Using-XML-in-SQL-Statements.html
CREATE TABLE xwarehouses (
warehouse_id NUMBER,
warehouse_spec XMLTYPE)
XMLTYPE warehouse_spec STORE AS OBJECT RELATIONAL
XMLSCHEMA "http://www.example.com/xwarehouses.xsd"
ELEMENT "Warehouse";
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/VALIDATE_CONVERSION-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/VALIDATE_CONVERSION.html
SELECT VALIDATE_CONVERSION(1000 AS BINARY_DOUBLE)
FROM DUAL;
SELECT VALIDATE_CONVERSION('1234.56' AS BINARY_FLOAT)
FROM DUAL;
SELECT VALIDATE_CONVERSION('July 20, 1969, 20:18' AS DATE,
'Month dd, YYYY, HH24:MI', 'NLS_DATE_LANGUAGE = American')
FROM DUAL;
SELECT VALIDATE_CONVERSION('200 00:00:00' AS INTERVAL DAY TO SECOND)
FROM DUAL;
SELECT VALIDATE_CONVERSION('P1Y2M' AS INTERVAL YEAR TO MONTH)
FROM DUAL;
SELECT VALIDATE_CONVERSION('$100,00' AS NUMBER,
'$999D99', 'NLS_NUMERIC_CHARACTERS = '',.''')
FROM DUAL;
SELECT VALIDATE_CONVERSION('29-Jan-02 17:24:00' AS TIMESTAMP,
'DD-MON-YY HH24:MI:SS')
FROM DUAL;
SELECT VALIDATE_CONVERSION('1999-12-01 11:00:00 -8:00'
AS TIMESTAMP WITH TIME ZONE, 'YYYY-MM-DD HH:MI:SS TZH:TZM')
FROM DUAL;
SELECT VALIDATE_CONVERSION('11-May-16 17:30:00'
AS TIMESTAMP WITH LOCAL TIME ZONE, 'DD-MON-YY HH24:MI:SS')
FROM DUAL;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/VALIDATE_CONVERSION-1.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/VALIDATE_CONVERSION.html
SELECT VALIDATE_CONVERSION('$29.99' AS BINARY_FLOAT)
FROM DUAL;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/VALIDATE_CONVERSION-2.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/VALIDATE_CONVERSION.html
SELECT VALIDATE_CONVERSION('$29.99' AS BINARY_FLOAT, '$99D99')
FROM DUAL;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/VALUE-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/VALUE.html
SELECT VALUE(p) FROM persons p;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/VARIANCE-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/VARIANCE.html
SELECT VARIANCE(salary) "Variance"
FROM employees;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/VARIANCE-1.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/VARIANCE.html
SELECT last_name, salary, VARIANCE(salary)
OVER (ORDER BY hire_date) "Variance"
FROM employees
WHERE department_id = 30
ORDER BY last_name, salary, "Variance";
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/VAR_POP-1.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/VAR_POP.html
SELECT VAR_POP(salary) FROM employees;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/VAR_POP-2.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/VAR_POP.html
SELECT t.calendar_month_desc,
VAR_POP(SUM(s.amount_sold))
OVER (ORDER BY t.calendar_month_desc) "Var_Pop",
VAR_SAMP(SUM(s.amount_sold))
OVER (ORDER BY t.calendar_month_desc) "Var_Samp"
FROM sales s, times t
WHERE s.time_id = t.time_id AND t.calendar_year = 1998
GROUP BY t.calendar_month_desc
ORDER BY t.calendar_month_desc, "Var_Pop", "Var_Samp";
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/VAR_SAMP-1.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/VAR_SAMP.html
SELECT VAR_SAMP(salary) FROM employees;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/VSIZE-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/VSIZE.html
SELECT last_name, VSIZE (last_name) "BYTES"
FROM employees
WHERE department_id = 10
ORDER BY employee_id;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/WIDTH_BUCKET-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/WIDTH_BUCKET.html
SELECT customer_id, cust_last_name, credit_limit,
WIDTH_BUCKET(credit_limit, 100, 5000, 10) "Credit Group"
FROM customers WHERE nls_territory = 'SWITZERLAND'
ORDER BY "Credit Group", customer_id, cust_last_name, credit_limit;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/XML-Conditions-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/XML-Conditions.html
SELECT ANY_PATH FROM RESOURCE_VIEW
WHERE EQUALS_PATH(res, '/sys/schemas/OE/www.example.com')=1;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/XML-Conditions-1.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/XML-Conditions.html
SELECT ANY_PATH FROM RESOURCE_VIEW
WHERE UNDER_PATH(res, '/sys/schemas/OE/www.example.com')=1;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/XMLAGG-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/XMLAGG.html
SELECT XMLELEMENT("Department",
XMLAGG(XMLELEMENT("Employee",
e.job_id||' '||e.last_name)
ORDER BY last_name))
as "Dept_list"
FROM employees e
WHERE e.department_id = 30;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/XMLAGG-1.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/XMLAGG.html
SELECT XMLELEMENT("Department",
XMLAGG(XMLELEMENT("Employee", e.job_id||' '||e.last_name)))
AS "Dept_list"
FROM employees e
GROUP BY e.department_id;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/XMLCDATA-1.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/XMLCDATA.html
SELECT XMLELEMENT("PurchaseOrder",
XMLAttributes(dummy as "pono"),
XMLCdata('
]>')) "XMLCData" FROM DUAL;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/XMLCOLATTVAL-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/XMLCOLATTVAL.html
SELECT XMLELEMENT("Emp",
XMLCOLATTVAL(e.employee_id, e.last_name, e.salary)) "Emp Element"
FROM employees e
WHERE employee_id = 204;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/XMLCOMMENT-1.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/XMLCOMMENT.html
SELECT XMLCOMMENT('OrderAnalysisComp imported, reconfigured, disassembled')
AS "XMLCOMMENT" FROM DUAL;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/XMLCONCAT-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/XMLCONCAT.html
SELECT XMLCONCAT(XMLELEMENT("First", e.first_name),
XMLELEMENT("Last", e.last_name)) AS "Result"
FROM employees e
WHERE e.employee_id > 202;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/XMLDATA-Pseudocolumn-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/XMLDATA-Pseudocolumn.html
CREATE TABLE xml_lob_tab of XMLTYPE
XMLTYPE STORE AS CLOB;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/XMLDATA-Pseudocolumn-1.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/XMLDATA-Pseudocolumn.html
ALTER TABLE xml_lob_tab
MODIFY LOB (XMLDATA) (STORAGE (MAXSIZE 2G) CACHE);
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/XMLDATA-Pseudocolumn-2.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/XMLDATA-Pseudocolumn.html
ALTER TABLE xwarehouses
ADD (UNIQUE(XMLDATA."WarehouseId"));
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/XMLDIFF-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/XMLDIFF.html
SELECT XMLDIFF(
XMLTYPE('
Chapter 1.
Chapter 2.
'),
XMLTYPE('
Chapter 1.
')
)
FROM DUAL;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/XMLELEMENT-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/XMLELEMENT.html
SELECT XMLELEMENT("Emp", XMLELEMENT("Name",
e.job_id||' '||e.last_name),
XMLELEMENT("Hiredate", e.hire_date)) as "Result"
FROM employees e WHERE employee_id > 200;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/XMLELEMENT-1.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/XMLELEMENT.html
SELECT XMLELEMENT("Emp",
XMLATTRIBUTES(e.employee_id AS "ID", e.last_name),
XMLELEMENT("Dept", e.department_id),
XMLELEMENT("Salary", e.salary)) AS "Emp Element"
FROM employees e
WHERE e.employee_id = 206;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/XMLELEMENT-2.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/XMLELEMENT.html
SELECT XMLELEMENT("Emp", XMLATTRIBUTES(e.employee_id, e.last_name),
XMLELEMENT("Dept", XMLATTRIBUTES(e.department_id,
(SELECT d.department_name FROM departments d
WHERE d.department_id = e.department_id) as "Dept_name")),
XMLELEMENT("salary", e.salary),
XMLELEMENT("Hiredate", e.hire_date)) AS "Emp Element"
FROM employees e
WHERE employee_id = 205;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/XMLFOREST-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/XMLFOREST.html
SELECT XMLELEMENT("Emp",
XMLFOREST(e.employee_id, e.last_name, e.salary))
"Emp Element"
FROM employees e WHERE employee_id = 204;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/XMLPARSE-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/XMLPARSE.html
SELECT XMLPARSE(CONTENT '124
Acme Enterprises
32987457
'
WELLFORMED) AS PO FROM DUAL;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/XMLPATCH-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/XMLPATCH.html
SELECT XMLPATCH(
XMLTYPE('
Chapter 1.
Chapter 2.
'),
XMLTYPE('
')
)
FROM DUAL;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/XMLPI-1.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/XMLPI.html
SELECT XMLPI(NAME "Order analysisComp", 'imported, reconfigured, disassembled')
AS "XMLPI" FROM DUAL;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/XMLQUERY-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/XMLQUERY.html
SELECT warehouse_name,
EXTRACTVALUE(warehouse_spec, '/Warehouse/Area'),
XMLQuery(
'for $i in /Warehouse
where $i/Area > 50000
return
{
if ($i/RailAccess = "Y") then "true" else "false"
}
' PASSING warehouse_spec RETURNING CONTENT) "Big_warehouses"
FROM warehouses;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/XMLSEQUENCE-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/XMLSEQUENCE.html
SELECT EXTRACT(warehouse_spec, '/Warehouse') as "Warehouse"
FROM warehouses WHERE warehouse_name = 'San Francisco';
SELECT VALUE(p)
FROM warehouses w,
TABLE(XMLSEQUENCE(EXTRACT(warehouse_spec, '/Warehouse/*'))) p
WHERE w.warehouse_name = 'San Francisco';
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/XMLSERIALIZE-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/XMLSERIALIZE.html
SELECT XMLSERIALIZE(CONTENT XMLTYPE('Grandco')) AS xmlserialize_doc
FROM DUAL;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/XMLTABLE-2.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/XMLTABLE.html
SELECT warehouse_name warehouse,
warehouse2."Water", warehouse2."Rail"
FROM warehouses,
XMLTABLE('/Warehouse'
PASSING warehouses.warehouse_spec
COLUMNS
"Water" varchar2(6) PATH 'WaterAccess',
"Rail" varchar2(6) PATH 'RailAccess')
warehouse2;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/XMLTRANSFORM-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/XMLTRANSFORM.html
CREATE TABLE xsl_tab (col1 XMLTYPE);
INSERT INTO xsl_tab VALUES (
XMLTYPE.createxml(
'
'));
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/XMLTRANSFORM-1.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/XMLTRANSFORM.html
SELECT XMLTRANSFORM(w.warehouse_spec, x.col1).GetClobVal()
FROM warehouses w, xsl_tab x
WHERE w.warehouse_name = 'San Francisco';
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/alter-domain-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/alter-domain.html
ALTER DOMAIN day_of_week
MODIFY DISPLAY LOWER(day_of_week);
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/alter-domain-1.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/alter-domain.html
ALTER DOMAIN day_of_week
DROP DISPLAY;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/alter-domain-2.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/alter-domain.html
ALTER DOMAIN day_of_week
ADD DISPLAY INITCAP(day_of_week);
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/alter-domain-3.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/alter-domain.html
ALTER DOMAIN year_of_birth
MODIFY ORDER MOD(year_of_birth,100);
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/alter-domain-4.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/alter-domain.html
ALTER DOMAIN year_of_birth
DROP ORDER;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/alter-domain-5.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/alter-domain.html
ALTER DOMAIN year_of_birth
ADD ORDER FLOOR(year_of_birth/100);
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/alter-domain-6.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/alter-domain.html
ALTER DOMAIN day_of_week
ANNOTATIONS(Display 'Day of week');
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/alter-mle-env-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/alter-mle-env.html
ALTER MLE ENV scott."myenv" SET LANGUAGE OPTIONS 'js.strict=
true ';
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/alter-mle-module-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/alter-mle-module.html
ALTER MLE MODULE myMLEModule
SET METADATA USING CLOB (
SELECT JSON(
'{
"name": "value",
"version": "1.2.0",
"commitHash": "23fas4h",
"projectName": "Database Backend"
}')
)
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/analytic-view-measure-expressions-5.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/analytic-view-measure-expressions.html
SELECT geography_hier.member_name AS "Region",
units AS "Units",
units_geog_rank_level AS "Rank"
FROM ANALYTIC VIEW (
USING sales_av HIERARCHIES (geography_hier)
ADD MEASURES (
units_geog_rank_level AS (
RANK() OVER (
HIERARCHY geography_hier
ORDER BY units desc nulls last
WITHIN LEVEL))
)
)
WHERE geography_hier.level_name IN ('REGION')
ORDER BY units_geog_rank_level;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/annotations_clause-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/annotations_clause.html
CREATE TABLE t1 (T NUMBER) ANNOTATIONS(Operations '["Sort", "Group"]', Hidden);
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/annotations_clause-1.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/annotations_clause.html
CREATE TABLE t1 (T NUMBER) ANNOTATIONS (ADD Hidden);
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/annotations_clause-2.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/annotations_clause.html
ALTER TABLE t1 ANNOTATIONS(DROP Operations, DROP Hidden);
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/annotations_clause-3.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/annotations_clause.html
CREATE TABLE t1 (T NUMBER ANNOTATIONS(Operations 'Sort' , Hidden) );
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/annotations_clause-4.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/annotations_clause.html
CREATE TABLE employee (
id NUMBER(5)
ANNOTATIONS(Identity, Display 'Employee ID', "Group" 'Emp_Info'),
ename VARCHAR2(50)
ANNOTATIONS(Display 'Employee Name', "Group" 'Emp_Info'),
sal NUMBER
ANNOTATIONS(Display 'Employee Salary', UI_Hidden)
) ANNOTATIONS (Display 'Employee Table');
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/annotations_clause-5.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/annotations_clause.html
ALTER TABLE employee
MODIFY ename ANNOTATIONS (
DROP "Group",
DROP IF EXISTS missing_annotation,
REPLACE Display 'Emp name'
);
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/boolean_and_agg-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/boolean_and_agg.html
SELECT BOOLEAN_AND_AGG(c2)
FROM t;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/boolean_and_agg-1.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/boolean_and_agg.html
SELECT BOOLEAN_AND_AGG(c2)
FROM t
WHERE c1 = 0;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/boolean_and_agg-2.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/boolean_and_agg.html
SELECT BOOLEAN_AND_AGG(c2)
FROM t
WHERE c2 IS FALSE;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/boolean_and_agg-3.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/boolean_and_agg.html
SELECT BOOLEAN_AND_AGG(c2)
FROM t
WHERE c2 IS FALSE OR c2 IS NULL;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/boolean_and_agg-4.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/boolean_and_agg.html
SELECT BOOLEAN_AND_AGG(c2)
FROM t
WHERE c2 IS NOT TRUE OR c2 IS NULL;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/boolean_and_agg-5.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/boolean_and_agg.html
SELECT BOOLEAN_AND_AGG(c2)
FROM t
WHERE c2 IS NOT FALSE OR c2 IS NULL;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/boolean_and_agg-6.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/boolean_and_agg.html
SELECT BOOLEAN_AND_AGG(c2 OR c2 OR (c2))
FROM t
WHERE c2 IS NOT FALSE OR c2 IS NULL;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/boolean_or_agg-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/boolean_or_agg.html
SELECT BOOLEAN_OR_AGG(c2)
FROM t;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/boolean_or_agg-1.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/boolean_or_agg.html
SELECT BOOLEAN_OR_AGG(c2)
FROM t
WHERE c1 = 0;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/boolean_or_agg-2.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/boolean_or_agg.html
SELECT BOOLEAN_OR_AGG(c2)
FROM t
WHERE c2 IS TRUE;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/boolean_or_agg-3.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/boolean_or_agg.html
SELECT BOOLEAN_OR_AGG(c2)
FROM t
WHERE c2 IS TRUE OR c2 IS NULL;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/boolean_or_agg-4.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/boolean_or_agg.html
SELECT BOOLEAN_OR_AGG(c2)
FROM t
WHERE c2 IS NOT FALSE OR c2 IS NULL;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/boolean_or_agg-5.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/boolean_or_agg.html
SELECT BOOLEAN_OR_AGG(c2)
FROM t
WHERE c2 IS NOT TRUE OR c2 IS NULL;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/boolean_or_agg-6.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/boolean_or_agg.html
SELECT BOOLEAN_OR_AGG(c2 OR c2)
FROM t
WHERE c2 IS NOT TRUE OR c2 IS NULL;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ceil-datetime-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ceil-datetime.html
ALTER SESSION SET NLS_DATE_FORMAT = 'DD-MON-YYYY HH24:MI:SS';
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ceil-datetime-1.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ceil-datetime.html
SELECT CEIL(TO_DATE ('28-FEB-2023','DD-MON-YYYY'), 'MM') AS month_ceiling;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ceil-datetime-2.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ceil-datetime.html
SELECT CEIL(TO_TIMESTAMP ('28-FEB-2023 14:10:10','DD-MON-YYYY HH24:MI:SS'),'HH24') AS hour_ceiling;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ceil-interval-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ceil-interval.html
SELECT CEIL(INTERVAL '+123-5' YEAR(3) TO MONTH) AS year_ceil;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ceil-interval-1.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ceil-interval.html
SELECT CEIL(INTERVAL '+99-11' YEAR(2) TO MONTH, 'YEAR');
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ceil-interval-2.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ceil-interval.html
SELECT CEIL(INTERVAL '+999999999-11' YEAR(9) TO MONTH, 'YEAR') AS year_ceil;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ceil-interval-3.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ceil-interval.html
SELECT CEIL(INTERVAL '+4 12:42:10.222' DAY(2) TO SECOND(3), 'DD') AS day_ceil;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/con_id_to_con_name-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/con_id_to_con_name.html
SELECT CON_ID, NAME FROM V$CONTAINERS;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/con_id_to_con_name-1.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/con_id_to_con_name.html
SELECT CON_ID_TO_CON_NAME(4) "CON_NAME" FROM DUAL;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/con_id_to_dbid-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/con_id_to_dbid.html
SELECT CON_ID, NAME, DBID FROM V$CONTAINERS;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/con_id_to_dbid-1.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/con_id_to_dbid.html
SELECT CON_ID_TO_DBID(4) FROM DUAL;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/con_id_to_guid-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/con_id_to_guid.html
SELECT CON_ID, NAME, GUID FROM V$CONTAINERS;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/con_id_to_guid-1.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/con_id_to_guid.html
SELECT CON_ID_TO_GUID(4) "CON_GUID" FROM DUAL;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/con_id_to_uid-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/con_id_to_uid.html
SELECT CON_ID, NAME, CON_UID FROM V$CONTAINERS;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/con_id_to_uid-1.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/con_id_to_uid.html
SELECT CON_ID_TO_UID(4) "PDB_UID" FROM DUAL;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/constraint-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/constraint.html
CREATE TABLE promotions_var1
( promo_id NUMBER(6)
CONSTRAINT promo_id_u UNIQUE
, promo_name VARCHAR2(20)
, promo_category VARCHAR2(15)
, promo_cost NUMBER(10,2)
, promo_begin_date DATE
, promo_end_date DATE
) ;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/constraint-1.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/constraint.html
CREATE TABLE promotions_var2
( promo_id NUMBER(6)
, promo_name VARCHAR2(20)
, promo_category VARCHAR2(15)
, promo_cost NUMBER(10,2)
, promo_begin_date DATE
, promo_end_date DATE
, CONSTRAINT promo_id_u UNIQUE (promo_id)
USING INDEX PCTFREE 20
TABLESPACE stocks
STORAGE (INITIAL 8M) );
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/constraint-10.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/constraint.html
ALTER TABLE dept_20
ADD CONSTRAINT fk_empid_hiredate
FOREIGN KEY (employee_id, hire_date)
REFERENCES hr.job_history(employee_id, start_date)
EXCEPTIONS INTO wrong_emp;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/constraint-11.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/constraint.html
CREATE TABLE divisions
(div_no NUMBER CONSTRAINT check_divno
CHECK (div_no BETWEEN 10 AND 99)
DISABLE,
div_name VARCHAR2(9) CONSTRAINT check_divname
CHECK (div_name = UPPER(div_name))
DISABLE,
office VARCHAR2(10) CONSTRAINT check_office
CHECK (office IN ('DALLAS','BOSTON',
'PARIS','TOKYO'))
DISABLE);
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/constraint-12.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/constraint.html
CREATE TABLE dept_20
(employee_id NUMBER(4) PRIMARY KEY,
last_name VARCHAR2(10),
job_id VARCHAR2(9),
manager_id NUMBER(4),
salary NUMBER(7,2),
commission_pct NUMBER(7,2),
department_id NUMBER(2),
CONSTRAINT check_sal CHECK (salary * commission_pct <= 5000));
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/constraint-13.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/constraint.html
CREATE TABLE order_detail
(CONSTRAINT pk_od PRIMARY KEY (order_id, part_no),
order_id NUMBER
CONSTRAINT fk_oid
REFERENCES oe.orders(order_id),
part_no NUMBER
CONSTRAINT fk_pno
REFERENCES oe.product_information(product_id),
quantity NUMBER
CONSTRAINT nn_qty NOT NULL
CONSTRAINT check_qty CHECK (quantity > 0),
cost NUMBER
CONSTRAINT check_cost CHECK (cost > 0) );
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/constraint-14.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/constraint.html
CREATE TABLE Product(
Id NUMBER NOT NULL PRIMARY KEY,
Name VARCHAR2(50),
Price NUMBER CHECK (mod(price,4) = 0 and 10 <> price) PRECHECK,
Color NUMBER CHECK (Color >= 10 and Color <=50 and mod(color,2) = 0)
PRECHECK,
Description VARCHAR2(50) CHECK (Length(Description) <= 40) PRECHECK,
Constant NUMBER CHECK (Constant=10) PRECHECK,
CONSTRAINT TC1 CHECK (Color > 0 AND Price > 10) PRECHECK,
CONSTRAINT TC2 CHECK (CATEGORY IN ('Home', 'Apparel') AND Price > 10)
);
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/constraint-15.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/constraint.html
ALTER TABLE Product MODIFY (Name VARCHAR2(50) CHECK
(regexp_like(Name, '^Product')) PRECHECK);
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/constraint-16.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/constraint.html
ALTER TABLE Product MODIFY CONSTRAINT TC2 PRECHECK;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/constraint-17.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/constraint.html
ALTER TABLE Product MODIFY CONSTRAINT TC1 NOPRECHECK;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/constraint-19.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/constraint.html
SELECT CONSTRAINT_NAME, SEARCH_CONDITION, PRECHECK
FROM USER_CONSTRAINTS
WHERE table_name='PRODUCT' and constraint_type='C';
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/constraint-2.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/constraint.html
ALTER TABLE warehouses
ADD CONSTRAINT wh_unq UNIQUE (warehouse_id, warehouse_name)
USING INDEX PCTFREE 5
EXCEPTIONS INTO wrong_id;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/constraint-21.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/constraint.html
CREATE TABLE products
( product_id VARCHAR2(20) COLLATE BINARY_CI
CONSTRAINT product_pk PRIMARY KEY
, description VARCHAR2(1000) COLLATE BINARY_CI
CONSTRAINT product_description_unq UNIQUE
);
CREATE TABLE product_components
( component_id VARCHAR2(40) COLLATE BINARY_CI
CONSTRAINT product_component_pk PRIMARY KEY
, product_id CONSTRAINT product_component_fk REFERENCES products(product_id)
, description VARCHAR2(1000) COLLATE BINARY_CI
CONSTRAINT product_component_descr_unq UNIQUE
);
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/constraint-22.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/constraint.html
INSERT INTO products(product_id, description)
VALUES('BICY0001', 'Men''s bicycle, fr 21", wh 24", gear 3x7');
INSERT INTO product_components(component_id, product_id, description)
VALUES('BICY0001_FRAME01', 'BICY0001', 'Aluminium frame 21"');
INSERT INTO product_components(component_id, product_id, description)
VALUES('BICY0001_WHEEL01', 'bicy0001', 'Wheels 24"');
INSERT INTO product_components(component_id, product_id, description)
VALUES('BICY0001_GEAR01', 'Bicy0001', 'Front derailleur 3 chainrings');
INSERT INTO product_components(component_id, product_id, description)
VALUES('BICY0001_gear02', 'BiCy0001', 'Rear derailleur 7 chainrings');
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/constraint-23.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/constraint.html
INSERT INTO products(product_id, description)
VALUES('BICY0002', 'MEN''S BICYCLE, fr 21", wh 24", gear 3x7');
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/constraint-24.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/constraint.html
INSERT INTO products(component_id, product_id, description)
VALUES('bicy0001', 'Women''s bicycle, fr 21", wh 24", gear 2x6');
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/constraint-25.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/constraint.html
INSERT INTO product_components(component_id, product_id, description)
VALUES('BICY0001_gear03', 'BiCy0001', 'REAR DERAILLEUR 7 CHAINRINGS');
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/constraint-26.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/constraint.html
CREATE TYPE person_name AS OBJECT
(first_name VARCHAR2(30), last_name VARCHAR2(30));
/
CREATE TABLE students (name person_name, age INTEGER,
CHECK (name.first_name IS NOT NULL AND
name.last_name IS NOT NULL));
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/constraint-27.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/constraint.html
CREATE TYPE cust_address_typ_new AS OBJECT
( street_address VARCHAR2(40)
, postal_code VARCHAR2(10)
, city VARCHAR2(30)
, state_province VARCHAR2(10)
, country_id CHAR(2)
);
/
CREATE TABLE address_table OF cust_address_typ_new;
CREATE TABLE customer_addresses (
add_id NUMBER,
address REF cust_address_typ_new
SCOPE IS address_table);
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/constraint-28.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/constraint.html
CREATE TABLE customer_addresses (
add_id NUMBER,
address REF cust_address_typ REFERENCES address_table);
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/constraint-29.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/constraint.html
CREATE TABLE employees_obj
( e_name VARCHAR2(100),
e_number NUMBER,
e_dept REF department_typ SCOPE IS departments_obj_t );
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/constraint-3.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/constraint.html
CREATE TABLE locations_demo
( location_id NUMBER(4) CONSTRAINT loc_id_pk PRIMARY KEY
, street_address VARCHAR2(40)
, postal_code VARCHAR2(12)
, city VARCHAR2(30)
, state_province VARCHAR2(25)
, country_id CHAR(2)
) ;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/constraint-30.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/constraint.html
CREATE TABLE employees_obj
( e_name VARCHAR2(100),
e_number NUMBER,
e_dept REF department_typ REFERENCES departments_obj_t);
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/constraint-31.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/constraint.html
CREATE TABLE promotions_var3
( promo_id NUMBER(6)
, promo_name VARCHAR2(20)
, promo_category VARCHAR2(15)
, promo_cost NUMBER(10,2)
, promo_begin_date DATE
, promo_end_date DATE
, CONSTRAINT promo_id_u UNIQUE (promo_id, promo_cost)
USING INDEX (CREATE UNIQUE INDEX promo_ix1
ON promotions_var3 (promo_id, promo_cost))
, CONSTRAINT promo_id_u2 UNIQUE (promo_cost, promo_id)
USING INDEX promo_ix1);
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/constraint-32.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/constraint.html
CREATE TABLE games (scores NUMBER CHECK (scores >= 0));
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/constraint-33.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/constraint.html
CREATE TABLE games
(scores NUMBER, CONSTRAINT unq_num UNIQUE (scores)
INITIALLY DEFERRED DEFERRABLE);
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/constraint-4.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/constraint.html
CREATE TABLE locations_demo
( location_id NUMBER(4)
, street_address VARCHAR2(40)
, postal_code VARCHAR2(12)
, city VARCHAR2(30)
, state_province VARCHAR2(25)
, country_id CHAR(2)
, CONSTRAINT loc_id_pk PRIMARY KEY (location_id));
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/constraint-5.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/constraint.html
ALTER TABLE locations_demo
MODIFY (country_id CONSTRAINT country_nn NOT NULL);
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/constraint-6.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/constraint.html
ALTER TABLE sales
ADD CONSTRAINT sales_pk PRIMARY KEY (prod_id, cust_id) DISABLE;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/constraint-7.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/constraint.html
CREATE TABLE dept_20
(employee_id NUMBER(4),
last_name VARCHAR2(10),
job_id VARCHAR2(9),
manager_id NUMBER(4),
hire_date DATE,
salary NUMBER(7,2),
commission_pct NUMBER(7,2),
department_id CONSTRAINT fk_deptno
REFERENCES departments(department_id) );
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/constraint-8.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/constraint.html
CREATE TABLE dept_20
(employee_id NUMBER(4),
last_name VARCHAR2(10),
job_id VARCHAR2(9),
manager_id NUMBER(4),
hire_date DATE,
salary NUMBER(7,2),
commission_pct NUMBER(7,2),
department_id,
CONSTRAINT fk_deptno
FOREIGN KEY (department_id)
REFERENCES departments(department_id) );
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/constraint-9.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/constraint.html
CREATE TABLE dept_20
(employee_id NUMBER(4) PRIMARY KEY,
last_name VARCHAR2(10),
job_id VARCHAR2(9),
manager_id NUMBER(4) CONSTRAINT fk_mgr
REFERENCES employees ON DELETE SET NULL,
hire_date DATE,
salary NUMBER(7,2),
commission_pct NUMBER(7,2),
department_id NUMBER(2) CONSTRAINT fk_deptno
REFERENCES departments(department_id)
ON DELETE CASCADE );
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/create-domain-10.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/create-domain.html
CREATE DOMAIN US_city AS
(
name AS VARCHAR2(30) ANNOTATIONS (Address),
state AS VARCHAR2(2) ANNOTATIONS (Address),
zip AS NUMBER ANNOTATIONS (Address)
)
CONSTRAINT City_CK CHECK(state in ('CA','AZ','TX') and zip < 100000)
DISPLAY name||', '|| state ||', '||TO_CHAR(zip)
ORDER state||', '||TO_CHAR(zip)||', '||name
ANNOTATIONS (Title 'Domain Annotation');
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/create-domain-11.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/create-domain.html
CREATE DOMAIN flight_details AS
(
flight_num AS VARCHAR2(100) NOT NULL,
origin AS VARCHAR2(200)
CONSTRAINT origin_3_char_c CHECK (LENGTH(origin) = 3),
destination AS VARCHAR2(200)
CONSTRAINT dest_3_char_c CHECK (LENGTH(destination) = 3)
)
CONSTRAINT flight_c
CHECK
(
flight_num LIKE '%-%' AND
origin IS NOT NULL AND
destination IS NOT NULL
)
CONSTRAINT origin_dest_different_c
CHECK (origin <> destination)
DISPLAY flight_num||', '||origin||', '||destination
ORDER flight_num||destination;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/create-domain-12.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/create-domain.html
CREATE DOMAIN meals_details AS
(
restaurant AS VARCHAR2(100) NOT NULL,
meal_type AS VARCHAR2(200),
diner_count AS NUMBER
)
CONSTRAINT meals_c
CHECK
(
restaurant IS NOT NULL AND
meal_type IN ('Breakfast', 'Lunch', 'Dinner') AND
diner_count IS NOT NULL
)
DISPLAY meal_type||', '||restaurant||', '||diner_count;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/create-domain-13.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/create-domain.html
CREATE DOMAIN lodging_details AS
(
hotel AS VARCHAR2(100) NOT NULL,
nights_count AS NUMBER
)
CONSTRAINT lodging_c
CHECK (hotel IS NOT NULL AND nights_count > 0)
DISPLAY hotel||', '||nights_count;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/create-domain-14.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/create-domain.html
CREATE FLEXIBLE DOMAIN expense_details (val1, val2, val3, val4)
CHOOSE DOMAIN USING (typ VARCHAR2(10))
FROM DECODE(typ,
'Flight', flight_details(val1, val2, val3),
'Meals', meals_details(val1, val2, val4),
'Lodging', lodging_details(val1, val4));
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/create-domain-15.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/create-domain.html
CREATE FLEXIBLE DOMAIN expense_details (val1, val2, val3, val4)
CHOOSE DOMAIN USING(typ VARCHAR2(10))
FROM CASE
WHEN typ BETWEEN 'A' AND 'G' THEN flight_details(val1, val2, val3)
WHEN typ = 'Meals' THEN meals_details(val1, val2, val4)
WHEN typ LIKE 'Lodg%' THEN lodging_details(val1, val4)
END;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/create-domain-16.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/create-domain.html
CREATE DOMAIN w2_form AS JSON
CONSTRAINT CHECK (VALUE IS JSON VALIDATE USING '{
"title": "W2_form",
"type": "object",
"properties": {
"social_security_number": {
"type": "string",
"description": "The person social security number."
},
"wages": {
"description": "total wages",
"type": "number",
"minimum": 0
},
"social_security_wages": {
"type": "number",
"description": "wages subject to social security tax"
},
"Federal Income Tax Withheld": {
"type": "number",
"description": "withheld of tax to federal income tax"
},
"Social Security Tax Withheld": {
"type": "number",
"description": "withheld of social security tax"
}
},
"required": [
"social_security_number",
"wages",
"Federal Income Tax Withheld"
]
}'
);
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/create-domain-17.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/create-domain.html
CREATE TABLE tax_report(id NUMBER, income JSON DOMAIN w2_form);
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/create-domain-18.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/create-domain.html
INSERT INTO tax_report VALUES
(1, '{"wages": 100, "social_security_number": "111", "Federal Income Tax Withheld":10}'
);
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/create-domain-19.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/create-domain.html
INSERT INTO tax_report VALUES
(2, '{"wages": 100}'
);
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/create-domain-20.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/create-domain.html
CREATE DOMAIN w2_form AS JSON VALIDATE USING '{
"title": "W2_form",
"type": "object",
"properties": {
"social_security_number": {
"type": "string",
"description": "The person social security number."
},
"wages": {
"description": "total wages",
"type": "number",
"minimum": 0
},
"social_security_wages": {
"type": "number",
"description": "wages subject to social security tax"
},
"Federal Income Tax Withheld": {
"type": "number",
"description": "withheld of tax to federal income tax"
},
"Social Security Tax Withheld": {
"type": "number",
"description": "withheld of social security tax"
}
},
"required": [
"social_security_number",
"wages",
"Federal Income Tax Withheld"
]
}';
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/create-domain-21.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/create-domain.html
CREATE DOMAIN email AS VARCHAR2(30)
CONSTRAINT EMAIL_C CHECK (REGEXP_LIKE (email, '^(\S+)\@(\S+)\.(\S+)$'))
DISPLAY '---' || SUBSTR(email, INSTR(email, '@') + 1)
ANNOTATIONS(allowed_operations
'{
"allowed_operations": {
"title": "Allowed operations",
"operations": [
"Sort",
"Group By",
"Picklist"
]
}
}');
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/create-domain-22.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/create-domain.html
SELECT jt.* FROM user_annotations_usage a,
JSON_TABLE (annotation_value,
'$.allowed_operations.operations[*]'
COLUMNS (value VARCHAR2(50 CHAR) PATH '$')) jt
WHERE annotation_name = 'ALLOWED_OPERATIONS'
AND object_name = 'EMAIL' ;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/create-domain-24.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/create-domain.html
CREATE DOMAIN temperature AS NUMBER(3)
ANNOTATIONS (display_units '{ "units": ["celsius", "fahrenheit"] }');
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/create-domain-25.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/create-domain.html
SELECT jt.* FROM user_annotations_usage,
JSON_TABLE(annotation_value, '$.units[*]'
COLUMNS (value VARCHAR2(30 CHAR) PATH '$')) jt
WHERE annotation_name = 'DISPLAY_UNITS'
AND object_name = 'TEMPERATURE';
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/create-domain-27.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/create-domain.html
CREATE DOMAIN dj5 AS JSON CONSTRAINT dj5chk
CHECK (dj5 IS JSON validate
'{
"type": "object",
"properties": {
"a": {
"type": "number"
}
}
}'
);
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/create-domain-28.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/create-domain.html
CREATE TABLE jtab(
id NUMBER PRIMARY KEY,
jcol JSON DOMAIN dj5
);
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/create-domain-29.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/create-domain.html
CREATE DOMAIN order_status AS
ENUM (
New ,
Open ,
Shipped ,
Closed ,
Cancelled
);
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/create-domain-30.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/create-domain.html
SELECT * FROM order_status;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/create-domain-32.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/create-domain.html
CREATE TABLE orders (
id NUMBER,
cust VARCHAR2(100),
status ORDER_STATUS
);
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/create-domain-33.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/create-domain.html
DESCRIBE orders;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/create-domain-35.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/create-domain.html
INSERT INTO orders VALUES
(1, 'Costco', order_status.open ),
(2, 'BMW', order_status.closed ),
(3, 'Nestle', order_status.shipped );
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/create-domain-36.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/create-domain.html
SELECT ID, DOMAIN_DISPLAY(STATUS) FROM orders;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/create-domain-38.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/create-domain.html
SELECT ID, STATUS FROM orders;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/create-domain-4.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/create-domain.html
CREATE DOMAIN day_of_week AS CHAR(3 CHAR)
CONSTRAINT day_of_week_c
CHECK (UPPER(VALUE) IN ('MON', 'TUE', 'WED', 'THU', 'FRI', 'SAT', 'SUN'))
DEFERRABLE INITIALLY DEFERRED
DISPLAY SUBSTR(VALUE, 1, 2);
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/create-domain-40.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/create-domain.html
UPDATE orders SET STATUS = 2 WHERE STATUS = 5;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/create-domain-41.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/create-domain.html
SELECT 2 * ORDER_STATUS.CANCELLED;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/create-domain-43.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/create-domain.html
CREATE DOMAIN days_of_week AS
ENUM (
Sunday = Su = 0,
Monday = Mo,
Tuesday = Tu,
Wednesday = We,
Thursday = Th,
Friday = Fr,
Saturday = Sa
);
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/create-domain-5.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/create-domain.html
CREATE DOMAIN year_of_birth AS NUMBER(4)
CONSTRAINT CHECK ( (trunc(year_of_birth) = year_of_birth) and (year_of_birth >= 1900) )
DISPLAY (CASE WHEN year_of_birth < 2000 THEN '19-' ELSE '20-' END) || MOD(year_of_birth, 100)
ORDER year_of_birth-1900 ;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/create-domain-6.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/create-domain.html
CREATE DOMAIN day_of_week AS CHAR(3 CHAR)
CONSTRAINT day_of_week_c
CHECK (day_of_week IN ('MON', 'TUE', 'WED', 'THU', 'FRI', 'SAT', 'SUN'))
INITIALLY DEFERRED
ORDER CASE day_of_week
WHEN 'MON' THEN 0
WHEN 'TUE' THEN 1
WHEN 'WED' THEN 2
WHEN 'THU' THEN 3
WHEN 'FRI' THEN 4
WHEN 'SAT' THEN 5
WHEN 'SUN' THEN 6
ELSE 7
END;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/create-domain-7.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/create-domain.html
CREATE SEQUENCE IF NOT EXISTS email_seq;
CREATE DOMAIN email AS VARCHAR2(30)
DEFAULT ON NULL email_seq.NEXTVAL || '@domain.com'
CONSTRAINT EMAIL_C CHECK (REGEXP_LIKE (email, '^(\S+)\@(\S+)\.(\S+)$'))
DISPLAY '---' || SUBSTR(email, INSTR(email, '@') + 1);
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/create-domain-8.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/create-domain.html
CREATE DOMAIN dept_codes AS NUMBER(3) STRICT
CONSTRAINT dept_chk CHECK (dept_codes > 99 AND dept_codes != 200)
ANNOTATIONS (Title 'Domain Annotation');
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/create-domain-9.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/create-domain.html
CREATE DOMAIN hourly_wages AS NUMBER(10)
DEFAULT ON NULL 15
CONSTRAINT minimal_wage_c
CHECK (hourly_wages >= 7 and hourly_wages <=1000) ENABLE
DISPLAY TO_CHAR(hourly_wages, '$999.99')
ORDER ( -1*hourly_wages )
ANNOTATIONS (Title 'Domain Annotation');
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/create-mle-env-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/create-mle-env.html
CREATE MLE ENV scott."myenv";
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/create-mle-env-1.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/create-mle-env.html
CREATE MLE ENV scott."myenv" CLONE "other_env";
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/create-property-graph-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/create-property-graph.html
CREATE PROPERTY GRAPH “myGraph” VERTEX TABLES (my_table_1);
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/create-property-graph-1.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/create-property-graph.html
CREATE PROPERTY GRAPH “myGraph” VERTEX TABLES (other_schema.my_table_1);
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/create-property-graph-10.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/create-property-graph.html
ALTER TABLE t DROP CONSTRAINT fkc;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/create-property-graph-11.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/create-property-graph.html
ALTER TABLE t DISABLE CONSTRAINT fkc;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/create-property-graph-12.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/create-property-graph.html
ALTER TABLE t ENABLE NOVALIDATE CONSTRAINT fkc;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/create-property-graph-13.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/create-property-graph.html
DROP TABLE t ;
DROP MATERIALIZED VIEW t;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/create-property-graph-14.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/create-property-graph.html
RENAME t TO t2;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/create-property-graph-16.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/create-property-graph.html
ALTER TABLE t RENAME C TO C2;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/create-property-graph-17.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/create-property-graph.html
CREATE PROPERTY GRAPH “myGraph”
VERTEX TABLES (“myschema”. “mytable”, “mytable2” AS T2);
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/create-property-graph-18.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/create-property-graph.html
CREATE PROPERTY GRAPH “myGraph”
VERTEX TABLES (“myschema”. “mytable” LABEL “person”);
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/create-property-graph-19.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/create-property-graph.html
CREATE PROPERTY GRAPH “myGraph”
VERTEX TABLES (“myschema”. “mytable” LABEL “mytable”);
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/create-property-graph-2.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/create-property-graph.html
CREATE PROPERTY GRAPH “myGraph”
VERTEX TABLES (
VT1,
VT2 KEY(PK2),
VT3 KEY(PK31, PK32),
VT2 AS ALTVT2 KEY(PK4)
);
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/create-property-graph-23.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/create-property-graph.html
CREATE PROPERTY GRAPH “myGraph”
VERTEX TABLES (“myschema”. “mytable” LABEL “foo” LABEL “bar”);
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/create-property-graph-3.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/create-property-graph.html
CREATE PROPERTY GRAPH “myGraph” VERTEX TABLES (my_table_1, other_schema.my_table_1 AS my_table2);
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/create-property-graph-4.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/create-property-graph.html
CREATE PROPERTY GRAPH “myGraph”
VERTEX TABLES (
VT1,
VT2 KEY(PK2),
VT3 KEY(PK31, PK32),
VT2 AS ALTVT2 KEY(PK4)
)
EDGE TABLES (
E1 SOURCE VT1
DESTINATION VT2,
E2 SOURCE KEY(FK1) REFERENCES VT1 (PK1)
DESTINATION KEY(FK2) REFERENCES VT2 (PK2),
E3 SOURCE KEY(FK1) REFERENCES VT1 (PK1)
DESTINATION VT2,
E4 SOURCE VT1
DESTINATION KEY(FK5) REFERENCES VT2(RK5))
;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/create-property-graph-7.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/create-property-graph.html
ALTER TABLE t DROP CONSTRAINT pkc;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/create-property-graph-8.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/create-property-graph.html
ALTER TABLE t DISABLE CONSTRAINT pkc;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/create-property-graph-9.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/create-property-graph.html
ALTER TABLE t ENABLE NOVALIDATE CONSTRAINT pkc;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/create-vector-index-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/create-vector-index.html
CREATE VECTOR INDEX galaxies_hnsw_idx ON galaxies (embedding) ORGANIZATION INMEMORY NEIGHBOR GRAPH
DISTANCE COSINE
WITH TARGET ACCURACY 95;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/create-vector-index-1.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/create-vector-index.html
CREATE VECTOR INDEX galaxies_hnsw_idx ON galaxies (embedding) ORGANIZATION INMEMORY NEIGHBOR GRAPH
DISTANCE COSINE
WITH TARGET ACCURACY 90 PARAMETERS (type HNSW, neighbors 40, efconstruction 500);
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/create-vector-index-2.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/create-vector-index.html
CREATE VECTOR INDEX galaxies_ivf_idx ON galaxies (embedding) ORGANIZATION NEIGHBOR PARTITIONS
DISTANCE COSINE
WITH TARGET ACCURACY 95;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/create-vector-index-3.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/create-vector-index.html
CREATE VECTOR INDEX galaxies_ivf_idx ON galaxies (embedding) ORGANIZATION NEIGHBOR PARTITIONS
DISTANCE COSINE
WITH TARGET ACCURACY 90 PARAMETERS (type IVF, neighbor partitions 10);
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/domain_check-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/domain_check.html
CREATE DOMAIN dgreater AS (c1 AS NUMBER, c2 AS NUMBER ) CHECK (c1 > c2);
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/domain_check-1.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/domain_check.html
CREATE DOMAIN three_chars AS CHAR(3 CHAR) STRICT;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/domain_check-10.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/domain_check.html
SELECT order_id,
product_id,
amount,
currency_code,
DOMAIN_CHECK(currency, order_id, product_id) order_product,
DOMAIN_CHECK(currency, amount, currency_code) amount_currency,
DOMAIN_CHECK(currency, currency_code, amount) currency_amount,
DOMAIN_CHECK(currency, order_id, currency_code) order_currency
FROM order_items;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/domain_check-11.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/domain_check.html
SELECT DOMAIN_CHECK(not_a_domain, 'raises an error');
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/domain_check-2.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/domain_check.html
SELECT DOMAIN_CHECK (three_chars, 'ab') two_chars,
DOMAIN_CHECK (three_chars, 'abc') three_chars,
DOMAIN_CHECK (three_chars, 'abcd') four_chars;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/domain_check-3.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/domain_check.html
CREATE DOMAIN dgreater AS (
c1 AS NUMBER, c2 AS NUMBER
)
CHECK (c1 > c2);
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/domain_check-4.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/domain_check.html
SELECT DOMAIN_CHECK (dgreater, 1) one_expr;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/domain_check-5.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/domain_check.html
SELECT DOMAIN_CHECK (dgreater, 1, 2) first_lower,
DOMAIN_CHECK (dgreater, 2, 1) first_higher,
DOMAIN_CHECK (dgreater, 'b', 'a') letters;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/domain_check-6.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/domain_check.html
CREATE DOMAIN day_of_week AS CHAR(3 CHAR);
CREATE TABLE calendar_dates (
calendar_date DATE,
day_of_week_abbr day_of_week
);
INSERT INTO calendar_dates
VALUES(DATE'2023-05-01', 'MON'),
(DATE'2023-05-02', 'tue'),
(DATE'2023-05-05', 'fRI');
SELECT day_of_week_abbr,
DOMAIN_CHECK(day_of_week, day_of_week_abbr) domain_column,
DOMAIN_CHECK(day_of_week, calendar_date) nondomain_column,
DOMAIN_CHECK(day_of_week, CAST('MON' AS day_of_week)) domain_value,
DOMAIN_CHECK(day_of_week, 'mon') nondomain_value
FROM calendar_dates;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/domain_check-7.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/domain_check.html
CREATE DOMAIN day_of_week AS CHAR(3 CHAR)
CONSTRAINT CHECK(day_of_week IN ('MON','TUE','WED','THU','FRI','SAT','SUN'))
INITIALLY DEFERRED;
CREATE TABLE calendar_dates (
calendar_date DATE,
day_of_week_abbr day_of_week
);
INSERT INTO calendar_dates
VALUES(DATE'2023-05-01', 'MON'),
(DATE'2023-05-02', 'tue'),
(DATE'2023-05-05', 'fRI');
SELECT day_of_week_abbr,
DOMAIN_CHECK(day_of_week, day_of_week_abbr) domain_column,
DOMAIN_CHECK(day_of_week, calendar_date) nondomain_column,
DOMAIN_CHECK(day_of_week, CAST('MON' AS day_of_week)) domain_value,
DOMAIN_CHECK(day_of_week, 'mon') nondomain_value
FROM calendar_dates;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/domain_check-9.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/domain_check.html
CREATE TABLE order_items (
order_id INTEGER,
product_id INTEGER,
amount NUMBER(10, 2),
currency_code CHAR(3 CHAR),
DOMAIN currency(amount, currency_code)
);
INSERT INTO order_items
VALUES (1, 1, 9.99, 'USD'),
(2, 2, 1234.56, 'GBP'),
(3, 3, -999999, 'JPY'),
(4, 4, 3141592, 'XXX') ,
(5, 5, 2718281, '123');
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/domain_check_type-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/domain_check_type.html
CREATE DOMAIN three_chars AS CHAR(3 CHAR) STRICT;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/domain_check_type-1.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/domain_check_type.html
SELECT DOMAIN_CHECK_TYPE (three_chars, 'ab') two_chars,
DOMAIN_CHECK_TYPE (three_chars, 'abc') three_chars,
DOMAIN_CHECK_TYPE (three_chars, 'abcd') four_chars;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/domain_check_type-10.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/domain_check_type.html
SELECT DOMAIN_CHECK_TYPE(not_a_domain, 'raises an error');
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/domain_check_type-2.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/domain_check_type.html
CREATE DOMAIN dgreater AS (
c1 AS NUMBER, c2 AS NUMBER
)
CHECK (c1 > c2);
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/domain_check_type-3.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/domain_check_type.html
SELECT DOMAIN_CHECK_TYPE (dgreater, 1) one_expr;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/domain_check_type-4.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/domain_check_type.html
SELECT DOMAIN_CHECK_TYPE (dgreater, 1, 2) first_lower,
DOMAIN_CHECK_TYPE (dgreater, 2, 1) first_higher,
DOMAIN_CHECK_TYPE (dgreater, 'b', 'a') letters;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/domain_check_type-5.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/domain_check_type.html
CREATE DOMAIN day_of_week AS CHAR(3 CHAR);
CREATE TABLE calendar_dates (
calendar_date DATE,
day_of_week_abbr day_of_week
);
INSERT INTO calendar_dates
VALUES(DATE'2023-05-01', 'MON'),
(DATE'2023-05-02', 'tue'),
(DATE'2023-05-05', 'fRI');
SELECT day_of_week_abbr,
DOMAIN_CHECK_TYPE(day_of_week, day_of_week_abbr) domain_column,
DOMAIN_CHECK_TYPE(day_of_week, calendar_date) nondomain_column,
DOMAIN_CHECK_TYPE(day_of_week, CAST('MON' AS day_of_week)) domain_value,
DOMAIN_CHECK_TYPE(day_of_week, 'mon') nondomain_value
FROM calendar_dates;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/domain_check_type-6.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/domain_check_type.html
CREATE DOMAIN day_of_week AS CHAR(3 CHAR)
CONSTRAINT CHECK(day_of_week IN ('MON','TUE','WED','THU','FRI','SAT','SUN'))
INITIALLY DEFERRED;
CREATE TABLE calendar_dates (
calendar_date DATE,
day_of_week_abbr day_of_week
);
INSERT INTO calendar_dates
VALUES(DATE'2023-05-01', 'MON'),
(DATE'2023-05-02', 'tue'),
(DATE'2023-05-05', 'fRI');
SELECT day_of_week_abbr,
DOMAIN_CHECK_TYPE(day_of_week, day_of_week_abbr) domain_column,
DOMAIN_CHECK_TYPE(day_of_week, calendar_date) nondomain_column,
DOMAIN_CHECK_TYPE(day_of_week, CAST('MON' AS day_of_week)) domain_value,
DOMAIN_CHECK_TYPE(day_of_week, 'mon') nondomain_value
FROM calendar_dates;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/domain_check_type-8.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/domain_check_type.html
CREATE TABLE order_items (
order_id INTEGER,
product_id INTEGER,
amount NUMBER(10, 2),
currency_code CHAR(3 CHAR),
DOMAIN currency(amount, currency_code)
);
INSERT INTO order_items
VALUES (1, 1, 9.99, 'USD'),
(2, 2, 1234.56, 'GBP'),
(3, 3, -999999, 'JPY'),
(4, 4, 3141592, 'XXX') ,
(5, 5, 2718281, '123');
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/domain_check_type-9.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/domain_check_type.html
SELECT order_id,
product_id,
amount,
currency_code,
DOMAIN_CHECK_TYPE(currency, order_id, product_id) order_product,
DOMAIN_CHECK_TYPE(currency, amount, currency_code) amount_currency,
DOMAIN_CHECK_TYPE(currency, currency_code, amount) currency_amount,
DOMAIN_CHECK_TYPE(currency, order_id, currency_code) order_currency
FROM order_items;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/domain_display-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/domain_display.html
CREATE DOMAIN day_of_week AS CHAR(3 CHAR)
DISPLAY INITCAP(day_of_week);
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/domain_display-1.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/domain_display.html
CREATE TABLE calendar_dates (
calendar_date DATE,
day_of_week_abbr day_of_week
);
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/domain_display-2.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/domain_display.html
INSERT INTO calendar_dates
VALUES(DATE'2023-05-01', 'MON'),
(DATE'2023-05-02', 'tue'),
(DATE'2023-05-05', 'fRI');
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/domain_display-3.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/domain_display.html
SELECT day_of_week_abbr,
DOMAIN_DISPLAY(day_of_week_abbr) domain_column,
DOMAIN_DISPLAY(calendar_date) nondomain_column,
DOMAIN_DISPLAY(CAST('MON' AS day_of_week)) domain_value,
DOMAIN_DISPLAY('MON') nondomain_value
FROM calendar_dates;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/domain_display-5.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/domain_display.html
CREATE TABLE order_items (
order_id INTEGER,
product_id INTEGER,
amount NUMBER(10, 2),
currency_code CHAR(3 CHAR),
DOMAIN currency(amount, currency_code)
);
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/domain_display-6.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/domain_display.html
INSERT INTO order_items
VALUES (1, 1, 9.99, 'USD'),
(2, 2, 1234.56, 'GBP'),
(3, 3, 4321, 'EUR'),
(4, 4, 3141592, 'JPY');
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/domain_display-7.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/domain_display.html
SELECT order_id,
product_id,
DOMAIN_DISPLAY(amount, currency_code) domain_cols,
DOMAIN_DISPLAY(currency_code, amount) domain_cols_wrong_order,
DOMAIN_DISPLAY(order_id, product_id) nondomain_cols,
DOMAIN_DISPLAY(amount) domain_cols_subset
FROM order_items;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/domain_name-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/domain_name.html
CREATE DOMAIN hr.day_of_week AS CHAR(3 CHAR);
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/domain_name-1.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/domain_name.html
CREATE TABLE hr.calendar_dates (
calendar_date DATE,
day_of_week_abbr hr.day_of_week
);
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/domain_name-2.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/domain_name.html
INSERT INTO hr.calendar_dates
VALUES(DATE'2023-05-01', 'MON');
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/domain_name-3.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/domain_name.html
SELECT day_of_week_abbr,
DOMAIN_NAME(day_of_week_abbr) domain_column,
DOMAIN_NAME(calendar_date) nondomain_column,
DOMAIN_NAME(CAST('MON' AS hr.day_of_week)) domain_value,
DOMAIN_NAME('MON') nondomain_value
FROM hr.calendar_dates;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/domain_name-5.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/domain_name.html
CREATE TABLE co.order_items (
order_id INTEGER,
product_id INTEGER,
amount NUMBER(10, 2),
currency_code CHAR(3 CHAR),
DOMAIN co.currency(amount, currency_code)
);
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/domain_name-6.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/domain_name.html
INSERT INTO co.order_items
VALUES (1, 1, 9.99, 'USD');
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/domain_name-7.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/domain_name.html
SELECT order_id,
product_id,
DOMAIN_NAME(amount, currency_code) domain_cols,
DOMAIN_NAME(currency_code, amount) domain_cols_wrong_order,
DOMAIN_NAME(order_id, product_id) nondomain_cols,
DOMAIN_NAME(amount) domain_cols_subset
FROM co.order_items
ORDER BY domain_cols;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/domain_order-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/domain_order.html
CREATE DOMAIN day_of_week AS CHAR(3 CHAR)
ORDER CASE UPPER(day_of_week)
WHEN 'MON' THEN 0
WHEN 'TUE' THEN 1
WHEN 'WED' THEN 2
WHEN 'THU' THEN 3
WHEN 'FRI' THEN 4
WHEN 'SAT' THEN 5
WHEN 'SUN' THEN 6
ELSE 7
END;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/domain_order-1.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/domain_order.html
CREATE TABLE calendar_dates (
calendar_date DATE,
day_of_week_abbr day_of_week
);
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/domain_order-2.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/domain_order.html
INSERT INTO calendar_dates
VALUES(DATE'2023-05-01', 'MON'),
(DATE'2023-05-02', 'TUE'),
(DATE'2023-05-05', 'FRI'),
(DATE'2023-05-08', 'mon');
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/domain_order-3.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/domain_order.html
SELECT day_of_week_abbr,
DOMAIN_ORDER(day_of_week_abbr) domain_column,
DOMAIN_ORDER(calendar_date) nondomain_column,
DOMAIN_ORDER(CAST('MON' AS day_of_week)) domain_value,
DOMAIN_ORDER('MON') nondomain_value
FROM calendar_dates
ORDER BY DOMAIN_ORDER(day_of_week_abbr);
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/domain_order-5.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/domain_order.html
CREATE TABLE order_items (
order_id INTEGER,
product_id INTEGER,
amount NUMBER(10, 2),
currency_code CHAR(3 CHAR),
DOMAIN currency(amount, currency_code)
);
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/domain_order-6.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/domain_order.html
INSERT INTO order_items
VALUES (1, 1, 9.99, 'USD'),
(2, 2, 1234.56, 'USD'),
(3, 3, 4321, 'EUR'),
(4, 4, 3141592, 'JPY'),
(5, 5, 2718281, 'JPY');
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/domain_order-7.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/domain_order.html
SELECT order_id,
product_id,
DOMAIN_ORDER(amount, currency_code) domain_cols,
DOMAIN_ORDER(currency_code, amount) domain_cols_wrong_order,
DOMAIN_ORDER(order_id, product_id) nondomain_cols,
DOMAIN_ORDER(amount) domain_cols_subset
FROM order_items
ORDER BY domain_cols;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/drop-domain-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/drop-domain.html
DROP DOMAIN email;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/drop-domain-1.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/drop-domain.html
DROP DOMAIN day_of_week;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/drop-domain-2.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/drop-domain.html
DROP DOMAIN day_of_week FORCE PRESERVE;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/drop-pmem-filestore-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/drop-pmem-filestore.html
DROP PMEM FILESTORE cloud_db_1 EXCLUDING CONTENTS
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/file_specification-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/file_specification.html
CREATE DATABASE payable
LOGFILE GROUP 1 ('diska:log1.log', 'diskb:log1.log') SIZE 50K,
GROUP 2 ('diska:log2.log', 'diskb:log2.log') SIZE 50K
DATAFILE 'diskc:dbone.dbf' SIZE 30M;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/file_specification-1.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/file_specification.html
ALTER DATABASE payable
ADD LOGFILE GROUP 3 ('diska:log3.log', 'diskb:log3.log')
SIZE 50K REUSE;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/file_specification-2.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/file_specification.html
ALTER DATABASE ADD LOGFILE GROUP 5
('4k_disk_a:log5.log', '4k_disk_b:log5.log')
SIZE 100M BLOCKSIZE 4096 REUSE;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/file_specification-3.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/file_specification.html
CREATE TABLESPACE stocks
DATAFILE 'stock1.dbf' SIZE 10M,
'stock2.dbf' SIZE 10M,
'stock3.dbf' SIZE 10M;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/file_specification-4.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/file_specification.html
ALTER TABLESPACE stocks
ADD DATAFILE 'stock4.dbf' SIZE 10M REUSE;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/file_specification-5.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/file_specification.html
ALTER DATABASE testdb
DATAFILE '+dgroup_01/testdb/datafile/system.261.1' ONLINE;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/floor-datetime-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/floor-datetime.html
ALTER SESSION SET NLS_DATE_FORMAT = 'DD-MON-YYYY HH24:MI:SS';
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/floor-datetime-1.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/floor-datetime.html
SELECT FLOOR(TO_DATE ('28-FEB-2023','DD-MON-YYYY'), 'MM') AS month_floor;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/floor-datetime-2.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/floor-datetime.html
SELECT FLOOR(TO_TIMESTAMP ('28-FEB-2023 14:10:10','DD-MON-YYYY HH24:MI:SS'),'HH24') AS hour_floor;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/floor-interval-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/floor-interval.html
SELECT FLOOR(INTERVAL '+123-5' YEAR(3) TO MONTH) as year_floor;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/floor-interval-1.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/floor-interval.html
SELECT FLOOR(INTERVAL '+99-11' YEAR(2) TO MONTH, 'YEAR') as year_floor;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/floor-interval-2.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/floor-interval.html
SELECT FLOOR(INTERVAL '+4 12:42:10.222' DAY(2) TO SECOND(3), 'DD') as year_floor;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/from_vector-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/from_vector.html
SELECT FROM_VECTOR(TO_VECTOR('[1, 2, 3]') );
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/from_vector-1.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/from_vector.html
SELECT FROM_VECTOR(TO_VECTOR('[1.1, 2.2, 3.3]', 3, FLOAT32) );
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/from_vector-2.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/from_vector.html
SELECT FROM_VECTOR( TO_VECTOR('[1.1, 2.2, 3.3]', 3, FLOAT32) RETURNING VARCHAR2(1000));
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/from_vector-3.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/from_vector.html
SELECT FROM_VECTOR(TO_VECTOR('[1.1, 2.2, 3.3]', 3, FLOAT32) RETURNING CLOB );
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/from_vector-4.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/from_vector.html
SELECT FROM_VECTOR(TO_VECTOR('[5,[2,4],[1.0,2.0]]', 5, FLOAT64, SPARSE) RETURNING CLOB FORMAT SPARSE);
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/from_vector-5.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/from_vector.html
SELECT FROM_VECTOR(TO_VECTOR('[5,[2,4],[1.0,2.0]]', 5, FLOAT64, SPARSE) RETURNING CLOB FORMAT DENSE);
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/from_vector-6.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/from_vector.html
SELECT dataVec FROM vecTab;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/from_vector-7.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/from_vector.html
SELECT FROM_VECTOR(dataVec) FROM vecTab;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/graph-pattern-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/graph-pattern.html
SELECT *
FROM GRAPH_TABLE ( students_graph
MATCH (a IS person) <-[e1 IS friends]- (b IS person)
<-[e2 IS friends]- (c IS person)
<-[e3 is friends]- (a IS person)
WHERE a.name= 'Mary'
COLUMNS (a.name AS person_a, b.name AS person_b, c.name AS person_c)
);
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/graph-pattern-10.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/graph-pattern.html
SELECT *
FROM GRAPH_TABLE ( students_graph
MATCH (n IS person) -[IS friends]-{2}(m IS person)
WHERE n.name = 'Mary' AND m.name <> n.name
COLUMNS (m.name AS fof)
);
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/graph-pattern-11.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/graph-pattern.html
SELECT *
FROM GRAPH_TABLE ( students_graph
MATCH (n IS person) (-[IS friends]-){2}(m IS person)
WHERE n.name = 'Mary' AND m.name <> n.name
COLUMNS (m.name AS fof)
);
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/graph-pattern-13.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/graph-pattern.html
SELECT COUNT(*)
FROM GRAPH_TABLE ( students_graph
MATCH (v)
COLUMNS (1 AS dummy)
);
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/graph-pattern-15.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/graph-pattern.html
SELECT name, birthday
FROM GRAPH_TABLE ( students_graph
MATCH (p IS person WHERE p.dob > DATE '1980-01-01')
COLUMNS (p.name, p.dob AS birthday)
)
ORDER BY birthday;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/graph-pattern-17.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/graph-pattern.html
SELECT COUNT(*)
FROM GRAPH_TABLE ( students_graph
MATCH ->
COLUMNS (1 AS dummy)
);
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/graph-pattern-19.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/graph-pattern.html
SELECT *
FROM GRAPH_TABLE ( students_graph
MATCH -[e IS friends WHERE e.meeting_date > DATE '2001-01-01']->
COLUMNS (e.meeting_date)
);
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/graph-pattern-2.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/graph-pattern.html
SELECT *
FROM GRAPH_TABLE ( students_graph
MATCH (a IS person) <-[e1 IS friends]- (b IS person),
(b) <-[e2 IS friends]- (c IS person),
(c) <-[e3 is friends]- (a IS person)
WHERE a.name= 'Mary'
COLUMNS (a.name AS person_a, b.name AS person_b, c.name AS person_c)
);
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/graph-pattern-21.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/graph-pattern.html
SELECT *
FROM GRAPH_TABLE ( students_graph
MATCH (n IS person WHERE n.name = 'Mary')
-[e IS friends WHERE e.meeting_date > DATE '2001-01-01']-
() -[IS friends]- (m IS person)
WHERE m.name <> n.name
COLUMNS (m.name, e.meeting_date)
);
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/graph-pattern-23.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/graph-pattern.html
SELECT DISTINCT name
FROM GRAPH_TABLE ( students_graph
MATCH (a IS person) -[e IS friends WHERE e.meeting_date > DATE '2000-09-15']-{2} ("b" IS person)
WHERE a.name = 'John' AND a.name <> "b".name
COLUMNS ("b".name)
);
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/graph-pattern-25.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/graph-pattern.html
SELECT *
FROM GRAPH_TABLE ( students_graph
MATCH (p1 IS person) -[e1 IS friends]- (p2 IS person)
, (p1) -[IS student_of]-> (u1 IS university)
, (p2) -[IS student_of]-> (u2 IS university)
WHERE p1.name = 'Mary'
COLUMNS (p1.name, p2.name AS friend, e1.meeting_date, u1.name AS univ_1, u2.name AS univ_2)
);
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/graph-pattern-27.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/graph-pattern.html
SELECT *
FROM GRAPH_TABLE ( students_graph
MATCH (p IS person) -[e IS friends]-{2,5} (friend IS person)
WHERE p.name = 'Alice' AND
COUNT(e.friendship_id) = COUNT(DISTINCT e.friendship_id)
COLUMNS (LISTAGG(e.friendship_id, ', ') AS friendship_ids,
COUNT(e.friendship_id) AS path_length));
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/graph-pattern-29.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/graph-pattern.html
SELECT *
FROM GRAPH_TABLE ( students_graph
MATCH (x IS person|university)
COLUMNS (x.name, x.dob)
)
ORDER BY name;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/graph-pattern-3.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/graph-pattern.html
SELECT COUNT(*)
FROM GRAPH_TABLE ( students_graph
MATCH (v)
COLUMNS (1 AS dummy)
);
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/graph-pattern-31.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/graph-pattern.html
SELECT *
FROM GRAPH_TABLE ( students_graph
MATCH (n IS person) -[e IS student_of|friends]-> (m IS university|"PERSON")
WHERE n.name = 'Mary'
COLUMNS (e.subject, e.meeting_date, m.name)
)
ORDER BY subject, meeting_date, name;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/graph-pattern-33.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/graph-pattern.html
SELECT Gt.name
FROM GRAPH_TABLE ( students_graph
MATCH (a IS person WHERE a.name = 'John')
-[e IS friends WHERE e.meeting_date > DATE '2000-09-15']-
(b IS person)
COLUMNS (b.name)
) GT;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/graph-pattern-35.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/graph-pattern.html
SELECT DISTINCT name
FROM GRAPH_TABLE ( students_graph
MATCH (a IS person)
-[e IS friends WHERE e.meeting_date > DATE '2000-09-15']-{2}
(b IS person)
WHERE a.name = 'John' AND a.name <> b.name
COLUMNS (b.name)
);
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/graph-pattern-37.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/graph-pattern.html
SELECT DISTINCT name, height
FROM GRAPH_TABLE ( students_graph
MATCH (a IS person|person_ht)
(-[e IS friends]- (x IS person_ht) WHERE x.height > a.height) {,3}
(b IS person|person_ht)
WHERE a.name = 'Mary'
COLUMNS (b.name, b.height)
)
ORDER BY height;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/graph-pattern-38.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/graph-pattern.html
SELECT *
FROM GRAPH_TABLE ( students_graph
MATCH (u1 IS university) -[e]-{,3} (u2 IS university)
WHERE u1.name = 'ABC' AND u2.name = 'XYZ'
COLUMNS (JSON_ARRAYAGG(CASE WHEN e.subject IS NOT NULL THEN e.subject
ELSE CAST(e.friendship_id AS VARCHAR(100)) END) AS path));
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/graph-pattern-40.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/graph-pattern.html
SELECT DISTINCT name, birthday
FROM GRAPH_TABLE ( students_graph
MATCH
(a IS person)
( (x) -[e IS friends]- (y IS person)
WHERE x.dob < y.dob ){1,3}
(b IS person)
WHERE a.name = 'Bob'
COLUMNS (b.name, b.dob AS birthday)
)
ORDER BY birthday;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/graph-pattern-42.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/graph-pattern.html
SELECT *
FROM GRAPH_TABLE ( students_graph
MATCH (p IS person) ( -[e IS friends]-> (friend IS person)
WHERE p.person_id <> friend.person_id){2,3}
WHERE p.name = 'John'
COLUMNS (COUNT(e.friendship_id) AS path_length,
LISTAGG(friend.name, ', ') AS names,
LISTAGG(e.meeting_date, ', ') AS meeting_dates ));
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/graph-pattern-44.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/graph-pattern.html
SELECT Gt.name
FROM GRAPH_TABLE ( students_graph
MATCH (a IS person) -[e IS friends]- (b IS person)
WHERE a.name = 'John' AND e.meeting_date > DATE '2000-09-15'
COLUMNS (b.name)
) GT;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/graph-pattern-5.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/graph-pattern.html
SELECT COUNT(*)
FROM GRAPH_TABLE ( students_graph
MATCH -[e]->
COLUMNS (1 AS dummy)
);
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/graph-pattern-7.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/graph-pattern.html
SELECT *
FROM GRAPH_TABLE ( students_graph
MATCH (n IS person) -[IS friends]- () -[IS friends]- (m IS person)
WHERE n.name = 'Mary' AND m.name <> n.name
COLUMNS (m.name AS fof)
);
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/graph-pattern-9.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/graph-pattern.html
SELECT *
FROM GRAPH_TABLE ( students_graph
MATCH (n IS person) -[IS friends]- -[IS friends]- (m IS person)
WHERE n.name = 'Mary' AND m.name <> n.name
COLUMNS (m.name AS fof)
);
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/graph-reference-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/graph-reference.html
SELECT COUNT(*)
FROM GRAPH_TABLE ( scott.students_graph
MATCH (a IS person)
COLUMNS (a.name)
);
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/graph-reference-2.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/graph-reference.html
INSERT INTO university (name) VALUES ('u3');
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/graph-reference-3.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/graph-reference.html
SELECT COUNT(*)
FROM GRAPH_TABLE (
students_graph
MATCH (u IS university)
COLUMNS (u.*)
);
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/graph-reference-4.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/graph-reference.html
SELECT COUNT(*)
FROM GRAPH_TABLE (
students_graph AS OF TIMESTAMP (SYSTIMESTAMP - INTERVAL '2' MINUTE)
MATCH (u IS university)
COLUMNS (u.*)
);
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/graph-reference-5.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/graph-reference.html
DELETE FROM university WHERE name = 'u3';
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/graph-table-shape-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/graph-table-shape.html
SELECT *
FROM GRAPH_TABLE ( students_graph
MATCH (n IS person|person_ht)
COLUMNS (n.name, n.height * 3.281 AS height_in_feet)
)
ORDER BY name;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/graph-table-shape-10.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/graph-table-shape.html
SELECT *
FROM GRAPH_TABLE ( students_graph
MATCH (u1 IS university)
<-[IS student_of]- (p1 IS person)
-[IS friends]-{1,2} (p2 IS person)
-[IS student_of]-> (u2 IS university)
WHERE u1.name = 'ABC' AND u2.name = 'XYZ'
ONE ROW PER VERTEX (v)
COLUMNS (MATCHNUM() AS matchnum,
ELEMENT_NUMBER(v) AS element_number,
CASE WHEN v.person_id IS NOT NULL
THEN 'person'
ELSE 'university'
END AS label,
v.name))
ORDER BY matchnum, element_number;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/graph-table-shape-2.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/graph-table-shape.html
SELECT *
FROM GRAPH_TABLE ( students_graph
MATCH (p1 IS person) -[e IS friends]-> (p2 IS person)
COLUMNS ( p1.*, p2.name AS p2_name, e.* )
)
ORDER BY 1, 2, 3, 4, 5;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/graph-table-shape-4.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/graph-table-shape.html
SELECT *
FROM GRAPH_TABLE ( students_graph
MATCH (v)
COLUMNS ( v.* )
)
ORDER BY 1, 2, 3, 4, 5;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/graph-table-shape-6.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/graph-table-shape.html
SELECT *
FROM GRAPH_TABLE ( students_graph
MATCH (n IS person) -[e1 IS friends]->{0,3} (IS person)
WHERE n.name = 'John'
ONE ROW PER VERTEX (v)
COLUMNS (
LISTAGG(e1.friendship_id, ', ') AS friendship_ids,
v.name)
);
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/graph-table-shape-8.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/graph-table-shape.html
SELECT *
FROM GRAPH_TABLE ( students_graph
MATCH (n IS person) -[e1 IS friends]->{0,3} (IS person)
WHERE n.name = 'John'
ONE ROW PER STEP (src, e2, dst)
COLUMNS (
LISTAGG(e1.friendship_id, ', ') AS friendship_ids,
src.name AS src_name,
e2.friendship_id,
dst.name AS dst_name)
);
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/graph_table-operator-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/graph_table-operator.html
CREATE TABLE university (
id NUMBER GENERATED ALWAYS AS IDENTITY (START WITH 1 INCREMENT BY 1),
name VARCHAR2(10),
CONSTRAINT u_pk PRIMARY KEY (id));
INSERT INTO university (name) VALUES ('ABC');
INSERT INTO university (name) VALUES ('XYZ');
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/graph_table-operator-1.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/graph_table-operator.html
CREATE TABLE persons (
person_id NUMBER GENERATED ALWAYS AS IDENTITY (START WITH 1 INCREMENT
BY 1),
name VARCHAR2(10),
birthdate DATE,
height FLOAT DEFAULT ON NULL 0,
person_data JSON,
CONSTRAINT person_pk PRIMARY KEY (person_id));
INSERT INTO persons (name, height, birthdate, person_data)
VALUES ('John', 1.80, to_date('13/06/1963', 'DD/MM/YYYY'), '{"department":"IT","role":"Software Developer"}');
INSERT INTO persons (name, height, birthdate, person_data)
VALUES ('Mary', 1.65, to_date('25/09/1982', 'DD/MM/YYYY'), '{"department":"HR","role":"HR Manager"}');
INSERT INTO persons (name, height, birthdate, person_data)
VALUES ('Bob', 1.75, to_date('11/03/1966', 'DD/MM/YYYY'), '{"department":"IT","role":"Technical Consultant"}');
INSERT INTO persons (name, height, birthdate, person_data)
VALUES ('Alice', 1.70, to_date('01/02/1987', 'DD/MM/YYYY'), '{"department":"HR","role":"HR Assistant"}');
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/graph_table-operator-2.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/graph_table-operator.html
CREATE TABLE students (
s_id NUMBER GENERATED ALWAYS AS IDENTITY (START WITH 1 INCREMENT BY 1),
s_univ_id NUMBER,
s_person_id NUMBER,
subject VARCHAR2(10),
CONSTRAINT stud_pk PRIMARY KEY (s_id),
CONSTRAINT stud_fk_person FOREIGN KEY (s_person_id) REFERENCES persons(person_id),
CONSTRAINT stud_fk_univ FOREIGN KEY (s_univ_id) REFERENCES university(id)
);
INSERT INTO students(s_univ_id, s_person_id,subject) VALUES (1,1,'Arts');
INSERT INTO students(s_univ_id, s_person_id,subject) VALUES (1,3,'Music');
INSERT INTO students(s_univ_id, s_person_id,subject) VALUES (2,2,'Math');
INSERT INTO students(s_univ_id, s_person_id,subject) VALUES (2,4,'Science');
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/graph_table-operator-3.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/graph_table-operator.html
CREATE TABLE friendships (
friendship_id NUMBER GENERATED ALWAYS AS IDENTITY (START WITH 1 INCREMENT BY 1),
person_a NUMBER,
person_b NUMBER,
meeting_date DATE,
CONSTRAINT fk_person_a_id FOREIGN KEY (person_a) REFERENCES persons(person_id),
CONSTRAINT fk_person_b_id FOREIGN KEY (person_b) REFERENCES persons(person_id),
CONSTRAINT fs_pk PRIMARY KEY (friendship_id)
);
INSERT INTO friendships (person_a, person_b, meeting_date) VALUES (1, 3, to_date('01/09/2000', 'DD/MM/YYYY'));
INSERT INTO friendships (person_a, person_b, meeting_date) VALUES (2, 4, to_date('19/09/2000', 'DD/MM/YYYY'));
INSERT INTO friendships (person_a, person_b, meeting_date) VALUES (2, 1, to_date('19/09/2000', 'DD/MM/YYYY'));
INSERT INTO friendships (person_a, person_b, meeting_date) VALUES (3, 2, to_date('10/07/2001', 'DD/MM/YYYY'));
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/graph_table-operator-4.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/graph_table-operator.html
CREATE PROPERTY GRAPH students_graph
VERTEX TABLES (
persons KEY (person_id)
LABEL person
PROPERTIES (person_id, name, birthdate AS dob)
LABEL person_ht
PROPERTIES (height),
university KEY (id)
)
EDGE TABLES (
friendships AS friends
KEY (friendship_id)
SOURCE KEY (person_a) REFERENCES persons(person_id)
DESTINATION KEY (person_b) REFERENCES persons(person_id)
PROPERTIES (friendship_id, meeting_date),
students AS student_of
SOURCE KEY (s_person_id) REFERENCES persons(person_id)
DESTINATION KEY (s_univ_id) REFERENCES university(id)
PROPERTIES (subject)
);
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/graph_table-operator-5.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/graph_table-operator.html
SELECT *
FROM GRAPH_TABLE ( students_graph
MATCH (a IS person) -[e IS friends]- (b IS person)
WHERE a.name = 'John'
COLUMNS (b.name)
);
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/is_uuid-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/is_uuid.html
SELECT IS_UUID('{e24e8de0-d663-428f-baaa-1be5f019cd25}') FROM DUAL;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/is_uuid-2.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/is_uuid.html
SELECT IS_UUID('{d20f8c3cde134b958d25eff3fbdb7e71}') FROM DUAL;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ora_shardspace_name-pseudocolumn-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ora_shardspace_name-pseudocolumn.html
SELECT CUST_NAME, CUST_ID FROM CUSTOMER WHERE ORA_SHARDSPACE_NAME = 'EUROPE'
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/ora_shardspace_name-pseudocolumn-1.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ora_shardspace_name-pseudocolumn.html
SELECT CUST_NAME, CUST_ID FROM CUSTOMER
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/raw_to_uuid-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/raw_to_uuid.html
SELECT RAW_TO_UUID(UUID()) FROM DUAL;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/round-interval-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/round-interval.html
SELECT ROUND(INTERVAL '+123-06' YEAR(3) TO MONTH) AS year_round;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/round-interval-1.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/round-interval.html
SELECT ROUND(INTERVAL '+99-11' YEAR(2) TO MONTH, 'YEAR') AS year_round;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/round-interval-2.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/round-interval.html
SELECT ROUND(INTERVAL '-999999999-11' YEAR(9) TO MONTH, 'YEAR')AS year_round;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/round-interval-3.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/round-interval.html
SELECT ROUND(INTERVAL '+4 12:42:10.222' DAY(2) TO SECOND(3), 'DD') AS day_round;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/shard_chunk_id-operator-2.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/shard_chunk_id-operator.html
SELECT SHARD_CHUNK_ID(null, class, custno, name) FROM customers;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/storage_clause-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/storage_clause.html
CREATE TABLE divisions
(div_no NUMBER(2),
div_name VARCHAR2(14),
location VARCHAR2(13) )
STORAGE ( INITIAL 8M MAXSIZE 1G );
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/storage_clause-1.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/storage_clause.html
SELECT INITIAL_EXTENT FROM USER_TABLES WHERE TABLE_NAME='DIVISIONS';
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/sys_row_etag-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/sys_row_etag.html
CREATE TABLE foo (c1 NUMBER, c2 NUMBER, c3 NUMBER);
INSERT INTO foo VALUES (1, 2, 3);
SELECT SYS_ROW_ETAG(c2, c1) FROM foo;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/time_bucket-datetime-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/time_bucket-datetime.html
ALTER SESSION SET NLS_DATE_FORMAT='YYYY-MM-DD';
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/to_boolean-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/to_boolean.html
SELECT TO_BOOLEAN(0), TO_BOOLEAN('true'), TO_BOOLEAN('no');
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/to_boolean-2.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/to_boolean.html
SELECT TO_BOOLEAN(1) FROM DUAL;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/to_vector-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/to_vector.html
SELECT TO_VECTOR('[34.6, 77.8]');
SELECT TO_VECTOR('[34.6, 77.8]', 2, FLOAT32);
SELECT TO_VECTOR('[34.6, 77.8, -89.34]', 3, FLOAT32);
SELECT TO_VECTOR('[34.6, 77.8, -89.34]', 3, FLOAT32, DENSE);
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/to_vector-1.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/to_vector.html
INSERT INTO vecTab VALUES(TO_VECTOR('[1.1, 2.9, 3.14]'));
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/to_vector-2.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/to_vector.html
INSERT INTO vecTab VALUES ('[1.1, 2.9, 3.14]');
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/trunc-interval-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/trunc-interval.html
SELECT TRUNC(INTERVAL '+123-06' YEAR(3) TO MONTH) AS year_trunc;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/trunc-interval-1.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/trunc-interval.html
SELECT TRUNC(INTERVAL '+99-11' YEAR(2) TO MONTH, 'YEAR') AS year_trunc;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/trunc-interval-2.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/trunc-interval.html
SELECT TRUNC(INTERVAL '+4 12:42:10.222' DAY(2) TO SECOND(3), 'DD') AS day_trunc;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/uuid-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/uuid.html
SELECT UUID() from dual;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/uuid_to_raw-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/uuid_to_raw.html
SELECT UUID_TO_RAW ('{82e19137-f810-44ad-b26e-379d828408a1}') FROM DUAL;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/uuid_to_raw-2.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/uuid_to_raw.html
SELECT UUID_TO_RAW('{d20f8c3c-de13-4b95-8d25-eff3fbdb7e71}') FROM DUAL;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/value-expressions-graph_table-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/value-expressions-graph_table.html
SELECT GT.name, GT.birthday
FROM GRAPH_TABLE ( students_graph
MATCH (p IS person|university)
COLUMNS (p.name, p.dob AS birthday)
) GT
ORDER BY GT.birthday, GT.name;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/value-expressions-graph_table-10.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/value-expressions-graph_table.html
SELECT name
FROM GRAPH_TABLE ( students_graph
MATCH (p IS person)
-[IS friends]- (friend IS person)
-[IS friends]- (friend_of_friend IS person)
WHERE p.name = 'Mary' AND NOT vertex_equal(p, friend_of_friend)
COLUMNS (friend_of_friend.name)
)
ORDER BY name;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/value-expressions-graph_table-12.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/value-expressions-graph_table.html
SELECT *
FROM GRAPH_TABLE ( students_graph
MATCH (p1 IS person) -[e IS friends]- (p2 IS person)
WHERE p1.name = 'Mary'
COLUMNS (e.friendship_id,
e.meeting_date,
CASE WHEN p1 IS SOURCE OF e THEN p1.name ELSE p2.name END AS from_person,
CASE WHEN p1 IS DESTINATION OF e THEN p1.name ELSE p2.name END AS to_person))
ORDER BY friendship_id;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/value-expressions-graph_table-13.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/value-expressions-graph_table.html
SELECT *
FROM GRAPH_TABLE ( students_graph
MATCH (p1 IS person) -[e1 IS friends]- (p2 IS person)
-[e2 IS friends]- (p3 IS person)
WHERE p1.name = 'John'
AND ((p1 IS SOURCE OF e1 AND p2 IS SOURCE OF e2) OR
(p1 IS DESTINATION OF e1 AND p2 IS DESTINATION OF e2))
COLUMNS (p1.name AS person_1,
CASE WHEN p1 IS SOURCE OF e1
THEN 'Outgoing' ELSE 'Incoming'
END AS e1_direction,
p2.name AS person_2,
CASE WHEN p2 IS SOURCE OF e2
THEN 'Outgoing' ELSE 'Incoming'
END AS e2_direction,
p3.name AS person_3))
ORDER BY 1, 2, 3;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/value-expressions-graph_table-14.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/value-expressions-graph_table.html
SELECT *
FROM GRAPH_TABLE ( students_graph
MATCH (p IS person) -[e IS friends]-{2,5} (friend IS person)
WHERE p.name = 'Alice' AND
COUNT(edge_id(e)) = COUNT(DISTINCT edge_id(e))
COLUMNS (LISTAGG(e.friendship_id, ', ') AS friendship_ids,
COUNT(edge_id(e)) AS path_length))
ORDER BY path_length, friendship_ids;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/value-expressions-graph_table-16.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/value-expressions-graph_table.html
SELECT *
FROM GRAPH_TABLE ( students_graph
MATCH (u1 IS university) -[e]-{,3} (u2 IS university)
WHERE u1.name = 'ABC' AND u2.name = 'XYZ'
COLUMNS (JSON_ARRAYAGG(CASE WHEN e.subject IS NOT NULL THEN e.subject
ELSE CAST(e.friendship_id AS VARCHAR(100)) END) AS path))
ORDER BY path;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/value-expressions-graph_table-17.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/value-expressions-graph_table.html
SELECT *
FROM GRAPH_TABLE ( students_graph
MATCH (p IS person) ( -[e IS friends]-> (friend IS person)
WHERE p.person_id <> friend.person_id){2,3}
WHERE p.name = 'John'
COLUMNS (COUNT(edge_id(e)) AS path_length,
LISTAGG(friend.name, ', ') AS names,
LISTAGG(e.meeting_date, ', ') AS meeting_dates ))
ORDER BY path_length;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/value-expressions-graph_table-19.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/value-expressions-graph_table.html
CREATE PROPERTY GRAPH persons_graph VERTEX TABLES ( persons );
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/value-expressions-graph_table-2.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/value-expressions-graph_table.html
SELECT *
FROM GRAPH_TABLE ( students_graph
MATCH (n IS person)
COLUMNS ( n.name, n.height )
)
ORDER BY height;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/value-expressions-graph_table-20.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/value-expressions-graph_table.html
SELECT *
FROM GRAPH_TABLE ( persons_graph
MATCH (n)
WHERE n.person_data.department = 'HR'
COLUMNS (n.name, n.person_data.role.string() AS role)
);
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/value-expressions-graph_table-21.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/value-expressions-graph_table.html
SELECT *
FROM GRAPH_TABLE ( students_graph
MATCH (p IS person)
COLUMNS (MATCHNUM() AS matchnum,
p.name))
ORDER BY matchnum;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/value-expressions-graph_table-23.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/value-expressions-graph_table.html
SELECT *
FROM GRAPH_TABLE ( students_graph
MATCH (p1 IS person) -[IS friends]-{1,2} (p2 IS person)
WHERE p1.name = 'John' AND p2.name = 'Mary'
ONE ROW PER VERTEX (v)
COLUMNS (MATCHNUM() AS matchnum,
ELEMENT_NUMBER(v) AS element_number,
v.name))
ORDER BY matchnum, element_number;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/value-expressions-graph_table-25.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/value-expressions-graph_table.html
SELECT *
FROM GRAPH_TABLE ( students_graph
MATCH (p1 IS person) -[IS friends]-{1,2} (p2 IS person)
WHERE p1.name = 'John' AND p2.name = 'Mary'
ONE ROW PER STEP (v1, e, v2)
COLUMNS (MATCHNUM() AS matchnum,
ELEMENT_NUMBER(e) AS element_number,
v1.name AS name1,
e.friendship_id,
v2.name AS name2))
ORDER BY matchnum, element_number;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/value-expressions-graph_table-27.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/value-expressions-graph_table.html
SELECT *
FROM GRAPH_TABLE ( students_graph
MATCH (p1 IS person) -[IS friends]-{0,1} (p2 IS person)
WHERE p1.name = 'John'
ONE ROW PER STEP (v1, e, v2)
COLUMNS (MATCHNUM() AS matchnum,
ELEMENT_NUMBER(e) AS element_number,
v1.name AS name1,
e.friendship_id,
v2.name AS name2))
ORDER BY matchnum, element_number;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/value-expressions-graph_table-4.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/value-expressions-graph_table.html
SELECT CAST(p2_id AS VARCHAR2(200)) AS p2_id
FROM GRAPH_TABLE ( students_graph
MATCH (p1 IS person) -[e1 IS friends]- (p2 IS person)
WHERE p1.name = 'Mary'
COLUMNS (vertex_id(p2) AS p2_id)
)
ORDER BY p2_id;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/value-expressions-graph_table-6.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/value-expressions-graph_table.html
SELECT GT.p2_id.KEY_VALUE
FROM GRAPH_TABLE ( students_graph
MATCH (p1 IS person) -[e1 IS friends]- (p2 IS person)
WHERE p1.name = 'Mary'
COLUMNS (vertex_id(p2) AS p2_id)
) GT
ORDER BY key_value;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/value-expressions-graph_table-8.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/value-expressions-graph_table.html
SELECT DISTINCT json_value(e_id, '$.ELEM_TABLE') AS elem_table
FROM GRAPH_TABLE ( students_graph
MATCH -[e]-
COLUMNS (edge_id(e) AS e_id)
)
ORDER BY elem_table;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/vector-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/vector.html
INSERT INTO vecTab VALUES ('[1.1, 2.9, 3.14]');
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/vector-1.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/vector.html
SELECT VECTOR('[34.6, 77.8]');
SELECT VECTOR('[34.6, 77.8]', 2, FLOAT32);
SELECT VECTOR('[34.6, 77.8, -89.34]', 3, FLOAT32);
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/vector_chunks-1.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/vector_chunks.html
COLUMN chunk_offset HEADING Offset FORMAT 999
COLUMN chunk_length HEADING Len FORMAT 999
COLUMN chunk_text HEADING Text FORMAT a60
VARIABLE txt VARCHAR2(4000)
EXECUTE :txt := 'An example text value to split with VECTOR_CHUNKS, having over 10 words because the minimum MAX value is 10';
SELECT * FROM VECTOR_CHUNKS(:txt BY WORDS MAX 10);
SELECT * FROM VECTOR_CHUNKS('Another example text value to split with VECTOR_CHUNKS, having over 10 words because the minimum MAX value is 10' BY WORDS MAX 10);
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/vector_chunks-2.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/vector_chunks.html
CREATE TABLE documentation_tab (
id NUMBER,
text VARCHAR2(2000));
INSERT INTO documentation_tab
VALUES(1, 'sample');
COMMIT;
SET LINESIZE 100;
SET PAGESIZE 20;
COLUMN pos FORMAT 999;
COLUMN siz FORMAT 999;
COLUMN txt FORMAT a60;
SELECT D.id id, C.chunk_offset pos, C.chunk_length siz, C.chunk_text txt
FROM documentation_tab D, VECTOR_CHUNKS(D.text
BY words
MAX 200
OVERLAP 10
SPLIT BY recursively
LANGUAGE american
NORMALIZE all) C;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/vector_dimension_count-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/vector_dimension_count.html
SELECT VECTOR_DIMENSION_COUNT( TO_VECTOR('[34.6, 77.8]', 2, FLOAT64) );
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/vector_dimension_format-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/vector_dimension_format.html
SELECT VECTOR_DIMENSION_FORMAT(TO_VECTOR('[34.6, 77.8]', 2, FLOAT64));
SELECT VECTOR_DIMENSION_FORMAT(TO_VECTOR('[34.6, 77.8, 9]', 3, FLOAT32));
SELECT VECTOR_DIMENSION_FORMAT(TO_VECTOR('[34.6, 77.8, 9.10]', 3, INT8));
SELECT VECTOR_DIMENSION_FORMAT(TO_VECTOR('[206, 32]', 16, BINARY));
SELECT VECTOR_DIMENSION_FORMAT(TO_VECTOR('[34.6, 77.8, 9, 10]', 3, INT8));
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/vector_embedding-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/vector_embedding.html
SELECT TO_VECTOR(VECTOR_EMBEDDING(model USING 'hello' as data)) AS embedding;
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/vector_norm-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/vector_norm.html
SELECT VECTOR_NORM( TO_VECTOR('[4, 3]', 2, FLOAT32) );
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/vector_serialize-0.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/vector_serialize.html
SELECT VECTOR_SERIALIZE(VECTOR('[1.1,2.2,3.3]',3,FLOAT32));
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/vector_serialize-1.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/vector_serialize.html
SELECT VECTOR_SERIALIZE(VECTOR('[1.1, 2.2, 3.3]',3,FLOAT32) RETURNING VARCHAR2(1000));
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/vector_serialize-2.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/vector_serialize.html
SELECT VECTOR_SERIALIZE(VECTOR('[1.1, 2.2, 3.3]',3,FLOAT32) RETURNING CLOB);
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/vector_serialize-3.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/vector_serialize.html
SELECT VECTOR_SERIALIZE(TO_VECTOR('[5,[2,4],[1.0,2.0]]', 5, FLOAT64, SPARSE) RETURNING CLOB FORMAT SPARSE);
================================================
FILE: zpa-checks/src/integrationTest/resources/sources/oracle-database_23/sqlrf/vector_serialize-4.sql
================================================
-- https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/vector_serialize.html
SELECT VECTOR_SERIALIZE(TO_VECTOR('[5,[2,4],[1.0,2.0]]', 5, FLOAT64, SPARSE) RETURNING CLOB FORMAT DENSE);
================================================
FILE: zpa-checks/src/main/kotlin/com/felipebz/zpa/checks/AbstractBaseCheck.kt
================================================
/**
* Z PL/SQL Analyzer
* Copyright (C) 2015-2026 Felipe Zorzo
* mailto:felipe AT felipezorzo DOT com DOT br
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package com.felipebz.zpa.checks
import com.felipebz.zpa.CustomAnnotationBasedRulesDefinition.Companion.convertCheckClassName
import com.felipebz.zpa.api.checks.PlSqlCheck
import java.util.*
abstract class AbstractBaseCheck : PlSqlCheck() {
private val bundle: ResourceBundle = ResourceBundle.getBundle("org.sonar.l10n.plsqlopen", Locale.getDefault())
protected fun getLocalizedMessage(): String {
return bundle.getString("${convertCheckClassName(this::class.java)}.message")
}
}
================================================
FILE: zpa-checks/src/main/kotlin/com/felipebz/zpa/checks/AddParenthesesInNestedExpressionCheck.kt
================================================
/**
* Z PL/SQL Analyzer
* Copyright (C) 2015-2026 Felipe Zorzo
* mailto:felipe AT felipezorzo DOT com DOT br
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package com.felipebz.zpa.checks
import com.felipebz.flr.api.AstNode
import com.felipebz.zpa.api.PlSqlGrammar
import com.felipebz.zpa.api.annotations.*
@Rule(priority = Priority.MAJOR)
@ConstantRemediation("2min")
@RuleInfo(scope = RuleInfo.Scope.ALL)
@ActivatedByDefault
class AddParenthesesInNestedExpressionCheck : AbstractBaseCheck() {
override fun init() {
subscribeTo(PlSqlGrammar.OR_EXPRESSION)
}
override fun visitNode(node: AstNode) {
val andExpressions = node.getChildren(PlSqlGrammar.AND_EXPRESSION)
for (andExpression in andExpressions) {
addIssue(andExpression, getLocalizedMessage())
}
}
}
================================================
FILE: zpa-checks/src/main/kotlin/com/felipebz/zpa/checks/CharacterDatatypeUsageCheck.kt
================================================
/**
* Z PL/SQL Analyzer
* Copyright (C) 2015-2026 Felipe Zorzo
* mailto:felipe AT felipezorzo DOT com DOT br
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package com.felipebz.zpa.checks
import com.felipebz.flr.api.AstNode
import com.felipebz.zpa.typeIs
import com.felipebz.zpa.api.PlSqlGrammar
import com.felipebz.zpa.api.PlSqlKeyword
import com.felipebz.zpa.api.annotations.*
@Rule(priority = Priority.MINOR, tags = [Tags.OBSOLETE])
@ConstantRemediation("5min")
@RuleInfo(scope = RuleInfo.Scope.ALL)
@ActivatedByDefault
class CharacterDatatypeUsageCheck : AbstractBaseCheck() {
override fun init() {
subscribeTo(PlSqlGrammar.CHARACTER_DATAYPE)
}
override fun visitNode(node: AstNode) {
val datatype = node.firstChild
if (datatype.typeIs(CHAR_DATATYPE)) {
addIssue(node, getLocalizedMessage(), datatype.tokenValue)
}
}
companion object {
val CHAR_DATATYPE = arrayOf(PlSqlKeyword.CHAR, PlSqlKeyword.VARCHAR)
}
}
================================================
FILE: zpa-checks/src/main/kotlin/com/felipebz/zpa/checks/CheckList.kt
================================================
/**
* Z PL/SQL Analyzer
* Copyright (C) 2015-2026 Felipe Zorzo
* mailto:felipe AT felipezorzo DOT com DOT br
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package com.felipebz.zpa.checks
object CheckList {
const val SONAR_WAY_PROFILE = "Sonar way"
val checks: List>
get() = listOf(
EmptyBlockCheck::class.java,
ParsingErrorCheck::class.java,
CollapsibleIfStatementsCheck::class.java,
InequalityUsageCheck::class.java,
ComparisonWithNullCheck::class.java,
TooManyRowsHandlerCheck::class.java,
InsertWithoutColumnsCheck::class.java,
DeclareSectionWithoutDeclarationsCheck::class.java,
NvlWithNullParameterCheck::class.java,
ComparisonWithBooleanCheck::class.java,
CharacterDatatypeUsageCheck::class.java,
SelectAllColumnsCheck::class.java,
ColumnsShouldHaveTableNameCheck::class.java,
SelectWithRownumAndOrderByCheck::class.java,
ToDateWithoutFormatCheck::class.java,
ExplicitInParameterCheck::class.java,
VariableInitializationWithNullCheck::class.java,
UselessParenthesisCheck::class.java,
IdenticalExpressionCheck::class.java,
EmptyStringAssignmentCheck::class.java,
DuplicatedValueInInCheck::class.java,
VariableInitializationWithFunctionCallCheck::class.java,
IfWithExitCheck::class.java,
FunctionWithOutParameterCheck::class.java,
SameConditionCheck::class.java,
AddParenthesesInNestedExpressionCheck::class.java,
RaiseStandardExceptionCheck::class.java,
NotFoundCheck::class.java,
QueryWithoutExceptionHandlingCheck::class.java,
UnusedVariableCheck::class.java,
VariableHidingCheck::class.java,
DbmsOutputPutCheck::class.java,
ReturnOfBooleanExpressionCheck::class.java,
UnnecessaryElseCheck::class.java,
DeadCodeCheck::class.java,
ConcatenationWithNullCheck::class.java,
SameBranchCheck::class.java,
UnusedParameterCheck::class.java,
CommitRollbackCheck::class.java,
UnnecessaryNullStatementCheck::class.java,
DuplicateConditionIfElsifCheck::class.java,
UnnecessaryAliasInQueryCheck::class.java,
VariableInCountCheck::class.java,
UnhandledUserDefinedExceptionCheck::class.java,
UnusedCursorCheck::class.java,
NotASelectedExpressionCheck::class.java,
InvalidReferenceToObjectCheck::class.java,
CursorBodyInPackageSpecCheck::class.java,
XPathCheck::class.java,
VariableNameCheck::class.java,
ToCharInOrderByCheck::class.java,
DisabledTestCheck::class.java,
RedundantExpectationCheck::class.java,
UnnecessaryLikeCheck::class.java)
}
================================================
FILE: zpa-checks/src/main/kotlin/com/felipebz/zpa/checks/CheckUtils.kt
================================================
/**
* Z PL/SQL Analyzer
* Copyright (C) 2015-2026 Felipe Zorzo
* mailto:felipe AT felipezorzo DOT com DOT br
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package com.felipebz.zpa.checks
import com.felipebz.flr.api.AstNode
import com.felipebz.flr.api.AstNodeType
import com.felipebz.zpa.typeIs
import com.felipebz.zpa.api.PlSqlGrammar
import com.felipebz.zpa.api.PlSqlKeyword
import com.felipebz.zpa.api.matchers.MethodMatcher
import com.felipebz.zpa.api.squid.SemanticAstNode
import com.felipebz.zpa.api.symbols.PlSqlType
object CheckUtils {
private val TERMINATION_STATEMENTS = arrayOf(PlSqlGrammar.RETURN_STATEMENT, PlSqlGrammar.EXIT_STATEMENT, PlSqlGrammar.CONTINUE_STATEMENT, PlSqlGrammar.RAISE_STATEMENT)
private val PROGRAM_UNITS = arrayOf(PlSqlGrammar.ANONYMOUS_BLOCK, PlSqlGrammar.CREATE_PROCEDURE, PlSqlGrammar.PROCEDURE_DECLARATION, PlSqlGrammar.CREATE_FUNCTION, PlSqlGrammar.FUNCTION_DECLARATION, PlSqlGrammar.CREATE_PACKAGE_BODY)
private val WHEN = arrayOf(PlSqlKeyword.WHEN)
private val NVL_WITH_NULL_MATCHER = MethodMatcher.create().name("nvl").addParameters(PlSqlType.UNKNOWN, PlSqlType.NULL)
private val RAISE_APPLICATION_ERROR_MATCHER = MethodMatcher.create().name("raise_application_error").withNoParameterConstraint()
val terminationStatements: Array
get() = TERMINATION_STATEMENTS.clone()
fun isNullLiteralOrEmptyString(node: AstNode): Boolean {
return (node as SemanticAstNode).plSqlType === PlSqlType.NULL
}
fun isEmptyString(node: AstNode): Boolean {
return node.hasDirectChildren(PlSqlGrammar.CHARACTER_LITERAL) && (node as SemanticAstNode).plSqlType === PlSqlType.NULL
}
@JvmStatic
fun equalNodes(node1: AstNode, node2: AstNode): Boolean {
val first = skipExpressionsWithoutEffect(node1)
val second = skipExpressionsWithoutEffect(node2)
if (first.type != second.type || first.numberOfChildren != second.numberOfChildren) {
return false
}
if (first.numberOfChildren == 0) {
return first.token.value == second.token.value
}
val children1 = first.children
val children2 = second.children
for (i in children1.indices) {
if (!equalNodes(children1[i], children2[i])) {
return false
}
}
return true
}
fun containsNode(node1: AstNode, node2: AstNode): Boolean {
val currentNode = skipParenthesis(node1)
val nodeToCheck = skipParenthesis(node2)
val type = currentNode.type
val descendants = ArrayList()
if (nodeToCheck.type === type) {
descendants.add(nodeToCheck)
}
descendants.addAll(nodeToCheck.getDescendants(type))
var probableNode: AstNode? = null
for (descendant in descendants) {
if (descendant.tokenValue.equals(currentNode.tokenValue, ignoreCase = true)) {
probableNode = descendant
}
}
return probableNode != null && equalNodes(probableNode, currentNode)
}
fun skipExpressionsWithoutEffect(node: AstNode): AstNode {
var newNode = skipParenthesis(node)
newNode = skipNvlWithNull(newNode)
return newNode
}
fun skipParenthesis(node: AstNode): AstNode {
return if (node.type === PlSqlGrammar.BRACKED_EXPRESSION) {
node.children[1]
} else node
}
fun skipNvlWithNull(node: AstNode): AstNode {
if (NVL_WITH_NULL_MATCHER.matches(node)) {
val arguments = NVL_WITH_NULL_MATCHER.getArgumentsValues(node)
return arguments[0]
}
return node
}
fun isTerminationStatement(node: AstNode): Boolean {
return (node.typeIs(TERMINATION_STATEMENTS) || RAISE_APPLICATION_ERROR_MATCHER.matches(node)) && !node.hasDirectChildren(*WHEN)
}
fun isProgramUnit(node: AstNode?): Boolean {
return node != null && node.typeIs(PROGRAM_UNITS)
}
}
================================================
FILE: zpa-checks/src/main/kotlin/com/felipebz/zpa/checks/CollapsibleIfStatementsCheck.kt
================================================
/**
* Z PL/SQL Analyzer
* Copyright (C) 2015-2026 Felipe Zorzo
* mailto:felipe AT felipezorzo DOT com DOT br
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package com.felipebz.zpa.checks
import com.felipebz.flr.api.AstNode
import com.felipebz.zpa.asTree
import com.felipebz.zpa.sslr.IfStatement
import com.felipebz.zpa.api.PlSqlGrammar
import com.felipebz.zpa.api.annotations.*
@Rule(priority = Priority.MAJOR, tags = [Tags.CLUMSY])
@ConstantRemediation("5min")
@RuleInfo(scope = RuleInfo.Scope.ALL)
@ActivatedByDefault
class CollapsibleIfStatementsCheck : AbstractBaseCheck() {
override fun init() {
subscribeTo(PlSqlGrammar.IF_STATEMENT)
}
override fun visitNode(node: AstNode) {
val ifStatement = node.asTree()
val singleIfChild = singleIfChild(ifStatement)
if (singleIfChild != null && !hasElseOrElsif(ifStatement) && !hasElseOrElsif(singleIfChild)) {
addIssue(singleIfChild, getLocalizedMessage())
}
}
private fun hasElseOrElsif(ifStatement: IfStatement): Boolean {
return ifStatement.elsifClauses.isNotEmpty() || ifStatement.elseClause != null
}
private fun singleIfChild(ifStatement: IfStatement): IfStatement? {
val statements = ifStatement.statements
if (statements.size == 1) {
val nestedIf = statements[0].getChildren(PlSqlGrammar.IF_STATEMENT)
if (nestedIf.size == 1) {
return nestedIf[0].asTree()
}
}
return null
}
}
================================================
FILE: zpa-checks/src/main/kotlin/com/felipebz/zpa/checks/ColumnsShouldHaveTableNameCheck.kt
================================================
/**
* Z PL/SQL Analyzer
* Copyright (C) 2015-2026 Felipe Zorzo
* mailto:felipe AT felipezorzo DOT com DOT br
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package com.felipebz.zpa.checks
import com.felipebz.flr.api.AstNode
import com.felipebz.zpa.typeIs
import com.felipebz.zpa.api.DmlGrammar
import com.felipebz.zpa.api.PlSqlGrammar
import com.felipebz.zpa.api.annotations.*
@Rule(priority = Priority.MAJOR)
@ConstantRemediation("2min")
@RuleInfo(scope = RuleInfo.Scope.ALL)
@ActivatedByDefault
class ColumnsShouldHaveTableNameCheck : AbstractBaseCheck() {
override fun init() {
subscribeTo(DmlGrammar.SELECT_COLUMN)
}
override fun visitNode(node: AstNode) {
var candidate = node.firstChild
if (candidate.hasChildren()) {
candidate = candidate.firstChild
}
val selectExpression = node.parentOrNull
if (selectExpression != null &&
selectExpression.hasDirectChildren(DmlGrammar.FROM_CLAUSE) &&
selectExpression.getFirstChild(DmlGrammar.FROM_CLAUSE).getChildren(DmlGrammar.DML_TABLE_EXPRESSION_CLAUSE).size > 1 &&
candidate.typeIs(PlSqlGrammar.IDENTIFIER_NAME) &&
!candidate.hasDirectChildren(PlSqlGrammar.NON_RESERVED_KEYWORD) &&
semantic(candidate).symbol == null) {
addIssue(candidate, getLocalizedMessage(), candidate.tokenOriginalValue)
}
}
}
================================================
FILE: zpa-checks/src/main/kotlin/com/felipebz/zpa/checks/CommitRollbackCheck.kt
================================================
/**
* Z PL/SQL Analyzer
* Copyright (C) 2015-2026 Felipe Zorzo
* mailto:felipe AT felipezorzo DOT com DOT br
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package com.felipebz.zpa.checks
import com.felipebz.flr.api.AstNode
import com.felipebz.zpa.typeIs
import com.felipebz.zpa.api.PlSqlGrammar
import com.felipebz.zpa.api.PlSqlKeyword
import com.felipebz.zpa.api.annotations.*
@Rule(priority = Priority.MAJOR)
@ConstantRemediation("30min")
@RuleInfo(scope = RuleInfo.Scope.MAIN)
@ActivatedByDefault
class CommitRollbackCheck : AbstractBaseCheck() {
override fun init() {
subscribeTo(PlSqlGrammar.COMMIT_STATEMENT, PlSqlGrammar.ROLLBACK_STATEMENT)
}
override fun visitNode(node: AstNode) {
val scope = context.currentScope
var outerScope = scope
while (outerScope?.outer != null && outerScope.outer?.type != null) {
outerScope = outerScope.outer
}
val isRollbackToSavepoint = node.typeIs(PlSqlGrammar.ROLLBACK_STATEMENT) && node.hasDirectChildren(PlSqlKeyword.TO)
val currentScopeIsAutonomousTransaction = scope?.isAutonomousTransaction ?: false
val isInsideABlockStatement = outerScope?.type == PlSqlGrammar.BLOCK_STATEMENT
if (!isRollbackToSavepoint && !currentScopeIsAutonomousTransaction && !isInsideABlockStatement) {
addLineIssue(getLocalizedMessage(), node.tokenLine, node.tokenValue)
}
}
}
================================================
FILE: zpa-checks/src/main/kotlin/com/felipebz/zpa/checks/ComparisonWithBooleanCheck.kt
================================================
/**
* Z PL/SQL Analyzer
* Copyright (C) 2015-2026 Felipe Zorzo
* mailto:felipe AT felipezorzo DOT com DOT br
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package com.felipebz.zpa.checks
import com.felipebz.flr.api.AstNode
import com.felipebz.zpa.typeIs
import com.felipebz.zpa.api.PlSqlGrammar
import com.felipebz.zpa.api.annotations.*
@Rule(priority = Priority.MINOR)
@ConstantRemediation("2min")
@RuleInfo(scope = RuleInfo.Scope.ALL)
@ActivatedByDefault
class ComparisonWithBooleanCheck : AbstractBaseCheck() {
override fun init() {
subscribeTo(PlSqlGrammar.COMPARISON_EXPRESSION)
}
override fun visitNode(node: AstNode) {
val children = node.getChildren(PlSqlGrammar.LITERAL)
for (child in children) {
if (child.firstChild.typeIs(PlSqlGrammar.BOOLEAN_LITERAL)) {
addLineIssue(getLocalizedMessage(), node.tokenLine, child.tokenValue)
return
}
}
}
}
================================================
FILE: zpa-checks/src/main/kotlin/com/felipebz/zpa/checks/ComparisonWithNullCheck.kt
================================================
/**
* Z PL/SQL Analyzer
* Copyright (C) 2015-2026 Felipe Zorzo
* mailto:felipe AT felipezorzo DOT com DOT br
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package com.felipebz.zpa.checks
import com.felipebz.flr.api.AstNode
import com.felipebz.zpa.typeIs
import com.felipebz.zpa.api.ConditionsGrammar
import com.felipebz.zpa.api.PlSqlGrammar
import com.felipebz.zpa.api.annotations.*
@Rule(priority = Priority.BLOCKER, tags = [Tags.BUG])
@ConstantRemediation("5min")
@RuleInfo(scope = RuleInfo.Scope.ALL)
@ActivatedByDefault
class ComparisonWithNullCheck : AbstractBaseCheck() {
override fun init() {
subscribeTo(PlSqlGrammar.COMPARISON_EXPRESSION)
}
override fun visitNode(node: AstNode) {
val children = node.getChildren(PlSqlGrammar.LITERAL)
for (child in children) {
if (CheckUtils.isNullLiteralOrEmptyString(child)) {
val operator = node.getFirstChild(ConditionsGrammar.RELATIONAL_OPERATOR)
val suggestion = if (operator.firstChild.typeIs(PlSqlGrammar.EQUALS_OPERATOR)) {
"IS NULL"
} else {
"IS NOT NULL"
}
addIssue(node, getLocalizedMessage(), suggestion)
}
}
}
}
================================================
FILE: zpa-checks/src/main/kotlin/com/felipebz/zpa/checks/ConcatenationWithNullCheck.kt
================================================
/**
* Z PL/SQL Analyzer
* Copyright (C) 2015-2026 Felipe Zorzo
* mailto:felipe AT felipezorzo DOT com DOT br
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package com.felipebz.zpa.checks
import com.felipebz.flr.api.AstNode
import com.felipebz.zpa.api.PlSqlGrammar
import com.felipebz.zpa.api.annotations.*
@Rule(priority = Priority.MINOR)
@ConstantRemediation("1min")
@RuleInfo(scope = RuleInfo.Scope.ALL)
@ActivatedByDefault
class ConcatenationWithNullCheck : AbstractBaseCheck() {
override fun init() {
subscribeTo(PlSqlGrammar.CONCATENATION_EXPRESSION)
}
override fun visitNode(node: AstNode) {
for (child in node.children) {
if (CheckUtils.isNullLiteralOrEmptyString(child)) {
addIssue(child, getLocalizedMessage())
}
}
}
}
================================================
FILE: zpa-checks/src/main/kotlin/com/felipebz/zpa/checks/CursorBodyInPackageSpecCheck.kt
================================================
/**
* Z PL/SQL Analyzer
* Copyright (C) 2015-2026 Felipe Zorzo
* mailto:felipe AT felipezorzo DOT com DOT br
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package com.felipebz.zpa.checks
import com.felipebz.flr.api.AstNode
import com.felipebz.zpa.api.DmlGrammar
import com.felipebz.zpa.api.PlSqlGrammar
import com.felipebz.zpa.api.annotations.ConstantRemediation
import com.felipebz.zpa.api.annotations.Priority
import com.felipebz.zpa.api.annotations.Rule
import com.felipebz.zpa.api.annotations.RuleInfo
import com.felipebz.zpa.api.symbols.Symbol.Kind
@Rule(priority = Priority.MAJOR)
@ConstantRemediation("10min")
@RuleInfo(scope = RuleInfo.Scope.MAIN)
class CursorBodyInPackageSpecCheck : AbstractBaseCheck() {
override fun init() {
subscribeTo(PlSqlGrammar.CREATE_PACKAGE)
}
override fun visitNode(node: AstNode) {
val cursors = context.currentScope?.getSymbols(Kind.CURSOR) ?: emptyList()
for (cursor in cursors) {
val cursorDeclaration = cursor.declaration.parent
if (cursorDeclaration.hasDirectChildren(DmlGrammar.SELECT_EXPRESSION)) {
addIssue(cursorDeclaration, getLocalizedMessage(), cursor.name)
}
}
}
}
================================================
FILE: zpa-checks/src/main/kotlin/com/felipebz/zpa/checks/DbmsOutputPutCheck.kt
================================================
/**
* Z PL/SQL Analyzer
* Copyright (C) 2015-2026 Felipe Zorzo
* mailto:felipe AT felipezorzo DOT com DOT br
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package com.felipebz.zpa.checks
import com.felipebz.flr.api.AstNode
import com.felipebz.zpa.api.PlSqlGrammar
import com.felipebz.zpa.api.annotations.*
import com.felipebz.zpa.api.matchers.MethodMatcher
@Rule(priority = Priority.MINOR)
@ConstantRemediation("5min")
@RuleInfo(scope = RuleInfo.Scope.MAIN)
@ActivatedByDefault
class DbmsOutputPutCheck : AbstractBaseCheck() {
override fun init() {
subscribeTo(PlSqlGrammar.METHOD_CALL)
}
override fun visitNode(node: AstNode) {
val put = MethodMatcher.create()
.schema("sys").schemaIsOptional()
.packageName("dbms_output")
.name("put")
.addParameter()
val putLine = MethodMatcher.create()
.schema("sys").schemaIsOptional()
.packageName("dbms_output")
.name("put_line")
.addParameter()
if (!put.matches(node) && !putLine.matches(node)) {
return
}
addIssue(node, getLocalizedMessage())
}
}
================================================
FILE: zpa-checks/src/main/kotlin/com/felipebz/zpa/checks/DeadCodeCheck.kt
================================================
/**
* Z PL/SQL Analyzer
* Copyright (C) 2015-2026 Felipe Zorzo
* mailto:felipe AT felipezorzo DOT com DOT br
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package com.felipebz.zpa.checks
import com.felipebz.flr.api.AstNode
import com.felipebz.zpa.typeIs
import com.felipebz.zpa.api.PlSqlGrammar
import com.felipebz.zpa.api.annotations.*
@Rule(priority = Priority.MAJOR, tags = [Tags.UNUSED])
@ConstantRemediation("5min")
@RuleInfo(scope = RuleInfo.Scope.ALL)
@ActivatedByDefault
class DeadCodeCheck : AbstractBaseCheck() {
override fun init() {
subscribeTo(*CheckUtils.terminationStatements)
subscribeTo(PlSqlGrammar.METHOD_CALL)
}
override fun visitNode(node: AstNode) {
if (CheckUtils.isTerminationStatement(node)) {
var parent = node.parent
while (!checkNode(parent)) {
parent = parent.parent
}
}
}
private fun checkNode(node: AstNode?): Boolean {
if (!shouldCheckNode(node) || node == null) {
return true
}
val nextSibling = node.nextSiblingOrNull
if (nextSibling != null && nextSibling.typeIs(PlSqlGrammar.STATEMENT)) {
addIssue(nextSibling, getLocalizedMessage())
return true
}
return false
}
private fun shouldCheckNode(node: AstNode?): Boolean {
if (node == null || CheckUtils.isProgramUnit(node)) {
return false
}
return if (node.typeIs(STATEMENT_OR_CALL)) {
true
} else {
node.typeIs(STATEMENT_SECTION) && !node.hasDirectChildren(PlSqlGrammar.EXCEPTION_HANDLERS)
}
}
companion object {
val STATEMENT_OR_CALL = arrayOf(PlSqlGrammar.STATEMENT, PlSqlGrammar.BLOCK_STATEMENT, PlSqlGrammar.CALL_STATEMENT)
val STATEMENT_SECTION = arrayOf(PlSqlGrammar.STATEMENTS_SECTION, PlSqlGrammar.STATEMENTS)
}
}
================================================
FILE: zpa-checks/src/main/kotlin/com/felipebz/zpa/checks/DeclareSectionWithoutDeclarationsCheck.kt
================================================
/**
* Z PL/SQL Analyzer
* Copyright (C) 2015-2026 Felipe Zorzo
* mailto:felipe AT felipezorzo DOT com DOT br
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package com.felipebz.zpa.checks
import com.felipebz.flr.api.AstNode
import com.felipebz.zpa.api.PlSqlGrammar
import com.felipebz.zpa.api.PlSqlKeyword
import com.felipebz.zpa.api.annotations.*
@Rule(priority = Priority.INFO)
@ConstantRemediation("1min")
@RuleInfo(scope = RuleInfo.Scope.ALL)
@ActivatedByDefault
class DeclareSectionWithoutDeclarationsCheck : AbstractBaseCheck() {
override fun init() {
subscribeTo(PlSqlGrammar.BLOCK_STATEMENT)
}
override fun visitNode(node: AstNode) {
if (node.hasDirectChildren(PlSqlKeyword.DECLARE) && !node.hasDescendant(PlSqlGrammar.DECLARE_SECTION)) {
addIssue(node, getLocalizedMessage())
}
}
}
================================================
FILE: zpa-checks/src/main/kotlin/com/felipebz/zpa/checks/DisabledTestCheck.kt
================================================
/**
* Z PL/SQL Analyzer
* Copyright (C) 2015-2026 Felipe Zorzo
* mailto:felipe AT felipezorzo DOT com DOT br
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package com.felipebz.zpa.checks
import com.felipebz.flr.api.Trivia
import com.felipebz.zpa.api.annotations.ActivatedByDefault
import com.felipebz.zpa.api.annotations.Priority
import com.felipebz.zpa.api.annotations.Rule
import com.felipebz.zpa.api.annotations.RuleInfo
@Rule(priority = Priority.MAJOR, tags = [Tags.UTPLSQL])
@RuleInfo(scope = RuleInfo.Scope.TEST)
@ActivatedByDefault
class DisabledTestCheck : AbstractBaseCheck() {
override fun visitComment(trivia: Trivia, content: String) {
if (content.trim().equals("%disabled", ignoreCase = true)) {
addIssue(trivia.token, getLocalizedMessage())
}
}
}
================================================
FILE: zpa-checks/src/main/kotlin/com/felipebz/zpa/checks/DuplicateConditionIfElsifCheck.kt
================================================
/**
* Z PL/SQL Analyzer
* Copyright (C) 2015-2026 Felipe Zorzo
* mailto:felipe AT felipezorzo DOT com DOT br
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package com.felipebz.zpa.checks
import com.felipebz.flr.api.AstNode
import com.felipebz.zpa.asTree
import com.felipebz.zpa.sslr.IfStatement
import com.felipebz.zpa.api.PlSqlGrammar
import com.felipebz.zpa.api.annotations.*
@Rule(priority = Priority.BLOCKER, tags = [Tags.BUG])
@ConstantRemediation("5min")
@RuleInfo(scope = RuleInfo.Scope.ALL)
@ActivatedByDefault
class DuplicateConditionIfElsifCheck : AbstractBaseCheck() {
override fun init() {
subscribeTo(PlSqlGrammar.IF_STATEMENT)
}
override fun visitNode(node: AstNode) {
val ifStatement = node.asTree()
val conditions = collectConditionsFromBranches(ifStatement)
findSameConditions(conditions)
}
private fun findSameConditions(branches: List) {
for (i in 1 until branches.size) {
checkCondition(branches, i)
}
}
private fun checkCondition(conditions: List, index: Int) {
val condition = conditions[index]
for (j in 0 until index) {
val otherCondition = conditions[j]
if (CheckUtils.equalNodes(otherCondition, condition)) {
addIssue(condition, getLocalizedMessage(), otherCondition.token.line)
.secondary(otherCondition, "Original")
return
}
}
}
private fun collectConditionsFromBranches(ifStatement: IfStatement): List {
val conditionsFromBranches = ArrayList()
conditionsFromBranches.add(ifStatement.condition)
for (branch in ifStatement.elsifClauses) {
conditionsFromBranches.add(branch.condition)
}
return conditionsFromBranches
}
}
================================================
FILE: zpa-checks/src/main/kotlin/com/felipebz/zpa/checks/DuplicatedValueInInCheck.kt
================================================
/**
* Z PL/SQL Analyzer
* Copyright (C) 2015-2026 Felipe Zorzo
* mailto:felipe AT felipezorzo DOT com DOT br
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package com.felipebz.zpa.checks
import com.felipebz.flr.api.AstNode
import com.felipebz.zpa.typeIs
import com.felipebz.zpa.api.PlSqlGrammar
import com.felipebz.zpa.api.PlSqlPunctuator
import com.felipebz.zpa.api.annotations.*
@Rule(priority = Priority.BLOCKER, tags = [Tags.BUG])
@ConstantRemediation("5min")
@RuleInfo(scope = RuleInfo.Scope.ALL)
@ActivatedByDefault
class DuplicatedValueInInCheck : AbstractBaseCheck() {
override fun init() {
subscribeTo(PlSqlGrammar.IN_EXPRESSION)
}
override fun visitNode(node: AstNode) {
val values = getInValue(node)
findSameValues(values)
}
private fun getInValue(inExpression: AstNode): List {
val values = ArrayList()
var current = inExpression.getFirstChildOrNull(PlSqlPunctuator.LPARENTHESIS)
while (current != null) {
current = current.nextSibling
if (current.typeIs(PlSqlPunctuator.RPARENTHESIS)) {
current = null
} else if (!current.typeIs(PlSqlPunctuator.COMMA)) {
values.add(current)
}
}
return values
}
private fun findSameValues(values: List) {
for (i in 1 until values.size) {
checkValue(values, i)
}
}
private fun checkValue(values: List, index: Int) {
val current = values[index]
for (j in 0 until index) {
val other = values[j]
if (CheckUtils.equalNodes(current, other)) {
addIssue(current, getLocalizedMessage(), current.tokenOriginalValue)
.secondary(other, "Original")
return
}
}
}
}
================================================
FILE: zpa-checks/src/main/kotlin/com/felipebz/zpa/checks/EmptyBlockCheck.kt
================================================
/**
* Z PL/SQL Analyzer
* Copyright (C) 2015-2026 Felipe Zorzo
* mailto:felipe AT felipezorzo DOT com DOT br
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package com.felipebz.zpa.checks
import com.felipebz.flr.api.AstNode
import com.felipebz.zpa.isOf
import com.felipebz.zpa.sslr.NullStatement
import com.felipebz.zpa.api.PlSqlGrammar
import com.felipebz.zpa.api.annotations.*
@Rule(priority = Priority.MINOR, tags = [Tags.UNUSED])
@ConstantRemediation("5min")
@RuleInfo(scope = RuleInfo.Scope.ALL)
@ActivatedByDefault
class EmptyBlockCheck : AbstractBaseCheck() {
override fun init() {
subscribeTo(PlSqlGrammar.STATEMENTS_SECTION)
}
override fun visitNode(node: AstNode) {
if (context.currentScope?.isOverridingMember == true) {
return
}
val statements = node.getFirstChild(PlSqlGrammar.STATEMENTS).getChildren(PlSqlGrammar.STATEMENT)
if (statements.size == 1) {
val statement = statements[0]
if (statement.isOf()) {
addIssue(statement, getLocalizedMessage())
}
}
}
}
================================================
FILE: zpa-checks/src/main/kotlin/com/felipebz/zpa/checks/EmptyStringAssignmentCheck.kt
================================================
/**
* Z PL/SQL Analyzer
* Copyright (C) 2015-2026 Felipe Zorzo
* mailto:felipe AT felipezorzo DOT com DOT br
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package com.felipebz.zpa.checks
import com.felipebz.flr.api.AstNode
import com.felipebz.zpa.api.PlSqlGrammar
import com.felipebz.zpa.api.annotations.*
@Rule(priority = Priority.MINOR)
@ConstantRemediation("2min")
@RuleInfo(scope = RuleInfo.Scope.ALL)
@ActivatedByDefault
class EmptyStringAssignmentCheck : AbstractBaseCheck() {
override fun init() {
subscribeTo(PlSqlGrammar.ASSIGNMENT_STATEMENT)
}
override fun visitNode(node: AstNode) {
val value = node.getLastChildOrNull(PlSqlGrammar.LITERAL)
if (value != null && CheckUtils.isEmptyString(value)) {
addIssue(node, getLocalizedMessage())
}
}
}
================================================
FILE: zpa-checks/src/main/kotlin/com/felipebz/zpa/checks/ExplicitInParameterCheck.kt
================================================
/**
* Z PL/SQL Analyzer
* Copyright (C) 2015-2026 Felipe Zorzo
* mailto:felipe AT felipezorzo DOT com DOT br
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package com.felipebz.zpa.checks
import com.felipebz.flr.api.AstNode
import com.felipebz.zpa.api.PlSqlGrammar
import com.felipebz.zpa.api.PlSqlKeyword
import com.felipebz.zpa.api.annotations.*
@Rule(priority = Priority.MINOR)
@ConstantRemediation("2min")
@RuleInfo(scope = RuleInfo.Scope.ALL)
@ActivatedByDefault
class ExplicitInParameterCheck : AbstractBaseCheck() {
override fun init() {
subscribeTo(PlSqlGrammar.PARAMETER_DECLARATION)
}
override fun visitNode(node: AstNode) {
if (!node.hasDirectChildren(PlSqlKeyword.IN, PlSqlKeyword.OUT)) {
addIssue(node, getLocalizedMessage())
}
}
}
================================================
FILE: zpa-checks/src/main/kotlin/com/felipebz/zpa/checks/FunctionWithOutParameterCheck.kt
================================================
/**
* Z PL/SQL Analyzer
* Copyright (C) 2015-2026 Felipe Zorzo
* mailto:felipe AT felipezorzo DOT com DOT br
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package com.felipebz.zpa.checks
import com.felipebz.flr.api.AstNode
import com.felipebz.zpa.api.PlSqlGrammar
import com.felipebz.zpa.api.PlSqlKeyword
import com.felipebz.zpa.api.annotations.*
@Rule(priority = Priority.MAJOR)
@ConstantRemediation("1h")
@RuleInfo(scope = RuleInfo.Scope.ALL)
@ActivatedByDefault
class FunctionWithOutParameterCheck : AbstractBaseCheck() {
override fun init() {
subscribeTo(PlSqlGrammar.PARAMETER_DECLARATION)
}
override fun visitNode(node: AstNode) {
if (node.parent.hasParent(PlSqlGrammar.FUNCTION_DECLARATION, PlSqlGrammar.CREATE_FUNCTION) && node.hasDirectChildren(PlSqlKeyword.OUT)) {
addIssue(node, getLocalizedMessage())
}
}
}
================================================
FILE: zpa-checks/src/main/kotlin/com/felipebz/zpa/checks/IdenticalExpressionCheck.kt
================================================
/**
* Z PL/SQL Analyzer
* Copyright (C) 2015-2026 Felipe Zorzo
* mailto:felipe AT felipezorzo DOT com DOT br
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package com.felipebz.zpa.checks
import com.felipebz.flr.api.AstNode
import com.felipebz.zpa.api.ConditionsGrammar
import com.felipebz.zpa.api.PlSqlGrammar
import com.felipebz.zpa.api.annotations.*
@Rule(priority = Priority.BLOCKER, tags = [Tags.BUG])
@ConstantRemediation("2min")
@RuleInfo(scope = RuleInfo.Scope.ALL)
@ActivatedByDefault
class IdenticalExpressionCheck : AbstractBaseCheck() {
override fun init() {
subscribeTo(PlSqlGrammar.COMPARISON_EXPRESSION)
}
override fun visitNode(node: AstNode) {
val operator = node.getFirstChildOrNull(ConditionsGrammar.RELATIONAL_OPERATOR)
if (operator != null) {
val leftSide = node.firstChild
val rightSide = node.lastChild
if (CheckUtils.equalNodes(leftSide, rightSide)) {
addIssue(leftSide, getLocalizedMessage(), operator.tokenValue)
.secondary(rightSide, "Original")
}
}
}
}
================================================
FILE: zpa-checks/src/main/kotlin/com/felipebz/zpa/checks/IfWithExitCheck.kt
================================================
/**
* Z PL/SQL Analyzer
* Copyright (C) 2015-2026 Felipe Zorzo
* mailto:felipe AT felipezorzo DOT com DOT br
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package com.felipebz.zpa.checks
import com.felipebz.flr.api.AstNode
import com.felipebz.zpa.sslr.IfStatement
import com.felipebz.zpa.tryGetAsTree
import com.felipebz.zpa.api.PlSqlGrammar
import com.felipebz.zpa.api.annotations.*
@Rule(priority = Priority.MINOR)
@ConstantRemediation("5min")
@RuleInfo(scope = RuleInfo.Scope.ALL)
@ActivatedByDefault
class IfWithExitCheck : AbstractBaseCheck() {
override fun init() {
subscribeTo(PlSqlGrammar.EXIT_STATEMENT)
}
override fun visitNode(node: AstNode) {
val statement = node.parent
val ifStatement = statement.parent.parent.tryGetAsTree()
if (ifStatement != null &&
ifStatement.elsifClauses.isEmpty() && ifStatement.elseClause == null &&
ifStatement.statements.size == 1) {
addIssue(ifStatement, getLocalizedMessage())
}
}
}
================================================
FILE: zpa-checks/src/main/kotlin/com/felipebz/zpa/checks/InequalityUsageCheck.kt
================================================
/**
* Z PL/SQL Analyzer
* Copyright (C) 2015-2026 Felipe Zorzo
* mailto:felipe AT felipezorzo DOT com DOT br
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package com.felipebz.zpa.checks
import com.felipebz.flr.api.AstNode
import com.felipebz.zpa.api.PlSqlGrammar
import com.felipebz.zpa.api.annotations.*
@Rule(priority = Priority.MAJOR, tags = [Tags.OBSOLETE])
@ConstantRemediation("5min")
@RuleInfo(scope = RuleInfo.Scope.ALL)
@ActivatedByDefault
class InequalityUsageCheck : AbstractBaseCheck() {
override fun init() {
subscribeTo(PlSqlGrammar.NOTEQUALS_NONSTANDARD_OPERATOR)
}
override fun visitNode(node: AstNode) {
addLineIssue(getLocalizedMessage(), node.tokenLine, node.tokens.joinToString("") { it.value })
}
}
================================================
FILE: zpa-checks/src/main/kotlin/com/felipebz/zpa/checks/InsertWithoutColumnsCheck.kt
================================================
/**
* Z PL/SQL Analyzer
* Copyright (C) 2015-2026 Felipe Zorzo
* mailto:felipe AT felipezorzo DOT com DOT br
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package com.felipebz.zpa.checks
import com.felipebz.flr.api.AstNode
import com.felipebz.zpa.api.DmlGrammar
import com.felipebz.zpa.api.PlSqlGrammar
import com.felipebz.zpa.api.annotations.*
import com.felipebz.zpa.api.symbols.PlSqlType
@Rule(priority = Priority.CRITICAL, tags = [Tags.CONVENTION, Tags.BUG])
@ConstantRemediation("5min")
@RuleInfo(scope = RuleInfo.Scope.ALL)
@ActivatedByDefault
class InsertWithoutColumnsCheck : AbstractBaseCheck() {
override fun init() {
subscribeTo(DmlGrammar.SINGLE_TABLE_INSERT)
}
override fun visitNode(node: AstNode) {
if (!node.hasDescendant(DmlGrammar.INSERT_COLUMNS)) {
val valuesClause = node.getFirstChildOrNull(DmlGrammar.VALUES_CLAUSE);
if (valuesClause != null &&
semantic(valuesClause.lastChild).plSqlType === PlSqlType.ROWTYPE) {
return
}
if (node.parent.parent.parent.type === PlSqlGrammar.FORALL_STATEMENT) {
return
}
addIssue(node, getLocalizedMessage())
}
}
}
================================================
FILE: zpa-checks/src/main/kotlin/com/felipebz/zpa/checks/InvalidReferenceToObjectCheck.kt
================================================
/**
* Z PL/SQL Analyzer
* Copyright (C) 2015-2026 Felipe Zorzo
* mailto:felipe AT felipezorzo DOT com DOT br
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package com.felipebz.zpa.checks
import com.felipebz.flr.api.AstNode
import com.felipebz.zpa.FormsMetadataAwareCheck
import com.felipebz.zpa.typeIs
import com.felipebz.zpa.api.PlSqlGrammar
import com.felipebz.zpa.api.annotations.*
import com.felipebz.zpa.api.matchers.MethodMatcher
import java.util.*
@Rule(priority = Priority.MAJOR, tags = [Tags.BUG])
@ConstantRemediation("5min")
@RuleInfo(scope = RuleInfo.Scope.MAIN)
@ActivatedByDefault
class InvalidReferenceToObjectCheck : AbstractBaseCheck(), FormsMetadataAwareCheck {
private val verifiers = listOf(
Verifier(MethodMatcher.create().name("find_alert").addParameter(), ObjectType.ALERT),
Verifier(MethodMatcher.create().name("set_alert_button_property").addParameters(4), ObjectType.ALERT),
Verifier(MethodMatcher.create().name("set_alert_property").addParameters(3), ObjectType.ALERT),
Verifier(MethodMatcher.create().name("show_alert").addParameter(), ObjectType.ALERT),
Verifier(MethodMatcher.create().name("find_lov").addParameter(), ObjectType.LOV),
Verifier(MethodMatcher.create().name("get_lov_property").addParameters(2), ObjectType.LOV),
Verifier(MethodMatcher.create().name("set_lov_column_property").addParameters(4), ObjectType.LOV),
Verifier(MethodMatcher.create().name("set_lov_property").addParameters(3), ObjectType.LOV),
Verifier(MethodMatcher.create().name("set_lov_property").addParameters(4), ObjectType.LOV),
Verifier(MethodMatcher.create().name("show_lov").addParameter(), ObjectType.LOV),
Verifier(MethodMatcher.create().name("find_block").addParameter(), ObjectType.BLOCK),
Verifier(MethodMatcher.create().name("get_block_property").addParameters(2), ObjectType.BLOCK),
Verifier(MethodMatcher.create().name("go_block").addParameter(), ObjectType.BLOCK),
Verifier(MethodMatcher.create().name("set_block_property").addParameters(3), ObjectType.BLOCK),
Verifier(MethodMatcher.create().name("set_block_property").addParameters(4), ObjectType.BLOCK),
Verifier(MethodMatcher.create().name("checkbox_checked").addParameter(), ObjectType.ITEM),
Verifier(MethodMatcher.create().name("convert_other_value").addParameter(), ObjectType.ITEM),
Verifier(MethodMatcher.create().name("display_item").addParameters(2), ObjectType.ITEM),
Verifier(MethodMatcher.create().name("find_item").addParameter(), ObjectType.ITEM),
Verifier(MethodMatcher.create().name("get_item_instance_property").addParameters(3), ObjectType.ITEM),
Verifier(MethodMatcher.create().name("get_item_property").addParameters(2), ObjectType.ITEM),
Verifier(MethodMatcher.create().name("get_radio_button_property").addParameters(3), ObjectType.ITEM),
Verifier(MethodMatcher.create().name("go_item").addParameter(), ObjectType.ITEM),
Verifier(MethodMatcher.create().name("image_scroll").addParameters(3), ObjectType.ITEM),
Verifier(MethodMatcher.create().name("image_zoom").addParameters(2), ObjectType.ITEM),
Verifier(MethodMatcher.create().name("image_zoom").addParameters(3), ObjectType.ITEM),
Verifier(MethodMatcher.create().name("play_sound").addParameter(), ObjectType.ITEM),
Verifier(MethodMatcher.create().name("read_image_file").addParameters(3), 3, ObjectType.ITEM),
Verifier(MethodMatcher.create().name("read_sound_file").addParameters(3), 3, ObjectType.ITEM),
Verifier(MethodMatcher.create().name("recalculate").addParameter(), ObjectType.ITEM),
Verifier(MethodMatcher.create().name("set_item_instance_property").addParameters(4), ObjectType.ITEM),
Verifier(MethodMatcher.create().name("set_item_property").addParameters(3), ObjectType.ITEM),
Verifier(MethodMatcher.create().name("set_item_property").addParameters(4), ObjectType.ITEM),
Verifier(MethodMatcher.create().name("set_radio_button_property").addParameters(4), ObjectType.ITEM),
Verifier(MethodMatcher.create().name("set_radio_button_property").addParameters(5), ObjectType.ITEM),
Verifier(MethodMatcher.create().name("write_image_file").addParameters(5), 3, ObjectType.ITEM),
Verifier(MethodMatcher.create().name("write_sound_file").addParameters(5), 3, ObjectType.ITEM)
)
override fun init() {
subscribeTo(PlSqlGrammar.METHOD_CALL)
}
override fun visitNode(node: AstNode) {
val verifier = verifiers.firstOrNull { v -> v.matcher.matches(node) }
if (verifier != null) {
val argument = verifier.matcher.getArgumentsValues(node)[verifier.argumentToCheck]
if (!isVarcharLiteral(argument)) {
return
}
val value = argument.tokenOriginalValue.replace("'", "")
val reportIssue = when (verifier.type) {
ObjectType.ALERT -> validateAlert(value)
ObjectType.BLOCK -> validateBlock(value)
ObjectType.ITEM -> validateItem(value)
ObjectType.LOV -> validateLov(value)
}
if (reportIssue) {
addIssue(argument, getLocalizedMessage(), value,
verifier.matcher.methodName.uppercase(Locale.getDefault())
)
}
}
}
private fun validateAlert(value: String): Boolean {
return context.formsMetadata?.alerts?.none { alert -> alert.equals(value, ignoreCase = true) } ?: false
}
private fun validateBlock(value: String): Boolean {
return context.formsMetadata?.blocks?.none { block -> block.name.equals(value, ignoreCase = true) } ?: false
}
private fun validateItem(value: String): Boolean {
val formsMetadata = context.formsMetadata ?: return false
var reportIssue = true
for (block in formsMetadata.blocks) {
if (block.items.any { item ->
val fullName = "${block.name}.$item"
fullName.equals(value, ignoreCase = true)
}) {
reportIssue = false
}
}
return reportIssue
}
private fun validateLov(value: String): Boolean {
return context.formsMetadata?.lovs?.none { lov -> lov.equals(value, ignoreCase = true) } ?: false
}
private enum class ObjectType {
ALERT, BLOCK, ITEM, LOV
}
private inner class Verifier(val matcher: MethodMatcher, argumentToCheck: Int, val type: ObjectType) {
val argumentToCheck: Int = argumentToCheck - 1
constructor(matcher: MethodMatcher, type: ObjectType) : this(matcher, 1, type)
}
private fun isVarcharLiteral(argument: AstNode): Boolean {
return if (argument.typeIs(PlSqlGrammar.LITERAL)) {
argument.hasDirectChildren(PlSqlGrammar.CHARACTER_LITERAL)
} else false
}
}
================================================
FILE: zpa-checks/src/main/kotlin/com/felipebz/zpa/checks/NotASelectedExpressionCheck.kt
================================================
/**
* Z PL/SQL Analyzer
* Copyright (C) 2015-2026 Felipe Zorzo
* mailto:felipe AT felipezorzo DOT com DOT br
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package com.felipebz.zpa.checks
import com.felipebz.flr.api.AstNode
import com.felipebz.zpa.typeIs
import com.felipebz.zpa.api.DmlGrammar
import com.felipebz.zpa.api.PlSqlGrammar
import com.felipebz.zpa.api.PlSqlKeyword
import com.felipebz.zpa.api.annotations.*
@Rule(priority = Priority.CRITICAL, tags = [Tags.BUG])
@ConstantRemediation("5min")
@RuleInfo(scope = RuleInfo.Scope.ALL)
@ActivatedByDefault
class NotASelectedExpressionCheck : AbstractBaseCheck() {
override fun init() {
subscribeTo(DmlGrammar.SELECT_EXPRESSION)
}
override fun visitNode(node: AstNode) {
val firstQueryBlock = node.getFirstChild(DmlGrammar.QUERY_BLOCK)
if (!firstQueryBlock.children[1].typeIs(PlSqlKeyword.DISTINCT) || !node.hasDirectChildren(DmlGrammar.ORDER_BY_CLAUSE)) {
return
}
val columns = firstQueryBlock.getChildren(DmlGrammar.SELECT_COLUMN)
val orderByItems = node.getFirstChild(DmlGrammar.ORDER_BY_CLAUSE).getChildren(DmlGrammar.ORDER_BY_ITEM)
for (orderByItem in orderByItems) {
checkOrderByItem(orderByItem, columns)
}
}
private fun checkOrderByItem(orderByItem: AstNode, columns: List) {
val orderByItemValue = skipVariableName(orderByItem.firstChild)
if (orderByItemValue.typeIs(PlSqlGrammar.LITERAL)) {
return
}
var found = false
for (column in columns) {
val candidates = extractAcceptableValuesFromColumn(column)
for (candidate in candidates) {
if (CheckUtils.containsNode(candidate, orderByItemValue)) {
found = true
}
}
}
if (!found) {
addIssue(orderByItemValue, getLocalizedMessage())
}
}
private fun skipVariableName(node: AstNode): AstNode {
return if (node.typeIs(PlSqlGrammar.VARIABLE_NAME)) {
node.firstChild
} else node
}
private fun extractAcceptableValuesFromColumn(column: AstNode): List {
val values = ArrayList()
val selectedExpression = skipVariableName(column.firstChild)
values.add(selectedExpression)
// if the value is "table.column", "column" can be used in order by
if (selectedExpression.typeIs(PlSqlGrammar.MEMBER_EXPRESSION)) {
values.add(selectedExpression.lastChild)
}
if (column.numberOfChildren > 1) {
val alias = skipVariableName(column.lastChild)
values.add(alias)
}
return values
}
}
================================================
FILE: zpa-checks/src/main/kotlin/com/felipebz/zpa/checks/NotFoundCheck.kt
================================================
/**
* Z PL/SQL Analyzer
* Copyright (C) 2015-2026 Felipe Zorzo
* mailto:felipe AT felipezorzo DOT com DOT br
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package com.felipebz.zpa.checks
import com.felipebz.flr.api.AstNode
import com.felipebz.zpa.typeIs
import com.felipebz.zpa.api.PlSqlGrammar
import com.felipebz.zpa.api.PlSqlPunctuator
import com.felipebz.zpa.api.annotations.*
@Rule(priority = Priority.MINOR)
@ConstantRemediation("5min")
@RuleInfo(scope = RuleInfo.Scope.ALL)
@ActivatedByDefault
class NotFoundCheck : AbstractBaseCheck() {
override fun init() {
subscribeTo(PlSqlGrammar.MEMBER_EXPRESSION)
}
override fun visitNode(node: AstNode) {
val parent = node.parent
if (parent.typeIs(PlSqlGrammar.NOT_EXPRESSION) && node.numberOfChildren == 3) {
val foundCandidate = node.lastChild
val percentCandidate = foundCandidate.previousAstNode
if (percentCandidate.typeIs(PlSqlPunctuator.MOD) && "FOUND" == foundCandidate.tokenValue) {
addIssue(node, getLocalizedMessage())
}
}
}
}
================================================
FILE: zpa-checks/src/main/kotlin/com/felipebz/zpa/checks/NvlWithNullParameterCheck.kt
================================================
/**
* Z PL/SQL Analyzer
* Copyright (C) 2015-2026 Felipe Zorzo
* mailto:felipe AT felipezorzo DOT com DOT br
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package com.felipebz.zpa.checks
import com.felipebz.flr.api.AstNode
import com.felipebz.zpa.api.PlSqlGrammar
import com.felipebz.zpa.api.annotations.*
import com.felipebz.zpa.api.matchers.MethodMatcher
@Rule(priority = Priority.BLOCKER, tags = [Tags.BUG])
@ConstantRemediation("5min")
@RuleInfo(scope = RuleInfo.Scope.ALL)
@ActivatedByDefault
class NvlWithNullParameterCheck : AbstractBaseCheck() {
override fun init() {
subscribeTo(PlSqlGrammar.METHOD_CALL)
}
override fun visitNode(node: AstNode) {
val nvl = MethodMatcher.create().name("nvl").addParameters(2)
if (!nvl.matches(node)) {
return
}
for (argument in nvl.getArgumentsValues(node)) {
if (CheckUtils.isNullLiteralOrEmptyString(argument)) {
addIssue(node, getLocalizedMessage(), argument.tokenValue)
}
}
}
}
================================================
FILE: zpa-checks/src/main/kotlin/com/felipebz/zpa/checks/ParsingErrorCheck.kt
================================================
/**
* Z PL/SQL Analyzer
* Copyright (C) 2015-2026 Felipe Zorzo
* mailto:felipe AT felipezorzo DOT com DOT br
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package com.felipebz.zpa.checks
import com.felipebz.flr.api.AstNode
import com.felipebz.zpa.api.PlSqlGrammar
import com.felipebz.zpa.api.annotations.Priority
import com.felipebz.zpa.api.annotations.Rule
import com.felipebz.zpa.api.annotations.RuleInfo
@Rule(priority = Priority.INFO)
@RuleInfo(scope = RuleInfo.Scope.ALL)
class ParsingErrorCheck : AbstractBaseCheck() {
override fun init() {
val parsingException = context.parsingException()
if (parsingException != null) {
parsingException.message?.let {
addLineIssue(it, parsingException.line)
}
}
subscribeTo(PlSqlGrammar.RECOVERY)
}
override fun visitNode(node: AstNode) {
addIssue(node, getLocalizedMessage())
}
}
================================================
FILE: zpa-checks/src/main/kotlin/com/felipebz/zpa/checks/QueryWithoutExceptionHandlingCheck.kt
================================================
/**
* Z PL/SQL Analyzer
* Copyright (C) 2015-2026 Felipe Zorzo
* mailto:felipe AT felipezorzo DOT com DOT br
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package com.felipebz.zpa.checks
import com.felipebz.flr.api.AstNode
import com.felipebz.zpa.typeIs
import com.felipebz.zpa.api.DmlGrammar
import com.felipebz.zpa.api.PlSqlGrammar
import com.felipebz.zpa.api.PlSqlKeyword
import com.felipebz.zpa.api.annotations.*
@Rule(priority = Priority.CRITICAL)
@ConstantRemediation("20min")
@RuleInfo(scope = RuleInfo.Scope.MAIN)
@ActivatedByDefault
class QueryWithoutExceptionHandlingCheck : AbstractBaseCheck() {
@RuleProperty(key = "strict", defaultValue = "true")
var strictMode = true
override fun init() {
subscribeTo(PlSqlGrammar.SELECT_STATEMENT)
}
override fun visitNode(node: AstNode) {
val intoClause = node.getFirstDescendantOrNull(DmlGrammar.INTO_CLAUSE)
if (intoClause?.firstChild.typeIs(PlSqlKeyword.BULK)) {
return
}
if (strictMode) {
val parentBlock = node.getFirstAncestorOrNull(PlSqlGrammar.STATEMENTS_SECTION)
if (parentBlock?.hasDirectChildren(PlSqlGrammar.EXCEPTION_HANDLERS) == false) {
addIssue(node, getLocalizedMessage())
}
} else {
val hasExceptionHandler = context.currentScope?.hasExceptionHandler ?: false
if (!hasExceptionHandler) {
addIssue(node, getLocalizedMessage())
}
}
}
}
================================================
FILE: zpa-checks/src/main/kotlin/com/felipebz/zpa/checks/RaiseStandardExceptionCheck.kt
================================================
/**
* Z PL/SQL Analyzer
* Copyright (C) 2015-2026 Felipe Zorzo
* mailto:felipe AT felipezorzo DOT com DOT br
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package com.felipebz.zpa.checks
import com.felipebz.flr.api.AstNode
import com.felipebz.zpa.asTree
import com.felipebz.zpa.sslr.RaiseStatement
import com.felipebz.zpa.api.PlSqlGrammar
import com.felipebz.zpa.api.annotations.*
@Rule(priority = Priority.MAJOR)
@ConstantRemediation("20min")
@RuleInfo(scope = RuleInfo.Scope.ALL)
@ActivatedByDefault
class RaiseStandardExceptionCheck : AbstractBaseCheck() {
private val standardExceptions = listOf(
"ACCESS_INTO_NULL",
"CASE_NOT_FOUND",
"COLLECTION_IS_NULL",
"CURSOR_ALREADY_OPEN",
"DUP_VAL_ON_INDEX",
"INVALID_CURSOR",
"INVALID_NUMBER",
"LOGIN_DENIED",
"NO_DATA_FOUND",
"NOT_LOGGED_ON",
"PROGRAM_ERROR",
"ROWTYPE_MISMATCH",
"SELF_IS_NULL",
"STORAGE_ERROR",
"SUBSCRIPT_BEYOND_COUNT",
"SUBSCRIPT_OUTSIDE_LIMIT",
"SYS_INVALID_ROWID",
"TIMEOUT_ON_RESOURCE",
"TOO_MANY_ROWS",
"VALUE_ERROR",
"ZERO_DIVIDE")
override fun init() {
subscribeTo(PlSqlGrammar.RAISE_STATEMENT)
}
override fun visitNode(node: AstNode) {
val statement = node.asTree()
val exceptionIdentifier = statement.exception
if (exceptionIdentifier != null) {
val exceptionName = exceptionIdentifier.tokenValue
if (standardExceptions.contains(exceptionName)) {
addLineIssue(getLocalizedMessage(), exceptionIdentifier.tokenLine, exceptionName)
}
}
}
}
================================================
FILE: zpa-checks/src/main/kotlin/com/felipebz/zpa/checks/RedundantExpectationCheck.kt
================================================
/**
* Z PL/SQL Analyzer
* Copyright (C) 2015-2026 Felipe Zorzo
* mailto:felipe AT felipezorzo DOT com DOT br
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package com.felipebz.zpa.checks
import com.felipebz.flr.api.AstNode
import com.felipebz.zpa.api.PlSqlGrammar
import com.felipebz.zpa.api.annotations.*
import com.felipebz.zpa.api.matchers.MethodMatcher
@Rule(priority = Priority.MAJOR, tags = [Tags.UTPLSQL, Tags.BUG])
@ConstantRemediation("5min")
@RuleInfo(scope = RuleInfo.Scope.TEST)
@ActivatedByDefault
class RedundantExpectationCheck : AbstractBaseCheck() {
override fun init() {
subscribeTo(PlSqlGrammar.METHOD_CALL)
}
override fun visitNode(node: AstNode) {
if (expectMatcher.matches(node)) {
val expectationNode = node.nextSibling.nextSibling
val actualValue = expectMatcher.getArgumentsValues(node)[0]
val matcherArguments = expectMatcher.getArgumentsValues(expectationNode)
if (matcherArguments.isEmpty()) {
return
}
val expectedValue = matcherArguments[0]
if (CheckUtils.equalNodes(actualValue, expectedValue)) {
addIssue(actualValue, getLocalizedMessage()).secondary(expectedValue, "Expected value")
}
}
}
companion object {
private val expectMatcher = MethodMatcher.create()
.packageName("UT")
.name("EXPECT")
.withNoParameterConstraint()
}
}
================================================
FILE: zpa-checks/src/main/kotlin/com/felipebz/zpa/checks/ReturnOfBooleanExpressionCheck.kt
================================================
/**
* Z PL/SQL Analyzer
* Copyright (C) 2015-2026 Felipe Zorzo
* mailto:felipe AT felipezorzo DOT com DOT br
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package com.felipebz.zpa.checks
import com.felipebz.flr.api.AstNode
import com.felipebz.zpa.asTree
import com.felipebz.zpa.sslr.IfStatement
import com.felipebz.zpa.sslr.TreeWithStatements
import com.felipebz.zpa.typeIs
import com.felipebz.zpa.api.PlSqlGrammar
import com.felipebz.zpa.api.annotations.*
@Rule(priority = Priority.MINOR, tags = [Tags.CLUMSY])
@ConstantRemediation("2min")
@RuleInfo(scope = RuleInfo.Scope.ALL)
@ActivatedByDefault
class ReturnOfBooleanExpressionCheck : AbstractBaseCheck() {
override fun init() {
subscribeTo(PlSqlGrammar.IF_STATEMENT)
}
override fun visitNode(node: AstNode) {
val ifStatement = node.asTree()
val elseClause = ifStatement.elseClause
if (!hasElsif(ifStatement) && elseClause != null) {
val firstBoolean = getBooleanValue(ifStatement)
val secondBoolean = getBooleanValue(elseClause)
if (firstBoolean != null && secondBoolean != null
&& firstBoolean.tokenValue != secondBoolean.tokenValue) {
addIssue(node, getLocalizedMessage())
}
}
}
private fun hasElsif(ifStatement: IfStatement): Boolean {
return ifStatement.elsifClauses.isNotEmpty()
}
private fun getBooleanValue(node: TreeWithStatements): AstNode? {
return extractBooleanValueFromReturn(getStatementFrom(node))
}
private fun getStatementFrom(node: TreeWithStatements): AstNode? {
val statements = node.statements
return if (statements.size == 1) {
statements[0]
} else null
}
private fun extractBooleanValueFromReturn(node: AstNode?): AstNode? {
if (node != null) {
val child = node.firstChild
if (child.typeIs(PlSqlGrammar.RETURN_STATEMENT)) {
val expression = child.getFirstChildOrNull(PlSqlGrammar.LITERAL)
return getBooleanLiteral(expression)
}
}
return null
}
private fun getBooleanLiteral(expression: AstNode?): AstNode? {
return expression?.getFirstChildOrNull(PlSqlGrammar.BOOLEAN_LITERAL)
}
}
================================================
FILE: zpa-checks/src/main/kotlin/com/felipebz/zpa/checks/SameBranchCheck.kt
================================================
/**
* Z PL/SQL Analyzer
* Copyright (C) 2015-2026 Felipe Zorzo
* mailto:felipe AT felipezorzo DOT com DOT br
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package com.felipebz.zpa.checks
import com.felipebz.flr.api.AstNode
import com.felipebz.zpa.asTree
import com.felipebz.zpa.sslr.IfStatement
import com.felipebz.zpa.api.PlSqlGrammar
import com.felipebz.zpa.api.annotations.*
@Rule(priority = Priority.MAJOR, tags = [Tags.BUG])
@ConstantRemediation("10min")
@RuleInfo(scope = RuleInfo.Scope.ALL)
@ActivatedByDefault
class SameBranchCheck : AbstractBaseCheck() {
override fun init() {
subscribeTo(PlSqlGrammar.IF_STATEMENT)
}
override fun visitNode(node: AstNode) {
val ifStatement = node.asTree()
val branches = collectStatementsFromBranches(ifStatement)
findSameBranches(branches)
}
private fun findSameBranches(branches: List) {
for (i in 1 until branches.size) {
checkBranch(branches, i)
}
}
private fun checkBranch(branches: List, index: Int) {
val branch = branches[index]
val previousBranchIndex = index - 1
val otherBranch = branches[previousBranchIndex]
if (CheckUtils.equalNodes(otherBranch, branch)) {
addIssue(branch, getLocalizedMessage(), otherBranch.token.line)
.secondary(otherBranch, "Original")
}
}
private fun collectStatementsFromBranches(ifStatement: IfStatement): List {
val statementsFromBranches = ArrayList()
statementsFromBranches.add(ifStatement.statements.astNode)
for (branch in ifStatement.elsifClauses) {
statementsFromBranches.add(branch.statements.astNode)
}
val elseBranch = ifStatement.elseClause
if (elseBranch != null) {
statementsFromBranches.add(elseBranch.statements.astNode)
}
return statementsFromBranches
}
}
================================================
FILE: zpa-checks/src/main/kotlin/com/felipebz/zpa/checks/SameConditionCheck.kt
================================================
/**
* Z PL/SQL Analyzer
* Copyright (C) 2015-2026 Felipe Zorzo
* mailto:felipe AT felipezorzo DOT com DOT br
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package com.felipebz.zpa.checks
import com.felipebz.flr.api.AstNode
import com.felipebz.zpa.typeIs
import com.felipebz.zpa.api.PlSqlGrammar
import com.felipebz.zpa.api.PlSqlKeyword
import com.felipebz.zpa.api.annotations.*
@Rule(priority = Priority.BLOCKER, tags = [Tags.BUG])
@ConstantRemediation("5min")
@RuleInfo(scope = RuleInfo.Scope.ALL)
@ActivatedByDefault
class SameConditionCheck : AbstractBaseCheck() {
override fun init() {
subscribeTo(PlSqlGrammar.AND_EXPRESSION)
subscribeTo(PlSqlGrammar.OR_EXPRESSION)
}
override fun visitNode(node: AstNode) {
val expressions = getExpressions(node)
findSameConditions(expressions)
}
private fun findSameConditions(conditions: List) {
for (i in 1 until conditions.size) {
checkCondition(conditions, i)
}
}
private fun checkCondition(conditions: List, index: Int) {
val condition = conditions[index]
for (j in 0 until index) {
val otherCondition = conditions[j]
if (CheckUtils.equalNodes(otherCondition, condition)) {
addIssue(condition, getLocalizedMessage(), otherCondition.token.line)
.secondary(otherCondition, "Original")
return
}
}
}
private fun getExpressions(node: AstNode): List {
val expressions = ArrayList()
for (subnode in node.children) {
if (!subnode.typeIs(PlSqlKeyword.AND) && !subnode.typeIs(PlSqlKeyword.OR)) {
expressions.add(subnode)
}
}
return expressions
}
}
================================================
FILE: zpa-checks/src/main/kotlin/com/felipebz/zpa/checks/SelectAllColumnsCheck.kt
================================================
/**
* Z PL/SQL Analyzer
* Copyright (C) 2015-2026 Felipe Zorzo
* mailto:felipe AT felipezorzo DOT com DOT br
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package com.felipebz.zpa.checks
import com.felipebz.flr.api.AstNode
import com.felipebz.zpa.typeIs
import com.felipebz.zpa.api.DmlGrammar
import com.felipebz.zpa.api.PlSqlGrammar
import com.felipebz.zpa.api.PlSqlPunctuator
import com.felipebz.zpa.api.annotations.*
import com.felipebz.zpa.api.symbols.PlSqlType
@Rule(priority = Priority.MAJOR, tags = [Tags.PERFORMANCE])
@ConstantRemediation("30min")
@RuleInfo(scope = RuleInfo.Scope.ALL)
@ActivatedByDefault
class SelectAllColumnsCheck : AbstractBaseCheck() {
override fun init() {
subscribeTo(DmlGrammar.SELECT_COLUMN)
}
override fun visitNode(node: AstNode) {
val topParent = node.parent.parent.parent
if (topParent.typeIs(PlSqlGrammar.EXISTS_EXPRESSION)) {
return
}
if (topParent.typeIs(PlSqlGrammar.CURSOR_DECLARATION)) {
// TODO this is very complex and it probably can be simplified in the future
val fetchDestination = semantic(topParent.getFirstChild(PlSqlGrammar.IDENTIFIER_NAME))
.symbol?.usages.orEmpty()
.map { it.parent.parent }
.filter { it.typeIs(PlSqlGrammar.FETCH_STATEMENT) }
.map { it.getFirstChild(DmlGrammar.INTO_CLAUSE).getFirstChildOrNull(PlSqlGrammar.VARIABLE_NAME) }
.firstOrNull()
if (fetchDestination != null && semantic(fetchDestination).plSqlType == PlSqlType.ROWTYPE) {
return
}
}
var candidate = node.firstChild
if (candidate.typeIs(PlSqlGrammar.OBJECT_REFERENCE)) {
candidate = candidate.lastChild
}
if (candidate.typeIs(PlSqlPunctuator.MULTIPLICATION)) {
val intoClause = node.parent.getFirstChildOrNull(DmlGrammar.INTO_CLAUSE)
if (intoClause != null) {
val variablesInInto = intoClause.getChildren(PlSqlGrammar.VARIABLE_NAME, PlSqlGrammar.MEMBER_EXPRESSION, PlSqlGrammar.METHOD_CALL)
val type = semantic(variablesInInto[0]).plSqlType
if (variablesInInto.size == 1 && (type == PlSqlType.ROWTYPE || type == PlSqlType.ASSOCIATIVE_ARRAY)) {
return
}
}
addIssue(node, getLocalizedMessage())
}
}
}
================================================
FILE: zpa-checks/src/main/kotlin/com/felipebz/zpa/checks/SelectWithRownumAndOrderByCheck.kt
================================================
/**
* Z PL/SQL Analyzer
* Copyright (C) 2015-2026 Felipe Zorzo
* mailto:felipe AT felipezorzo DOT com DOT br
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package com.felipebz.zpa.checks
import com.felipebz.flr.api.AstNode
import com.felipebz.zpa.api.DmlGrammar
import com.felipebz.zpa.api.PlSqlGrammar
import com.felipebz.zpa.api.annotations.*
@Rule(priority = Priority.BLOCKER, tags = [Tags.BUG])
@ConstantRemediation("20min")
@RuleInfo(scope = RuleInfo.Scope.ALL)
@ActivatedByDefault
class SelectWithRownumAndOrderByCheck : AbstractBaseCheck() {
override fun init() {
subscribeTo(DmlGrammar.SELECT_EXPRESSION)
}
override fun visitNode(node: AstNode) {
if (!hasOrderByClause(node)) {
return
}
val queryBlock = node.getFirstChild(DmlGrammar.QUERY_BLOCK)
val whereClause = queryBlock.getChildren(DmlGrammar.WHERE_CLAUSE)
if (whereClause.isEmpty()) {
return
}
val whereComparisonConditions = whereClause[0].getDescendants(PlSqlGrammar.COMPARISON_EXPRESSION)
if (whereComparisonConditions.isEmpty()) {
return
}
for (comparison in whereComparisonConditions) {
for (child in comparison.getChildren(PlSqlGrammar.VARIABLE_NAME)) {
if ("rownum".equals(child.tokenValue, ignoreCase = true) && node == child.getFirstAncestor(DmlGrammar.SELECT_EXPRESSION)) {
addIssue(comparison, getLocalizedMessage())
}
}
}
}
private fun hasOrderByClause(node: AstNode): Boolean {
return node.hasDirectChildren(DmlGrammar.ORDER_BY_CLAUSE)
}
}
================================================
FILE: zpa-checks/src/main/kotlin/com/felipebz/zpa/checks/Tags.kt
================================================
/**
* Z PL/SQL Analyzer
* Copyright (C) 2015-2026 Felipe Zorzo
* mailto:felipe AT felipezorzo DOT com DOT br
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package com.felipebz.zpa.checks
object Tags {
const val BRAIN_OVERLOAD = "brain-overload"
const val BUG = "bug"
const val CLUMSY = "clumsy"
const val CONVENTION = "convention"
const val OBSOLETE = "obsolete"
const val SECURITY = "security"
const val UNUSED = "unused"
const val CERT = "cert"
const val PITFALL = "pitfall"
const val MISRA = "misra"
const val CONFUSING = "confusing"
const val CWE = "cwe"
const val PERFORMANCE = "performance"
const val UTPLSQL = "utplsql"
}
================================================
FILE: zpa-checks/src/main/kotlin/com/felipebz/zpa/checks/ToCharInOrderByCheck.kt
================================================
/**
* Z PL/SQL Analyzer
* Copyright (C) 2015-2026 Felipe Zorzo
* mailto:felipe AT felipezorzo DOT com DOT br
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package com.felipebz.zpa.checks
import com.felipebz.flr.api.AstNode
import com.felipebz.zpa.api.DmlGrammar
import com.felipebz.zpa.api.PlSqlGrammar
import com.felipebz.zpa.api.annotations.*
import com.felipebz.zpa.api.matchers.MethodMatcher
import com.felipebz.zpa.api.symbols.PlSqlType
@Rule(priority = Priority.MAJOR, tags = [Tags.BUG])
@ConstantRemediation("5min")
@RuleInfo(scope = RuleInfo.Scope.ALL)
@ActivatedByDefault
class ToCharInOrderByCheck : AbstractBaseCheck() {
override fun init() {
subscribeTo(DmlGrammar.ORDER_BY_ITEM)
}
override fun visitNode(node: AstNode) {
val expression = node.firstChild
if (toChar.matches(expression)) {
addIssue(node, getLocalizedMessage())
}
if (expression.type === PlSqlGrammar.LITERAL && semantic(expression).plSqlType === PlSqlType.NUMERIC) {
val index = Integer.parseInt(expression.tokenOriginalValue)
val selectExpression = node.getFirstAncestor(DmlGrammar.SELECT_EXPRESSION)
val queryBlock = selectExpression.getFirstChild(DmlGrammar.QUERY_BLOCK)
val columns = queryBlock.getChildren(DmlGrammar.SELECT_COLUMN)
if (index > 0 && index <= columns.size) {
val selectColumn = columns[index - 1].firstChild
if (toChar.matches(selectColumn)) {
addIssue(node, getLocalizedMessage())
}
}
}
}
companion object {
private val toChar = MethodMatcher.create().name("to_char").withNoParameterConstraint()
}
}
================================================
FILE: zpa-checks/src/main/kotlin/com/felipebz/zpa/checks/ToDateWithoutFormatCheck.kt
================================================
/**
* Z PL/SQL Analyzer
* Copyright (C) 2015-2026 Felipe Zorzo
* mailto:felipe AT felipezorzo DOT com DOT br
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package com.felipebz.zpa.checks
import com.felipebz.flr.api.AstNode
import com.felipebz.zpa.api.PlSqlGrammar
import com.felipebz.zpa.api.SingleRowSqlFunctionsGrammar
import com.felipebz.zpa.api.annotations.*
@Rule(priority = Priority.MAJOR, tags = [Tags.BUG])
@ConstantRemediation("5min")
@RuleInfo(scope = RuleInfo.Scope.ALL)
@ActivatedByDefault
class ToDateWithoutFormatCheck : AbstractBaseCheck() {
override fun init() {
subscribeTo(SingleRowSqlFunctionsGrammar.TO_DATE_EXPRESSION)
}
override fun visitNode(node: AstNode) {
val arguments = node.getChildren(PlSqlGrammar.ARGUMENT)
if (arguments.size == 1 && !CheckUtils.isNullLiteralOrEmptyString(arguments.first().lastChild)) {
addIssue(node, getLocalizedMessage())
}
}
}
================================================
FILE: zpa-checks/src/main/kotlin/com/felipebz/zpa/checks/TooManyRowsHandlerCheck.kt
================================================
/**
* Z PL/SQL Analyzer
* Copyright (C) 2015-2026 Felipe Zorzo
* mailto:felipe AT felipezorzo DOT com DOT br
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package com.felipebz.zpa.checks
import com.felipebz.flr.api.AstNode
import com.felipebz.zpa.isOf
import com.felipebz.zpa.sslr.NullStatement
import com.felipebz.zpa.typeIs
import com.felipebz.zpa.api.PlSqlGrammar
import com.felipebz.zpa.api.annotations.*
@Rule(priority = Priority.CRITICAL, tags = [Tags.BUG])
@ConstantRemediation("5min")
@RuleInfo(scope = RuleInfo.Scope.ALL)
@ActivatedByDefault
class TooManyRowsHandlerCheck : AbstractBaseCheck() {
override fun init() {
subscribeTo(PlSqlGrammar.EXCEPTION_HANDLER)
}
override fun visitNode(node: AstNode) {
// is a TOO_MANY_ROWS handler
val exceptions = node.getChildren(PlSqlGrammar.VARIABLE_NAME)
for (exception in exceptions) {
val child = exception.firstChild
if (child.typeIs(PlSqlGrammar.IDENTIFIER_NAME) && "TOO_MANY_ROWS".equals(child.tokenValue, ignoreCase = true)) {
// and have only one NULL_STATEMENT
val children = node.getFirstChild(PlSqlGrammar.STATEMENTS).children
if (children.size == 1 && children[0].isOf()) {
addIssue(node, getLocalizedMessage())
}
}
}
}
}
================================================
FILE: zpa-checks/src/main/kotlin/com/felipebz/zpa/checks/UnhandledUserDefinedExceptionCheck.kt
================================================
/**
* Z PL/SQL Analyzer
* Copyright (C) 2015-2026 Felipe Zorzo
* mailto:felipe AT felipezorzo DOT com DOT br
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package com.felipebz.zpa.checks
import com.felipebz.flr.api.AstNode
import com.felipebz.zpa.asTree
import com.felipebz.zpa.sslr.RaiseStatement
import com.felipebz.zpa.api.PlSqlGrammar
import com.felipebz.zpa.api.PlSqlKeyword
import com.felipebz.zpa.api.annotations.ConstantRemediation
import com.felipebz.zpa.api.annotations.Priority
import com.felipebz.zpa.api.annotations.Rule
import com.felipebz.zpa.api.annotations.RuleInfo
import com.felipebz.zpa.api.symbols.Symbol
import java.util.*
@Rule(priority = Priority.CRITICAL, tags = [Tags.BUG])
@ConstantRemediation("5min")
@RuleInfo(scope = RuleInfo.Scope.ALL)
class UnhandledUserDefinedExceptionCheck : AbstractBaseCheck() {
override fun init() {
subscribeTo(PlSqlGrammar.RAISE_STATEMENT)
}
override fun visitNode(node: AstNode) {
val statement = node.asTree()
val identifier = statement.exception
?: return
val identifierName = identifier.tokenValue
val symbols = context.currentScope?.getSymbolsAcessibleInScope(identifierName) ?: ArrayDeque()
if (symbols.isNotEmpty()) {
val checkException = exceptionShouldBeChecked(symbols.first)
if (checkException && !isHandled(identifierName)) {
addIssue(node, getLocalizedMessage(), identifierName)
}
}
}
private fun exceptionShouldBeChecked(exceptionDeclaration: Symbol): Boolean {
return exceptionDeclaration.scope.type !in PACKAGE_SPEC_OR_BODY
}
private fun isHandled(identifierName: String): Boolean {
var outerScope = context.currentScope
do {
val scopeNode = outerScope?.tree
val statements = scopeNode?.getFirstChildOrNull(PlSqlGrammar.STATEMENTS_SECTION)
val exceptionHandlers = statements?.getFirstChildOrNull(PlSqlGrammar.EXCEPTION_HANDLERS)
if (statements != null && exceptionHandlers != null) {
for (handler in exceptionHandlers.getChildren(PlSqlGrammar.EXCEPTION_HANDLER)) {
if (handler.hasDirectChildren(PlSqlKeyword.OTHERS) && !handler.hasDescendant(PlSqlKeyword.SQLERRM)) {
return true
}
for (exceptionName in handler.getChildren(PlSqlGrammar.VARIABLE_NAME)) {
if (exceptionName.tokenValue == identifierName) {
return true
}
}
}
}
outerScope = outerScope?.outer
} while (outerScope != null)
return false
}
companion object {
val PACKAGE_SPEC_OR_BODY = arrayOf(PlSqlGrammar.CREATE_PACKAGE, PlSqlGrammar.CREATE_PACKAGE_BODY)
}
}
================================================
FILE: zpa-checks/src/main/kotlin/com/felipebz/zpa/checks/UnnecessaryAliasInQueryCheck.kt
================================================
/**
* Z PL/SQL Analyzer
* Copyright (C) 2015-2026 Felipe Zorzo
* mailto:felipe AT felipezorzo DOT com DOT br
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package com.felipebz.zpa.checks
import com.felipebz.flr.api.AstNode
import com.felipebz.flr.api.AstNodeType
import com.felipebz.zpa.api.DmlGrammar
import com.felipebz.zpa.api.PlSqlGrammar
import com.felipebz.zpa.api.annotations.*
@Rule(priority = Priority.MINOR)
@ConstantRemediation("1min")
@RuleInfo(scope = RuleInfo.Scope.ALL)
class UnnecessaryAliasInQueryCheck : AbstractBaseCheck() {
@RuleProperty(key = "acceptedLength", defaultValue = "" + DEFAULT_ACCEPTED_LENGTH)
var acceptedLength = DEFAULT_ACCEPTED_LENGTH
private val dmlStatements = arrayOf(
DmlGrammar.QUERY_BLOCK,
PlSqlGrammar.UPDATE_STATEMENT,
PlSqlGrammar.DELETE_STATEMENT)
override fun init() {
subscribeTo(*dmlStatements)
}
override fun visitNode(node: AstNode) {
if (node.hasAncestor(*dmlStatements)) {
// if the current node is inside another DML statement (i.e. subquery), the node should be
// ignored because it is considered in the analysis of the outer statement
return
}
val tableReferences = hashMapOf>()
for (fromClause in node.getDescendants(DmlGrammar.DML_TABLE_EXPRESSION_CLAUSE)) {
val table = fromClause.getFirstChildOrNull(DmlGrammar.TABLE_REFERENCE)
val alias = fromClause.getFirstChildOrNull(DmlGrammar.ALIAS)
if (table != null) {
tableReferences.getOrPut(table.tokenValue) { mutableListOf() }
.add(TableReference(table, alias))
}
}
for (references in tableReferences.values) {
checkReference(references)
}
}
private fun checkReference(references: MutableList) {
if (references.size == 1) {
val reference: TableReference = references[0]
var alias: String? = null
if (reference.alias != null) {
alias = reference.alias.tokenValue
}
if (alias != null && reference.alias != null && alias.length < acceptedLength) {
addIssue(reference.alias, getLocalizedMessage(),
reference.table.tokenOriginalValue,
reference.alias.tokenOriginalValue)
}
}
}
internal class TableReference(val table: AstNode, val alias: AstNode?)
companion object {
private const val DEFAULT_ACCEPTED_LENGTH = 3
}
}
================================================
FILE: zpa-checks/src/main/kotlin/com/felipebz/zpa/checks/UnnecessaryElseCheck.kt
================================================
/**
* Z PL/SQL Analyzer
* Copyright (C) 2015-2026 Felipe Zorzo
* mailto:felipe AT felipezorzo DOT com DOT br
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package com.felipebz.zpa.checks
import com.felipebz.flr.api.AstNode
import com.felipebz.zpa.api.PlSqlGrammar
import com.felipebz.zpa.api.annotations.*
@Rule(priority = Priority.MINOR)
@ConstantRemediation("2min")
@RuleInfo(scope = RuleInfo.Scope.ALL)
@ActivatedByDefault
class UnnecessaryElseCheck : AbstractBaseCheck() {
override fun init() {
subscribeTo(PlSqlGrammar.ELSE_CLAUSE)
}
override fun visitNode(node: AstNode) {
val ifStatement = checkNotNull(node.parent)
if (!hasElsifClause(ifStatement) && hasTerminationStatement(ifStatement)) {
addLineIssue(getLocalizedMessage(), node.tokenLine)
}
}
private fun hasElsifClause(node: AstNode): Boolean {
return node.hasDirectChildren(PlSqlGrammar.ELSIF_CLAUSE)
}
private fun hasTerminationStatement(ifStatement: AstNode): Boolean {
for (statement in ifStatement.getFirstChild(PlSqlGrammar.STATEMENTS).children) {
val internal = statement.firstChild
if (CheckUtils.isTerminationStatement(internal)) {
return true
}
}
return false
}
}
================================================
FILE: zpa-checks/src/main/kotlin/com/felipebz/zpa/checks/UnnecessaryLikeCheck.kt
================================================
/**
* Z PL/SQL Analyzer
* Copyright (C) 2015-2026 Felipe Zorzo
* mailto:felipe AT felipezorzo DOT com DOT br
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package com.felipebz.zpa.checks
import com.felipebz.flr.api.AstNode
import com.felipebz.zpa.api.ConditionsGrammar
import com.felipebz.zpa.api.PlSqlGrammar
import com.felipebz.zpa.api.PlSqlKeyword
import com.felipebz.zpa.api.annotations.*
@Rule(priority = Priority.MINOR, tags = [Tags.CONFUSING])
@ConstantRemediation("5min")
@RuleInfo(scope = RuleInfo.Scope.ALL)
@ActivatedByDefault
class UnnecessaryLikeCheck : AbstractBaseCheck() {
private val escapeRegex = Regex("[%_]")
override fun init() {
subscribeTo(ConditionsGrammar.LIKE_CONDITION)
}
override fun visitNode(node: AstNode) {
val escapeChar = if (node.hasDescendant(PlSqlKeyword.ESCAPE) &&
node.lastChild.hasDirectChildren(PlSqlGrammar.CHARACTER_LITERAL))
node.lastChild.tokenValue.trim('\'')
else
""
val regex = if (escapeChar.isEmpty()) escapeRegex else Regex("[^${Regex.escape(escapeChar)}][%_]")
val likeNode = node.getFirstChild(PlSqlKeyword.LIKE).nextSibling
if (likeNode.hasDirectChildren(PlSqlGrammar.CHARACTER_LITERAL) && !likeNode.tokenValue.contains(regex)) {
addIssue(node, getLocalizedMessage())
}
}
}
================================================
FILE: zpa-checks/src/main/kotlin/com/felipebz/zpa/checks/UnnecessaryNullStatementCheck.kt
================================================
/**
* Z PL/SQL Analyzer
* Copyright (C) 2015-2026 Felipe Zorzo
* mailto:felipe AT felipezorzo DOT com DOT br
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package com.felipebz.zpa.checks
import com.felipebz.flr.api.AstNode
import com.felipebz.zpa.api.PlSqlGrammar
import com.felipebz.zpa.api.annotations.*
@Rule(priority = Priority.MINOR)
@ConstantRemediation("1min")
@RuleInfo(scope = RuleInfo.Scope.ALL)
@ActivatedByDefault
class UnnecessaryNullStatementCheck : AbstractBaseCheck() {
override fun init() {
subscribeTo(PlSqlGrammar.NULL_STATEMENT)
}
override fun visitNode(node: AstNode) {
val parent = node.parent
if (parent.previousSiblingOrNull != null || parent.nextSiblingOrNull != null) {
addIssue(node, getLocalizedMessage())
}
}
}
================================================
FILE: zpa-checks/src/main/kotlin/com/felipebz/zpa/checks/UnusedCursorCheck.kt
================================================
/**
* Z PL/SQL Analyzer
* Copyright (C) 2015-2026 Felipe Zorzo
* mailto:felipe AT felipezorzo DOT com DOT br
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package com.felipebz.zpa.checks
import com.felipebz.flr.api.AstNode
import com.felipebz.zpa.api.PlSqlGrammar
import com.felipebz.zpa.api.PlSqlKeyword
import com.felipebz.zpa.api.annotations.*
import com.felipebz.zpa.api.symbols.Scope
import com.felipebz.zpa.api.symbols.Symbol
@Rule(priority = Priority.MAJOR, tags = [Tags.UNUSED])
@ConstantRemediation("2min")
@RuleInfo(scope = RuleInfo.Scope.ALL)
@ActivatedByDefault
class UnusedCursorCheck : AbstractBaseCheck() {
override fun leaveFile(node: AstNode) {
val scopes = context.symbolTable.scopes
for (scope in scopes) {
if (scope.type == PlSqlGrammar.CREATE_PACKAGE) {
continue
}
checkScope(scope)
}
}
private fun checkScope(scope: Scope) {
val symbols = scope.getSymbols(Symbol.Kind.CURSOR)
for (symbol in symbols) {
val parent = checkNotNull(symbol.declaration.parent)
if (symbol.usages.isEmpty() && !parent.hasDirectChildren(PlSqlKeyword.RETURN)) {
addIssue(parent, getLocalizedMessage(), symbol.name)
}
}
}
}
================================================
FILE: zpa-checks/src/main/kotlin/com/felipebz/zpa/checks/UnusedParameterCheck.kt
================================================
/**
* Z PL/SQL Analyzer
* Copyright (C) 2015-2026 Felipe Zorzo
* mailto:felipe AT felipezorzo DOT com DOT br
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package com.felipebz.zpa.checks
import com.felipebz.flr.api.AstNode
import com.felipebz.zpa.api.DmlGrammar
import com.felipebz.zpa.api.PlSqlGrammar
import com.felipebz.zpa.api.annotations.*
import com.felipebz.zpa.api.symbols.Scope
import com.felipebz.zpa.api.symbols.Symbol
import java.util.regex.Pattern
@Rule(priority = Priority.MAJOR, tags = [Tags.UNUSED])
@ConstantRemediation("30min")
@RuleInfo(scope = RuleInfo.Scope.ALL)
@ActivatedByDefault
class UnusedParameterCheck : AbstractBaseCheck() {
@RuleProperty(key = "ignoreMethods", defaultValue = "")
var ignoreMethods = ""
private val ignoreRegex: Pattern? by lazy {
if ("" != ignoreMethods) {
Pattern.compile(ignoreMethods, Pattern.CASE_INSENSITIVE)
} else null
}
override fun leaveFile(node: AstNode) {
val scopes = context.symbolTable.scopes
for (scope in scopes) {
// is overriding something?
if (scope.isOverridingMember) {
continue
}
val scopeNode = scope.tree ?: continue
// ignore procedure/function specification and overriding members
if (scope.type in DECLARATION_OR_CONSTRUCTOR) {
// is specification?
if (!scopeNode.hasDirectChildren(PlSqlGrammar.STATEMENTS_SECTION)) {
continue
}
}
// cursor declaration (without implementation)
if (scope.type == PlSqlGrammar.CURSOR_DECLARATION && !scopeNode.hasDirectChildren(DmlGrammar.SELECT_EXPRESSION)) {
continue
}
// ignore methods by name
if (scope.type in PROCEDURE_OR_FUNCTION && ignoreRegex != null) {
val matchesRegex = ignoreRegex?.matcher(scope.identifier)?.matches() ?: false
if (matchesRegex) {
continue
}
}
checkScope(scope)
}
}
private fun checkScope(scope: Scope) {
val symbols = scope.getSymbols(Symbol.Kind.PARAMETER)
for (symbol in symbols) {
// SELF parameter in type members
if (scope.outer?.type == PlSqlGrammar.CREATE_TYPE_BODY && symbol.name.equals("self", ignoreCase = true)) {
continue
}
if (symbol.usages.isEmpty()) {
val parent = checkNotNull(symbol.declaration.parent)
addIssue(parent, getLocalizedMessage(), symbol.name)
}
}
}
companion object {
val DECLARATION_OR_CONSTRUCTOR =
arrayOf(PlSqlGrammar.PROCEDURE_DECLARATION,
PlSqlGrammar.FUNCTION_DECLARATION,
PlSqlGrammar.TYPE_CONSTRUCTOR)
val PROCEDURE_OR_FUNCTION =
arrayOf(PlSqlGrammar.PROCEDURE_DECLARATION,
PlSqlGrammar.FUNCTION_DECLARATION,
PlSqlGrammar.CREATE_PROCEDURE,
PlSqlGrammar.CREATE_FUNCTION)
}
}
================================================
FILE: zpa-checks/src/main/kotlin/com/felipebz/zpa/checks/UnusedVariableCheck.kt
================================================
/**
* Z PL/SQL Analyzer
* Copyright (C) 2015-2026 Felipe Zorzo
* mailto:felipe AT felipezorzo DOT com DOT br
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package com.felipebz.zpa.checks
import com.felipebz.flr.api.AstNode
import com.felipebz.zpa.api.PlSqlGrammar
import com.felipebz.zpa.api.annotations.*
import com.felipebz.zpa.api.symbols.Scope
import com.felipebz.zpa.api.symbols.Symbol
@Rule(priority = Priority.MAJOR, tags = [Tags.UNUSED])
@ConstantRemediation("2min")
@RuleInfo(scope = RuleInfo.Scope.ALL)
@ActivatedByDefault
class UnusedVariableCheck : AbstractBaseCheck() {
override fun leaveFile(node: AstNode) {
val scopes = context.symbolTable.scopes
for (scope in scopes) {
if (scope.type !in arrayOf(PlSqlGrammar.CREATE_PACKAGE, PlSqlGrammar.FOR_STATEMENT)) {
checkScope(scope)
}
}
}
private fun checkScope(scope: Scope) {
val symbols = scope.getSymbols(Symbol.Kind.VARIABLE)
for (symbol in symbols) {
if (symbol.usages.isEmpty()) {
addIssue(symbol.declaration, getLocalizedMessage(), symbol.name)
}
}
}
}
================================================
FILE: zpa-checks/src/main/kotlin/com/felipebz/zpa/checks/UselessParenthesisCheck.kt
================================================
/**
* Z PL/SQL Analyzer
* Copyright (C) 2015-2026 Felipe Zorzo
* mailto:felipe AT felipezorzo DOT com DOT br
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package com.felipebz.zpa.checks
import com.felipebz.flr.api.AstNode
import com.felipebz.zpa.typeIs
import com.felipebz.zpa.api.PlSqlGrammar
import com.felipebz.zpa.api.annotations.*
@Rule(priority = Priority.MINOR)
@ConstantRemediation("2min")
@RuleInfo(scope = RuleInfo.Scope.ALL)
@ActivatedByDefault
class UselessParenthesisCheck : AbstractBaseCheck() {
override fun init() {
subscribeTo(PlSqlGrammar.BRACKED_EXPRESSION)
}
override fun visitNode(node: AstNode) {
val parent = node.parent
if (parent.typeIs(PlSqlGrammar.BRACKED_EXPRESSION) && parent.numberOfChildren == 3) {
addIssue(node, getLocalizedMessage())
}
}
}
================================================
FILE: zpa-checks/src/main/kotlin/com/felipebz/zpa/checks/VariableHidingCheck.kt
================================================
/**
* Z PL/SQL Analyzer
* Copyright (C) 2015-2026 Felipe Zorzo
* mailto:felipe AT felipezorzo DOT com DOT br
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package com.felipebz.zpa.checks
import com.felipebz.flr.api.AstNode
import com.felipebz.zpa.asSemantic
import com.felipebz.zpa.api.PlSqlGrammar
import com.felipebz.zpa.api.annotations.*
import com.felipebz.zpa.api.symbols.Symbol
@Rule(priority = Priority.MAJOR)
@ConstantRemediation("5min")
@RuleInfo(scope = RuleInfo.Scope.ALL)
@ActivatedByDefault
class VariableHidingCheck : AbstractBaseCheck() {
override fun init() {
subscribeTo(PlSqlGrammar.VARIABLE_DECLARATION, PlSqlGrammar.EXCEPTION_DECLARATION)
}
override fun visitNode(node: AstNode) {
val identifier = node.getFirstChild(PlSqlGrammar.IDENTIFIER_NAME)
val name = identifier.tokenValue
val scope = identifier.asSemantic().symbol?.scope
if (scope != null) {
val symbols = scope.getSymbolsAcessibleInScope(name, Symbol.Kind.VARIABLE, Symbol.Kind.PARAMETER)
if (symbols.size > 1) {
val originalVariable = symbols.last.declaration
if (originalVariable != identifier) {
addIssue(identifier, getLocalizedMessage(), name, originalVariable.tokenLine)
.secondary(originalVariable, "Original")
}
}
}
}
}
================================================
FILE: zpa-checks/src/main/kotlin/com/felipebz/zpa/checks/VariableInCountCheck.kt
================================================
/**
* Z PL/SQL Analyzer
* Copyright (C) 2015-2026 Felipe Zorzo
* mailto:felipe AT felipezorzo DOT com DOT br
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package com.felipebz.zpa.checks
import com.felipebz.flr.api.AstNode
import com.felipebz.zpa.typeIs
import com.felipebz.zpa.api.DmlGrammar
import com.felipebz.zpa.api.PlSqlGrammar
import com.felipebz.zpa.api.annotations.*
import com.felipebz.zpa.api.matchers.MethodMatcher
@Rule(priority = Priority.BLOCKER, tags = [Tags.BUG])
@ConstantRemediation("2min")
@RuleInfo(scope = RuleInfo.Scope.ALL)
@ActivatedByDefault
class VariableInCountCheck : AbstractBaseCheck() {
override fun init() {
subscribeTo(PlSqlGrammar.METHOD_CALL)
}
override fun visitNode(node: AstNode) {
val count = MethodMatcher.create().name("count").addParameter()
if (!node.parent.typeIs(DmlGrammar.SELECT_COLUMN) || !count.matches(node)) {
return
}
checkArguments(node, count.getArgumentsValues(node))
}
private fun checkArguments(currentNode: AstNode, arguments: List) {
if (arguments.size != 1) {
return
}
val value = arguments[0]
val symbol = semantic(value).symbol
if (symbol != null) {
addIssue(currentNode, getLocalizedMessage(), value.tokenOriginalValue)
}
}
}
================================================
FILE: zpa-checks/src/main/kotlin/com/felipebz/zpa/checks/VariableInitializationWithFunctionCallCheck.kt
================================================
/**
* Z PL/SQL Analyzer
* Copyright (C) 2015-2026 Felipe Zorzo
* mailto:felipe AT felipezorzo DOT com DOT br
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package com.felipebz.zpa.checks
import com.felipebz.flr.api.AstNode
import com.felipebz.zpa.typeIs
import com.felipebz.zpa.api.PlSqlGrammar
import com.felipebz.zpa.api.annotations.*
@Rule(priority = Priority.MAJOR)
@ConstantRemediation("5min")
@RuleInfo(scope = RuleInfo.Scope.ALL)
@ActivatedByDefault
class VariableInitializationWithFunctionCallCheck : AbstractBaseCheck() {
override fun init() {
subscribeTo(PlSqlGrammar.DEFAULT_VALUE_ASSIGNMENT)
}
override fun visitNode(node: AstNode) {
if (node.hasParent(PlSqlGrammar.VARIABLE_DECLARATION)) {
val datatype = node.parent.getFirstChild(PlSqlGrammar.DATATYPE)
val expression = node.lastChild
if (expression.typeIs(PlSqlGrammar.METHOD_CALL) && datatype.tokenValue != expression.tokenValue) {
addIssue(node, getLocalizedMessage())
}
}
}
}
================================================
FILE: zpa-checks/src/main/kotlin/com/felipebz/zpa/checks/VariableInitializationWithNullCheck.kt
================================================
/**
* Z PL/SQL Analyzer
* Copyright (C) 2015-2026 Felipe Zorzo
* mailto:felipe AT felipezorzo DOT com DOT br
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package com.felipebz.zpa.checks
import com.felipebz.flr.api.AstNode
import com.felipebz.zpa.api.PlSqlGrammar
import com.felipebz.zpa.api.annotations.*
@Rule(priority = Priority.MINOR)
@ConstantRemediation("2min")
@RuleInfo(scope = RuleInfo.Scope.ALL)
@ActivatedByDefault
class VariableInitializationWithNullCheck : AbstractBaseCheck() {
override fun init() {
subscribeTo(PlSqlGrammar.DEFAULT_VALUE_ASSIGNMENT)
}
override fun visitNode(node: AstNode) {
if (node.hasParent(PlSqlGrammar.VARIABLE_DECLARATION, PlSqlGrammar.RECORD_FIELD_DECLARATION)) {
val expression = node.lastChild
if (CheckUtils.isNullLiteralOrEmptyString(expression)) {
addIssue(node, getLocalizedMessage())
}
}
}
}
================================================
FILE: zpa-checks/src/main/kotlin/com/felipebz/zpa/checks/VariableNameCheck.kt
================================================
/**
* Z PL/SQL Analyzer
* Copyright (C) 2015-2026 Felipe Zorzo
* mailto:felipe AT felipezorzo DOT com DOT br
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package com.felipebz.zpa.checks
import com.felipebz.flr.api.AstNode
import com.felipebz.zpa.api.PlSqlGrammar
import com.felipebz.zpa.api.annotations.*
import java.util.regex.Pattern
@Rule(priority = Priority.MINOR)
@ConstantRemediation("10min")
@RuleInfo(scope = RuleInfo.Scope.ALL)
@ActivatedByDefault
class VariableNameCheck : AbstractBaseCheck() {
@RuleProperty(key = "regexp", defaultValue = DEFAULT_REGEXP)
var regexp = DEFAULT_REGEXP
private val pattern: Pattern by lazy {
Pattern.compile(regexp)
}
override fun init() {
subscribeTo(PlSqlGrammar.VARIABLE_DECLARATION)
}
override fun visitNode(node: AstNode) {
val identifier = node.getFirstChild(PlSqlGrammar.IDENTIFIER_NAME)
val name = identifier.tokenOriginalValue
if (!pattern.matcher(name).matches()) {
addIssue(identifier, getLocalizedMessage(), name, regexp)
}
}
companion object {
private const val DEFAULT_REGEXP = "[a-zA-Z]([a-zA-Z0-9_]*[a-zA-Z0-9])?"
}
}
================================================
FILE: zpa-checks/src/main/kotlin/com/felipebz/zpa/checks/XPathCheck.kt
================================================
/**
* Z PL/SQL Analyzer
* Copyright (C) 2015-2026 Felipe Zorzo
* mailto:felipe AT felipezorzo DOT com DOT br
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package com.felipebz.zpa.checks
import com.felipebz.flr.api.AstNode
import com.felipebz.flr.xpath.api.AstNodeXPathQuery
import com.felipebz.zpa.squid.AnalysisException
import com.felipebz.zpa.api.annotations.*
@Rule(priority = Priority.MAJOR)
@RuleInfo(scope = RuleInfo.Scope.ALL)
@RuleTemplate
class XPathCheck : AbstractBaseCheck() {
@RuleProperty(key = "xpathQuery")
var xpathQuery = DEFAULT_XPATH_QUERY
@RuleProperty(key = "message", defaultValue = "" + DEFAULT_MESSAGE)
var message = DEFAULT_MESSAGE
private var query: AstNodeXPathQuery? = null
private fun query(): AstNodeXPathQuery? {
if (query == null && xpathQuery.isNotEmpty()) {
try {
query = AstNodeXPathQuery.create(xpathQuery)
} catch (e: RuntimeException) {
throw AnalysisException(
"Unable to initialize the XPath engine, perhaps because of an invalid query: $xpathQuery", e)
}
}
return query
}
override fun visitFile(node: AstNode) {
if (query() != null) {
val objects = query()?.selectNodes(node) ?: emptyList()
for (obj in objects) {
if (obj is AstNode) {
addIssue(obj, message)
} else if (obj is Boolean && obj) {
addFileIssue(message)
}
}
}
}
companion object {
private const val DEFAULT_XPATH_QUERY = ""
private const val DEFAULT_MESSAGE = "The XPath expression matches this piece of code"
}
}
================================================
FILE: zpa-checks/src/main/resources/org/sonar/l10n/plsqlopen/rules/plsql/AddParenthesesInNestedExpression.html
================================================
An AND condition has a higher precedence than an OR condition, so you should wrap the AND condition in parentheses
for clarity and to ensure that the operators are evaluated in the order that you intend.
Consider this example:
SELECT dogs.name
FROM dogs
WHERE dogs.sex = 'male'
and dogs.color = 'white'
or dogs.size = 'big';
Without parentheses, one would think that it is equivalent to:
SELECT dogs.name
FROM dogs
WHERE dogs.sex = 'male'
and (dogs.color = 'white' or dogs.size = 'big');
But the original query is parsed as:
SELECT dogs.name
FROM dogs
WHERE (dogs.sex = 'male' and dogs.color = 'white')
or dogs.size = 'big';
================================================
FILE: zpa-checks/src/main/resources/org/sonar/l10n/plsqlopen/rules/plsql/CharacterDatatypeUsage.html
================================================
Currently, the VARCHAR and VARCHAR2 data types are identical. But to accommodate emerging SQL standards, VARCHAR might become a separate data type in future.
The CHAR data type doesn't have any advantage over VARCHAR2 and makes searching more difficult because the right-padded values.
declare
var1 varchar(10); -- noncompliant
var2 char(10); -- noncompliant
var3 varchar2(10); -- compliant
begin
null;
end;
================================================
FILE: zpa-checks/src/main/resources/org/sonar/l10n/plsqlopen/rules/plsql/CollapsibleIfStatements.html
================================================
Merging collapsible if statements increases the code's readability.
Noncompliant Code Example
if condition1 then
if condition2 then
-- code
end if;
end if;
Compliant Solution
if condition1 and condition2 then
-- code
end if;
================================================
FILE: zpa-checks/src/main/resources/org/sonar/l10n/plsqlopen/rules/plsql/ColumnsShouldHaveTableName.html
================================================
Specify the table name of the columns in a SELECT statement to improve readability and guarantee that the code won't stop working when the table changes.
================================================
FILE: zpa-checks/src/main/resources/org/sonar/l10n/plsqlopen/rules/plsql/CommitRollback.html
================================================
Usually, the control of the transaction should be handled by the its "owner".
If the transaction was started by some Java code, the commit and rollback of this should be done in the Java code.
So, in this situation, calling a COMMIT or ROLLBACK from a database object is a bad pratice and should be avoided.
This rule ignores procedures and functions with PRAGMA AUTONOMOUS_TRANSACTION.
================================================
FILE: zpa-checks/src/main/resources/org/sonar/l10n/plsqlopen/rules/plsql/ComparisonWithBoolean.html
================================================
Remove literal boolean values from comparisons to improve readability.
Noncompliant Code Example
if var = true then ...
if var = false then ...
Compliant Solution
if var then ...
if not var then ...
================================================
FILE: zpa-checks/src/main/resources/org/sonar/l10n/plsqlopen/rules/plsql/ComparisonWithNull.html
================================================
To test for nulls, use only the comparison conditions IS NULL and IS NOT NULL. Any other comparison with nulls will result in NULL.
Keep in mind that an empty string is equivalent to a NULL literal.
Noncompliant Code Example
if var = null then
-- code
end if;
Or:
if other_var = '' then
-- code
end if;
Compliant Solution
if var is null then
-- code
end if;
if other_var is null then
-- code
end if;
================================================
FILE: zpa-checks/src/main/resources/org/sonar/l10n/plsqlopen/rules/plsql/ConcatenationWithNull.html
================================================
Concatenating a VARCHAR2 value with NULL is no-op. So, the NULL value should be removed.
A concatenation of any other datatype with NULL will cause a implicit cast to VARCHAR2. If this is the desired behavior,
replace the concatenation by a TO_CHAR call to make the intention explicit. See this example:
var := NVL(''||id, 'Empty');
You should use this:
var := NVL(TO_CHAR(id), 'Empty');
================================================
FILE: zpa-checks/src/main/resources/org/sonar/l10n/plsqlopen/rules/plsql/CursorBodyInPackageSpec.html
================================================
Cursor declarations can be splitted in two parts: specification and body. When declaring a cursor
in a package specification, the package specification should contains only the cursor specification
and the cursor body should be added to the package body.
In newer versions of Oracle Forms, the usage of cursors declared with body in a package specification
also causes the compilation error "internal error [Unexpected fragile external reference.]".
Noncompliant Code Example
create or replace package pkg is
cursor cur is
select dummy from dual;
end;
Compliant Solution
create or replace package pkg is
type cur_type is record(dummy varchar2(1));
cursor cur return cur_type;
end;
/
create or replace package body pkg is
cursor cur return cur_type is
select dummy from dual;
end;
/
================================================
FILE: zpa-checks/src/main/resources/org/sonar/l10n/plsqlopen/rules/plsql/DbmsOutputPut.html
================================================
The output of DBMS_OUTPUT.PUT/DBMS_OUTPUT.PUT_LINE will not be visible when SERVEROUTPUT is set to OFF.
Moreover, unless this call is explicitly necessary, is better to use logging mechanism instead.
================================================
FILE: zpa-checks/src/main/resources/org/sonar/l10n/plsqlopen/rules/plsql/DeadCode.html
================================================
Jump statements (return, exit, continue, and raise) move control flow out of the current code block.
Typically, any statements in a block that come after a jump are simply wasted keystrokes lying in wait to confuse the unwary.
Noncompliant Code Example
begin
raise my_error;
log('finished'); -- this code will never be executed
end;
Compliant Solution
begin
raise my_error;
end;
================================================
FILE: zpa-checks/src/main/resources/org/sonar/l10n/plsqlopen/rules/plsql/DeclareSectionWithoutDeclarations.html
================================================
You don't need to add the DECLARE keyword in a block if it doesn't contains any declaration.
================================================
FILE: zpa-checks/src/main/resources/org/sonar/l10n/plsqlopen/rules/plsql/DisabledTest.html
================================================
When a test fails due, for example, to infrastructure issues, you might want to ignore it temporarily.
But without some kind of notation about why the test is being disabled, it may never be reactivated.
This rule raises an issue for each disabled test that does not have a notation about why it was disabled.
Noncompliant Code Example
-- %test(my test)
-- %disabled
procedure test;
Compliant Solution
-- %test(my test)
procedure test;
Exceptions
The rule doesn't raise an issue if there is a comment in the %disabled annotation.
================================================
FILE: zpa-checks/src/main/resources/org/sonar/l10n/plsqlopen/rules/plsql/DuplicateConditionIfElsif.html
================================================
A chain of if/elsif statements is evaluated from top to bottom.
At most, only one branch will be executed: the first one with a condition that evaluates to true.
Therefore, duplicating a condition automatically leads to dead code. Usually, this is due to a copy/paste error.
At best, it's simply dead code and at worst, it's a bug that is likely to induce further bugs as the code is maintained,
and obviously it could lead to unexpected behavior.
Noncompliant Code Example
IF (param = 1) THEN
open();
ELSIF (param = 2) THEN
close();
ELSIF (param = 1) THEN // Incorrect
move();
END IF;
Compliant Solution
IF (param = 1) THEN
open();
ELSIF (param = 2) THEN
close();
ELSIF (param = 3) THEN
move();
END IF;
================================================
FILE: zpa-checks/src/main/resources/org/sonar/l10n/plsqlopen/rules/plsql/DuplicatedValueInIn.html
================================================
Duplicated values in an IN condition can be either a copy/paste error and therefore a bug, or it is simply wasted code, and should be simplified.
Noncompliant Code Example
if value in (a, a, b) then ...
Compliant Solution
if value in (a, b) then ...
================================================
FILE: zpa-checks/src/main/resources/org/sonar/l10n/plsqlopen/rules/plsql/EmptyBlock.html
================================================
Most of the time a block of code is empty when a piece of code is really missing. So such empty block must be either filled or removed.
Noncompliant Code Example
begin
null;
end;
================================================
FILE: zpa-checks/src/main/resources/org/sonar/l10n/plsqlopen/rules/plsql/EmptyStringAssignment.html
================================================
To improve the readability, avoid using empty strings to represent NULL.
Noncompliant Code Example
var := '';
Compliant Solution
var := null;
================================================
FILE: zpa-checks/src/main/resources/org/sonar/l10n/plsqlopen/rules/plsql/ExplicitInParameter.html
================================================
If not set, the parameter mode is IN. However, defining it explicitly does make the code easier to read.
CREATE OR REPLACE PROCEDURE myproc(value VARCHAR2) IS -- violation
BEGIN
NULL;
END;
CREATE OR REPLACE PROCEDURE myproc(value IN VARCHAR2) IS -- correct, the parameter mode is defined
BEGIN
NULL;
END;
================================================
FILE: zpa-checks/src/main/resources/org/sonar/l10n/plsqlopen/rules/plsql/FunctionWithOutParameter.html
================================================
Functions with OUT parameters are complex to understand.
It is impossible to tell whether an argument is a input or output just by looking at the function call.
Also, functions with OUT parameters cannot be called from SQL.
Noncompliant Code Example
CREATE OR REPLACE FUNCTION get_product_info(id IN NUMBER, value OUT NUMBER) RETURN VARCHAR2 IS
BEGIN
...
END;
================================================
FILE: zpa-checks/src/main/resources/org/sonar/l10n/plsqlopen/rules/plsql/IdenticalExpression.html
================================================
Using the same value on either side of an operator is almost always a mistake.
It can be either a copy/paste error and therefore a bug, or it is simply wasted code, and should be simplified.
Noncompliant Code Example
if a = a then ...
================================================
FILE: zpa-checks/src/main/resources/org/sonar/l10n/plsqlopen/rules/plsql/IfWithExit.html
================================================
To improve the code readability always use EXIT WHEN instead of an IF statement to exit from a loop.
Noncompliant Code Example
if condition1 then
exit;
end if;
Compliant Solution
exit when condition1;
================================================
FILE: zpa-checks/src/main/resources/org/sonar/l10n/plsqlopen/rules/plsql/InequalityUsage.html
================================================
The forms "<>", "!=", "~=" and "^=" are equivalent, but only the "<>" form is defined in ANSI SQL.
Noncompliant Code Example
if a != b then
Compliant Solution
if a <> b then
================================================
FILE: zpa-checks/src/main/resources/org/sonar/l10n/plsqlopen/rules/plsql/InsertWithoutColumns.html
================================================
Specify the columns in an INSERT statement to guarantee that the code won't stop working when a new column is added.
Noncompliant Code Example
insert into tab values (1);
Compliant Solution
insert into tab (col) values (1);
================================================
FILE: zpa-checks/src/main/resources/org/sonar/l10n/plsqlopen/rules/plsql/InvalidReferenceToObject.html
================================================
In Oracle Forms, many procedures and functions need a reference to an object (blocks, itens, alerts...).
Unfortunately, the only way to pass a reference to an object is using a VARCHAR2 variable and these references
are not checked by the compiler.
Currently this rule checks the following methods:
Alert bultins:
- FIND_ALERT
- SET_ALERT_BUTTON_PROPERTY
- SET_ALERT_PROPERTY
- SHOW_ALERT
Block bultins:
- FIND_BLOCK
- GET_BLOCK_PROPERTY
- GO_BLOCK
- SET_BLOCK_PROPERTY
Item bultins:
- CHECKBOX_CHECKED
- CONVERT_OTHER_VALUE
- DISPLAY_ITEM
- FIND_ITEM
- GET_ITEM_INSTANCE_PROPERTY
- GET_ITEM_PROPERTY
- GET_RADIO_BUTTON_PROPERTY
- GO_ITEM
- IMAGE_SCROLL
- IMAGE_ZOOM
- IMAGE_ZOOM
- PLAY_SOUND
- READ_IMAGE_FILE
- READ_SOUND_FILE
- RECALCULATE
- SET_ITEM_INSTANCE_PROPERTY
- SET_ITEM_PROPERTY
- SET_ITEM_PROPERTY
- SET_RADIO_BUTTON_PROPERTY
- SET_RADIO_BUTTON_PROPERTY
- WRITE_IMAGE_FILE
- WRITE_SOUND_FILE
LOV bultins:
- FIND_LOV
- GET_LOV_PROPERTY
- SET_LOV_COLUMN_PROPERTY
- SET_LOV_PROPERTY
- SHOW_LOV
Note: this rule is automatically disabled when the project's sonar.plsql.forms.metadata is not specified.
.
================================================
FILE: zpa-checks/src/main/resources/org/sonar/l10n/plsqlopen/rules/plsql/NotASelectedExpression.html
================================================
In a SELECT DISTINCT with an ORDER BY clause, if you specify a value in the ORDER BY that does not exists
in the SELECT clause, Oracle will raise the exception ORA-01791: not a SELECTed expression.
See this example:
SELECT DISTINCT item.name
FROM item
ORDER BY item.group_id
The item.id column is not in the SELECT clause, so Oracle will raise an ORA-01791. The corrected version can be:
SELECT DISTINCT item.name, item.group_id
FROM item
ORDER BY item.group_id
If the column in SELECT clause has an alias, you also can use the alias in the ORDER BY clause:
-- valid queries
SELECT DISTINCT item.name AS full_name
FROM item
ORDER BY item.name;
SELECT DISTINCT item.name AS full_name
FROM item
ORDER BY full_name;
Be aware that until the version 11.2.0.4, Oracle accepted some incorrect values in ORDER BY, like:
SELECT DISTINCT UPPER(item.name) AS full_name, item.group_id
FROM item
ORDER BY item.name -- should be "UPPER(item.name)" or "full_name"
You should fix the queries to avoid compatibility issues with newer versions of the Oracle database.
================================================
FILE: zpa-checks/src/main/resources/org/sonar/l10n/plsqlopen/rules/plsql/NotFound.html
================================================
Use cursor%NOTFOUND instead of NOT cursor%FOUND.
================================================
FILE: zpa-checks/src/main/resources/org/sonar/l10n/plsqlopen/rules/plsql/NvlWithNullParameter.html
================================================
The NVL function lets you replace a null value with a valid value value. So, don't specify a NULL literal or an empty string as a parameter of a NVL call.
Noncompliant Code Example
var := nvl(x, '');
================================================
FILE: zpa-checks/src/main/resources/org/sonar/l10n/plsqlopen/rules/plsql/ParsingError.html
================================================
When the PL/SQL parser fails, it is possible to record the failure as a violation on the file. This way, not only it is possible to track the number of files that do not parse but also to easily find out why they do not parse.
================================================
FILE: zpa-checks/src/main/resources/org/sonar/l10n/plsqlopen/rules/plsql/QueryWithoutExceptionHandling.html
================================================
Usually you should add an exception handling block for SELECT statements, to avoid unexpected exceptions.
================================================
FILE: zpa-checks/src/main/resources/org/sonar/l10n/plsqlopen/rules/plsql/RaiseStandardException.html
================================================
You should review all the RAISE statements that causes a predefined exception, because usually this is a sign of bad logic. Consider this example:
CREATE OR REPLACE FUNCTION group_has_users(id IN NUMBER) RETURN BOOLEAN IS
has_users BOOLEAN;
user_id user_group.user_id%TYPE;
BEGIN
BEGIN
SELECT user_group.user_id
INTO user_id
FROM user_group
WHERE user_group.group_id = id;
RAISE TOO_MANY_ROWS;
EXCEPTION
WHEN NO_DATA_FOUND THEN
has_users := FALSE;
WHEN TOO_MANY_ROWS THEN
has_users := TRUE;
END;
RETURN has_users;
END;
In this case, the TOO_MANY_ROWS exception is being used as a flow control mechanism. This function could be rewritten to avoid the RAISE statement:
CREATE OR REPLACE FUNCTION group_has_users(id IN NUMBER) RETURN BOOLEAN IS
number_of_users NUMBER;
BEGIN
BEGIN
SELECT COUNT(*)
INTO number_of_users
FROM user_group
WHERE user_group.group_id = id;
EXCEPTION
WHEN OTHERS THEN
number_of_users := 0;
END;
RETURN number_of_users > 0;
END;
================================================
FILE: zpa-checks/src/main/resources/org/sonar/l10n/plsqlopen/rules/plsql/RedundantExpectation.html
================================================
From the utPLSQL documentation:
Validation of the code under test (the tested logic of procedure/function etc.) is performed by comparing
the actual data against the expected data. utPLSQL uses a combination of expectation and matcher to
perform the check on the data.
Some validations are written in the form of ut.expect(actual_value).matcher(expected_value).
This rules checks if the actual_value and the expected_value are the same thing. Example:
...
begin
v_expected := '2345';
v_actual := betwnstr('1234567', 2, 5);
ut.expect(v_actual).to_equal(v_actual); -- This expectation is wrong, it's always true
end;
================================================
FILE: zpa-checks/src/main/resources/org/sonar/l10n/plsqlopen/rules/plsql/ReturnOfBooleanExpression.html
================================================
Return of boolean literal statements wrapped into IF-THEN-ELSE ones should be simplified.
Noncompliant Code Example
IF expression THEN
RETURN TRUE;
ELSE
RETURN FALSE;
END IF;
Compliant Solution
RETURN expression;
================================================
FILE: zpa-checks/src/main/resources/org/sonar/l10n/plsqlopen/rules/plsql/SameBranch.html
================================================
Having two branches in the same if structure with the same implementation is at best duplicate code,
and at worst a coding error. If the same logic is truly needed for both instances, then they should be combined.
Noncompliant Code Example
IF var BETWEEN 0 AND 10 THEN
do_the_thing();
ELSIF var BETWEEN 10 AND 20 THEN
do_the_thing(); -- Noncompliant; duplicates first condition
ELSIF var BETWEEN 20 AND 50 THEN
do_the_another_thing();
ELSE
do_the_rest()
END IF;
Compliant Solution
IF var BETWEEN 0 AND 10 THEN
do_the_thing();
ELSIF var BETWEEN 10 AND 20 THEN
do_the_second_thing();
ELSIF var BETWEEN 20 AND 50 THEN
do_the_another_thing();
ELSE
do_the_rest()
END IF;
================================================
FILE: zpa-checks/src/main/resources/org/sonar/l10n/plsqlopen/rules/plsql/SameCondition.html
================================================
Duplicate a condition in a comparison is almost always a mistake.
It can be either a copy/paste error and therefore a bug, or it is simply wasted code, and should be simplified.
Noncompliant Code Example
IF (x = 1) AND (x = 1) THEN ...
================================================
FILE: zpa-checks/src/main/resources/org/sonar/l10n/plsqlopen/rules/plsql/SelectAllColumns.html
================================================
SELECT * returns all the available columns. You should explicitly list the necessary columns.
When considering using *, you should consider the possibility that more fields will be added to the table later.
Noncompliant Code Example
begin
select *
into var
from emp;
select emp.*
into var
from emp;
end;
================================================
FILE: zpa-checks/src/main/resources/org/sonar/l10n/plsqlopen/rules/plsql/SelectWithRownumAndOrderBy.html
================================================
In a SELECT expression, the WHERE clause is executed before the ORDER BY clause. Consider this example:
DECLARE
CURSOR recent_users IS
SELECT user.name,
user.creation_date
FROM user
WHERE ROWNUM <= 5
ORDER BY user.creation_date DESC;
BEGIN
...
This query won't return the last 5 created users. The database will filter the users without any ordering and after, apply the ORDER BY clause. The corrected query is:
DECLARE
CURSOR recent_users IS
SELECT name,
creation_date
FROM (SELECT user.name,
user.creation_date
FROM user
ORDER BY user.creation_date DESC)
WHERE ROWNUM <= 5;
BEGIN
...
================================================
FILE: zpa-checks/src/main/resources/org/sonar/l10n/plsqlopen/rules/plsql/ToCharInOrderBy.html
================================================
The usage of TO_CHAR function in a ORDER BY is almost always a mistake.
The column value will be ordered alphabetically instead of being ordered according its datatype.
Noncompliant Code Example
Suppose we have the data below in the EMP table:
| empno |
hiredate |
| 1 |
2019-10-01 |
| 5 |
2019-10-10 |
| 15 |
2018-10-02 |
| 20 |
2018-10-20 |
The queries below return an unwanted result:
select empno from emp order by to_char(empno);
select hiredate from emp order by to_char(hiredate, 'dd-mm-rrrr');
| hiredate |
| 01-OCT-19 |
| 02-OCT-18 |
| 10-OCT-19 |
| 20-OCT-18 |
Compliant Code Example
To order these columns correctly we must remove the TO_CHAR call.
select empno from emp order by empno;
select hiredate from emp order by hiredate;
| hiredate |
| 02-OCT-18 |
| 20-OCT-18 |
| 01-OCT-19 |
| 10-OCT-19 |
================================================
FILE: zpa-checks/src/main/resources/org/sonar/l10n/plsqlopen/rules/plsql/ToDateWithoutFormat.html
================================================
Always specify the date format in TO_DATE calls.
Noncompliant Code Example
begin
var := to_date('2015-01-01');
end;
Compliant Solution
begin
var := to_date('2015-01-01', 'YYYY-MM-DD');
end;
================================================
FILE: zpa-checks/src/main/resources/org/sonar/l10n/plsqlopen/rules/plsql/TooManyRowsHandler.html
================================================
When a SELECT INTO statement causes the predefined exception TOO_MANY_ROWS the values of the variables in the INTO clause are undefined.
Noncompliant Code Example
begin
select empno
into var
from emp;
exception
when too_many_rows then
null;
end;
Compliant Solution
begin
select empno
into var
from emp;
exception
when too_many_rows then
var := null;
end;
================================================
FILE: zpa-checks/src/main/resources/org/sonar/l10n/plsqlopen/rules/plsql/UnhandledUserDefinedException.html
================================================
When a custom exception is declared and not handled in the code, raising this exception will cause the error
"ORA-06510: PL/SQL: unhandled user-defined exception" in the database or the error "User-defined exception" in
Oracle Forms.
It is a good practice to handle custom exceptions.
Noncompliant Code Example
DECLARE
my_exception EXCEPTION;
BEGIN
...
RAISE my_exception; -- this will cause an "user-defined exception"
END;
Compliant Solution
DECLARE
my_exception EXCEPTION;
BEGIN
...
RAISE my_exception;
EXCEPTION
WHEN my_exception THEN
...
END;
This check will also trigger a violation if the exception is handled by a OTHERS handler and it has a reference to SQLERRM.
In this case, the SQLERRM will return "User-defined exception", which is not very useful.
DECLARE
my_exception EXCEPTION;
BEGIN
...
RAISE my_exception;
EXCEPTION
WHEN OTHERS THEN
log(SQLERRM);
END;
================================================
FILE: zpa-checks/src/main/resources/org/sonar/l10n/plsqlopen/rules/plsql/UnnecessaryAliasInQuery.html
================================================
An alias can be used in tables when you plan to add the same table more than once in the FROM clause
(e.g. self join), or you want to shorten the table name to make the SQL statement shorter and easier to read.
But when abused, aliases can have the opposite effect: decrease legibility.
Consider using aliases only when the table appears more than once in a query.
Noncompliant Code Example
SELECT a.id,
b.id,
b.name
FROM employee a,
dept b
WHERE a.dept_id = b.id;
Compliant Solution
SELECT employee.id,
dept.id,
dept.name
FROM employee,
dept
WHERE employee.dept_id = dept.id;
================================================
FILE: zpa-checks/src/main/resources/org/sonar/l10n/plsqlopen/rules/plsql/UnnecessaryElse.html
================================================
When the IF clause of a IF-THEN-ELSE structure does not complete successfully, the ELSE clause is unnecessary.
Noncompliant Code Example
BEGIN
IF condition THEN
RETURN value;
ELSE
value := NULL;
END IF;
END;
Compliant Solution
BEGIN
IF condition THEN
RETURN value;
END IF;
value := NULL;
END;
================================================
FILE: zpa-checks/src/main/resources/org/sonar/l10n/plsqlopen/rules/plsql/UnnecessaryLike.html
================================================
Using a LIKE condition without a wildcard (% or _) is suspicious. A maintainer can suppose whether a wildcard is
forgotten or it is meant as equality test.
Noncompliant Code Example
if (last_name like 'Smith') ...
Compliant Solution
if (last_name like 'Smith%') ...
-- or
if (last_name = 'Smith') ...
================================================
FILE: zpa-checks/src/main/resources/org/sonar/l10n/plsqlopen/rules/plsql/UnnecessaryNullStatement.html
================================================
A NULL statement at the same level of other statements is useless, so should be removed.
Noncompliant Code Example
BEGIN
var := 1;
NULL; -- this NULL statement can be removed
END
Compliant Solution
BEGIN
var := 1;
END
================================================
FILE: zpa-checks/src/main/resources/org/sonar/l10n/plsqlopen/rules/plsql/UnusedCursor.html
================================================
If a local cursor is declared but not used, it is dead code and should be removed.
Doing so will improve maintainability because developers will not wonder what the cursor is used for.
================================================
FILE: zpa-checks/src/main/resources/org/sonar/l10n/plsqlopen/rules/plsql/UnusedParameter.html
================================================
Unused parameters are misleading. Whatever the value passed to such parameters is, the behavior will be the same.
Noncompliant Code Example
PROCEDURE do_something(a IN NUMBER, b IN NUMBER) IS -- "b" is unused
BEGIN
compute(a);
END;
Compliant Solution
PROCEDURE do_something(a IN NUMBER) IS
BEGIN
compute(a);
END;
================================================
FILE: zpa-checks/src/main/resources/org/sonar/l10n/plsqlopen/rules/plsql/UnusedVariable.html
================================================
If a local variable is declared but not used, it is dead code and should be removed.
Doing so will improve maintainability because developers will not wonder what the variable is used for.
================================================
FILE: zpa-checks/src/main/resources/org/sonar/l10n/plsqlopen/rules/plsql/UselessParenthesis.html
================================================
Useless parentheses can sometimes be misleading and so should be removed.
Noncompliant Code Example
if ((a = b)) then ...
Compliant Solution
if (a = b) then ...
================================================
FILE: zpa-checks/src/main/resources/org/sonar/l10n/plsqlopen/rules/plsql/VariableHiding.html
================================================
Redeclaring variables in inner scopes is allowed in PL/SQL, but it can cause confusion and should therefore be avoided.
================================================
FILE: zpa-checks/src/main/resources/org/sonar/l10n/plsqlopen/rules/plsql/VariableInCount.html
================================================
Using the COUNT built-in with local variable is misleading and in the most of time it is a coding error.
Noncompliant Code Example
DECLARE
v_empno emp.empno%TYPE;
...
BEGIN
-- Because the v_empno is NULL at this point, this COUNT always returns 0.
SELECT COUNT(v_empno)
INTO i
FROM employee
WHERE employee.deptno = v_deptno;
END;
Compliant Solution
BEGIN
SELECT COUNT(*)
INTO i
FROM employee
WHERE employee.deptno = v_deptno;
END;
================================================
FILE: zpa-checks/src/main/resources/org/sonar/l10n/plsqlopen/rules/plsql/VariableInitializationWithFunctionCall.html
================================================
If your initialization fails you will not be able to handle the error in your exceptions block.
Noncompliant Code Example
DECLARE
employee_name emp.name%TYPE := get_employee_name(id => 5);
BEGIN
...
END;
Compliant Solution
DECLARE
employee_name emp.name%TYPE;
BEGIN
employee_name := get_employee_name(id => 5);
...
END;
================================================
FILE: zpa-checks/src/main/resources/org/sonar/l10n/plsqlopen/rules/plsql/VariableInitializationWithNull.html
================================================
By default, new variables and RECORD fields are initialized with NULL. So, you don't need to initialize them with NULL.
================================================
FILE: zpa-checks/src/main/resources/org/sonar/l10n/plsqlopen/rules/plsql/VariableName.html
================================================
This rule checks that all variable names match a provided regular expression.
Example
Considering the default expression:
DECLARE
dept_name dept.name%type; -- Compliant
dept_name_ dept.name%type; -- Noncompliant
BEGIN
...
END;
================================================
FILE: zpa-checks/src/main/resources/org/sonar/l10n/plsqlopen/rules/plsql/XPath.html
================================================
This rule allows the definition of custom rules using XPath expressions.
Issues are created depending on the return value of the XPath expression. If the XPath expression returns:
- a single or list of AST nodes, then a line issue with the given message is created for each node
- a boolean, then a file issue with the given message is created only if the boolean is true
- anything else, no issue is created
================================================
FILE: zpa-checks/src/main/resources/org/sonar/l10n/plsqlopen.properties
================================================
AddParenthesesInNestedExpression.message=Add parentheses around this AND condition to make the operator precedence explicit.
AddParenthesesInNestedExpression.name=Add parentheses in nested expression
CharacterDatatypeUsage.message=Use VARCHAR2 instead of {0}.
CharacterDatatypeUsage.name=Use VARCHAR2 instead of CHAR and VARCHAR
CollapsibleIfStatements.message=This IF statement can be merged with the enclosing one.
CollapsibleIfStatements.name=Collapsible "if" statements should be merged
ColumnsShouldHaveTableName.message=Specify the table of column "{0}".
ColumnsShouldHaveTableName.name=The columns in a SELECT should be prefixed with table name
CommitRollback.message=Avoid {0} calls unless it is in an autonomous transaction.
CommitRollback.name=Avoid COMMIT/ROLLBACK calls in database objects
ComparisonWithBoolean.message=Remove the literal "{0}" of this comparison.
ComparisonWithBoolean.name=Avoid superfluous comparation against boolean literals
ComparisonWithNull.message=Fix this comparison or change to "{0}".
ComparisonWithNull.name=Do not compare values against the NULL literal or an empty string
ConcatenationWithNull.message=Review this concatenation with NULL value.
ConcatenationWithNull.name=Unnecessary concatenation with NULL value
CursorBodyInPackageSpec.message=Move the body of the cursor "{0}" to the package body.
CursorBodyInPackageSpec.name=Do not declare cursor bodies in a package specification
DbmsOutputPut.message=Avoid direct calls to DBMS_OUTPUT procedures.
DbmsOutputPut.name=Avoid direct calls to DBMS_OUTPUT procedures
DeadCode.message=This code will never be executed.
DeadCode.name=Dead code should be removed
DeclareSectionWithoutDeclarations.message=Remove this DECLARE keyword.
DeclareSectionWithoutDeclarations.name=Do not add the DECLARE keyword if the block doesn't have any declaration
DisabledTest.message=Fix or remove this disabled unit test.
DisabledTest.name=Tests should not be disabled
DuplicateConditionIfElsif.message=This code can not be reached because the condition duplicates a previous condition in the same sequence of "if/else if" statements.
DuplicateConditionIfElsif.name=Related "if/elsif" statements should not have the same condition
DuplicatedValueInIn.message=Remove or fix the duplicated value "{0}" in the IN condition.
DuplicatedValueInIn.name=Duplicated value in an IN condition
EmptyBlock.message=Either remove or fill this block of code.
EmptyBlock.name=Empty blocks should be removed
EmptyStringAssignment.message=Replace this empty string by NULL.
EmptyStringAssignment.name=Avoid using empty strings to represent NULL
ExplicitInParameter.message=Explicitly declare this parameter as IN.
ExplicitInParameter.name=Parameter mode should be explicitly declared
FunctionWithOutParameter.message=Rewrite this function to not depend on OUT parameters.
FunctionWithOutParameter.name=Avoid functions with OUT parameters
IdenticalExpression.message=Identical expressions on both sides of operator "{0}".
IdenticalExpression.name=Identical expressions should not be used on both sides of an operator
IfWithExit.message=Replace this IF ... EXIT by a EXIT WHEN statement.
IfWithExit.name=Use EXIT WHEN instead of an IF statement to exit from a loop
InequalityUsage.message=Replace "{0}" by "<>".
InequalityUsage.name=Only "<>" should be used to test inequality
InsertWithoutColumns.message=Specify the columns in this INSERT.
InsertWithoutColumns.name=Always specify the columns in an INSERT statement
InvalidReferenceToObject.message=Invalid reference to the object "{0}" in this {1} call.
InvalidReferenceToObject.name=Invalid reference to Oracle Forms object
NotASelectedExpression.message=This value does not exists in the SELECT clause. Fix this expression or add this value in the SELECT.
NotASelectedExpression.name=ORDER BY items must appear in the select list if SELECT DISTINCT is specified
NotFound.message=Use %NOTFOUND instead of NOT ...%FOUND.
NotFound.name=Use cursor%NOTFOUND instead of NOT cursor%FOUND
NvlWithNullParameter.message=This NVL does not have any effect. Fix the {0} parameter or remove this NVL.
NvlWithNullParameter.name=Do not pass a NULL literal or an empty string to NVL
ParsingError.message=This code wasn't parsed correctly. No issue will be registered on it.
ParsingError.name=Parser failure
QueryWithoutExceptionHandling.message=Handle exceptions of this query.
QueryWithoutExceptionHandling.name=Avoid queries without an exception handling block
QueryWithoutExceptionHandling.param.strictMode=If false, allows inner block without exception handling.
RaiseStandardException.message=Avoid raising the standard exception {0}.
RaiseStandardException.name=Avoid raising standard exceptions
RedundantExpectation.message=This test expectation is redundant. The actual value is the same as the one used in the matcher.
RedundantExpectation.name=Test expectations should not be redundant
ReturnOfBooleanExpression.message=Replace this if-then-else statement by a single return statement.
ReturnOfBooleanExpression.name=Return of boolean expressions should not be wrapped into an "if-then-else" statement
SameBranch.message=Either merge this branch with the identical one on line {0} or change one of the implementations.
SameBranch.name=Branches in the same conditional structure should not have exactly the same implementation
SameCondition.message=This condition duplicates the one on line {0}.
SameCondition.name=Identical conditions should not be duplicated
SelectAllColumns.message=SELECT * should not be used.
SelectAllColumns.name=SELECT * should not be used
SelectWithRownumAndOrderBy.message=Move this ROWNUM comparation to a more external level to guarantee the ordering.
SelectWithRownumAndOrderBy.name=A SELECT cannot have a comparison with ROWNUM and an ORDER BY at the same level
ToCharInOrderBy.message=This TO_CHAR may be causing the records to be fetched in the wrong order.
ToCharInOrderBy.name=Avoid TO_CHAR in an ORDER BY clause
ToDateWithoutFormat.message=Specify the date format in this TO_DATE.
ToDateWithoutFormat.name=TO_DATE without date format
TooManyRowsHandler.message=Handle the variables used in the SELECT INTO statements here so their values do not become undefined.
TooManyRowsHandler.name=Avoid masking the TOO_MANY_ROWS exception
UnhandledUserDefinedException.message=There is no exception handler for "{0}" here. This will cause an "user-defined exception" error.
UnhandledUserDefinedException.name=User defined exceptions should be handled
UnnecessaryAliasInQuery.message=This statement has only one reference to the table "{0}". Remove the alias "{1}" to improve the readability.
UnnecessaryAliasInQuery.name=Unnecessary alias for table reference
UnnecessaryAliasInQuery.param.acceptedLength=Ignore alias with size greater than or equals to this
UnnecessaryElse.message=This ELSE can be replaced by an END IF. When the corresponding IF is executed, the code execution will be stopped. Either way, the code within this ELSE will always run, regardless of the ELSE block.
UnnecessaryElse.name=Unnecessary ELSE clause
UnnecessaryLike.message=This LIKE condition is not using any wildcard. Replace with an equality comparator or add a wildcard.
UnnecessaryLike.name=Do not use LIKE conditions without wildcards
UnnecessaryNullStatement.message=This NULL statement does not have any effect here.
UnnecessaryNullStatement.name=Unnecessary NULL statement
UnusedCursor.message=Remove this unused "{0}" cursor.
UnusedCursor.name=Unused cursors should be removed
UnusedParameter.message=Remove this unused "{0}" parameter.
UnusedParameter.name=Unused parameters should be removed
UnusedParameter.param.ignoreMethods=Regular Expression describing method names that should be ignored for this check
UnusedVariable.message=Remove this unused "{0}" local variable.
UnusedVariable.name=Unused local variables should be removed
UselessParenthesis.message=Remove those useless parenthesis.
UselessParenthesis.name=Useless parentheses around expressions should be removed to prevent any misunderstanding
VariableHiding.message=This variable "{0}" hides the declaration on line {1}.
VariableHiding.name=Do not redeclare variables in inner scope
VariableInCount.message=Looks like there is a "{0}" variable in this context. Review if this COUNT is correct.
VariableInCount.name=Don't pass variables to COUNT function
VariableInitializationWithFunctionCall.message=Move this initialization to the BEGIN...END block.
VariableInitializationWithFunctionCall.name=Avoid initializing variables using functions in the declaration section
VariableInitializationWithNull.message=Remove this unnecessary initialization to NULL.
VariableInitializationWithNull.name=Variables and RECORD fields do not need to be initialized with NULL
VariableName.message=Rename {0} to match the regular expression {1}.
VariableName.name=Variables should comply with a naming convention
XPath.name=Track breaches of an XPath rule
================================================
FILE: zpa-checks/src/main/resources/org/sonar/l10n/plsqlopen_pt_BR/rules/plsql/AddParenthesesInNestedExpression.html
================================================
Uma condição AND tem uma precedência maior que uma condição OR, então você deve envolver a condição AND em parênteses
por questão de clareza e para garantir que os operadores sejam avaliados na ordem que você deseja.
Considere esse exemplo:
SELECT cachorros.nome
FROM cachorros
WHERE cachorros.sexo = 'macho'
and cachorros.cor = 'branco'
or cachorros.tamanho = 'grande';
Sem parênteses, alguém poderia pensar que ela equivale a:
SELECT cachorros.nome
FROM cachorros
WHERE cachorros.sexo = 'macho'
and (cachorros.tamanho = 'branco' or cachorros.size = 'grande');
Mas a consulta original é processada como:
SELECT cachorros.nome
FROM cachorros
WHERE (cachorros.sexo = 'macho' and cachorros.cor = 'branco')
or cachorros.tamanho = 'grande';
================================================
FILE: zpa-checks/src/main/resources/org/sonar/l10n/plsqlopen_pt_BR/rules/plsql/CharacterDatatypeUsage.html
================================================
Atualmente os tipos de dados VARCHAR e VARCHAR2 são idênticos. Mas para acomodar padrões SQL emergentes, o VARCHAR pode se tornar um tipo de dados diferente no futuro.
O tipo de dados CHAR não oferece nenhuma vantagem sobre o VARCHAR2 e faz com que a pesquisa seja mais difícil devido aos valores com espaços à direita.
declare
var1 varchar(10); -- violação
var2 char(10); -- violação
var3 varchar2(10); -- ok
begin
null;
end;
================================================
FILE: zpa-checks/src/main/resources/org/sonar/l10n/plsqlopen_pt_BR/rules/plsql/CollapsibleIfStatements.html
================================================
Una comandos if aninhados para melhorar a legibilidade do código.
Código em desconformidade
if condition1 then
if condition2 then
-- code
end if;
end if;
Código correto
if condition1 and condition2 then
-- code
end if;
================================================
FILE: zpa-checks/src/main/resources/org/sonar/l10n/plsqlopen_pt_BR/rules/plsql/ColumnsShouldHaveTableName.html
================================================
Especifique o nome da tabela nas colunas de um comando SELECT para melhorar a legibilidade e evitar que o código pare de funcionar quando a tabela for alterada.
================================================
FILE: zpa-checks/src/main/resources/org/sonar/l10n/plsqlopen_pt_BR/rules/plsql/CommitRollback.html
================================================
Geralmente, o contole de uma transação deve ser responsabilidade do "proprietário" dela.
Se a transação foi iniciada por um código Java, o commit e rollback devem ser feitos no código Java.
Assim, nessa situação, chamar um COMMIT ou ROLLBACK a partir de um objeto de banco de dados é uma prática ruim e deve ser evitada.
Essa regra ignora procedimentos e funções com PRAGMA AUTONOMOUS_TRANSACTION.
================================================
FILE: zpa-checks/src/main/resources/org/sonar/l10n/plsqlopen_pt_BR/rules/plsql/ComparisonWithBoolean.html
================================================
Remova literais booleanos de comparações para melhorar a legibilidade.
Código em desconformidade
if var = true then ...
if var = false then ...
Código correto
if var then ...
if not var then ...
================================================
FILE: zpa-checks/src/main/resources/org/sonar/l10n/plsqlopen_pt_BR/rules/plsql/ComparisonWithNull.html
================================================
Para testar por nulls, use apenas as comparações IS NULL e IS NOT NULL. Qualquer outra comparação com nulls resultará em NULL.
Lembre que uma string vazia é equivalente ao literal NULL.
Código em desconformidade
if var = null then
-- code
end if;
Ou:
if var = '' then
-- code
end if;
Código correto
if var is null then
-- code
end if;
if other_var is null then
-- code
end if;
================================================
FILE: zpa-checks/src/main/resources/org/sonar/l10n/plsqlopen_pt_BR/rules/plsql/ConcatenationWithNull.html
================================================
Concatenar um valor VARCHAR2 com NULL não causa efeito nenhum. Sendo assim, o valor NULL deve ser removido.
Uma concatenação de qualquer outro tipo de dado com NULL causará uma conversão implícita para VARCHAR2. Se esse for o
comportamento desejado, substitua a concatenação por uma chamada para TO_CHAR para tornar isso explícito. Veja esse exemplo:
var := NVL(''||id, 'Vazio');
Você deveria usar:
var := NVL(TO_CHAR(id), 'Vazio');
================================================
FILE: zpa-checks/src/main/resources/org/sonar/l10n/plsqlopen_pt_BR/rules/plsql/CursorBodyInPackageSpec.html
================================================
Declarações de cursores podem ser separadas em duas partes: especificação e corpo. Ao declarar um
cursor em uma especificação de pacote, a especificação do pacote deveria conter apenas a especificação
do cursor e o corpo do cursor deve ser incluído no corpo do pacote.
Em versões mais novas do Oracle Forms, o uso de cursores declarados com corpo em especificação de pacote
também causa o erro de compilação "internal error [Unexpected fragile external reference.]".
Código em desconformidade
create or replace package pkg is
cursor cur is
select dummy from dual;
end;
Código correto
create or replace package pkg is
type cur_type is record(dummy varchar2(1));
cursor cur return cur_type;
end;
/
create or replace package body pkg is
cursor cur return cur_type is
select dummy from dual;
end;
/
================================================
FILE: zpa-checks/src/main/resources/org/sonar/l10n/plsqlopen_pt_BR/rules/plsql/DbmsOutputPut.html
================================================
A saída da chamada DBMS_OUTPUT.PUT/DBMS_OUTPUT.PUT_LINE não será visível quando SERVEROUTPUT estiver definido como OFF.
Além disso, a menos que essa chamada seja explicitamente necessária, é melhor usar um mecanismo de logging em vez disso.
================================================
FILE: zpa-checks/src/main/resources/org/sonar/l10n/plsqlopen_pt_BR/rules/plsql/DeadCode.html
================================================
Comandos como return, exit, continue, e raise alteram o fluxo para fora do bloco atual.
Geralmente, qualquer comando em um bloco que estiver depois de um desses comandos é código desnecessário esperando para confundir alguém desavisado.
Código em desconformidade
begin
raise my_error;
log('finished'); -- esse código nunca será executado
end;
Código correto
begin
raise my_error;
end;
================================================
FILE: zpa-checks/src/main/resources/org/sonar/l10n/plsqlopen_pt_BR/rules/plsql/DeclareSectionWithoutDeclarations.html
================================================
Você não precisa adicionar a palavra-chave DECLARE em um bloco se não há nenhuma declaração.
================================================
FILE: zpa-checks/src/main/resources/org/sonar/l10n/plsqlopen_pt_BR/rules/plsql/DisabledTest.html
================================================
Quando um teste falha, por exemplo, devido a problemas de infraestrutura, você pode querer ignorá-lo temporariamente.
Mas sem nenhum tipo de explicação do motivo do teste ter sido ignorado, talvez ele nunca seja reativado.
Essa regra registra um problema em cada teste desativado que não tem um comentário explicando o motivo disso.
Código em desconformidade
-- %test(my test)
-- %disabled
procedure test;
Código correto
-- %test(my test)
procedure test;
Exceções
A regra não registra um problema se houver um comentário na anotação %disabled.
================================================
FILE: zpa-checks/src/main/resources/org/sonar/l10n/plsqlopen_pt_BR/rules/plsql/DuplicateConditionIfElsif.html
================================================
Uma sequência de instruções if/elsif é avaliada de cima para baixo.
Apenas uma branch dessas instruções será executada de cada vez: a primeira que retornar true.
Assim, duplicar uma condição automaticamente leva a código inútil. Geralmente isso acontece por um erro ao copiar/colar.
Na melhor situação isso é apenas código inútil e na pior das situações é um bug que provavelmente causará mais problemas
na manutenção do código e obviamente pode levar a um comportamento inesperado.
Código em desconformidade
IF (param = 1) THEN
open();
ELSIF (param = 2) THEN
close();
ELSIF (param = 1) THEN // Incorreto
move();
END IF;
Código correto
IF (param = 1) THEN
open();
ELSIF (param = 2) THEN
close();
ELSIF (param = 3) THEN
move();
END IF;
================================================
FILE: zpa-checks/src/main/resources/org/sonar/l10n/plsqlopen_pt_BR/rules/plsql/DuplicatedValueInIn.html
================================================
Valores duplicados em uma condição IN pode ser um erro ao copiar/colar sendo então um bug, ou simplesmente é código inútil e deve ser simplificado.
Código em desconformidade
if value in (a, a, b) then ...
Código correto
if value in (a, b) then ...
================================================
FILE: zpa-checks/src/main/resources/org/sonar/l10n/plsqlopen_pt_BR/rules/plsql/EmptyBlock.html
================================================
Na maioria das vezes um bloco de código está vazio quando realmente falta alguma implementação. Então tal bloco deve ser preenchido ou removido.
Código em desconformidade
begin
null;
end;
================================================
FILE: zpa-checks/src/main/resources/org/sonar/l10n/plsqlopen_pt_BR/rules/plsql/EmptyStringAssignment.html
================================================
Para melhorar a legibilidade, evite usar strings vazias para representar NULL.
Código em desconformidade
var := '';
Código correto
var := null;
================================================
FILE: zpa-checks/src/main/resources/org/sonar/l10n/plsqlopen_pt_BR/rules/plsql/ExplicitInParameter.html
================================================
Se não for informado, o modo padrão dos parâmetros é IN. Porém, definir ele explicitamente faz com que o código seja mais fácil de ler.
CREATE OR REPLACE PROCEDURE myproc(value VARCHAR2) IS -- violação
BEGIN
NULL;
END;
CREATE OR REPLACE PROCEDURE myproc(value IN VARCHAR2) IS -- correto, o modo do parâmetro está definido
BEGIN
NULL;
END;
================================================
FILE: zpa-checks/src/main/resources/org/sonar/l10n/plsqlopen_pt_BR/rules/plsql/FunctionWithOutParameter.html
================================================
Funções com parâmetros OUT são difíceis de entender.
É impossível dizer se um parâmetro é de entrada ou saída apenas olhando para a chamada da função
Além disso, funções com parâmetros OUT não podem ser chamadas por SQL.
Código em desconformidade
CREATE OR REPLACE FUNCTION get_product_info(id IN NUMBER, value OUT NUMBER) RETURN VARCHAR2 IS
BEGIN
...
END;
================================================
FILE: zpa-checks/src/main/resources/org/sonar/l10n/plsqlopen_pt_BR/rules/plsql/IdenticalExpression.html
================================================
Usar o mesmo valor nos dois lados de um operador é quase sempre um equívoco.
Pode ser um erro causado por copiar/colar e então ser um bug ou simplesmente ser código desnecessários que deve ser simplificado.
Código em desconformidade
if a = a then ...
================================================
FILE: zpa-checks/src/main/resources/org/sonar/l10n/plsqlopen_pt_BR/rules/plsql/IfWithExit.html
================================================
Para melhorar a legibilidade sempre use EXIT WHEN em vez de um IF para sair de um loop.
Código em desconformidade
if condition1 then
exit;
end if;
Código correto
exit when condition1;
================================================
FILE: zpa-checks/src/main/resources/org/sonar/l10n/plsqlopen_pt_BR/rules/plsql/InequalityUsage.html
================================================
As formas "<>", "!=", "~=" and "^=" são equivalentes, mas apenas a forma "<>" está definida no padrão ANSI SQL.
Código em desconformidade
if a != b then
Código correto
if a <> b then
================================================
FILE: zpa-checks/src/main/resources/org/sonar/l10n/plsqlopen_pt_BR/rules/plsql/InsertWithoutColumns.html
================================================
Especifique as colunas em um comando insert para evitar que o código pare de funcionar após adicionar uma nova coluna na tabela.
Código em desconformidade
insert into tab values (1);
Código correto
insert into tab (col) values (1);
================================================
FILE: zpa-checks/src/main/resources/org/sonar/l10n/plsqlopen_pt_BR/rules/plsql/InvalidReferenceToObject.html
================================================
No Oracle Forms, vários procedimentos e funções precisam de uma refererência a um objeto (blocos, itens, alertas...).
Infelizmente, a única forma de passar uma referência a um objeto é usando uma variável VARCHAR2 e essas referências
não são verificadas pelo compilador.
Atualmente essa regra verifica os seguintes métodos:
Bultins para alertas:
- FIND_ALERT
- SET_ALERT_BUTTON_PROPERTY
- SET_ALERT_PROPERTY
- SHOW_ALERT
Bultins para blocos:
- FIND_BLOCK
- GET_BLOCK_PROPERTY
- GO_BLOCK
- SET_BLOCK_PROPERTY
Bultins para itens:
- CHECKBOX_CHECKED
- CONVERT_OTHER_VALUE
- DISPLAY_ITEM
- FIND_ITEM
- GET_ITEM_INSTANCE_PROPERTY
- GET_ITEM_PROPERTY
- GET_RADIO_BUTTON_PROPERTY
- GO_ITEM
- IMAGE_SCROLL
- IMAGE_ZOOM
- IMAGE_ZOOM
- PLAY_SOUND
- READ_IMAGE_FILE
- READ_SOUND_FILE
- RECALCULATE
- SET_ITEM_INSTANCE_PROPERTY
- SET_ITEM_PROPERTY
- SET_ITEM_PROPERTY
- SET_RADIO_BUTTON_PROPERTY
- SET_RADIO_BUTTON_PROPERTY
- WRITE_IMAGE_FILE
- WRITE_SOUND_FILE
Bultins para LOVs:
- FIND_LOV
- GET_LOV_PROPERTY
- SET_LOV_COLUMN_PROPERTY
- SET_LOV_PROPERTY
- SHOW_LOV
Nota: essa regra é desativada automaticamente quando a propriedade sonar.plsql.forms.metadata do projeto não está definida.
.
================================================
FILE: zpa-checks/src/main/resources/org/sonar/l10n/plsqlopen_pt_BR/rules/plsql/NotASelectedExpression.html
================================================
Em um SELECT DISTINCT com uma cláusula ORDER BY, se você especificar um valor no ORDER BY que não existe
na cláusula SELECT, o Oracle retornará a exceção ORA-01791: not a SELECTed expression.
Veja esse exemplo:
SELECT DISTINCT item.name
FROM item
ORDER BY item.group_id
A coluna item.id não está na cláusula SELECT, então o Oracle causará um ORA-01791. A versão corrigida pode ser:
SELECT DISTINCT item.name, item.group_id
FROM item
ORDER BY item.group_id
Se uma coluna na cláusula SELECT tem um alias, você também pode usar o alias na cláusula ORDER BY:
-- consultas válidas
SELECT DISTINCT item.name AS full_name
FROM item
ORDER BY item.name;
SELECT DISTINCT item.name AS full_name
FROM item
ORDER BY full_name;
Esteja ciente de que até a versão 11.2.0.4, o Oracle aceitava alguns valores incorretos em ORDER BY, como:
SELECT DISTINCT UPPER(item.name) AS full_name, item.group_id
FROM item
ORDER BY item.name -- deveria ser "UPPER(item.name)" ou "full_name"
Você deve corrigir as consultas para evitar problemas de compatibilidade com versões mais novas do Oracle.
================================================
FILE: zpa-checks/src/main/resources/org/sonar/l10n/plsqlopen_pt_BR/rules/plsql/NotFound.html
================================================
Use cursor%NOTFOUND em vez de NOT cursor%FOUND.
================================================
FILE: zpa-checks/src/main/resources/org/sonar/l10n/plsqlopen_pt_BR/rules/plsql/NvlWithNullParameter.html
================================================
A função NVL serve para substituir um valor nulo por um valor válido. Então, não especifque o literal NULL ou uma string vazia como parâmetro de uma chamada para NVL.
Código em desconformidade
var := nvl(x, '');
================================================
FILE: zpa-checks/src/main/resources/org/sonar/l10n/plsqlopen_pt_BR/rules/plsql/ParsingError.html
================================================
Quando o parser PL/SQL falha é possível registrar essa falha como uma violação no arquivo. Dessa forma, é possível registrar o número de arquivos que
não foram processados pelo parser e também identificar facilmente porque eles não foram entendidos.
================================================
FILE: zpa-checks/src/main/resources/org/sonar/l10n/plsqlopen_pt_BR/rules/plsql/QueryWithoutExceptionHandling.html
================================================
Geralmente você deve adicionar um bloco de tratamento de exceptions para comandos SELECT, para evitar exceções inesperadas.
================================================
FILE: zpa-checks/src/main/resources/org/sonar/l10n/plsqlopen_pt_BR/rules/plsql/RaiseStandardException.html
================================================
Você deve revisar todos os comandos RAISE que causam exceções pré-definidas, porque normalmente esse é um sinal de lógica ruim. Considere esse exemplo:
CREATE OR REPLACE FUNCTION grupo_tem_usuario(id IN NUMBER) RETURN BOOLEAN IS
tem_usuario BOOLEAN;
usuario_id usuario_grupo.usuario_id%TYPE;
BEGIN
BEGIN
SELECT usuario_grupo.usuario_id
INTO grupo_id
FROM usuario_grupo
WHERE usuario_grupo.grupo_id = id;
RAISE TOO_MANY_ROWS;
EXCEPTION
WHEN NO_DATA_FOUND THEN
tem_usuario := FALSE;
WHEN TOO_MANY_ROWS THEN
tem_usuario := TRUE;
END;
RETURN tem_usuario;
END;
Nesse caso, a exceção TOO_MANY_ROWS está sendo usada como mecanismo de controle de fluxo. Essa função poderia ser reescrita para evitar o comando RAISE:
CREATE OR REPLACE FUNCTION grupo_tem_usuario(id IN NUMBER) RETURN BOOLEAN IS
numero_de_usuarios NUMBER;
BEGIN
BEGIN
SELECT COUNT(*)
INTO numero_de_usuarios
FROM usuario_grupo
WHERE usuario_grupo.grupo_id = id;
EXCEPTION
WHEN OTHERS THEN
numero_de_usuarios := 0;
END;
RETURN numero_de_usuarios > 0;
END;
================================================
FILE: zpa-checks/src/main/resources/org/sonar/l10n/plsqlopen_pt_BR/rules/plsql/RedundantExpectation.html
================================================
De acordo com a documentação do utPLSQL:
A validação do código sob teste (a lógica testada do procedimento/função/etc.) é executada comparando
os dados reais com os dados esperados. O utPLSQL usa uma combinação de expectativa e um comparador para executar
a validação nos dados.
Algumas validações são escritas no formato ut.expect(valor_real).matcher(valor_esperado).
Essa regra verifica se o valor_real e o valor_esperado são a mesma coisa. Exemplo:
...
begin
v_expected := '2345';
v_actual := betwnstr('1234567', 2, 5);
ut.expect(v_actual).to_equal(v_actual); -- Essa expectativa está errada, ela é sempre verdadeira
end;
================================================
FILE: zpa-checks/src/main/resources/org/sonar/l10n/plsqlopen_pt_BR/rules/plsql/ReturnOfBooleanExpression.html
================================================
O retorno de literais boolean envolvidos em um IF-THEN-ELSE devem ser simplificados.
Código em desconformidade
IF expression THEN
RETURN TRUE;
ELSE
RETURN FALSE;
END IF;
Código correto
RETURN expression;
================================================
FILE: zpa-checks/src/main/resources/org/sonar/l10n/plsqlopen_pt_BR/rules/plsql/SameBranch.html
================================================
Ter duas branches na mesma estrutura if com a mesma implementação é código duplicado na melhor das hipóteses,
na pior é um erro de programação. Se a mesma lógica é realmente necessária para as duas situações, então as condições devem ser combinadas.
Código em desconformidade
IF var BETWEEN 0 AND 10 THEN
do_the_thing();
ELSIF var BETWEEN 10 AND 20 THEN
do_the_thing(); -- Noncompliant; duplicates first condition
ELSIF var BETWEEN 20 AND 50 THEN
do_the_another_thing();
ELSE
do_the_rest()
END IF;
Código correto
IF var BETWEEN 0 AND 10 THEN
do_the_thing();
ELSIF var BETWEEN 10 AND 20 THEN
do_the_second_thing();
ELSIF var BETWEEN 20 AND 50 THEN
do_the_another_thing();
ELSE
do_the_rest()
END IF;
================================================
FILE: zpa-checks/src/main/resources/org/sonar/l10n/plsqlopen_pt_BR/rules/plsql/SameCondition.html
================================================
Duplicar uma condição em uma comparação é quase sempre um equívoco.
Pode ser um erro causado por copiar/colar e então ser um bug ou simplesmente ser código desnecessários que deve ser simplificado.
Código em desconformidade
IF (x = 1) AND (x = 1) THEN ...
================================================
FILE: zpa-checks/src/main/resources/org/sonar/l10n/plsqlopen_pt_BR/rules/plsql/SelectAllColumns.html
================================================
SELECT * retorna todas as colunas disponíveis. Você deve listar explicitamente as colunas necessárias.
Ao usar *, você deve considerar a possibilidade de novas colunas serem adicionadas à tabela no futuro.
Código em desconformidade
begin
select *
into var
from emp;
select emp.*
into var
from emp;
end;
================================================
FILE: zpa-checks/src/main/resources/org/sonar/l10n/plsqlopen_pt_BR/rules/plsql/SelectWithRownumAndOrderBy.html
================================================
Em uma expressão SELECT, a cláusula WHERE é executada antes da cláusula ORDER BY. Considere esse exemplo:
DECLARE
CURSOR usuarios_recentes IS
SELECT usuario.nome,
usuario.data_de_criacao
FROM usuario
WHERE ROWNUM <= 5
ORDER BY usuario.data_de_criacao DESC;
BEGIN
...
Essa consulta não retornará os últimos 5 usuários criados. O banco de dados filtrará os usuários sem nenhuma ordenação e só então aplicará a cláusula ORDER BY. A consulta corrigida é:
DECLARE
CURSOR usuarios_recentes IS
SELECT nome,
data_de_criacao
FROM (SELECT usuario.nome,
usuario.data_de_criacao
FROM usuario
ORDER BY user.data_de_criacao DESC)
WHERE ROWNUM <= 5;
BEGIN
...
================================================
FILE: zpa-checks/src/main/resources/org/sonar/l10n/plsqlopen_pt_BR/rules/plsql/ToCharInOrderBy.html
================================================
O uso da função TO_CHAR em um ORDER BY quase sempre é um erro.
O valor da coluna será ordenado alfabeticamente em vez de ser ordenado de acordo com o tipo de dados da coluna.
Código em desconformidade
Supondo que temos os dados abaixo na tabela EMP:
| empno |
hiredate |
| 1 |
2019-10-01 |
| 5 |
2019-10-10 |
| 15 |
2018-10-02 |
| 20 |
2018-10-20 |
As consultas abaixo retornam um resultado indesejado:
select empno from emp order by to_char(empno);
select hiredate from emp order by to_char(hiredate, 'dd-mm-rrrr');
| hiredate |
| 01-OCT-19 |
| 02-OCT-18 |
| 10-OCT-19 |
| 20-OCT-18 |
Código correto
Para ordernar essa colunas corretamente precisamos remover a chamada para TO_CHAR.
select empno from emp order by empno;
select hiredate from emp order by hiredate;
| hiredate |
| 02-OCT-18 |
| 20-OCT-18 |
| 01-OCT-19 |
| 10-OCT-19 |
================================================
FILE: zpa-checks/src/main/resources/org/sonar/l10n/plsqlopen_pt_BR/rules/plsql/ToDateWithoutFormat.html
================================================
Sempre especifique o formato da data nas chamadas para TO_DATE.
Código em desconformidade
begin
var := to_date('2015-01-01');
end;
Código correto
begin
var := to_date('2015-01-01', 'YYYY-MM-DD');
end;
================================================
FILE: zpa-checks/src/main/resources/org/sonar/l10n/plsqlopen_pt_BR/rules/plsql/TooManyRowsHandler.html
================================================
Quando um comando SELECT INTO causa a exceção pré-definida TOO_MANY_ROWS os valores das variáveis na cláusula INTO ficam indefinidos.
Código em desconformidade
begin
select empno
into var
from emp;
exception
when too_many_rows then
null;
end;
Código correto
begin
select empno
into var
from emp;
exception
when too_many_rows then
var := null;
end;
================================================
FILE: zpa-checks/src/main/resources/org/sonar/l10n/plsqlopen_pt_BR/rules/plsql/UnhandledUserDefinedException.html
================================================
Quando uma exceção é declarada e não é tratada no código, lançar essa exceção causa o erro
"ORA-06510: PL/SQL: unhandled user-defined exception" no banco de dados ou o erro "User-defined exception" no
Oracle Forms.
É uma boa prática sempre tratar exceções personalizadas.
Código em desconformidade
DECLARE
my_exception EXCEPTION;
BEGIN
...
RAISE my_exception; -- isso causará um "user-defined exception"
END;
Código correto
DECLARE
my_exception EXCEPTION;
BEGIN
...
RAISE my_exception;
EXCEPTION
WHEN my_exception THEN
...
END;
Essa verificação também registrará uma violação se a exceção é tratada por um OTHERS e que tem uma referência a SQLERRM.
Nessa situação, a variável SQLERRM retornará "User-defined exception", o que não é muito útil.
DECLARE
my_exception EXCEPTION;
BEGIN
...
RAISE my_exception;
EXCEPTION
WHEN OTHERS THEN
log(SQLERRM);
END;
================================================
FILE: zpa-checks/src/main/resources/org/sonar/l10n/plsqlopen_pt_BR/rules/plsql/UnnecessaryAliasInQuery.html
================================================
Um alias pode ser usado em tabelas quando você pretende adicionar a mesma tabela mais que uma vez na cláusula FROM
(por exemplo, em self join) ou para reduzir o nome da tabela para tornar a instrução SQL menor e mais fácil de ler.
Mas se forem abusados, os aliases podem ter o efeito oposto: diminuir a legibilidade.
Prefira usar aliases apenas quando a tabela aparece mais de uma vez em uma consulta.
Código em desconformidade
SELECT a.id,
b.id,
b.name
FROM employee a,
dept b
WHERE a.dept_id = b.id;
Código correto
SELECT employee.id,
dept.id,
dept.name
FROM employee,
dept
WHERE employee.dept_id = dept.id;
================================================
FILE: zpa-checks/src/main/resources/org/sonar/l10n/plsqlopen_pt_BR/rules/plsql/UnnecessaryElse.html
================================================
Quando a cláusula IF de uma estrutura IF-THEN-ELSE não completa normalmente, a cláusa ELSE é desnecessária.
Código em desconformidade
BEGIN
IF condition THEN
RETURN value;
ELSE
value := NULL;
END IF;
END;
Código correto
BEGIN
IF condition THEN
RETURN value;
END IF;
value := NULL;
END;
================================================
FILE: zpa-checks/src/main/resources/org/sonar/l10n/plsqlopen_pt_BR/rules/plsql/UnnecessaryLike.html
================================================
Usar uma condição LIKE sem um curinga (% ou _) é suspeito. Um desenvolvedor pode supor que o curinha foi esquecido
ou se deveria ser um teste de igualdade.
Código em desconformidade
if (last_name like 'Smith') ...
Código correto
if (last_name like 'Smith%') ...
-- or
if (last_name = 'Smith') ...
================================================
FILE: zpa-checks/src/main/resources/org/sonar/l10n/plsqlopen_pt_BR/rules/plsql/UnnecessaryNullStatement.html
================================================
Uma instrução NULL no mesmo nível de outras instruções é inútil, portanto deve ser removida.
Código em desconformidade
BEGIN
var := 1;
NULL; -- essa instrução NULL pode ser removida
END
Código correto
BEGIN
var := 1;
END
================================================
FILE: zpa-checks/src/main/resources/org/sonar/l10n/plsqlopen_pt_BR/rules/plsql/UnusedCursor.html
================================================
Se um cursor é declarado mas não é usado, é código inútil e deve ser removido.
Fazer isso melhorará a manutenibilidade porque os desenvolvedores não terão que se preocupar com qual seria a utilidade do cursor.
================================================
FILE: zpa-checks/src/main/resources/org/sonar/l10n/plsqlopen_pt_BR/rules/plsql/UnusedParameter.html
================================================
Parâmetros não usados causam confusão. Não importa quais valores sejam passados para tais parâmetros, o comportamento do método será o mesmo.
Código em desconformidade
PROCEDURE do_something(a IN NUMBER, b IN NUMBER) IS -- "b" is unused
BEGIN
compute(a);
END;
Código correto
PROCEDURE do_something(a IN NUMBER) IS
BEGIN
compute(a);
END;
================================================
FILE: zpa-checks/src/main/resources/org/sonar/l10n/plsqlopen_pt_BR/rules/plsql/UnusedVariable.html
================================================
Se uma variável local é declarada mas não é usada, é código inútil e deve ser removida.
Fazer isso melhorará a manutenibilidade porque os desenvolvedores não terão que se preocupar com qual seria a utilidade da variável.
================================================
FILE: zpa-checks/src/main/resources/org/sonar/l10n/plsqlopen_pt_BR/rules/plsql/UselessParenthesis.html
================================================
Parênteses desnecessários podem às vezes ser confusos e por isso devem ser removidos.
Código em desconformidade
if ((a = b)) then ...
Código correto
if (a = b) then ...
================================================
FILE: zpa-checks/src/main/resources/org/sonar/l10n/plsqlopen_pt_BR/rules/plsql/VariableHiding.html
================================================
Redeclarar variáveis em um escopo mais interno é permitido no PL/SQL, mas pode causar confusão e por isso deve ser evitado.
================================================
FILE: zpa-checks/src/main/resources/org/sonar/l10n/plsqlopen_pt_BR/rules/plsql/VariableInCount.html
================================================
Usar a built-in COUNT com variáveis locais é confuso e na maioria das vezes é um erro de programação.
Código em desconformidade
DECLARE
v_empno emp.empno%TYPE;
...
BEGIN
-- Como a variável v_empno é NULL nesse ponto, esse COUNT sempre retornará 0.
SELECT COUNT(v_empno)
INTO i
FROM employee
WHERE employee.deptno = v_deptno;
END;
Código correto
BEGIN
SELECT COUNT(*)
INTO i
FROM employee
WHERE employee.deptno = v_deptno;
END;
================================================
FILE: zpa-checks/src/main/resources/org/sonar/l10n/plsqlopen_pt_BR/rules/plsql/VariableInitializationWithFunctionCall.html
================================================
Se a inicialização falhar você não será capaz de tratar o erro no bloco de exceções.
Código em desconformidade
DECLARE
employee_name emp.name%TYPE := get_employee_name(id => 5);
BEGIN
...
END;
Código correto
DECLARE
employee_name emp.name%TYPE;
BEGIN
employee_name := get_employee_name(id => 5);
...
END;
================================================
FILE: zpa-checks/src/main/resources/org/sonar/l10n/plsqlopen_pt_BR/rules/plsql/VariableInitializationWithNull.html
================================================
Por padrão, novas variáveis e campos de um RECORD são inicializados com NULL. Então você não precisa inicializá-las com NULL.
================================================
FILE: zpa-checks/src/main/resources/org/sonar/l10n/plsqlopen_pt_BR/rules/plsql/VariableName.html
================================================
Essa regra verifica se os nomes de todas as variáveis são aceitos na expressão regular fornecida.
Examplo
Considerando a expressão regular padrão:
DECLARE
dept_name dept.name%type; -- Correto
dept_name_ dept.name%type; -- Em desconformidade
BEGIN
...
END;
================================================
FILE: zpa-checks/src/main/resources/org/sonar/l10n/plsqlopen_pt_BR/rules/plsql/XPath.html
================================================
Essa regra permite a definição de regras personalizadas usando expressões XPath.
Os problemas são criados dependendo do retorno da expressão XPath. Se a expressão XPath retornar:
- um único nó ou uma lista de nós AST, então um problema é criado para cada nó com a mensagem definida
- um boolean, então um problema a nível de arquivo é criado com a mensagem definida se o boolean for verdadeiro
- qualquer outra situação, nenhum problema é criado
================================================
FILE: zpa-checks/src/main/resources/org/sonar/l10n/plsqlopen_pt_BR.properties
================================================
AddParenthesesInNestedExpression.message=Adicione parnteses em volta dessa condio AND para tornar a precedncia dos operadores mais explcita.
AddParenthesesInNestedExpression.name=Adicione parnteses em expresses aninhadas
CharacterDatatypeUsage.message=Use VARCHAR2 em vez de {0}.
CharacterDatatypeUsage.name=Use VARCHAR2 em vez de CHAR ou VARCHAR
CollapsibleIfStatements.message=Esse comando IF pode ser unido com o IF do nvel acima.
CollapsibleIfStatements.name=Comandos "if" aninhados devem ser unificados
ColumnsShouldHaveTableName.message=Especifique a tabela da coluna "{0}".
ColumnsShouldHaveTableName.name=As colunas em um SELECT devem ter o nome da tabela
CommitRollback.message=Evite {0} a menos que esteja em uma transao autnoma.
CommitRollback.name=Evite COMMIT/ROLLBACK em objetos do banco de dados
ComparisonWithBoolean.message=Remova o literal "{0}" dessa comparao.
ComparisonWithBoolean.name=Evite comparaes desnecessrias com literais booleanos
ComparisonWithNull.message=Corrija essa comparao ou altere para "{0}".
ComparisonWithNull.name=No compare valores com o literal NULL ou uma string vazia
ConcatenationWithNull.message=Revise essa concatenao com valor NULL.
ConcatenationWithNull.name=Concatenao desnecessria com valor NULL
CursorBodyInPackageSpec.message=Mova o corpo do cursor "{0}" para o corpo do pacote.
CursorBodyInPackageSpec.name=No declare corpos de cursores em uma especificao de pacote
DbmsOutputPut.message=Evite chamadas diretas aos procedimentos DBMS_OUTPUT.
DbmsOutputPut.name=Evite chamadas diretas aos procedimentos DBMS_OUTPUT
DeadCode.message=Esse cdigo nunca ser executado.
DeadCode.name=Cdigo morto deve ser removido
DeclareSectionWithoutDeclarations.message=Remova essa palavra-chave DECLARE.
DeclareSectionWithoutDeclarations.name=No adicione a palavra-chave DECLARE quando o bloco no conter nenhuma declarao
DisabledTest.message=Corrija ou remova esse teste unitrio desativado.
DisabledTest.name=Testes no devem ser desativados
DuplicateConditionIfElsif.message=Esse cdigo no ser executado porque a condio duplica uma condio anterior desse mesmo comando "if/elsif".
DuplicateConditionIfElsif.name=Instrues "if/elsif" relacionadas no podem ter a mesma condio
DuplicatedValueInIn.message=Remova ou corrija o valor duplicado "{0}" nessa condio IN.
DuplicatedValueInIn.name=Valor duplicado em uma condio IN
EmptyBlock.message=Remova ou preencha esse bloco de cdigo.
EmptyBlock.name=Blocos vazios devem ser removidos
EmptyStringAssignment.message=Substitua essa string vazia por NULL.
EmptyStringAssignment.name=Evite usar strings vazias para representar NULL
ExplicitInParameter.message=Declare explicitamente esse parmetro como IN.
ExplicitInParameter.name=O modo do parmetro deve estar definido explicitamente
FunctionWithOutParameter.message=Reescreva essa funo para no depender de parmetros OUT.
FunctionWithOutParameter.name=Evite funes com parmetros OUT
IdenticalExpression.message=Expresses idnticas nos dois lados do operador "{0}".
IdenticalExpression.name=Expresses idnticas no devem ser usadas nos dois lados de um operador
IfWithExit.message=Substitua esse IF ... EXIT por um comando EXIT WHEN.
IfWithExit.name=Use EXIT WHEN em vez de um comando IF para sair de um loop
InequalityUsage.message=Substitua "{0}" por "<>".
InequalityUsage.name=Apenas o operador "<>" deve ser usado para testar diferena
InsertWithoutColumns.message=Especifique as colunas nesse INSERT.
InsertWithoutColumns.name=Sempre especifique as colunas em um comando INSERT
InvalidReferenceToObject.message=Referncia invlida para o objeto "{0}" nessa chamada para {1}.
InvalidReferenceToObject.name=Referncia invlida para objeto do Oracle Forms
NotASelectedExpression.message=Esse valor no existe na clusula SELECT. Corrija essa expresso ou adicione esse valor no SELECT.
NotASelectedExpression.name=Os itens de um ORDER BY devem existir na consulta caso ela seja um SELECT DISTINCT
NotFound.message=Use %NOTFOUND em vez de NOT ...%FOUND.
NotFound.name=Use cursor%NOTFOUND em vez de NOT cursor%FOUND
NvlWithNullParameter.message=Esse NVL no tem nenhum efeito. Corrija o parmetro {0} ou remova esse NVL.
NvlWithNullParameter.name=No passe o literal NULL ou uma string vazia para o NVL
ParsingError.message=Esse trecho de cdigo no foi identificado corretamente pelo parser. Nenhum problema ser reportado nele.
ParsingError.name=Falha no parser
QueryWithoutExceptionHandling.message=Trate as excees dessa consulta.
QueryWithoutExceptionHandling.name=Evite consultas sem um bloco de tratamento de excees
QueryWithoutExceptionHandling.param.strictMode=Se falso, permite que blocos internos fiquem sem tratamento de exceo.
RaiseStandardException.message=Evite lanar a exceo padro {0}.
RaiseStandardException.name=Evite lanar excees pr-definidas
RedundantExpectation.message=Essa expectativa de teste redundante. O valor testado o mesmo que usado no comparador.
RedundantExpectation.name=Expectativas de teste no devem ser redundantes
ReturnOfBooleanExpression.message=Substitua esse if-then-else por um nico comando RETURN.
ReturnOfBooleanExpression.name=O retorno de expresses boolean no deve estar dentro de um comando "if-then-else"
SameBranch.message=Una essa branch com o cdigo idntico na linha {0} or altere uma das implementaes.
SameBranch.name=Branches da mesma estrutura condicional no devem ter exatamente a mesma implementao
SameCondition.message=Essa condio duplica a que est na linha {0}.
SameCondition.name=Condies idnticas no devem estar duplicadas
SelectAllColumns.message=SELECT * no deve ser usado.
SelectAllColumns.name=SELECT * no deve ser usado
SelectWithRownumAndOrderBy.message=Mova essa comparao com ROWNUM para um nvel mais externo para garantir a ordenao.
SelectWithRownumAndOrderBy.name=Um SELECT no pode ter uma comparao com ROWNUM e um ORDER BY no mesmo nvel
ToCharInOrderBy.message=Esse TO_CHAR pode estar fazendo com que os registros sejam retornados na ordem incorreta.
ToCharInOrderBy.name=Evite TO_CHAR em uma clusula ORDER BY
ToDateWithoutFormat.message=Especifique o formato da data nesse TO_DATE.
ToDateWithoutFormat.name=TO_DATE sem formato da data
TooManyRowsHandler.message=Trate as variveis utilizadas em comandos SELECT INTO aqui para que elas no fiquem com valores indefinidos.
TooManyRowsHandler.name=Evite mascarar a exceo TOO_MANY_ROWS
UnhandledUserDefinedException.message=No h um tratamento para a exceo "{0}" aqui. Isso causar o erro "user-defined exception".
UnhandledUserDefinedException.name=Excees definidas pelo usurio devem ser tratadas
UnnecessaryAliasInQuery.message=Esse comando tem apenas uma referncia para a tabela "{0}". Remova o alias "{1}" para tornar o cdigo mais legvel.
UnnecessaryAliasInQuery.name=Alias desnecessrio em tabela
UnnecessaryAliasInQuery.param.acceptedLength=Ignorar alias com tamanho maior ou igual a esse
UnnecessaryElse.message=Esse ELSE pode ser substitudo por um END IF. Se IF correspondente for executado, a execuo do cdigo ser interrompida. Caso contrrio, o cdigo dentro desse ELSE ser sempre executado, estando dentro de um ELSE ou no.
UnnecessaryElse.name=Clusula ELSE desnecessria
UnnecessaryLike.message=Essa condio LIKE no est utilizando nenhum curinga. Substituia por um comparador de igualdade ou adicione um curinga.
UnnecessaryLike.name=No use condies LIKE sem curingas
UnnecessaryNullStatement.message=Essa instruo NULL no tem nenhum efeito aqui.
UnnecessaryNullStatement.name=Instruo NULL desnecessria
UnusedCursor.message=Remova esse cursor "{0}" no utilizado.
UnusedCursor.name=Cursores no utilizados devem ser removidos
UnusedParameter.message=Remova esse parmetro "{0}" no utilizado.
UnusedParameter.name=Parmetros no utilizados devem ser removidos
UnusedParameter.param.ignoreMethods=Expresso regular que identifica os nomes de mtodos que devem ser ignorados nessa validao
UnusedVariable.message=Remova essa varivel local "{0}" no utilizada.
UnusedVariable.name=Variveis no utilizadas devem ser removidas
UselessParenthesis.message=Remova esses parnteses desnecessrios.
UselessParenthesis.name=Parnteses desnecessrios em expresses devem ser removidos para evitar qualquer mal entendido
VariableHiding.message=Essa varivel "{0}" oculta a declarao da linha {1}.
VariableHiding.name=No redeclare variveis em um escopo mais interno
VariableInCount.message=Parece que h uma varivel "{0}" nesse contexto. Revise se esse COUNT est correto.
VariableInCount.name=No passe variveis para a funo COUNT
VariableInitializationWithFunctionCall.message=Mova essa inicializao para o bloco BEGIN...END.
VariableInitializationWithFunctionCall.name=Evite inicializar variveis com chamadas de funes na seo de declaraes
VariableInitializationWithNull.message=Remova essa inicializao desnecessria para NULL.
VariableInitializationWithNull.name=Variveis e campos de um RECORD no precisam ser inicializados com NULL
VariableName.message=Renomeie {0} para corresponder expresso regular {1}.
VariableName.name=As variveis devem seguir o padro de nomenclatura
XPath.name=Controle violaes a partir de uma expresso XPath
================================================
FILE: zpa-checks/src/test/kotlin/com/felipebz/zpa/checks/AddParenthesesInNestedExpressionCheckTest.kt
================================================
/**
* Z PL/SQL Analyzer
* Copyright (C) 2015-2026 Felipe Zorzo
* mailto:felipe AT felipezorzo DOT com DOT br
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package com.felipebz.zpa.checks
import org.junit.jupiter.api.Test
import com.felipebz.zpa.checks.verifier.PlSqlCheckVerifier
class AddParenthesesInNestedExpressionCheckTest : BaseCheckTest() {
@Test
fun test() {
PlSqlCheckVerifier.verify(getPath("add_parentheses_in_nested_expression.sql"), AddParenthesesInNestedExpressionCheck())
}
}
================================================
FILE: zpa-checks/src/test/kotlin/com/felipebz/zpa/checks/BaseCheckTest.kt
================================================
/**
* Z PL/SQL Analyzer
* Copyright (C) 2015-2026 Felipe Zorzo
* mailto:felipe AT felipezorzo DOT com DOT br
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package com.felipebz.zpa.checks
import org.junit.jupiter.api.BeforeEach
import java.util.*
abstract class BaseCheckTest {
@BeforeEach
fun setUp() {
Locale.setDefault(Locale.ENGLISH)
}
protected fun getPath(filename: String) = defaultResourceFolder + filename
companion object {
private const val defaultResourceFolder = "src/test/resources/checks/"
}
}
================================================
FILE: zpa-checks/src/test/kotlin/com/felipebz/zpa/checks/CharacterDatatypeUsageCheckTest.kt
================================================
/**
* Z PL/SQL Analyzer
* Copyright (C) 2015-2026 Felipe Zorzo
* mailto:felipe AT felipezorzo DOT com DOT br
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package com.felipebz.zpa.checks
import org.junit.jupiter.api.Test
import com.felipebz.zpa.checks.verifier.PlSqlCheckVerifier
class CharacterDatatypeUsageCheckTest : BaseCheckTest() {
@Test
fun test() {
PlSqlCheckVerifier.verify(getPath("character_datatype_usage.sql"), CharacterDatatypeUsageCheck())
}
}
================================================
FILE: zpa-checks/src/test/kotlin/com/felipebz/zpa/checks/CheckListTest.kt
================================================
/**
* Z PL/SQL Analyzer
* Copyright (C) 2015-2026 Felipe Zorzo
* mailto:felipe AT felipezorzo DOT com DOT br
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package com.felipebz.zpa.checks
import org.assertj.core.api.Assertions.assertThat
import org.junit.jupiter.api.Test
import java.io.File
class CheckListTest {
/**
* Enforces that each check declared in list.
*/
@Test
fun count() {
val files = File("src/main/kotlin/com/felipebz/zpa/checks/")
.list { _, name -> name.contains("Check.") && !name.startsWith("Abstract") }
.map { File(it).nameWithoutExtension }
.toTypedArray()
assertThat(CheckList.checks.map { it.simpleName }).containsExactlyInAnyOrder(*files)
}
}
================================================
FILE: zpa-checks/src/test/kotlin/com/felipebz/zpa/checks/CollapsibleIfStatementsCheckTest.kt
================================================
/**
* Z PL/SQL Analyzer
* Copyright (C) 2015-2026 Felipe Zorzo
* mailto:felipe AT felipezorzo DOT com DOT br
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package com.felipebz.zpa.checks
import org.junit.jupiter.api.Test
import com.felipebz.zpa.checks.verifier.PlSqlCheckVerifier
class CollapsibleIfStatementsCheckTest : BaseCheckTest() {
@Test
fun test() {
PlSqlCheckVerifier.verify(getPath("collapsible_if_statements.sql"), CollapsibleIfStatementsCheck())
}
}
================================================
FILE: zpa-checks/src/test/kotlin/com/felipebz/zpa/checks/ColumnsShouldHaveTableNameCheckTest.kt
================================================
/**
* Z PL/SQL Analyzer
* Copyright (C) 2015-2026 Felipe Zorzo
* mailto:felipe AT felipezorzo DOT com DOT br
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package com.felipebz.zpa.checks
import org.junit.jupiter.api.Test
import com.felipebz.zpa.checks.verifier.PlSqlCheckVerifier
class ColumnsShouldHaveTableNameCheckTest : BaseCheckTest() {
@Test
fun test() {
PlSqlCheckVerifier.verify(getPath("columns_should_have_table_name.sql"), ColumnsShouldHaveTableNameCheck())
}
}
================================================
FILE: zpa-checks/src/test/kotlin/com/felipebz/zpa/checks/CommitRollbackCheckTest.kt
================================================
/**
* Z PL/SQL Analyzer
* Copyright (C) 2015-2026 Felipe Zorzo
* mailto:felipe AT felipezorzo DOT com DOT br
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package com.felipebz.zpa.checks
import org.junit.jupiter.api.Test
import com.felipebz.zpa.checks.verifier.PlSqlCheckVerifier
class CommitRollbackCheckTest : BaseCheckTest() {
@Test
fun test() {
PlSqlCheckVerifier.verify(getPath("commit_rollback.sql"), CommitRollbackCheck())
}
}
================================================
FILE: zpa-checks/src/test/kotlin/com/felipebz/zpa/checks/ComparisonWithBooleanCheckTest.kt
================================================
/**
* Z PL/SQL Analyzer
* Copyright (C) 2015-2026 Felipe Zorzo
* mailto:felipe AT felipezorzo DOT com DOT br
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package com.felipebz.zpa.checks
import org.junit.jupiter.api.Test
import com.felipebz.zpa.checks.verifier.PlSqlCheckVerifier
class ComparisonWithBooleanCheckTest : BaseCheckTest() {
@Test
fun test() {
PlSqlCheckVerifier.verify(getPath("comparison_with_boolean.sql"), ComparisonWithBooleanCheck())
}
}
================================================
FILE: zpa-checks/src/test/kotlin/com/felipebz/zpa/checks/ComparisonWithNullCheckTest.kt
================================================
/**
* Z PL/SQL Analyzer
* Copyright (C) 2015-2026 Felipe Zorzo
* mailto:felipe AT felipezorzo DOT com DOT br
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package com.felipebz.zpa.checks
import org.junit.jupiter.api.Test
import com.felipebz.zpa.checks.verifier.PlSqlCheckVerifier
class ComparisonWithNullCheckTest : BaseCheckTest() {
@Test
fun test() {
PlSqlCheckVerifier.verify(getPath("comparison_with_null.sql"), ComparisonWithNullCheck())
}
}
================================================
FILE: zpa-checks/src/test/kotlin/com/felipebz/zpa/checks/ConcatenationWithNullCheckTest.kt
================================================
/**
* Z PL/SQL Analyzer
* Copyright (C) 2015-2026 Felipe Zorzo
* mailto:felipe AT felipezorzo DOT com DOT br
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package com.felipebz.zpa.checks
import org.junit.jupiter.api.Test
import com.felipebz.zpa.checks.verifier.PlSqlCheckVerifier
class ConcatenationWithNullCheckTest : BaseCheckTest() {
@Test
fun test() {
PlSqlCheckVerifier.verify(getPath("concatenation_with_null.sql"), ConcatenationWithNullCheck())
}
}
================================================
FILE: zpa-checks/src/test/kotlin/com/felipebz/zpa/checks/CursorBodyInPackageSpecCheckTest.kt
================================================
/**
* Z PL/SQL Analyzer
* Copyright (C) 2015-2026 Felipe Zorzo
* mailto:felipe AT felipezorzo DOT com DOT br
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package com.felipebz.zpa.checks
import org.junit.jupiter.api.Test
import com.felipebz.zpa.checks.verifier.PlSqlCheckVerifier
class CursorBodyInPackageSpecCheckTest : BaseCheckTest() {
@Test
fun test() {
PlSqlCheckVerifier.verify(getPath("cursor_body_in_package_spec.sql"), CursorBodyInPackageSpecCheck())
}
}
================================================
FILE: zpa-checks/src/test/kotlin/com/felipebz/zpa/checks/DbmsOutputPutCheckTest.kt
================================================
/**
* Z PL/SQL Analyzer
* Copyright (C) 2015-2026 Felipe Zorzo
* mailto:felipe AT felipezorzo DOT com DOT br
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package com.felipebz.zpa.checks
import org.junit.jupiter.api.Test
import com.felipebz.zpa.checks.verifier.PlSqlCheckVerifier
class DbmsOutputPutCheckTest : BaseCheckTest() {
@Test
fun test() {
PlSqlCheckVerifier.verify(getPath("dbms_output_put.sql"), DbmsOutputPutCheck())
}
}
================================================
FILE: zpa-checks/src/test/kotlin/com/felipebz/zpa/checks/DeadCodeCheckTest.kt
================================================
/**
* Z PL/SQL Analyzer
* Copyright (C) 2015-2026 Felipe Zorzo
* mailto:felipe AT felipezorzo DOT com DOT br
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package com.felipebz.zpa.checks
import org.junit.jupiter.api.Test
import com.felipebz.zpa.checks.verifier.PlSqlCheckVerifier
class DeadCodeCheckTest : BaseCheckTest() {
@Test
fun test() {
PlSqlCheckVerifier.verify(getPath("dead_code.sql"), DeadCodeCheck())
}
}
================================================
FILE: zpa-checks/src/test/kotlin/com/felipebz/zpa/checks/DeclareSectionWithoutDeclarationsCheckTest.kt
================================================
/**
* Z PL/SQL Analyzer
* Copyright (C) 2015-2026 Felipe Zorzo
* mailto:felipe AT felipezorzo DOT com DOT br
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package com.felipebz.zpa.checks
import org.junit.jupiter.api.Test
import com.felipebz.zpa.checks.verifier.PlSqlCheckVerifier
class DeclareSectionWithoutDeclarationsCheckTest : BaseCheckTest() {
@Test
fun test() {
PlSqlCheckVerifier.verify(getPath("declare_section_without_declarations.sql"), DeclareSectionWithoutDeclarationsCheck())
}
}
================================================
FILE: zpa-checks/src/test/kotlin/com/felipebz/zpa/checks/DisabledTestCheckTest.kt
================================================
/**
* Z PL/SQL Analyzer
* Copyright (C) 2015-2026 Felipe Zorzo
* mailto:felipe AT felipezorzo DOT com DOT br
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package com.felipebz.zpa.checks
import org.junit.jupiter.api.Test
import com.felipebz.zpa.checks.verifier.PlSqlCheckVerifier
class DisabledTestCheckTest : BaseCheckTest() {
@Test
fun test() {
PlSqlCheckVerifier.verify(getPath("disabled_test.sql"), DisabledTestCheck())
}
}
================================================
FILE: zpa-checks/src/test/kotlin/com/felipebz/zpa/checks/DuplicateConditionIfElsifCheckTest.kt
================================================
/**
* Z PL/SQL Analyzer
* Copyright (C) 2015-2026 Felipe Zorzo
* mailto:felipe AT felipezorzo DOT com DOT br
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package com.felipebz.zpa.checks
import org.junit.jupiter.api.Test
import com.felipebz.zpa.checks.verifier.PlSqlCheckVerifier
class DuplicateConditionIfElsifCheckTest : BaseCheckTest() {
@Test
fun test() {
PlSqlCheckVerifier.verify(getPath("duplicate_condition_if_elsif.sql"), DuplicateConditionIfElsifCheck())
}
}
================================================
FILE: zpa-checks/src/test/kotlin/com/felipebz/zpa/checks/DuplicatedValueInInCheckTest.kt
================================================
/**
* Z PL/SQL Analyzer
* Copyright (C) 2015-2026 Felipe Zorzo
* mailto:felipe AT felipezorzo DOT com DOT br
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package com.felipebz.zpa.checks
import org.junit.jupiter.api.Test
import com.felipebz.zpa.checks.verifier.PlSqlCheckVerifier
class DuplicatedValueInInCheckTest : BaseCheckTest() {
@Test
fun test() {
PlSqlCheckVerifier.verify(getPath("duplicated_value_in_in.sql"), DuplicatedValueInInCheck())
}
}
================================================
FILE: zpa-checks/src/test/kotlin/com/felipebz/zpa/checks/EmptyBlockCheckTest.kt
================================================
/**
* Z PL/SQL Analyzer
* Copyright (C) 2015-2026 Felipe Zorzo
* mailto:felipe AT felipezorzo DOT com DOT br
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package com.felipebz.zpa.checks
import org.junit.jupiter.api.Test
import com.felipebz.zpa.checks.verifier.PlSqlCheckVerifier
class EmptyBlockCheckTest : BaseCheckTest() {
@Test
fun test() {
PlSqlCheckVerifier.verify(getPath("empty_block.sql"), EmptyBlockCheck())
}
}
================================================
FILE: zpa-checks/src/test/kotlin/com/felipebz/zpa/checks/EmptyStringAssignmentCheckTest.kt
================================================
/**
* Z PL/SQL Analyzer
* Copyright (C) 2015-2026 Felipe Zorzo
* mailto:felipe AT felipezorzo DOT com DOT br
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package com.felipebz.zpa.checks
import org.junit.jupiter.api.Test
import com.felipebz.zpa.checks.verifier.PlSqlCheckVerifier
class EmptyStringAssignmentCheckTest : BaseCheckTest() {
@Test
fun test() {
PlSqlCheckVerifier.verify(getPath("empty_string_assignment.sql"), EmptyStringAssignmentCheck())
}
}
================================================
FILE: zpa-checks/src/test/kotlin/com/felipebz/zpa/checks/ExplicitInParameterCheckTest.kt
================================================
/**
* Z PL/SQL Analyzer
* Copyright (C) 2015-2026 Felipe Zorzo
* mailto:felipe AT felipezorzo DOT com DOT br
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package com.felipebz.zpa.checks
import org.junit.jupiter.api.Test
import com.felipebz.zpa.checks.verifier.PlSqlCheckVerifier
class ExplicitInParameterCheckTest : BaseCheckTest() {
@Test
fun test() {
PlSqlCheckVerifier.verify(getPath("explicit_in_parameter.sql"), ExplicitInParameterCheck())
}
}
================================================
FILE: zpa-checks/src/test/kotlin/com/felipebz/zpa/checks/FunctionWithOutParameterCheckTest.kt
================================================
/**
* Z PL/SQL Analyzer
* Copyright (C) 2015-2026 Felipe Zorzo
* mailto:felipe AT felipezorzo DOT com DOT br
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package com.felipebz.zpa.checks
import org.junit.jupiter.api.Test
import com.felipebz.zpa.checks.verifier.PlSqlCheckVerifier
class FunctionWithOutParameterCheckTest : BaseCheckTest() {
@Test
fun test() {
PlSqlCheckVerifier.verify(getPath("function_with_out_parameter.sql"), FunctionWithOutParameterCheck())
}
}
================================================
FILE: zpa-checks/src/test/kotlin/com/felipebz/zpa/checks/IdenticalExpressionCheckTest.kt
================================================
/**
* Z PL/SQL Analyzer
* Copyright (C) 2015-2026 Felipe Zorzo
* mailto:felipe AT felipezorzo DOT com DOT br
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package com.felipebz.zpa.checks
import org.junit.jupiter.api.Test
import com.felipebz.zpa.checks.verifier.PlSqlCheckVerifier
class IdenticalExpressionCheckTest : BaseCheckTest() {
@Test
fun test() {
PlSqlCheckVerifier.verify(getPath("identical_expression.sql"), IdenticalExpressionCheck())
}
}
================================================
FILE: zpa-checks/src/test/kotlin/com/felipebz/zpa/checks/IfWithExitCheckTest.kt
================================================
/**
* Z PL/SQL Analyzer
* Copyright (C) 2015-2026 Felipe Zorzo
* mailto:felipe AT felipezorzo DOT com DOT br
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package com.felipebz.zpa.checks
import org.junit.jupiter.api.Test
import com.felipebz.zpa.checks.verifier.PlSqlCheckVerifier
class IfWithExitCheckTest : BaseCheckTest() {
@Test
fun test() {
PlSqlCheckVerifier.verify(getPath("if_with_exit.sql"), IfWithExitCheck())
}
}
================================================
FILE: zpa-checks/src/test/kotlin/com/felipebz/zpa/checks/InequalityUsageCheckTest.kt
================================================
/**
* Z PL/SQL Analyzer
* Copyright (C) 2015-2026 Felipe Zorzo
* mailto:felipe AT felipezorzo DOT com DOT br
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package com.felipebz.zpa.checks
import org.junit.jupiter.api.Test
import com.felipebz.zpa.checks.verifier.PlSqlCheckVerifier
class InequalityUsageCheckTest : BaseCheckTest() {
@Test
fun test() {
PlSqlCheckVerifier.verify(getPath("inequality_usage_check.sql"), InequalityUsageCheck())
}
}
================================================
FILE: zpa-checks/src/test/kotlin/com/felipebz/zpa/checks/InsertWithoutColumnsCheckTest.kt
================================================
/**
* Z PL/SQL Analyzer
* Copyright (C) 2015-2026 Felipe Zorzo
* mailto:felipe AT felipezorzo DOT com DOT br
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package com.felipebz.zpa.checks
import org.junit.jupiter.api.Test
import com.felipebz.zpa.checks.verifier.PlSqlCheckVerifier
class InsertWithoutColumnsCheckTest : BaseCheckTest() {
@Test
fun test() {
PlSqlCheckVerifier.verify(getPath("insert_without_columns.sql"), InsertWithoutColumnsCheck())
}
}
================================================
FILE: zpa-checks/src/test/kotlin/com/felipebz/zpa/checks/InvalidReferenceToObjectCheckTest.kt
================================================
/**
* Z PL/SQL Analyzer
* Copyright (C) 2015-2026 Felipe Zorzo
* mailto:felipe AT felipezorzo DOT com DOT br
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package com.felipebz.zpa.checks
import org.junit.jupiter.api.Test
import com.felipebz.zpa.checks.verifier.PlSqlCheckVerifier
import com.felipebz.zpa.metadata.Block
import com.felipebz.zpa.metadata.FormsMetadata
class InvalidReferenceToObjectCheckTest : BaseCheckTest() {
@Test
fun test() {
val metadata = FormsMetadata()
metadata.alerts = listOf("foo")
metadata.blocks = listOf(Block("foo", arrayOf("item1")))
metadata.lovs = listOf("foo")
PlSqlCheckVerifier.verify(getPath("invalid_reference_to_object.sql"), InvalidReferenceToObjectCheck(), metadata)
}
}
================================================
FILE: zpa-checks/src/test/kotlin/com/felipebz/zpa/checks/NotASelectedExpressionCheckTest.kt
================================================
/**
* Z PL/SQL Analyzer
* Copyright (C) 2015-2026 Felipe Zorzo
* mailto:felipe AT felipezorzo DOT com DOT br
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package com.felipebz.zpa.checks
import org.junit.jupiter.api.Test
import com.felipebz.zpa.checks.verifier.PlSqlCheckVerifier
class NotASelectedExpressionCheckTest : BaseCheckTest() {
@Test
fun test() {
PlSqlCheckVerifier.verify(getPath("not_a_selected_expression.sql"), NotASelectedExpressionCheck())
}
}
================================================
FILE: zpa-checks/src/test/kotlin/com/felipebz/zpa/checks/NotFoundCheckTest.kt
================================================
/**
* Z PL/SQL Analyzer
* Copyright (C) 2015-2026 Felipe Zorzo
* mailto:felipe AT felipezorzo DOT com DOT br
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package com.felipebz.zpa.checks
import org.junit.jupiter.api.Test
import com.felipebz.zpa.checks.verifier.PlSqlCheckVerifier
class NotFoundCheckTest : BaseCheckTest() {
@Test
fun test() {
PlSqlCheckVerifier.verify(getPath("not_found.sql"), NotFoundCheck())
}
}
================================================
FILE: zpa-checks/src/test/kotlin/com/felipebz/zpa/checks/NvlWithNullParameterCheckTest.kt
================================================
/**
* Z PL/SQL Analyzer
* Copyright (C) 2015-2026 Felipe Zorzo
* mailto:felipe AT felipezorzo DOT com DOT br
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package com.felipebz.zpa.checks
import org.junit.jupiter.api.Test
import com.felipebz.zpa.checks.verifier.PlSqlCheckVerifier
class NvlWithNullParameterCheckTest : BaseCheckTest() {
@Test
fun test() {
PlSqlCheckVerifier.verify(getPath("nvl_with_null_parameter.sql"), NvlWithNullParameterCheck())
}
}
================================================
FILE: zpa-checks/src/test/kotlin/com/felipebz/zpa/checks/ParsingErrorCheckTest.kt
================================================
/**
* Z PL/SQL Analyzer
* Copyright (C) 2015-2026 Felipe Zorzo
* mailto:felipe AT felipezorzo DOT com DOT br
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package com.felipebz.zpa.checks
import com.felipebz.flr.api.RecognitionException
import org.assertj.core.api.Assertions.assertThat
import org.junit.jupiter.api.Test
import com.felipebz.zpa.parser.PlSqlParser
import com.felipebz.zpa.squid.PlSqlConfiguration
import com.felipebz.zpa.api.PlSqlVisitorContext
import java.io.File
import java.nio.charset.StandardCharsets
class ParsingErrorCheckTest : BaseCheckTest() {
@Test
fun test() {
val file = File("src/test/resources/checks/parsing_error.sql")
val parser = PlSqlParser.create(PlSqlConfiguration(StandardCharsets.UTF_8))
val context: PlSqlVisitorContext
try {
parser.parse(file)
throw IllegalStateException("Expected RecognitionException")
} catch (e: RecognitionException) {
context = PlSqlVisitorContext(null, e, null)
}
val check = ParsingErrorCheck()
val issues = check.scanFileForIssues(context)
assertThat(issues).hasSize(1)
assertThat(issues[0].primaryLocation().startLine()).isEqualTo(1)
}
@Test
fun testTolerantParsing() {
val file = File("src/test/resources/checks/parsing_error.sql")
val parser = PlSqlParser.create(PlSqlConfiguration(StandardCharsets.UTF_8, isErrorRecoveryEnabled = true))
val rootTree = parser.parse(file)
val context = PlSqlVisitorContext(rootTree, null, null)
val check = ParsingErrorCheck()
val issues = check.scanFileForIssues(context)
assertThat(issues).hasSize(1)
assertThat(issues[0].primaryLocation().startLine()).isEqualTo(1)
}
}
================================================
FILE: zpa-checks/src/test/kotlin/com/felipebz/zpa/checks/QueryWithoutExceptionHandlingCheckTest.kt
================================================
/**
* Z PL/SQL Analyzer
* Copyright (C) 2015-2026 Felipe Zorzo
* mailto:felipe AT felipezorzo DOT com DOT br
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package com.felipebz.zpa.checks
import org.junit.jupiter.api.Test
import com.felipebz.zpa.checks.verifier.PlSqlCheckVerifier
class QueryWithoutExceptionHandlingCheckTest : BaseCheckTest() {
@Test
fun test() {
PlSqlCheckVerifier.verify(getPath("query_without_exception_handling.sql"), QueryWithoutExceptionHandlingCheck())
}
@Test
fun testNoStrict() {
val check = QueryWithoutExceptionHandlingCheck()
check.strictMode = false
PlSqlCheckVerifier.verify(getPath("query_without_exception_handling_no_strict.sql"), check)
}
}
================================================
FILE: zpa-checks/src/test/kotlin/com/felipebz/zpa/checks/RaiseStandardExceptionCheckTest.kt
================================================
/**
* Z PL/SQL Analyzer
* Copyright (C) 2015-2026 Felipe Zorzo
* mailto:felipe AT felipezorzo DOT com DOT br
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package com.felipebz.zpa.checks
import org.junit.jupiter.api.Test
import com.felipebz.zpa.checks.verifier.PlSqlCheckVerifier
class RaiseStandardExceptionCheckTest : BaseCheckTest() {
@Test
fun test() {
PlSqlCheckVerifier.verify(getPath("raise_standard_exception.sql"), RaiseStandardExceptionCheck())
}
}
================================================
FILE: zpa-checks/src/test/kotlin/com/felipebz/zpa/checks/RedundantExpectationCheckTest.kt
================================================
/**
* Z PL/SQL Analyzer
* Copyright (C) 2015-2026 Felipe Zorzo
* mailto:felipe AT felipezorzo DOT com DOT br
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package com.felipebz.zpa.checks
import org.junit.jupiter.api.Test
import com.felipebz.zpa.checks.verifier.PlSqlCheckVerifier
class RedundantExpectationCheckTest : BaseCheckTest() {
@Test
fun test() {
PlSqlCheckVerifier.verify(getPath("redundant_expectation.sql"), RedundantExpectationCheck())
}
}
================================================
FILE: zpa-checks/src/test/kotlin/com/felipebz/zpa/checks/ReturnOfBooleanExpressionCheckTest.kt
================================================
/**
* Z PL/SQL Analyzer
* Copyright (C) 2015-2026 Felipe Zorzo
* mailto:felipe AT felipezorzo DOT com DOT br
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package com.felipebz.zpa.checks
import org.junit.jupiter.api.Test
import com.felipebz.zpa.checks.verifier.PlSqlCheckVerifier
class ReturnOfBooleanExpressionCheckTest : BaseCheckTest() {
@Test
fun test() {
PlSqlCheckVerifier.verify(getPath("return_of_boolean_expression.sql"), ReturnOfBooleanExpressionCheck())
}
}
================================================
FILE: zpa-checks/src/test/kotlin/com/felipebz/zpa/checks/SameBranchCheckTest.kt
================================================
/**
* Z PL/SQL Analyzer
* Copyright (C) 2015-2026 Felipe Zorzo
* mailto:felipe AT felipezorzo DOT com DOT br
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package com.felipebz.zpa.checks
import org.junit.jupiter.api.Test
import com.felipebz.zpa.checks.verifier.PlSqlCheckVerifier
class SameBranchCheckTest : BaseCheckTest() {
@Test
fun test() {
PlSqlCheckVerifier.verify(getPath("same_branch.sql"), SameBranchCheck())
}
}
================================================
FILE: zpa-checks/src/test/kotlin/com/felipebz/zpa/checks/SameConditionCheckTest.kt
================================================
/**
* Z PL/SQL Analyzer
* Copyright (C) 2015-2026 Felipe Zorzo
* mailto:felipe AT felipezorzo DOT com DOT br
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package com.felipebz.zpa.checks
import org.junit.jupiter.api.Test
import com.felipebz.zpa.checks.verifier.PlSqlCheckVerifier
class SameConditionCheckTest : BaseCheckTest() {
@Test
fun test() {
PlSqlCheckVerifier.verify(getPath("same_condition.sql"), SameConditionCheck())
}
}
================================================
FILE: zpa-checks/src/test/kotlin/com/felipebz/zpa/checks/SelectAllColumnsCheckTest.kt
================================================
/**
* Z PL/SQL Analyzer
* Copyright (C) 2015-2026 Felipe Zorzo
* mailto:felipe AT felipezorzo DOT com DOT br
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package com.felipebz.zpa.checks
import org.junit.jupiter.api.Test
import com.felipebz.zpa.checks.verifier.PlSqlCheckVerifier
class SelectAllColumnsCheckTest : BaseCheckTest() {
@Test
fun test() {
PlSqlCheckVerifier.verify(getPath("select_all_columns.sql"), SelectAllColumnsCheck())
}
}
================================================
FILE: zpa-checks/src/test/kotlin/com/felipebz/zpa/checks/SelectWithRownumAndOrderByCheckTest.kt
================================================
/**
* Z PL/SQL Analyzer
* Copyright (C) 2015-2026 Felipe Zorzo
* mailto:felipe AT felipezorzo DOT com DOT br
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package com.felipebz.zpa.checks
import org.junit.jupiter.api.Test
import com.felipebz.zpa.checks.verifier.PlSqlCheckVerifier
class SelectWithRownumAndOrderByCheckTest : BaseCheckTest() {
@Test
fun test() {
PlSqlCheckVerifier.verify(getPath("select_with_rownum_and_order_by.sql"), SelectWithRownumAndOrderByCheck())
}
}
================================================
FILE: zpa-checks/src/test/kotlin/com/felipebz/zpa/checks/ToCharInOrderByCheckTest.kt
================================================
/**
* Z PL/SQL Analyzer
* Copyright (C) 2015-2026 Felipe Zorzo
* mailto:felipe AT felipezorzo DOT com DOT br
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package com.felipebz.zpa.checks
import org.junit.jupiter.api.Test
import com.felipebz.zpa.checks.verifier.PlSqlCheckVerifier
class ToCharInOrderByCheckTest : BaseCheckTest() {
@Test
fun test() {
PlSqlCheckVerifier.verify(getPath("to_char_in_order_by.sql"), ToCharInOrderByCheck())
}
}
================================================
FILE: zpa-checks/src/test/kotlin/com/felipebz/zpa/checks/ToDateWithoutFormatCheckTest.kt
================================================
/**
* Z PL/SQL Analyzer
* Copyright (C) 2015-2026 Felipe Zorzo
* mailto:felipe AT felipezorzo DOT com DOT br
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package com.felipebz.zpa.checks
import org.junit.jupiter.api.Test
import com.felipebz.zpa.checks.verifier.PlSqlCheckVerifier
class ToDateWithoutFormatCheckTest : BaseCheckTest() {
@Test
fun test() {
PlSqlCheckVerifier.verify(getPath("to_date_without_format.sql"), ToDateWithoutFormatCheck())
}
}
================================================
FILE: zpa-checks/src/test/kotlin/com/felipebz/zpa/checks/TooManyRowsHandlerCheckTest.kt
================================================
/**
* Z PL/SQL Analyzer
* Copyright (C) 2015-2026 Felipe Zorzo
* mailto:felipe AT felipezorzo DOT com DOT br
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package com.felipebz.zpa.checks
import org.junit.jupiter.api.Test
import com.felipebz.zpa.checks.verifier.PlSqlCheckVerifier
class TooManyRowsHandlerCheckTest : BaseCheckTest() {
@Test
fun test() {
PlSqlCheckVerifier.verify(getPath("too_many_rows_handler.sql"), TooManyRowsHandlerCheck())
}
}
================================================
FILE: zpa-checks/src/test/kotlin/com/felipebz/zpa/checks/UnhandledUserDefinedExceptionCheckTest.kt
================================================
/**
* Z PL/SQL Analyzer
* Copyright (C) 2015-2026 Felipe Zorzo
* mailto:felipe AT felipezorzo DOT com DOT br
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package com.felipebz.zpa.checks
import org.junit.jupiter.api.Test
import com.felipebz.zpa.checks.verifier.PlSqlCheckVerifier
class UnhandledUserDefinedExceptionCheckTest : BaseCheckTest() {
@Test
fun test() {
PlSqlCheckVerifier.verify(getPath("unhandled_user_defined_exception.sql"), UnhandledUserDefinedExceptionCheck())
}
}
================================================
FILE: zpa-checks/src/test/kotlin/com/felipebz/zpa/checks/UnnecessaryAliasInQueryCheckTest.kt
================================================
/**
* Z PL/SQL Analyzer
* Copyright (C) 2015-2026 Felipe Zorzo
* mailto:felipe AT felipezorzo DOT com DOT br
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package com.felipebz.zpa.checks
import org.junit.jupiter.api.Test
import com.felipebz.zpa.checks.verifier.PlSqlCheckVerifier
class UnnecessaryAliasInQueryCheckTest : BaseCheckTest() {
@Test
fun test() {
PlSqlCheckVerifier.verify(getPath("unnecessary_alias_in_query.sql"), UnnecessaryAliasInQueryCheck())
}
@Test
fun test2() {
val check = UnnecessaryAliasInQueryCheck()
check.acceptedLength = 4
PlSqlCheckVerifier.verify(getPath("unnecessary_alias_in_query_custom_length.sql"), check)
}
}
================================================
FILE: zpa-checks/src/test/kotlin/com/felipebz/zpa/checks/UnnecessaryElseCheckTest.kt
================================================
/**
* Z PL/SQL Analyzer
* Copyright (C) 2015-2026 Felipe Zorzo
* mailto:felipe AT felipezorzo DOT com DOT br
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package com.felipebz.zpa.checks
import org.junit.jupiter.api.Test
import com.felipebz.zpa.checks.verifier.PlSqlCheckVerifier
class UnnecessaryElseCheckTest : BaseCheckTest() {
@Test
fun test() {
PlSqlCheckVerifier.verify(getPath("unnecessary_else.sql"), UnnecessaryElseCheck())
}
}
================================================
FILE: zpa-checks/src/test/kotlin/com/felipebz/zpa/checks/UnnecessaryLikeCheckTest.kt
================================================
/**
* Z PL/SQL Analyzer
* Copyright (C) 2015-2026 Felipe Zorzo
* mailto:felipe AT felipezorzo DOT com DOT br
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package com.felipebz.zpa.checks
import org.junit.jupiter.api.Test
import com.felipebz.zpa.checks.verifier.PlSqlCheckVerifier
class UnnecessaryLikeCheckTest : BaseCheckTest() {
@Test
fun test() {
PlSqlCheckVerifier.verify(getPath("unnecessary_like.sql"), UnnecessaryLikeCheck())
}
}
================================================
FILE: zpa-checks/src/test/kotlin/com/felipebz/zpa/checks/UnnecessaryNullStatementCheckTest.kt
================================================
/**
* Z PL/SQL Analyzer
* Copyright (C) 2015-2026 Felipe Zorzo
* mailto:felipe AT felipezorzo DOT com DOT br
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package com.felipebz.zpa.checks
import org.junit.jupiter.api.Test
import com.felipebz.zpa.checks.verifier.PlSqlCheckVerifier
class UnnecessaryNullStatementCheckTest : BaseCheckTest() {
@Test
fun test() {
PlSqlCheckVerifier.verify(getPath("unnecessary_null_statement.sql"), UnnecessaryNullStatementCheck())
}
}
================================================
FILE: zpa-checks/src/test/kotlin/com/felipebz/zpa/checks/UnusedCursorCheckTest.kt
================================================
/**
* Z PL/SQL Analyzer
* Copyright (C) 2015-2026 Felipe Zorzo
* mailto:felipe AT felipezorzo DOT com DOT br
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package com.felipebz.zpa.checks
import org.junit.jupiter.api.Test
import com.felipebz.zpa.checks.verifier.PlSqlCheckVerifier
class UnusedCursorCheckTest : BaseCheckTest() {
@Test
fun test() {
PlSqlCheckVerifier.verify(getPath("unused_cursor.sql"), UnusedCursorCheck())
}
}
================================================
FILE: zpa-checks/src/test/kotlin/com/felipebz/zpa/checks/UnusedParameterCheckTest.kt
================================================
/**
* Z PL/SQL Analyzer
* Copyright (C) 2015-2026 Felipe Zorzo
* mailto:felipe AT felipezorzo DOT com DOT br
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package com.felipebz.zpa.checks
import org.junit.jupiter.api.Test
import com.felipebz.zpa.checks.verifier.PlSqlCheckVerifier
class UnusedParameterCheckTest : BaseCheckTest() {
@Test
fun test() {
PlSqlCheckVerifier.verify(getPath("unused_parameter.sql"), UnusedParameterCheck())
}
@Test
fun testIgnoreMethodsByName() {
val check = UnusedParameterCheck()
check.ignoreMethods = "(on_.*|fullmatch)"
PlSqlCheckVerifier.verify(getPath("unused_parameter_ignore_methods.sql"), check)
}
}
================================================
FILE: zpa-checks/src/test/kotlin/com/felipebz/zpa/checks/UnusedVariableCheckTest.kt
================================================
/**
* Z PL/SQL Analyzer
* Copyright (C) 2015-2026 Felipe Zorzo
* mailto:felipe AT felipezorzo DOT com DOT br
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package com.felipebz.zpa.checks
import org.junit.jupiter.api.Test
import com.felipebz.zpa.checks.verifier.PlSqlCheckVerifier
class UnusedVariableCheckTest : BaseCheckTest() {
@Test
fun test() {
PlSqlCheckVerifier.verify(getPath("unused_variable.sql"), UnusedVariableCheck())
}
}
================================================
FILE: zpa-checks/src/test/kotlin/com/felipebz/zpa/checks/UselessParenthesisCheckTest.kt
================================================
/**
* Z PL/SQL Analyzer
* Copyright (C) 2015-2026 Felipe Zorzo
* mailto:felipe AT felipezorzo DOT com DOT br
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package com.felipebz.zpa.checks
import org.junit.jupiter.api.Test
import com.felipebz.zpa.checks.verifier.PlSqlCheckVerifier
class UselessParenthesisCheckTest : BaseCheckTest() {
@Test
fun test() {
PlSqlCheckVerifier.verify(getPath("useless_parenthesis.sql"), UselessParenthesisCheck())
}
}
================================================
FILE: zpa-checks/src/test/kotlin/com/felipebz/zpa/checks/VariableHidingCheckTest.kt
================================================
/**
* Z PL/SQL Analyzer
* Copyright (C) 2015-2026 Felipe Zorzo
* mailto:felipe AT felipezorzo DOT com DOT br
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package com.felipebz.zpa.checks
import org.junit.jupiter.api.Test
import com.felipebz.zpa.checks.verifier.PlSqlCheckVerifier
class VariableHidingCheckTest : BaseCheckTest() {
@Test
fun test() {
PlSqlCheckVerifier.verify(getPath("variable_hiding.sql"), VariableHidingCheck())
}
}
================================================
FILE: zpa-checks/src/test/kotlin/com/felipebz/zpa/checks/VariableInCountCheckTest.kt
================================================
/**
* Z PL/SQL Analyzer
* Copyright (C) 2015-2026 Felipe Zorzo
* mailto:felipe AT felipezorzo DOT com DOT br
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package com.felipebz.zpa.checks
import org.junit.jupiter.api.Test
import com.felipebz.zpa.checks.verifier.PlSqlCheckVerifier
class VariableInCountCheckTest : BaseCheckTest() {
@Test
fun test() {
PlSqlCheckVerifier.verify(getPath("variable_in_count.sql"), VariableInCountCheck())
}
}
================================================
FILE: zpa-checks/src/test/kotlin/com/felipebz/zpa/checks/VariableInitializationWithFunctionCallCheckTest.kt
================================================
/**
* Z PL/SQL Analyzer
* Copyright (C) 2015-2026 Felipe Zorzo
* mailto:felipe AT felipezorzo DOT com DOT br
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package com.felipebz.zpa.checks
import org.junit.jupiter.api.Test
import com.felipebz.zpa.checks.verifier.PlSqlCheckVerifier
class VariableInitializationWithFunctionCallCheckTest : BaseCheckTest() {
@Test
fun test() {
PlSqlCheckVerifier.verify(getPath("variable_initialization_with_function_call.sql"), VariableInitializationWithFunctionCallCheck())
}
}
================================================
FILE: zpa-checks/src/test/kotlin/com/felipebz/zpa/checks/VariableInitializationWithNullCheckTest.kt
================================================
/**
* Z PL/SQL Analyzer
* Copyright (C) 2015-2026 Felipe Zorzo
* mailto:felipe AT felipezorzo DOT com DOT br
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package com.felipebz.zpa.checks
import org.junit.jupiter.api.Test
import com.felipebz.zpa.checks.verifier.PlSqlCheckVerifier
class VariableInitializationWithNullCheckTest : BaseCheckTest() {
@Test
fun test() {
PlSqlCheckVerifier.verify(getPath("variable_initialization_with_null.sql"), VariableInitializationWithNullCheck())
}
}
================================================
FILE: zpa-checks/src/test/kotlin/com/felipebz/zpa/checks/VariableNameCheckTest.kt
================================================
/**
* Z PL/SQL Analyzer
* Copyright (C) 2015-2026 Felipe Zorzo
* mailto:felipe AT felipezorzo DOT com DOT br
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package com.felipebz.zpa.checks
import org.junit.jupiter.api.Test
import com.felipebz.zpa.checks.verifier.PlSqlCheckVerifier
class VariableNameCheckTest : BaseCheckTest() {
@Test
fun test() {
PlSqlCheckVerifier.verify(getPath("variable_name.sql"), VariableNameCheck())
}
@Test
fun testIgnoreMethodsByName() {
val check = VariableNameCheck()
check.regexp = "\\w{3,}"
PlSqlCheckVerifier.verify(getPath("variable_name_alternative.sql"), check)
}
}
================================================
FILE: zpa-checks/src/test/kotlin/com/felipebz/zpa/checks/XPathCheckTest.kt
================================================
/**
* Z PL/SQL Analyzer
* Copyright (C) 2015-2026 Felipe Zorzo
* mailto:felipe AT felipezorzo DOT com DOT br
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package com.felipebz.zpa.checks
import org.junit.jupiter.api.Test
import org.junit.jupiter.api.assertThrows
import com.felipebz.zpa.checks.verifier.PlSqlCheckVerifier
import com.felipebz.zpa.squid.AnalysisException
class XPathCheckTest : BaseCheckTest() {
@Test
fun line_level_issue() {
analyze("xpath_statement.sql", "//STATEMENT")
}
@Test
fun boolean_true_result() {
analyze("xpath_count_statement.sql", "count(//STATEMENT) > 0")
}
@Test
fun boolean_false_result() {
analyze("xpath.sql", "count(//STATEMENT) < 0")
}
@Test
fun integer_xpath_result() {
analyze("xpath.sql", "count(//STATEMENT)")
}
@Test
fun empty_query() {
analyze("xpath.sql", "")
}
@Test
fun invalid_query() {
assertThrows {
analyze("xpath.sql", "+++")
}
}
private fun analyze(fileName: String, xpathQuery: String) {
val check = XPathCheck()
check.xpathQuery = xpathQuery
check.message = MESSAGE
PlSqlCheckVerifier.verify("src/test/resources/checks/$fileName", check)
}
companion object {
private const val MESSAGE = "Avoid statements"
}
}
================================================
FILE: zpa-checks/src/test/resources/checks/add_parentheses_in_nested_expression.sql
================================================
begin
var := (x = 1 or x = 2 and y = 3); -- Noncompliant {{Add parentheses around this AND condition to make the operator precedence explicit.}}
-- ^^^^^^^^^^^^^^^
var := (x = 1 or x = 2 and y = 3 or -- Noncompliant
-- ^^^^^^^^^^^^^^^
x = 4 and y = 5); -- Noncompliant
-- ^^^^^^^^^^^^^^^
select 1
into var
from dual
where x = 1
or x = 2 -- Noncompliant [[sc=10;el=+1;ec=15]]
and y = 3;
-- correct
var := (x = 1 or (x = 2 and y = 3));
var := (x = 1 or (x = 2 and y = 3) or (x = 4 and y = 5));
select 1
into var
from dual
where x = 1
or (x = 2
and y = 3);
end;
================================================
FILE: zpa-checks/src/test/resources/checks/character_datatype_usage.sql
================================================
declare
var1 varchar(10); -- Noncompliant {{Use VARCHAR2 instead of VARCHAR.}}
var2 char(10); -- Noncompliant {{Use VARCHAR2 instead of CHAR.}}
var3 varchar2(10); -- compliant
begin
null;
end;
================================================
FILE: zpa-checks/src/test/resources/checks/collapsible_if_statements.sql
================================================
begin
-- can be collapsed
if x = 1 then
if y = 2 then -- Noncompliant {{This IF statement can be merged with the enclosing one.}}
null;
end if;
end if;
if x = 1 then
if y = 2 then -- Noncompliant
if z = 3 then -- Noncompliant
null;
end if;
end if;
end if;
-- cannot be collapsed
-- if with elsif
if x = 1 then
if y = 2 then
null;
end if;
elsif x = 2 then
null;
end if;
-- if with else
if x = 1 then
if y = 2 then
null;
end if;
else
null;
end if;
-- if with more than 1 statement
if x = 1 then
null;
if y = 2 then
null;
end if;
end if;
if x = 1 then
if y = 2 then
null;
end if;
null;
end if;
-- internal if has elsif/else
if x = 1 then
if y = 2 then
null;
elsif y = 3 then
null;
else
null;
end if;
elsif x = 2 then
null;
end if;
end;
/
================================================
FILE: zpa-checks/src/test/resources/checks/columns_should_have_table_name.sql
================================================
declare
my_var number;
begin
select col, -- Noncompliant {{Specify the table of column "col".}}
-- ^^^
tab.col,
func(col),
'text'
from tab, tab2;
-- do not create issue when the select has one table
select col,
tab.col,
func(col),
'text'
from tab;
-- do not report error in rownum
select rownum
from tab, tab2;
-- do not report error when the column is a known variable
insert into tab (foo, bar, baz)
(select other.foo,
my_var, -- compliant
other.baz
from other, other2);
select my_var; -- do not report error in queries without tables
end;
-- DML in scripts should be checked too
select col, -- Noncompliant {{Specify the table of column "col".}}
-- ^^^
tab.col,
func(col),
'text'
from tab, tab2
/
================================================
FILE: zpa-checks/src/test/resources/checks/commit_rollback.sql
================================================
create procedure test is
procedure test2 is
pragma autonomous_transaction;
begin
commit; -- no violation here, it is in an autonomous transaction
end;
begin
commit; -- Noncompliant {{Avoid COMMIT calls unless it is in an autonomous transaction.}}
begin
rollback; -- Noncompliant {{Avoid ROLLBACK calls unless it is in an autonomous transaction.}}
-- should ignore rollback to savepoint
rollback to savepoint s1;
rollback to s1;
end;
end;
/
begin
commit; -- correct, it isn't a database object
end;
/
================================================
FILE: zpa-checks/src/test/resources/checks/comparison_with_boolean.sql
================================================
begin
var := (x = true); -- Noncompliant {{Remove the literal "TRUE" of this comparison.}}
var := (x != true); -- Noncompliant
var := (x = false); -- Noncompliant {{Remove the literal "FALSE" of this comparison.}}
var := (x != false); -- Noncompliant
var := (true = true); -- Noncompliant
var := (x = y);
end;
================================================
FILE: zpa-checks/src/test/resources/checks/comparison_with_null.sql
================================================
begin
-- noncompliant code
var := (foo = null); -- Noncompliant {{Fix this comparison or change to "IS NULL".}}
-- ^^^^^^^^^^
var := (foo = ''); -- Noncompliant
-- ^^^^^^^^
var := (foo <> null); -- Noncompliant {{Fix this comparison or change to "IS NOT NULL".}}
-- ^^^^^^^^^^^
var := (foo <> ''); -- Noncompliant
-- ^^^^^^^^^
-- valid code
var := (foo is null);
var := (foo is not null);
var := (foo = 'x');
var := (foo <> 'x');
var := (foo = 1);
end;
================================================
FILE: zpa-checks/src/test/resources/checks/concatenation_with_null.sql
================================================
begin
var := 'a'||null; -- Noncompliant {{Review this concatenation with NULL value.}}
-- ^^^^
var := 'a'||''; -- Noncompliant
-- ^^
var := 'a'||'1';
end;
================================================
FILE: zpa-checks/src/test/resources/checks/cursor_body_in_package_spec.sql
================================================
create package pkg is
cursor cur is -- Noncompliant {{Move the body of the cursor "CUR" to the package body.}}
select dummy from dual;
end;
/
create package pkg is
type cur_type is record(dummy varchar2(1));
cursor cur return cur_type; -- Compliant
end;
/
create package body pkg is
cursor cur is -- Compliant
select dummy from dual;
end;
/
================================================
FILE: zpa-checks/src/test/resources/checks/dbms_output_put.sql
================================================
begin
dbms_output.put('x'); -- Noncompliant {{Avoid direct calls to DBMS_OUTPUT procedures.}}
dbms_output.put_line('x'); -- Noncompliant
sys.dbms_output.put_line('x'); -- Noncompliant
my_output.put_line('x');
dbms_output.other('x');
put_line('x');
x.exists();
end;
================================================
FILE: zpa-checks/src/test/resources/checks/dead_code.sql
================================================
begin
return;
var := 1; -- Noncompliant {{This code will never be executed.}}
end;
/
begin
raise_application_error(-20999, 'Custom error message');
var := 1; -- Noncompliant
end;
/
begin
raise;
var := 1; -- Noncompliant
end;
/
begin
for i in 1..10 loop
continue;
var := 1; -- Noncompliant
end loop;
end;
/
begin
for i in 1..10 loop
exit;
var := 1; -- Noncompliant
end loop;
end;
/
begin
begin
return;
end;
var := 1; -- Noncompliant
end;
/
begin
begin
begin
return;
end;
end;
var := 1; -- Noncompliant
end;
/
-- correct
begin
return;
end;
/
begin
raise;
end;
/
begin
raise_application_error(-20999, 'Custom error message');
end;
/
begin
for i in 1..10 loop
continue when i = 5;
var := 1;
end loop;
end;
/
begin
for i in 1..10 loop
exit when i = 5;
var := 1;
end loop;
end;
/
begin
begin
return;
exception
when others then
null;
end;
var := 1;
end;
/
begin
begin
begin
return;
end;
exception
when others then
null;
end;
var := 1; -- violation
end;
/
================================================
FILE: zpa-checks/src/test/resources/checks/declare_section_without_declarations.sql
================================================
begin
declare -- Noncompliant {{Remove this DECLARE keyword.}}
begin
null;
end;
declare
var number;
begin
null;
end;
end;
================================================
FILE: zpa-checks/src/test/resources/checks/disabled_test.sql
================================================
create or replace package testpkg is
-- %suite
-- Noncompliant@+2 {{Fix or remove this disabled unit test.}}
-- %test
-- %disabled
procedure test;
-- %test
-- %disabled with some reason
procedure test2;
end testpkg;
================================================
FILE: zpa-checks/src/test/resources/checks/duplicate_condition_if_elsif.sql
================================================
begin
if foo then
null;
elsif foo then -- Noncompliant {{This code can not be reached because the condition duplicates a previous condition in the same sequence of "if/else if" statements.}}
null;
end if;
if foo then
null;
elsif bar then
null;
elsif bar then -- Noncompliant
null;
elsif (bar) then -- Noncompliant
null;
end if;
-- correct
if foo then
null;
end if;
if foo then
null;
elsif bar then
null;
elsif baz then
null;
end if;
end;
/
================================================
FILE: zpa-checks/src/test/resources/checks/duplicated_value_in_in.sql
================================================
begin
var := (x in (1, 1, 2)); -- Noncompliant {{Remove or fix the duplicated value "1" in the IN condition.}} [[secondary=2]]
-- ^
select col
into var
from tab
where col in (x, y, x); -- Noncompliant {{Remove or fix the duplicated value "x" in the IN condition.}} [[secondary=8]]
-- ^
-- correct
var := (x in (1, 2, 3));
end;
================================================
FILE: zpa-checks/src/test/resources/checks/empty_block.sql
================================================
begin
null; -- Noncompliant {{Either remove or fill this block of code.}}
end;
/
create type body t as
not overriding member procedure foo as
begin
null; -- Noncompliant
end;
overriding member procedure foo as
begin
null; -- Compliant, don't report violation on overriding member
end;
overriding member procedure foo as
begin
begin
null; -- Noncompliant
end;
end;
end;
/
declare
var number;
begin
null;
var := 1;
end;
/
declare
var number;
begin
var := 1;
end;
/
================================================
FILE: zpa-checks/src/test/resources/checks/empty_string_assignment.sql
================================================
begin
var := ''; -- Noncompliant {{Replace this empty string by NULL.}}
-- correct
var := ' ';
var := 'x';
var := null;
end;
================================================
FILE: zpa-checks/src/test/resources/checks/explicit_in_parameter.sql
================================================
create or replace procedure foo(bar number) is -- Noncompliant {{Explicitly declare this parameter as IN.}}
-- ^^^^^^^^^^
begin
null;
end;
/
create or replace procedure foo(p1 in number,
p2 out number,
p3 in out number) is
cursor cur(pcur number) is -- cursor parameters cannot raise a violation
select 1
from dual;
begin
null;
end;
/
================================================
FILE: zpa-checks/src/test/resources/checks/function_with_out_parameter.sql
================================================
create function foo(x in number,
y out number) -- Noncompliant {{Rewrite this function to not depend on OUT parameters.}}
return number is
begin
null;
end;
/
create function foo(x in number,
y in out number) -- Noncompliant
return number is
begin
null;
end;
/
create package pck is
function foo(x in number,
y out number) -- Noncompliant
return number is
begin
null;
end;
function foo(x in number,
y in out number) -- Noncompliant
return number is
begin
null;
end;
end;
/
-- correct
create function foo return number is
begin
null;
end;
/
================================================
FILE: zpa-checks/src/test/resources/checks/identical_expression.sql
================================================
begin
var := (a = a); -- Noncompliant {{Identical expressions on both sides of operator "=".}} [[secondary=2]]
-- ^
select 1
into var
from tab
where tab.col = tab.col; -- Noncompliant [[secondary=8]]
-- ^^^^^^^
var := not a = a; -- Noncompliant [[secondary=11]]
-- ^
var := (a) = a; -- Noncompliant [[secondary=14]]
-- ^^^
var := (a + b + (c)) = a + (b) + c; -- Noncompliant [[secondary=17]]
-- ^^^^^^^^^^^^^
-- valid
var := (a = b);
end;
================================================
FILE: zpa-checks/src/test/resources/checks/if_with_exit.sql
================================================
begin
if (x = y) then -- Noncompliant {{Replace this IF ... EXIT by a EXIT WHEN statement.}} [[sc=3;el=+2;ec=10]]
exit;
end if;
if (x = y) then
foo := bar;
exit; -- ok
end if;
if (x = y) then
exit; -- ok
foo := bar;
end if;
if (x = y) then
exit; -- ok
elsif (x = z) then
null;
end if;
if (x = y) then
exit; -- ok
else
null;
end if;
loop
exit; -- ok
end loop;
end;
================================================
FILE: zpa-checks/src/test/resources/checks/inequality_usage_check.sql
================================================
begin
foo := (x != a); -- Noncompliant {{Replace "!=" by "<>".}}
foo := (x ^= a); -- Noncompliant {{Replace "^=" by "<>".}}
foo := (x ~= a); -- Noncompliant {{Replace "~=" by "<>".}}
-- valid usage
foo := (x <> a);
end;
================================================
FILE: zpa-checks/src/test/resources/checks/insert_without_columns.sql
================================================
declare
var tab%rowtype;
subtype my_type is tab%rowtype;
v_my_type my_type;
type t_tab is table of tab%rowtype index by binary_integer;
v_tab t_tab;
begin
insert into tab values (1); -- Noncompliant {{Specify the columns in this INSERT.}}
insert into tab (col) values (1);
insert into tab values var;
insert into tab values var returning id into v_id;
for r_t in (select * from mytable) loop
insert into mytable values r_t;
end loop;
forall idx in v_tab.first .. v_tab.last
insert into tab values v_tab(idx);
insert into tab values v_tab(idx);
insert into tab values v_my_type;
end;
================================================
FILE: zpa-checks/src/test/resources/checks/invalid_reference_to_object.sql
================================================
begin
---------------
-- ALERT
---------------
find_alert(var); -- ignore variables
find_alert('foo');
find_alert('invalid'); -- Noncompliant {{Invalid reference to the object "invalid" in this FIND_ALERT call.}}
-- ^^^^^^^^^
set_alert_button_property('foo', alert_button1, label, 'label');
set_alert_button_property('invalid', alert_button1, label, 'label'); -- Noncompliant
-- ^^^^^^^^^
set_alert_property('foo', title, 'title');
set_alert_property('invalid', title, 'title'); -- Noncompliant
-- ^^^^^^^^^
show_alert('foo');
show_alert('invalid'); -- Noncompliant
-- ^^^^^^^^^
---------------
-- BLOCK
---------------
find_block('foo');
find_block('invalid'); -- Noncompliant
-- ^^^^^^^^^
get_block_property('foo', order_by);
get_block_property('invalid', order_by); -- Noncompliant
-- ^^^^^^^^^
go_block('foo');
go_block('invalid'); -- Noncompliant
-- ^^^^^^^^^
set_block_property('foo', order_by, 'col');
set_block_property('invalid', order_by, 'col'); -- Noncompliant
-- ^^^^^^^^^
set_block_property('foo', blockscrollbar_position, x, y);
set_block_property('invalid', blockscrollbar_position, x, y); -- Noncompliant
-- ^^^^^^^^^
---------------
-- ITEM
---------------
checkbox_checked('foo.item1');
checkbox_checked('foo.invalid'); -- Noncompliant
-- ^^^^^^^^^^^^^
convert_other_value('foo.item1');
convert_other_value('foo.invalid'); -- Noncompliant
-- ^^^^^^^^^^^^^
display_item('foo.item1', 'bar');
display_item('foo.invalid', 'bar'); -- Noncompliant
-- ^^^^^^^^^^^^^
find_item('foo.item1');
find_item('foo.invalid'); -- Noncompliant
-- ^^^^^^^^^^^^^
get_item_instance_property('foo.item1', current_record, visual_attribute);
get_item_instance_property('foo.invalid', current_record, visual_attribute); -- Noncompliant
-- ^^^^^^^^^^^^^
get_item_property('foo.item1', enabled);
get_item_property('foo.invalid', enabled); -- Noncompliant
-- ^^^^^^^^^^^^^
get_radio_button_property('foo.item1', 'bar', label);
get_radio_button_property('foo.invalid', 'bar', label); -- Noncompliant
-- ^^^^^^^^^^^^^
go_item('foo.item1');
go_item('foo.invalid'); -- Noncompliant
-- ^^^^^^^^^^^^^
image_scroll('foo.item1', x, y);
image_scroll('foo.invalid', x, y); -- Noncompliant
-- ^^^^^^^^^^^^^
image_zoom('foo.item1', adjust_to_fit);
image_zoom('foo.invalid', adjust_to_fit); -- Noncompliant
-- ^^^^^^^^^^^^^
image_zoom('foo.item1', zoom_in_factor, 10);
image_zoom('foo.invalid', zoom_in_factor, 10); -- Noncompliant
-- ^^^^^^^^^^^^^
play_sound('foo.item1');
play_sound('foo.invalid'); -- Noncompliant
-- ^^^^^^^^^^^^^
read_image_file('file.jpg', 'jpg', 'foo.item1');
read_image_file('file.jpg', 'jpg', 'foo.invalid'); -- Noncompliant
-- ^^^^^^^^^^^^^
read_sound_file('file.wav', 'wave', 'foo.item1');
read_sound_file('file.wav', 'wave', 'foo.invalid'); -- Noncompliant
-- ^^^^^^^^^^^^^
recalculate('foo.item1');
recalculate('foo.invalid'); -- Noncompliant
-- ^^^^^^^^^^^^^
set_item_instance_property('foo.item1', currrent_record, visual_attribute, 'bar');
set_item_instance_property('foo.invalid', currrent_record, visual_attribute, 'bar'); -- Noncompliant
-- ^^^^^^^^^^^^^
set_item_property('foo.item1', enabled, property_false);
set_item_property('foo.invalid', enabled, property_false); -- Noncompliant
-- ^^^^^^^^^^^^^
set_item_property('foo.item1', position, x, y);
set_item_property('foo.invalid', position, x, y); -- Noncompliant
-- ^^^^^^^^^^^^^
set_radio_button_property('foo.item1', 'bar', enabled, property_false);
set_radio_button_property('foo.invalid', 'bar', enabled, property_false); -- Noncompliant
-- ^^^^^^^^^^^^^
set_radio_button_property('foo.item1', 'bar', position, x, y);
set_radio_button_property('foo.invalid', 'bar', position, x, y); -- Noncompliant
-- ^^^^^^^^^^^^^
write_image_file('file.jpg', 'jpg', 'foo.item1', maximize_compression, original_depth);
write_image_file('file.jpg', 'jpg', 'foo.invalid', maximize_compression, original_depth); -- Noncompliant
-- ^^^^^^^^^^^^^
write_sound_file('file.wav', 'wave', 'foo.item1', original_quality, original_setting);
write_sound_file('file.wav', 'wave', 'foo.invalid', original_quality, original_setting); -- Noncompliant
-- ^^^^^^^^^^^^^
---------------
-- LOV
---------------
find_lov('foo');
find_lov('invalid'); -- Noncompliant
-- ^^^^^^^^^
get_lov_property('foo', title);
get_lov_property('invalid', title); -- Noncompliant
-- ^^^^^^^^^
set_lov_column_property('foo', 1, title, 'title');
set_lov_column_property('invalid', 1, title, 'title'); -- Noncompliant
-- ^^^^^^^^^
set_lov_property('foo', title, 'title');
set_lov_property('invalid', title, 'title'); -- Noncompliant
-- ^^^^^^^^^
set_lov_property('foo', position, x, y);
set_lov_property('invalid', position, x, y); -- Noncompliant
-- ^^^^^^^^^
show_lov('foo');
show_lov('invalid'); -- Noncompliant
-- ^^^^^^^^^
end;
================================================
FILE: zpa-checks/src/test/resources/checks/not_a_selected_expression.sql
================================================
select distinct emp.name
from emp
order by emp.id; -- Noncompliant {{This value does not exists in the SELECT clause. Fix this expression or add this value in the SELECT.}}
-- ^^^^^^
select distinct substr(emp.name, 0, 10) emp_name
from emp
order by emp.name; -- Noncompliant
-- ^^^^^^^^
-- Compliant queries
select distinct substr(emp.name, 0, 10) emp_name
from emp
order by substr(emp.name, 0, 10);
select distinct substr(emp.name, 0, 10) emp_name
from emp
order by emp_name;
select distinct substr(emp.name, 0, 10) emp_name
from emp
order by 1;
select distinct emp.name
from emp
order by emp.name;
select distinct name
from emp
order by name;
select distinct emp.name
from emp
order by name;
select emp.name
from emp
order by emp.id;
select distinct emp.name
from emp;
select distinct emp.name emp_name
from emp
order by name;
select distinct name
from emp
order by emp.name;
select distinct emp.name
from emp
order by length(emp.name);
select distinct (name)
from emp
order by substr(name, 2);
================================================
FILE: zpa-checks/src/test/resources/checks/not_found.sql
================================================
begin
var := not cur%found; -- Noncompliant {{Use %NOTFOUND instead of NOT ...%FOUND.}}
var := cur%notfound;
var := not cur.found;
var := cur.found;
var := cur%found;
end;
================================================
FILE: zpa-checks/src/test/resources/checks/nvl_with_null_parameter.sql
================================================
begin
var := nvl(x, null); -- Noncompliant {{This NVL does not have any effect. Fix the NULL parameter or remove this NVL.}}
-- ^^^^^^^^^^^^
var := nvl(null, x); -- Noncompliant
-- ^^^^^^^^^^^^
var := nvl(x, ''); -- Noncompliant {{This NVL does not have any effect. Fix the '' parameter or remove this NVL.}}
-- ^^^^^^^^^^
var := nvl('', x); -- Noncompliant
-- ^^^^^^^^^^
var := nvl(x, y);
var := nvl(x, 'y');
var := func(x, null);
var := pack.func(x, null);
end;
================================================
FILE: zpa-checks/src/test/resources/checks/parsing_error.sql
================================================
; invalid
================================================
FILE: zpa-checks/src/test/resources/checks/query_without_exception_handling.sql
================================================
begin
select 1 -- Noncompliant {{Handle exceptions of this query.}}
into var
from dual;
end;
/
begin
-- This is not valid code as it causes "PLS-00428: an INTO clause is expected in this SELECT statement" when compiling on
-- the database, but I'll keep this example here because the file is being parser correctly and the check shouldn't crash.
select 1 -- Noncompliant {{Handle exceptions of this query.}}
from dual;
end;
/
begin
if (true) then
select 1 -- Noncompliant
into var
from dual;
end if;
end;
/
begin
begin
select 1 -- Noncompliant, inner block without exception handling
into var
from dual;
end;
exception
when others then
null;
end;
/
create procedure foo is
begin
select 1 -- Noncompliant
into var
from dual;
end;
/
create function foo return number is
begin
select 1 -- Noncompliant
into var
from dual;
end;
/
create package body pack is
procedure foo is
begin
select 1 -- Noncompliant
into var
from dual;
end;
function foo return number is
begin
select 1 -- Noncompliant
into var
from dual;
end;
end;
/
-- correct code
begin
select 1
into var
from dual;
exception
when others then
null;
end;
/
begin -- outer block doesn't require an exception handling block
begin
select 1
into var
from dual;
exception
when others then
null;
end;
end;
/
create trigger foo
before insert on tab
begin
select 1
into var
from dual;
exception
when others then
null;
end;
/
-- queries with bulk collect should be ignored because they don't throw no_data_found/too_many_rows
begin
select 1
bulk collect into var
from dual;
end;
/
================================================
FILE: zpa-checks/src/test/resources/checks/query_without_exception_handling_no_strict.sql
================================================
begin
select 1 -- Noncompliant {{Handle exceptions of this query.}}
into var
from dual;
end;
/
begin
if (true) then
select 1 -- Noncompliant
into var
from dual;
end if;
end;
/
begin
begin
select 1 -- Compliant, because strict mode is disabled
into var
from dual;
end;
exception
when others then
null;
end;
/
create procedure foo is
begin
select 1 -- Noncompliant
into var
from dual;
end;
/
create function foo return number is
begin
select 1 -- Noncompliant
into var
from dual;
end;
/
create package body pack is
procedure foo is
begin
select 1 -- Noncompliant
into var
from dual;
end;
function foo return number is
begin
select 1 -- Noncompliant
into var
from dual;
end;
end;
/
-- correct code
begin
select 1
into var
from dual;
exception
when others then
null;
end;
/
begin -- outer block doesn't require an exception handling block
begin
select 1
into var
from dual;
exception
when others then
null;
end;
end;
/
create trigger foo
before insert on tab
begin
select 1
into var
from dual;
exception
when others then
null;
end;
/
================================================
FILE: zpa-checks/src/test/resources/checks/raise_standard_exception.sql
================================================
declare
e_custom exception;
begin
raise no_data_found; -- Noncompliant {{Avoid raising the standard exception NO_DATA_FOUND.}}
raise too_many_rows; -- Noncompliant {{Avoid raising the standard exception TOO_MANY_ROWS.}}
raise e_custom;
raise;
end;
================================================
FILE: zpa-checks/src/test/resources/checks/redundant_expectation.sql
================================================
declare
x number;
y number;
begin
ut.expect(x).to_be_equal(x); -- Noncompliant
-- ^
ut.expect(x).to_be_equal(y);
ut.expect(x).to_be_null();
end;
================================================
FILE: zpa-checks/src/test/resources/checks/return_of_boolean_expression.sql
================================================
begin
if (a = b) then -- Noncompliant {{Replace this if-then-else statement by a single return statement.}}
return true;
else
return false;
end if;
if (a = b) then -- Noncompliant
return false;
else
return true;
end if;
-- correct
if (a = b) then
return true;
elsif (a = c) then
return false;
else
return true;
end if;
if (a = b) then
return true;
else
return true;
end if;
if (a = b) then
return foo;
else
return false;
end if;
if (a = b) then
a := 1;
return true;
else
return false;
end if;
if (a = b) then
return true;
else
a := 1;
return false;
end if;
end;
================================================
FILE: zpa-checks/src/test/resources/checks/same_branch.sql
================================================
begin
if x then
var := 1;
elsif y then
var := 1; -- Noncompliant {{Either merge this branch with the identical one on line 3 or change one of the implementations.}} [[secondary=3]]
-- ^^^^^^^^^
end if;
if x then
var := 1;
else
var := 1; -- Noncompliant [[secondary=10]]
-- ^^^^^^^^^
end if;
if x then
var := 1;
else
var := (1); -- Noncompliant [[secondary=17]]
-- ^^^^^^^^^^^
end if;
-- compliant
if x then
var := 1;
elsif y then
var := 2;
elsif z then
var := 1;
end if;
end;
================================================
FILE: zpa-checks/src/test/resources/checks/same_condition.sql
================================================
begin
-- violations
var := (x = 1 and x = 1); -- Noncompliant {{This condition duplicates the one on line 3.}} [[secondary=3]]
-- ^^^^^
var := (x = 1 or x = 1); -- Noncompliant [[secondary=6]]
-- ^^^^^
var := (x = 1 or (x = 1)); -- Noncompliant [[secondary=9]]
-- ^^^^^^^
var := (x or nvl(x, null)); -- Noncompliant [[secondary=12]]
-- ^^^^^^^^^^^^
select tab.col
into var
from tab
where tab.col = 1
and tab.col = 1; -- Noncompliant [[secondary=18]]
-- ^^^^^^^^^^^
select tab.col
into var
from tab
where (tab.col = 1 and tab.col2 = 2)
or (tab.col = 1 and tab.col2 = 2); -- Noncompliant [[secondary=25]]
-- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-- correct
var := (x = 1 and y = 2);
var := (x = 1 or y = 2);
-- no violation because it is equivalent to ((x = 1 or y = 2) and x = 1)
-- but we could report a violation someday
var := (x = 1 or y = 2 and x = 1);
-- we could report a violation someday in this case too
var := (x = 1 and 1 = x);
end;
================================================
FILE: zpa-checks/src/test/resources/checks/select_all_columns.sql
================================================
declare
cursor cur is
select * -- Noncompliant {{SELECT * should not be used.}}
from emp;
row emp%rowtype;
type my_array is table of emp%rowtype;
row_table my_array;
begin
-- violations
select * -- Noncompliant {{SELECT * should not be used.}}
into var
from emp;
select emp.* -- Noncompliant
into var
from emp;
select distinct emp.* -- Noncompliant
into var
from emp;
select user.emp.* -- Noncompliant
into var
from user.emp;
select * -- Noncompliant
into pkg.var
from emp;
select *
into row_table(1)
from emp;
-- valid code
select emp.empno
into var
from emp;
select emp.sal * 2 -- does not match the multiplication operator
into var
from emp;
select count(*) -- count is acceptable
into var
from emp;
select emp.sal
into var
from emp
where exists (select * from e); -- in a exists expression is acceptable too
select *
into row
from emp;
select *
bulk collect into row_table
from emp;
end;
/
declare
v_foo emp%rowtype;
cursor cur is
select * -- Compliant
from emp;
begin
open cur;
fetch cur into v_foo;
close cur;
end;
/
================================================
FILE: zpa-checks/src/test/resources/checks/select_with_rownum_and_order_by.sql
================================================
begin
select name
into var
from user
where rownum <= 1 -- Noncompliant {{Move this ROWNUM comparation to a more external level to guarantee the ordering.}}
order by date;
select name
into var
from user
where (rownum <= 1) -- Noncompliant
order by date;
-- valid code
select name
into var
from user
where func(rownum) = filter
order by date;
select name
into var
from user
where rownum = 1;
select name
into var
from user
order by date;
select name
into var
from user
where foo = (select foo from bar where rownum = 1)
order by date;
end;
================================================
FILE: zpa-checks/src/test/resources/checks/to_char_in_order_by.sql
================================================
select *
from emp
order by to_char(empno); -- Noncompliant
-- ^^^^^^^^^^^^^^
select to_char(empno)
from emp
order by 1; -- Noncompliant
-- ^
select *
from emp
order by empno; -- Compliant
select empno
from emp
order by 1; -- Compliant
select empno, row_number() over (order by 0) -- Compliant
from emp
order by empno;
/* Actually this code causes the error "ORA-01785: ORDER BY item must be the number of a SELECT-list expression".
* It's still compliant as this is not the purpose of this rule.
*/
select empno
from emp
order by 0; -- Compliant
declare
my_empno number;
begin
select *
into foo
from emp
order by my_empno; -- Compliant
end;
================================================
FILE: zpa-checks/src/test/resources/checks/to_date_without_format.sql
================================================
begin
mydate := to_date('2015-01-01'); -- Noncompliant {{Specify the date format in this TO_DATE.}}
-- ^^^^^^^^^^^^^^^^^^^^^
to_date(null);
to_date('');
mydate := to_date('2015-01-01', 'rrrr-mm-dd');
mydate := my_to_date('2015-01-01');
mydate := pkg.to_date('2015-01-01');
end;
================================================
FILE: zpa-checks/src/test/resources/checks/too_many_rows_handler.sql
================================================
begin
select empno
into var
from emp;
exception
when too_many_rows then -- Noncompliant {{Handle the variables used in the SELECT INTO statements here so their values do not become undefined.}}
null;
end;
begin
select empno
into var
from emp;
exception
when no_data_found or too_many_rows then -- Noncompliant
null;
end;
-- compliant
begin
select empno
into var
from emp;
exception
when too_many_rows then
var := null;
end;
begin
select empno
into var
from emp;
exception
when too_many_rows then
log(sqlerrm);
raise myexception;
end;
begin
select empno
into var
from emp;
exception
when no_data_found then
null;
when pkg.error then
var := null;
when others then
null;
end;
================================================
FILE: zpa-checks/src/test/resources/checks/unhandled_user_defined_exception.sql
================================================
declare
ex exception;
ex_handled exception;
begin
raise ex; -- Noncompliant {{There is no exception handler for "EX" here. This will cause an "user-defined exception" error.}}
raise ex_handled; -- ok
raise ex_unknown; -- ok, we don't have any information about the excepton
raise pkg.ex; -- ok
exception
when ex_handled then
null;
end;
/
declare
ex exception;
begin
raise ex; -- Noncompliant, there is an "others" handler for this but we will report a violation becase there is a reference to sqlerrm in others
exception
when others then
log(sqlerrm);
end;
/
declare
ex exception;
begin
begin
raise ex; -- Noncompliant
exception
when others then
log(sqlerrm);
end;
end;
/
declare
ex exception;
begin
begin
raise ex;
exception
when ex then
null;
end;
if (x) then
raise ex; -- Noncompliant
end if;
end;
/
create package body pack is
ex exception;
procedure test is
begin
raise ex; -- we won't report a violation here because we don't have enough information to know if another method in this package handles this exception
end;
end;
/
declare
ex exception;
begin
raise ex;
exception
when others then
null;
end;
/
declare
ex exception;
begin
begin
raise ex;
end;
exception
when ex then
null;
when others then
log(sqlerrm);
end;
/
================================================
FILE: zpa-checks/src/test/resources/checks/unnecessary_alias_in_query.sql
================================================
begin
select *
from tab x; -- Noncompliant {{This statement has only one reference to the table "tab". Remove the alias "x" to improve the readability.}}
-- ^
select * from tab x, tab2; -- Noncompliant
-- ^
select * from tab x where exists (select 1 from tab2); -- Noncompliant
-- ^
select (select 1 from tab x) from tab2; -- Noncompliant
-- ^
update tab x set foo = bar where exists (select 1 from tab2); -- Noncompliant
-- ^
delete tab x where exists (select 1 from tab2); -- Noncompliant
-- ^
select *
from tab x -- Noncompliant
-- ^
union
select *
from tab x; -- Noncompliant
-- correct
select *
from tab x,
tab;
select *
from tab x,
tab y;
select *
from tab,
tab2;
select *
from tab
where exists (select 1 from tab x);
update tab
set foo = bar
where exists (select 1 from tab x);
delete tab
where exists (select 1 from tab x);
end;
/
================================================
FILE: zpa-checks/src/test/resources/checks/unnecessary_alias_in_query_custom_length.sql
================================================
begin
select *
from tab x; -- Noncompliant {{This statement has only one reference to the table "tab". Remove the alias "x" to improve the readability.}}
-- ^
select *
from tab xxxx, -- should be ignored because the accepted length is 4
tab2;
end;
/
================================================
FILE: zpa-checks/src/test/resources/checks/unnecessary_else.sql
================================================
begin
if (foo = bar) then
return;
else -- Noncompliant {{This ELSE can be replaced by an END IF. When the corresponding IF is executed, the code execution will be stopped. Either way, the code within this ELSE will always run, regardless of the ELSE block.}}
foo := null;
end if;
if (foo = bar) then
exit;
else -- Noncompliant
foo := null;
end if;
if (foo = bar) then
continue;
else -- Noncompliant
foo := null;
end if;
if (foo = bar) then
raise;
else -- Noncompliant
foo := null;
end if;
if (foo = bar) then
raise_application_error(-20999, 'Custom error message');
else -- Noncompliant
foo := null;
end if;
end;
-- correct
begin
if (foo = bar) then
get_data;
else
foo := null;
end if;
if (foo = bar) then
exit when baz;
else
foo := null;
end if;
if (foo = bar) then
continue when baz;
else
foo := null;
end if;
if (foo = bar) then
return;
elsif baz then
null;
else
foo := null;
end if;
end;
================================================
FILE: zpa-checks/src/test/resources/checks/unnecessary_like.sql
================================================
begin
var := x like 'a'; -- Noncompliant
-- ^^^^^^^^^^
var := x like 'a\%' escape '\'; -- Noncompliant
var := x like 'a\_' escape '\'; -- Noncompliant
var := x like '%a';
var := x like 'a_';
var := x like '%a\%' escape '\';
var := x like '%a\_' escape '\';
var := x like y;
var := x like y escape z;
var := x like x escape '\';
end;
================================================
FILE: zpa-checks/src/test/resources/checks/unnecessary_null_statement.sql
================================================
begin
v := 0;
null; -- Noncompliant {{This NULL statement does not have any effect here.}}
end;
/
begin
null; -- Noncompliant
v := 0;
end;
/
-- correct
begin
null;
end;
/
================================================
FILE: zpa-checks/src/test/resources/checks/unused_cursor.sql
================================================
declare
cursor cur is -- Noncompliant {{Remove this unused "CUR" cursor.}}
select 1 from dual;
cursor "cur2" is
select 1 from dual;
begin
open "cur2";
end;
create package pkg is
cursor cur is -- compliant, this is a package specification, we don't know if there are any usages
select 1 from dual;
end;
create package body pkg is
cursor cur return custom_type is -- compliant, let's assume that cursors with return type are declared in package spec
select 1 from dual;
end;
================================================
FILE: zpa-checks/src/test/resources/checks/unused_parameter.sql
================================================
create procedure foo(a number, b number, "c" number) is -- Noncompliant {{Remove this unused "B" parameter.}}
-- ^^^^^^^^
begin
print(a);
print("c");
end;
/
create function bar(a number, b number) return number is -- Noncompliant
-- ^^^^^^^^
begin
return a;
end;
/
create package test is
procedure foo(a number, b number); -- don't report violation on declaration
cursor bar(a number) return my_type; -- don't report violation on declaration
procedure foo(a number, b number) is -- Noncompliant
-- ^^^^^^^^
cursor cur(x number) is -- Noncompliant {{Remove this unused "X" parameter.}}
-- ^^^^^^^^
select 1 from dual;
begin
print(a);
end;
end;
/
create type foo as object ( -- don't report violation on declarations
constructor function foo(x number) return self as result,
member procedure foo(a number, b number);
)
/
create type t under super_t (
overriding member procedure foo(a number, b number); -- don't report violation on declaration
)
/
create type body t as
not overriding member procedure foo(a number) as -- Noncompliant
-- ^^^^^^^^
begin
null;
end;
overriding member procedure foo(a number, b number) as -- don't report violation on overriding member
begin
null;
end;
member procedure print(self in out nocopy t) is -- don't report violation on SELF parameter
begin
null;
end;
end;
/
procedure foo is
cursor cur(x number) is
select 1 from dual where cur.x = 1; -- don't report violation because "cur.x" refers to the cursor parameter
begin
null;
end;
/
================================================
FILE: zpa-checks/src/test/resources/checks/unused_parameter_ignore_methods.sql
================================================
create procedure on_event(a number, b number) is
--
begin
print(a);
end;
/
create procedure fullmatch(a number, b number) is
--
begin
print(a);
end;
/
create function on_event(p_event in integer)
return integer
as
begin
return 1;
end;
/
create function bar(a number, b number) return number is -- Noncompliant
-- ^^^^^^^^
begin
return a;
end;
/
================================================
FILE: zpa-checks/src/test/resources/checks/unused_variable.sql
================================================
declare
var number; -- Noncompliant {{Remove this unused "VAR" local variable.}}
i number; -- Noncompliant {{Remove this unused "I" local variable.}}
procedure proc is
proc_var number; -- Noncompliant {{Remove this unused "PROC_VAR" local variable.}}
begin
null;
end;
function func return number is
func_var number; -- Noncompliant {{Remove this unused "FUNC_VAR" local variable.}}
begin
null;
end;
begin
null;
declare
var2 number; -- Noncompliant {{Remove this unused "VAR2" local variable.}}
begin
null;
end;
for i in 1..2 loop -- this "i" variable is not the same as the one in declaration section
func(i);
end loop;
end;
/
create or replace package body test is
package_body_var number; -- Noncompliant {{Remove this unused "PACKAGE_BODY_VAR" local variable.}}
hidden_var number; -- Noncompliant {{Remove this unused "HIDDEN_VAR" local variable.}}
"VAR" number; -- Noncompliant {{Remove this unused "VAR" local variable.}}
"var" number;
procedure proc is
hidden_var number; -- this declaration hides the previous one
var number; -- this declaration hides the previous "VAR"
begin
hidden_var := 0;
var := 0;
"var" := 0;
end;
end;
/
-- correct
declare
simple_var number;
into_var number;
insert_var number;
comparision_var number;
case_insensitive_test number;
record_variable rectype;
error exception;
begin
simple_var := 0;
CASE_INSENSITIVE_TEST := 0;
record_variable.field := 0;
select 1
into into_var
from dual;
insert into tab (x) values (insert_var);
if (comparision_var = 1) then
null;
end if;
for i in 1..2 loop -- "i" variable is not used, but it is required here
null;
end loop;
raise error;
end;
/
create or replace package test is
package_body_var number; -- do not report error on package specifications
end;
/
create or replace package body test is
package_body_var number;
qualified_var number;
procedure proc is
begin
package_body_var := 0;
test.qualified_var := 0;
test.var := 0;
end;
end;
/
================================================
FILE: zpa-checks/src/test/resources/checks/useless_parenthesis.sql
================================================
begin
var := ((x = 1)); -- Noncompliant {{Remove those useless parenthesis.}}
-- ^^^^^^^
-- valid
var := (x = 1);
var := ((x = 1) or (y = 2));
end;
================================================
FILE: zpa-checks/src/test/resources/checks/variable_hiding.sql
================================================
declare
var number;
var2 number;
var3 number;
exc exception;
"QUOTEDVAR" number;
procedure test is
var number; -- Noncompliant {{This variable "VAR" hides the declaration on line 2.}} [[secondary=2]]
-- ^^^
begin
null;
end;
function test return number is
var2 number; -- Noncompliant {{This variable "VAR2" hides the declaration on line 3.}} [[secondary=3]]
-- ^^^^
begin
null;
end;
procedure test2 is
exc exception; -- Noncompliant {{This variable "EXC" hides the declaration on line 5.}} [[secondary=5]]
-- ^^^
begin
null;
end;
begin
declare
var3 number; -- Noncompliant {{This variable "VAR3" hides the declaration on line 4.}} [[secondary=4]]
-- ^^^^
quotedvar number; -- Noncompliant {{This variable "QUOTEDVAR" hides the declaration on line 6.}} [[secondary=6]]
"QuotedVar" number; -- this is a different variable
begin
null;
end;
end;
/
create package body test is
var number;
procedure test is
var number; -- Noncompliant {{This variable "VAR" hides the declaration on line 42.}} [[secondary=42]]
-- ^^^
begin
for i in 1..10 loop
declare
i number; -- Noncompliant {{This variable "I" hides the declaration on line 48.}} [[secondary=48]]
-- ^
begin
null;
end;
end loop;
end;
end;
/
create package test2 is
var number;
exc exception;
end;
/
create package body test2 is
var number; -- Noncompliant {{This variable "VAR" hides the declaration on line 61.}} [[secondary=61]]
exc exception; -- Noncompliant {{This variable "EXC" hides the declaration on line 62.}} [[secondary=62]]
end;
/
-- correct
declare
outer_var number;
"VAR2" number; --|
"Var2" number; --| These variables are not the same
"var2" number; --|
begin
declare
var number;
begin
null;
end;
declare
var number;
begin
null;
end;
end;
/
================================================
FILE: zpa-checks/src/test/resources/checks/variable_in_count.sql
================================================
declare
foo number;
begin
select count(foo) -- Noncompliant {{Looks like there is a "foo" variable in this context. Review if this COUNT is correct.}}
-- ^^^^^^^^^^
from tab;
-- don't report an error here, we don't have enough information to know if "bar" is a variable or a column of table "tab"
select count(bar)
from tab;
select count(foo, bar), -- the COUNT function has only 1 parameter, so this isn't the Oracle built-in
my_count(foo),
pack.count(foo)
from tab;
bar := count(foo); -- the Oracle built-in can't be used here
end;
select count(foo) from dual; -- we don't have a scope here
================================================
FILE: zpa-checks/src/test/resources/checks/variable_initialization_with_function_call.sql
================================================
create procedure foo(bar in varchar2 default func(x)) is
var1 varchar2(1) default func(x); -- Noncompliant {{Move this initialization to the BEGIN...END block.}}
var2 varchar2(1) := func(x); -- Noncompliant
var3 json := json(); -- Compliant
type rec is record (field varchar2(1) default func(x));
cursor cur(param in varchar2 default func(x)) is
select 1 from dual;
begin
null;
end;
================================================
FILE: zpa-checks/src/test/resources/checks/variable_initialization_with_null.sql
================================================
create procedure foo(bar in varchar2 default null) is -- parameter declaration, no issue
var1 varchar2(1) default null; -- Noncompliant {{Remove this unnecessary initialization to NULL.}}
var2 varchar2(1) default ''; -- Noncompliant
var3 varchar2(1) := null; -- Noncompliant
var4 varchar2(1) := ''; -- Noncompliant
type rec is record (field varchar2(1) default null); -- Noncompliant
cursor cur(param in varchar2 default null) is -- cursor parameter, no issue
select 1 from dual;
begin
null;
end;
================================================
FILE: zpa-checks/src/test/resources/checks/variable_name.sql
================================================
declare
employee_name varchar2(100);
employee_name_ varchar2(100); -- Noncompliant
--^^^^^^^^^^^^^^
begin
null;
end;
================================================
FILE: zpa-checks/src/test/resources/checks/variable_name_alternative.sql
================================================
declare
employee_name varchar2(100);
e varchar2(100); -- Noncompliant
--^
begin
null;
end;
================================================
FILE: zpa-checks/src/test/resources/checks/xpath.sql
================================================
begin
null;
end;
================================================
FILE: zpa-checks/src/test/resources/checks/xpath_count_statement.sql
================================================
-- Noncompliant@-1 {{Avoid statements}}
begin
null;
end;
================================================
FILE: zpa-checks/src/test/resources/checks/xpath_statement.sql
================================================
begin
null; -- Noncompliant {{Avoid statements}}
--^^^^^
end;
================================================
FILE: zpa-checks-testkit/build.gradle.kts
================================================
plugins {
id("com.felipebz.zpa.build-conventions")
}
dependencies {
compileOnly(project(":zpa-core"))
}
description = "ZPA Checks TestKit"
================================================
FILE: zpa-checks-testkit/src/main/kotlin/com/felipebz/zpa/checks/verifier/PlSqlCheckVerifier.kt
================================================
/**
* Z PL/SQL Analyzer
* Copyright (C) 2015-2026 Felipe Zorzo
* mailto:felipe AT felipezorzo DOT com DOT br
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package com.felipebz.zpa.checks.verifier
import com.felipebz.flr.api.Trivia
import com.felipebz.zpa.TestPlSqlVisitorRunner
import com.felipebz.zpa.metadata.FormsMetadata
import com.felipebz.zpa.symbols.DefaultTypeSolver
import com.felipebz.zpa.symbols.ScopeImpl
import com.felipebz.zpa.symbols.SymbolVisitor
import com.felipebz.zpa.api.checks.PlSqlCheck
import java.io.File
class PlSqlCheckVerifier : PlSqlCheck() {
private val expectedIssues = ArrayList()
override fun visitComment(trivia: Trivia, content: String) {
val text = content.trim { it <= ' ' }
val marker = "Noncompliant"
if (text.startsWith(marker)) {
var issueLine = trivia.token.line
var paramsAndMessage = text.substring(marker.length).trim { it <= ' ' }
if (paramsAndMessage.startsWith("@")) {
val spaceSplit = paramsAndMessage.split("[\\s\\[{]".toRegex(), 2).toTypedArray()
val shiftValue = spaceSplit[0]
if (shiftValue[1] != '+' && shiftValue[1] != '-') {
throw AssertionError("Use only '@+N' or '@-N' to shifts messages.")
}
issueLine += Integer.valueOf(shiftValue.substring(1))
paramsAndMessage = if (spaceSplit.size > 1) spaceSplit[1] else ""
}
val issue = TestIssue(null, issueLine)
if (paramsAndMessage.startsWith("{{")) {
val endIndex = paramsAndMessage.indexOf("}}")
val message = paramsAndMessage.substring(2, endIndex)
issue.message = message
paramsAndMessage = paramsAndMessage.substring(endIndex + 2).trim { it <= ' ' }
}
if (paramsAndMessage.startsWith("[[")) {
val endIndex = paramsAndMessage.indexOf("]]")
addParams(issue, paramsAndMessage.substring(2, endIndex))
}
expectedIssues.add(issue)
} else if (text.startsWith("^")) {
addPreciseLocation(trivia)
}
}
private fun addPreciseLocation(trivia: Trivia) {
val token = trivia.token
val line = token.line
val text = token.value
if (token.column > 1) {
throw IllegalStateException("Line $line: comments asserting a precise location should start at column 1")
}
val missingAssertionMessage = "Invalid test file: a precise location is provided at line $line but no issue is asserted at line ${line - 1}"
if (expectedIssues.isEmpty()) {
throw IllegalStateException(missingAssertionMessage)
}
val issue = expectedIssues[expectedIssues.size - 1]
if (issue.line != line - 1) {
throw IllegalStateException(missingAssertionMessage)
}
issue.endLine = issue.line
issue.startColumn = text.indexOf('^') + 1
issue.endColumn = text.lastIndexOf('^') + 2
}
companion object {
@JvmStatic
@JvmOverloads
fun verify(path: String, check: PlSqlCheck, metadata: FormsMetadata? = null) {
val verifier = PlSqlCheckVerifier()
val file = File(path)
TestPlSqlVisitorRunner.scanFile(file, metadata, SymbolVisitor(DefaultTypeSolver(), ScopeImpl()), verifier, check)
val issues = check.issues()
val actualIssues = issues.sortedBy { it.primaryLocation().startLine() }.iterator()
val expectedIssues = verifier.expectedIssues.sortedBy { it.line }
for (expected in expectedIssues) {
if (actualIssues.hasNext()) {
verifyIssue(expected, actualIssues.next())
} else {
throw AssertionError("Missing issue at line ${expected.line}")
}
}
if (actualIssues.hasNext()) {
val issue = actualIssues.next()
throw AssertionError("Unexpected issue at line ${line(issue)}: \"${issue.primaryLocation().message()}\"")
}
}
private fun verifyIssue(expected: TestIssue, actual: PreciseIssue) {
if (line(actual) > expected.line) {
throw AssertionError("Missing issue at line ${expected.line}")
}
if (line(actual) < expected.line) {
throw AssertionError("Unexpected issue at line ${line(actual)}: \"${actual.primaryLocation().message()}\"")
}
assertEquals(expected.message, actual.primaryLocation().message(), "Bad message at line ${expected.line}")
assertEquals(expected.effortToFix, actual.cost(), "Bad effortToFix at line ${expected.line}")
assertEquals(expected.startColumn, actual.primaryLocation().startLineOffset() + 1, "Bad start column at line ${expected.line}")
assertEquals(expected.endColumn, actual.primaryLocation().endLineOffset() + 1, "Bad end column at line ${expected.line}")
assertEquals(expected.endLine, actual.primaryLocation().endLine(), "Bad end line at line ${expected.line}")
assertEquals(expected.secondaryLines, secondary(actual), "Bad secondary locations at line ${expected.line}")
}
private fun assertEquals(expected: Any?, actual: Any?, message: String) {
if (expected != null && expected != actual) {
throw AssertionError("$message ==> expected: \"${expected}\" but was: \"${actual}\"")
}
}
private fun secondary(issue: PreciseIssue): List {
val result = ArrayList()
for (issueLocation in issue.secondaryLocations()) {
result.add(issueLocation.startLine())
}
return result.sorted()
}
private fun line(issue: PreciseIssue): Int {
return issue.primaryLocation().startLine()
}
private fun addParams(issue: TestIssue, params: String) {
for (param in params.split(';')) {
val equalIndex = param.indexOf('=')
if (equalIndex == -1) {
throw IllegalStateException("Invalid param at line 1: $param")
}
val name = param.substring(0, equalIndex)
val value = param.substring(equalIndex + 1)
when {
"effortToFix".equals(name, ignoreCase = true) -> issue.effortToFix = Integer.valueOf(value)
"sc".equals(name, ignoreCase = true) -> issue.startColumn = Integer.valueOf(value)
"ec".equals(name, ignoreCase = true) -> issue.endColumn = Integer.valueOf(value)
"el".equals(name, ignoreCase = true) -> issue.endLine = lineValue(issue.line, value)
"secondary".equals(name, ignoreCase = true) -> addSecondaryLines(issue, value)
else -> throw IllegalStateException("Invalid param at line 1: $name")
}
}
}
private fun addSecondaryLines(issue: TestIssue, value: String) {
val secondaryLines = ArrayList()
if ("" != value) {
for (secondary in value.split(',')) {
secondaryLines.add(lineValue(issue.line, secondary))
}
}
issue.secondaryLines = secondaryLines
}
private fun lineValue(baseLine: Int, shift: String): Int {
if (shift.startsWith("+")) {
return baseLine + Integer.valueOf(shift.substring(1))
}
return if (shift.startsWith("-")) {
baseLine - Integer.valueOf(shift.substring(1))
} else Integer.valueOf(shift)
}
}
}
================================================
FILE: zpa-checks-testkit/src/main/kotlin/com/felipebz/zpa/checks/verifier/TestIssue.kt
================================================
/**
* Z PL/SQL Analyzer
* Copyright (C) 2015-2026 Felipe Zorzo
* mailto:felipe AT felipezorzo DOT com DOT br
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package com.felipebz.zpa.checks.verifier
internal class TestIssue constructor(var message: String?, val line: Int) {
var effortToFix: Int? = null
var startColumn: Int? = null
var endColumn: Int? = null
var endLine: Int? = null
var secondaryLines: List? = null
override fun toString() = "$message[line=$line]"
}
================================================
FILE: zpa-checks-testkit/src/test/kotlin/com/felipebz/zpa/checks/verifier/PlSqlCheckVerifierTest.kt
================================================
/**
* Z PL/SQL Analyzer
* Copyright (C) 2015-2026 Felipe Zorzo
* mailto:felipe AT felipezorzo DOT com DOT br
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package com.felipebz.zpa.checks.verifier
import com.felipebz.flr.api.AstNode
import com.felipebz.flr.api.GenericTokenType
import com.felipebz.flr.api.Token
import org.assertj.core.api.Assertions.assertThat
import org.junit.jupiter.api.Test
import org.junit.jupiter.api.fail
import com.felipebz.zpa.checks.IssueLocation
import com.felipebz.zpa.squid.AnalysisException
import com.felipebz.zpa.api.checks.PlSqlCheck
class PlSqlCheckVerifierTest {
@Test
fun verify_line_issues() {
val visitor = FakeCheck().withDefaultIssues()
PlSqlCheckVerifier.verify(FILENAME_ISSUES, visitor)
}
@Test
fun verify_unexpected_issue() {
val visitor = FakeCheck().withDefaultIssues().withIssue(4, "extra message")
try {
PlSqlCheckVerifier.verify(FILENAME_ISSUES, visitor)
fail("Test should fail")
} catch (e: AssertionError) {
assertThat(e).hasMessage("Unexpected issue at line 4: \"extra message\"")
}
}
@Test
fun verify_combined_missing_expected_and_unexpected_issues() {
val visitor = FakeCheck().withDefaultIssues().withIssue(4, "extra message")
.withoutIssue(1)
try {
PlSqlCheckVerifier.verify(FILENAME_ISSUES, visitor)
fail("Test should fail")
} catch (e: AssertionError) {
assertThat(e).hasMessage("Missing issue at line 1")
}
}
@Test
fun verify_missing_expected_issue() {
val visitor = FakeCheck().withDefaultIssues().withoutIssue(1)
try {
PlSqlCheckVerifier.verify(FILENAME_ISSUES, visitor)
fail("Test should fail")
} catch (e: AssertionError) {
assertThat(e).hasMessage("Missing issue at line 1")
}
}
@Test
fun verify_no_issue() {
PlSqlCheckVerifier.verify(FILENAME_NO_ISSUE, noEffectCheck)
}
@Test
fun verify_should_fail_when_using_incorrect_shift() {
try {
PlSqlCheckVerifier.verify("src/test/resources/check_verifier_incorrect_shift.sql", noEffectCheck)
fail("Test should fail")
} catch (e: AssertionError) {
assertThat(e).hasMessage("Use only '@+N' or '@-N' to shifts messages.")
}
}
@Test
fun verify_should_fail_when_using_incorrect_attribute() {
try {
PlSqlCheckVerifier.verify("src/test/resources/check_verifier_incorrect_attribute.sql",
noEffectCheck)
fail("Test should fail")
} catch (e: AnalysisException) {
assertThat(e).hasMessage("Error executing checks on file check_verifier_incorrect_attribute.sql: Invalid param at line 1: invalid")
}
}
@Test
fun verify_should_fail_when_using_incorrect_attribute2() {
try {
PlSqlCheckVerifier.verify("src/test/resources/check_verifier_incorrect_attribute2.sql",
noEffectCheck)
fail("Test should fail")
} catch (e: AnalysisException) {
assertThat(e).hasMessage("Error executing checks on file check_verifier_incorrect_attribute2.sql: Invalid param at line 1: invalid")
}
}
@Test
fun verify_should_fail_when_using_incorrect_secondaryLocation() {
val visitor = FakeCheck().withDefaultIssues()
try {
PlSqlCheckVerifier.verify("src/test/resources/check_verifier_incorrect_secondary_location.sql", visitor)
fail("Test should fail")
} catch (e: AssertionError) {
assertThat(e).hasMessage("Bad secondary locations at line 8 ==> expected: \"[4]\" but was: \"[3, 4]\"")
}
}
@Test
fun verify_should_fail_when_using_incorrect_secondaryLocation2() {
val visitor = FakeCheck().withDefaultIssues()
try {
PlSqlCheckVerifier.verify("src/test/resources/check_verifier_incorrect_secondary_location2.sql", visitor)
fail("Test should fail")
} catch (e: AssertionError) {
assertThat(e).hasMessage("Bad secondary locations at line 8 ==> expected: \"[3, 4, 5]\" but was: \"[3, 4]\"")
}
}
@Test
fun verify_should_fail_when_precision_location_comment_is_invalid() {
try {
PlSqlCheckVerifier.verify("src/test/resources/check_verifier_incorrect_comment.sql", FakeCheck())
fail("Test should fail")
} catch (e: AnalysisException) {
assertThat(e).hasMessage("Error executing checks on file check_verifier_incorrect_comment.sql: Line 3: comments asserting a precise location should start at column 1")
}
}
@Test
fun verify_unexpected_precise_location() {
try {
PlSqlCheckVerifier.verify("src/test/resources/check_verifier_unexpected_precise_location.sql", FakeCheck())
} catch (e: AnalysisException) {
assertThat(e).hasMessage("Error executing checks on file check_verifier_unexpected_precise_location.sql: Invalid test file: a precise location is provided at line 3 but no issue is asserted at line 2")
}
}
@Test
fun verify_unexpected_precise_location2() {
try {
PlSqlCheckVerifier.verify("src/test/resources/check_verifier_unexpected_precise_location2.sql", FakeCheck())
} catch (e: AnalysisException) {
assertThat(e).hasMessage("Error executing checks on file check_verifier_unexpected_precise_location2.sql: Invalid test file: a precise location is provided at line 3 but no issue is asserted at line 2")
}
}
private class FakeCheck : PlSqlCheck() {
var issues = hashMapOf>()
var preciseIssues = linkedMapOf>()
fun withDefaultIssues(): FakeCheck {
return this.withIssue(1, "message")
.withIssue(2, "message1")
.withIssue(5, "message2")
.withIssue(6, "message3")
.withIssue(6, "message3")
.withPreciseIssue(
IssueLocation.preciseLocation(mockNode(8, 9, 8, 10), "message4"),
IssueLocation.atLineLevel("no message", 3),
IssueLocation.atLineLevel("no message", 4)
)
.withPreciseIssue(IssueLocation.atLineLevel("no message", 9))
.withPreciseIssue(IssueLocation.preciseLocation(mockNode(11, 5, 12, 11), "message12"))
.withIssue(14, "message17")
.withPreciseIssue(IssueLocation.preciseLocation(mockNode(15, 5, 15, 9), "baseline"))
}
fun withIssue(line: Int, message: String) = apply {
issues.getOrPut(line) { mutableListOf() }.add(message)
}
fun withPreciseIssue(vararg message: IssueLocation) = apply {
preciseIssues.getOrPut(message[0].startLine()) { mutableListOf() }.addAll(message.toList())
}
fun withoutIssue(line: Int) = apply {
issues.remove(line)
preciseIssues.remove(line)
}
override fun visitFile(node: AstNode) {
for ((line, messages) in issues) {
for (message in messages) {
addLineIssue(message, line)
}
}
for (locations in preciseIssues.values) {
var issue: PreciseIssue? = null
for (location in locations) {
if (issue == null) {
issue = addIssue(location).withCost(3)
} else {
issue.secondary(location)
}
}
}
}
fun mockNode(startLine: Int, startCharacter: Int, endLine: Int, endCharacter: Int): AstNode {
val token = Token.builder()
.setLine(startLine)
.setColumn(startCharacter - 1)
.setValueAndOriginalValue("")
.setType(GenericTokenType.IDENTIFIER)
.build()
val lastToken = Token.builder()
.setLine(endLine)
.setColumn(endCharacter - 1)
.setValueAndOriginalValue("")
.setType(GenericTokenType.IDENTIFIER)
.build()
val node = AstNode(token)
node.addChild(AstNode(token))
node.addChild(AstNode(lastToken))
return node
}
}
companion object {
private const val FILENAME_ISSUES = "src/test/resources/check_verifier.sql"
private const val FILENAME_NO_ISSUE = "src/test/resources/check_verifier_no_issue.sql"
private val noEffectCheck: PlSqlCheck
get() = object : PlSqlCheck() { }
}
}
================================================
FILE: zpa-checks-testkit/src/test/resources/check_verifier.sql
================================================
create procedure a is -- Noncompliant {{message}}
i integer; -- Noncompliant {{message1}}
begin -- test method
-- Noncompliant@+1 {{message2}}
null;
null;
-- Noncompliant@-1 {{message3}}
null; -- Noncompliant {{message4}} [[sc=9;ec=10;secondary=3,4]] bla bla bla
null; -- Noncompliant
-- Noncompliant@-4
func(foo, -- Noncompliant [[sc=5;el=+1;ec=11;effortToFix=3]]
bar);
-- Noncompliant@+1 blabla
null;
null; -- Noncompliant {{baseline}}
-- ^^^^
end;
/
================================================
FILE: zpa-checks-testkit/src/test/resources/check_verifier_incorrect_attribute.sql
================================================
begin
null; -- Noncompliant [[invalid=1]] {{message}}
end;
/
================================================
FILE: zpa-checks-testkit/src/test/resources/check_verifier_incorrect_attribute2.sql
================================================
begin
null; -- Noncompliant [[invalid=1=2]] {{message}}
end;
/
================================================
FILE: zpa-checks-testkit/src/test/resources/check_verifier_incorrect_comment.sql
================================================
begin
null; -- Noncompliant
-- ^
end;
/
================================================
FILE: zpa-checks-testkit/src/test/resources/check_verifier_incorrect_secondary_location.sql
================================================
create procedure a is -- Noncompliant {{message}}
i integer; -- Noncompliant {{message1}}
begin -- test method
-- Noncompliant@+1 {{message2}}
null;
null;
-- Noncompliant@-1 {{message3}}
null; -- Noncompliant {{message4}} [[sc=9;ec=10;secondary=4]] bla bla bla
null; -- Noncompliant
-- Noncompliant@-4
func(foo, -- Noncompliant [[sc=5;el=+1;ec=11]]
bar);
-- Noncompliant@+1 blabla
null;
end;
/
================================================
FILE: zpa-checks-testkit/src/test/resources/check_verifier_incorrect_secondary_location2.sql
================================================
create procedure a is -- Noncompliant {{message}}
i integer; -- Noncompliant {{message1}}
begin -- test method
-- Noncompliant@+1 {{message2}}
null;
null;
-- Noncompliant@-1 {{message3}}
null; -- Noncompliant {{message4}} [[sc=9;ec=10;secondary=3,4,5]] bla bla bla
null; -- Noncompliant
-- Noncompliant@-4
func(foo, -- Noncompliant [[sc=5;el=+1;ec=11]]
bar);
-- Noncompliant@+1 blabla
null;
end;
/
================================================
FILE: zpa-checks-testkit/src/test/resources/check_verifier_incorrect_shift.sql
================================================
begin
null; -- Noncompliant@#1 {{message}}
end;
/
================================================
FILE: zpa-checks-testkit/src/test/resources/check_verifier_no_issue.sql
================================================
begin
null;
end;
/
================================================
FILE: zpa-checks-testkit/src/test/resources/check_verifier_unexpected_precise_location.sql
================================================
begin
null;
--^^^^
end;
/
================================================
FILE: zpa-checks-testkit/src/test/resources/check_verifier_unexpected_precise_location2.sql
================================================
begin -- Noncompliant
null;
--^^^^
end;
/
================================================
FILE: zpa-core/build.gradle.kts
================================================
plugins {
id("com.felipebz.zpa.build-conventions")
}
dependencies {
api(libs.flr.core)
implementation(libs.jackson)
testImplementation(libs.flr.testing.harness)
}
description = "ZPA Core"
================================================
FILE: zpa-core/src/main/kotlin/com/felipebz/zpa/AstNodeExtensions.kt
================================================
/**
* Z PL/SQL Analyzer
* Copyright (C) 2015-2026 Felipe Zorzo
* mailto:felipe AT felipezorzo DOT com DOT br
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package com.felipebz.zpa
import com.felipebz.flr.api.AstNode
import com.felipebz.flr.api.AstNodeType
import com.felipebz.zpa.sslr.Tree
import com.felipebz.zpa.api.squid.SemanticAstNode
fun AstNode?.typeIs(type: AstNodeType): Boolean = this?.type == type
fun AstNode?.typeIs(types: Array): Boolean =
types.any { it == this?.type }
inline fun AstNode.asTree(): T =
this.asSemantic().tree as T
inline fun AstNode.tryGetAsTree(): T? =
this.asSemantic().tree as? T
inline fun List.asTree(): List =
this.asSemantic().map { it.tree as T }
inline fun AstNode.isOf(): Boolean =
this.asSemantic().tree is T
fun AstNode.asSemantic(): SemanticAstNode = (this as SemanticAstNode)
fun List.asSemantic(): List =
this.map { it.asSemantic() }
================================================
FILE: zpa-core/src/main/kotlin/com/felipebz/zpa/CustomAnnotationBasedRulesDefinition.kt
================================================
/**
* Z PL/SQL Analyzer
* Copyright (C) 2015-2026 Felipe Zorzo
* mailto:felipe AT felipezorzo DOT com DOT br
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package com.felipebz.zpa
import com.felipebz.zpa.rules.RuleMetadataLoader
import com.felipebz.zpa.rules.RulesDefinitionAnnotationLoader
import com.felipebz.zpa.rules.ZpaRepository
import com.felipebz.zpa.rules.ZpaRule
import com.felipebz.zpa.utils.getAnnotation
import com.felipebz.zpa.api.annotations.ActivatedByDefault
import com.felipebz.zpa.api.annotations.ConstantRemediation
import com.felipebz.zpa.api.annotations.RuleInfo
import com.felipebz.zpa.api.annotations.RuleTemplate
import java.io.IOException
import java.net.URL
import java.util.*
class CustomAnnotationBasedRulesDefinition(private val repository: ZpaRepository,
private val languageKey: String,
private val ruleMetadataLoader: RuleMetadataLoader) {
private val locale: Locale = Locale.getDefault()
private val externalDescriptionBasePath: String = String.format("%s/rules/plsql",
getLocalizedFolderName(String.format("/org/sonar/l10n/%s", languageKey), locale))
fun addRuleClasses(ruleClasses: Iterable>) {
val loader = RulesDefinitionAnnotationLoader(ruleMetadataLoader)
for (annotatedClass in ruleClasses) {
loader.load(repository, annotatedClass)
}
val newRules = ArrayList()
for (ruleClass in ruleClasses) {
val rule = newRule(ruleClass)
addHtmlDescription(rule)
rule.template = getAnnotation(ruleClass, RuleTemplate::class.java) != null
try {
val constant = getAnnotation(ruleClass, ConstantRemediation::class.java)
if (constant != null) {
rule.remediationConstant = constant.value
}
} catch (e: RuntimeException) {
throw IllegalArgumentException("Invalid remediation constant on $ruleClass", e)
}
val ruleInfo = getAnnotation(ruleClass, RuleInfo::class.java)
if (ruleInfo != null) {
rule.scope = ruleInfo.scope
}
val activatedByDefault = getAnnotation(ruleClass, ActivatedByDefault::class.java)
if (activatedByDefault != null) {
rule.isActivatedByDefault = true
}
newRules.add(rule)
}
setupExternalNames(newRules)
}
private fun addHtmlDescription(rule: ZpaRule) {
val resource = CustomAnnotationBasedRulesDefinition::class.java.getResource("$externalDescriptionBasePath/${rule.key}.html")
if (resource != null) {
addHtmlDescription(rule, resource)
}
}
private fun addHtmlDescription(rule: ZpaRule, resource: URL) {
try {
rule.htmlDescription = resource.readText()
} catch (e: IOException) {
throw IllegalStateException("Failed to read: $resource", e)
}
}
private fun newRule(ruleClass: Class<*>): ZpaRule {
val ruleKey = getRuleKey(ruleMetadataLoader, ruleClass)
return repository.rule(ruleKey) ?: throw IllegalStateException("Rule $ruleKey was not created")
}
private fun setupExternalNames(rules: Collection) {
val bundle: ResourceBundle
try {
bundle = ResourceBundle.getBundle("org.sonar.l10n.$languageKey", locale)
} catch (e: MissingResourceException) {
return
}
for (rule in rules) {
val baseKey = rule.key
val nameKey = "$baseKey.name"
if (bundle.containsKey(nameKey)) {
rule.name = bundle.getString(nameKey)
}
for (param in rule.params) {
val paramDescriptionKey = baseKey + ".param." + param.key
if (bundle.containsKey(paramDescriptionKey)) {
param.description = bundle.getString(paramDescriptionKey)
}
}
}
}
companion object {
/**
* Adds annotated rule classes to an instance of NewRepository. Fails if one of
* the classes has no SQALE annotation.
* @param repository repository of rules
* @param languageKey language identifier
* @param ruleClasses classes to add
*/
fun load(repository: ZpaRepository, languageKey: String, ruleClasses: Iterable>, ruleMetadataLoader: RuleMetadataLoader) {
CustomAnnotationBasedRulesDefinition(repository, languageKey, ruleMetadataLoader).addRuleClasses(ruleClasses)
}
fun getLocalizedFolderName(baseName: String, locale: Locale): String {
val control = ResourceBundle.Control.getControl(ResourceBundle.Control.FORMAT_DEFAULT)
var path = control.toBundleName(baseName, locale)
var url: URL? = CustomAnnotationBasedRulesDefinition::class.java.getResource(path)
if (url == null) {
val localeWithoutCountry = if (locale.country == null) locale else Locale(locale.language)
path = control.toBundleName(baseName, localeWithoutCountry)
url = CustomAnnotationBasedRulesDefinition::class.java.getResource(path)
if (url == null) {
path = baseName
CustomAnnotationBasedRulesDefinition::class.java.getResource(path)
}
}
return path
}
fun convertCheckClassName(ruleClass: Class<*>): String {
var name = ruleClass.simpleName
if (name.endsWith("Check")) {
name = name.substring(0, name.length - 5)
}
return name
}
fun getRuleKey(ruleMetadataLoader: RuleMetadataLoader, ruleClass: Class<*>): String {
val ruleAnnotation = ruleMetadataLoader.getRuleAnnotation(ruleClass)
?: throw IllegalArgumentException("No Rule annotation was found on $ruleClass")
return ruleAnnotation.key.ifEmpty { convertCheckClassName(ruleClass) }
}
}
}
================================================
FILE: zpa-core/src/main/kotlin/com/felipebz/zpa/FormsMetadataAwareCheck.kt
================================================
/**
* Z PL/SQL Analyzer
* Copyright (C) 2015-2026 Felipe Zorzo
* mailto:felipe AT felipezorzo DOT com DOT br
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package com.felipebz.zpa
// Marker interface to define checks that require Oracle Forms metadata
interface FormsMetadataAwareCheck
================================================
FILE: zpa-core/src/main/kotlin/com/felipebz/zpa/PlSqlChecks.kt
================================================
/**
* Z PL/SQL Analyzer
* Copyright (C) 2015-2026 Felipe Zorzo
* mailto:felipe AT felipezorzo DOT com DOT br
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package com.felipebz.zpa
import com.felipebz.zpa.rules.RuleMetadataLoader
import com.felipebz.zpa.rules.ZpaActiveRules
import com.felipebz.zpa.rules.ZpaChecks
import com.felipebz.zpa.rules.ZpaRuleKey
import com.felipebz.zpa.api.ZpaRulesDefinition
import com.felipebz.zpa.api.checks.PlSqlVisitor
class PlSqlChecks private constructor(private val activeRules: ZpaActiveRules, private val ruleMetadataLoader: RuleMetadataLoader) {
private val checksByRepository = hashSetOf()
val checks: Set = checksByRepository
fun addChecks(repositoryKey: String, checkClass: Iterable>): PlSqlChecks {
checksByRepository.add(ZpaChecks(activeRules, repositoryKey, ruleMetadataLoader)
.addAnnotatedChecks(checkClass))
return this
}
fun addCustomChecks(customRulesDefinitions: Array?): PlSqlChecks {
if (customRulesDefinitions != null) {
for (rulesDefinition in customRulesDefinitions) {
addChecks(rulesDefinition.repositoryKey(), rulesDefinition.checkClasses().toList())
}
}
return this
}
fun all(): List {
val allVisitors = ArrayList()
for (checks in checksByRepository) {
allVisitors.addAll(checks.all())
}
return allVisitors
}
fun ruleKey(check: PlSqlVisitor): ZpaRuleKey? {
var ruleKey: ZpaRuleKey?
for (checks in checksByRepository) {
ruleKey = checks.ruleKey(check)
if (ruleKey != null) {
return ruleKey
}
}
return null
}
companion object {
fun createPlSqlCheck(activeRules: ZpaActiveRules, ruleMetadataLoader: RuleMetadataLoader): PlSqlChecks {
return PlSqlChecks(activeRules, ruleMetadataLoader)
}
}
}
================================================
FILE: zpa-core/src/main/kotlin/com/felipebz/zpa/TestPlSqlVisitorRunner.kt
================================================
/**
* Z PL/SQL Analyzer
* Copyright (C) 2015-2026 Felipe Zorzo
* mailto:felipe AT felipezorzo DOT com DOT br
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package com.felipebz.zpa
import com.felipebz.zpa.metadata.FormsMetadata
import com.felipebz.zpa.parser.PlSqlParser
import com.felipebz.zpa.squid.PlSqlAstWalker
import com.felipebz.zpa.squid.PlSqlConfiguration
import com.felipebz.zpa.api.PlSqlFile
import com.felipebz.zpa.api.PlSqlVisitorContext
import com.felipebz.zpa.api.checks.PlSqlVisitor
import java.io.File
import java.io.IOException
import java.nio.charset.StandardCharsets
import java.nio.file.Path
object TestPlSqlVisitorRunner {
fun scanFile(file: File, metadata: FormsMetadata?, vararg visitors: PlSqlVisitor) {
val context = createContext(TestPlSqlFile(file), metadata)
val walker = PlSqlAstWalker(visitors.toList())
walker.walk(context)
}
private fun createContext(plSqlFile: PlSqlFile, metadata: FormsMetadata?): PlSqlVisitorContext {
val parser = PlSqlParser.create(PlSqlConfiguration(StandardCharsets.UTF_8))
val rootTree = parser.parse(plSqlFile.contents())
return PlSqlVisitorContext(rootTree, plSqlFile, metadata)
}
private class TestPlSqlFile(private val file: File) : PlSqlFile {
override fun contents(): String =
try {
file.readText()
} catch (e: IOException) {
throw IllegalStateException("Cannot read $file", e)
}
override fun fileName(): String = file.name
override fun path(): Path = file.toPath()
override fun type(): PlSqlFile.Type = PlSqlFile.Type.MAIN
}
}
================================================
FILE: zpa-core/src/main/kotlin/com/felipebz/zpa/api/AggregateSqlFunctionsGrammar.kt
================================================
/**
* Z PL/SQL Analyzer
* Copyright (C) 2015-2026 Felipe Zorzo
* mailto:felipe AT felipezorzo DOT com DOT br
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package com.felipebz.zpa.api
import com.felipebz.flr.grammar.GrammarRuleKey
import com.felipebz.zpa.sslr.PlSqlGrammarBuilder
import com.felipebz.zpa.api.DmlGrammar.ORDER_BY_CLAUSE
import com.felipebz.zpa.api.PlSqlGrammar.EXPRESSION
import com.felipebz.zpa.api.PlSqlKeyword.*
import com.felipebz.zpa.api.PlSqlPunctuator.*
enum class AggregateSqlFunctionsGrammar : GrammarRuleKey {
LISTAGG_EXPRESSION,
XMLAGG_EXPRESSION,
COLLECT_EXPRESSION,
JSON_ARRAYAGG_EXPRESSION,
JSON_OBJECTAGG_EXPRESSION,
AGGREGATE_SQL_FUNCTION;
companion object {
fun buildOn(b: PlSqlGrammarBuilder) {
b.rule(LISTAGG_EXPRESSION).define(
LISTAGG,
LPARENTHESIS, b.optional(b.firstOf(ALL, DISTINCT)), EXPRESSION, b.optional(COMMA, EXPRESSION),
b.optional(ON, OVERFLOW, b.firstOf(
ERROR,
b.sequence(TRUNCATE, b.optional(EXPRESSION), b.optional(b.firstOf(WITH, WITHOUT), COUNT)))),
RPARENTHESIS,
WITHIN, GROUP, LPARENTHESIS, DmlGrammar.ORDER_BY_CLAUSE, RPARENTHESIS)
b.rule(XMLAGG_EXPRESSION).define(
XMLAGG, LPARENTHESIS,
EXPRESSION, b.optional(ORDER_BY_CLAUSE),
RPARENTHESIS
)
b.rule(COLLECT_EXPRESSION).define(
COLLECT, LPARENTHESIS,
b.optional(b.firstOf(DISTINCT, UNIQUE)),
EXPRESSION,
b.optional(ORDER, BY, EXPRESSION),
RPARENTHESIS
)
b.rule(JSON_ARRAYAGG_EXPRESSION).define(
JSON_ARRAYAGG, LPARENTHESIS,
EXPRESSION, b.optional(FORMAT, JSON),
b.optional(ORDER_BY_CLAUSE),
b.optional(SingleRowSqlFunctionsGrammar.JSON_ON_NULL_CLAUSE),
b.optional(SingleRowSqlFunctionsGrammar.JSON_RETURNING_CLAUSE),
b.optional(STRICT),
RPARENTHESIS
)
b.rule(JSON_OBJECTAGG_EXPRESSION).define(
JSON_OBJECTAGG, LPARENTHESIS,
b.optional(KEY), EXPRESSION, VALUE, EXPRESSION,
b.optional(FORMAT, JSON),
b.optional(SingleRowSqlFunctionsGrammar.JSON_ON_NULL_CLAUSE),
b.optional(SingleRowSqlFunctionsGrammar.JSON_RETURNING_CLAUSE),
b.optional(STRICT),
b.optional(WITH, UNIQUE, KEYS),
RPARENTHESIS
)
b.rule(AGGREGATE_SQL_FUNCTION).define(
b.firstOf(
LISTAGG_EXPRESSION,
XMLAGG_EXPRESSION,
COLLECT_EXPRESSION,
JSON_ARRAYAGG_EXPRESSION,
JSON_OBJECTAGG_EXPRESSION
)
)
}
}
}
================================================
FILE: zpa-core/src/main/kotlin/com/felipebz/zpa/api/ConditionsGrammar.kt
================================================
/**
* Z PL/SQL Analyzer
* Copyright (C) 2015-2026 Felipe Zorzo
* mailto:felipe AT felipezorzo DOT com DOT br
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package com.felipebz.zpa.api
import com.felipebz.flr.grammar.GrammarRuleKey
import com.felipebz.zpa.sslr.PlSqlGrammarBuilder
import com.felipebz.zpa.api.PlSqlGrammar.*
import com.felipebz.zpa.api.PlSqlKeyword.*
enum class ConditionsGrammar : GrammarRuleKey {
// internal
RELATIONAL_OPERATOR,
IS_JSON_ARGS,
JSON_MODIFIER_LIST,
JSON_COLUMN_MODIFIER,
JSON_SCALAR_MODIFIER,
JSON_EQUAL_ON_ERROR_CLAUSE,
JSON_EXISTS_ON_EMPTY_CLAUSE,
JSON_EXISTS_ON_ERROR_CLAUSE,
// conditions
RELATIONAL_CONDITION,
BOOLEAN_TEST_CONDITION,
LIKE_CONDITION,
BETWEEN_CONDITION,
MULTISET_CONDITION,
IS_A_SET_CONDITION,
IS_EMPTY_CONDITION,
MEMBER_CONDITION,
SUBMULTISET_CONDITION,
IS_OF_CONDITION,
IS_JSON_CONDITION,
JSON_EQUAL_CONDITION,
JSON_EXISTS_CONDITION,
JSON_TEXTCONTAINS_CONDITION,
CONDITION;
companion object {
fun buildOn(b: PlSqlGrammarBuilder) {
b.rule(RELATIONAL_OPERATOR).define(
b.firstOf(
PlSqlGrammar.EQUALS_OPERATOR,
PlSqlGrammar.NOTEQUALS_OPERATOR,
PlSqlGrammar.LESSTHANOREQUALS_OPERATOR,
PlSqlGrammar.LESSTHAN_OPERATOR,
PlSqlGrammar.GREATERTHANOREQUALS_OPERATOR,
PlSqlGrammar.GREATERTHAN_OPERATOR
),
b.optional(b.firstOf(ANY, SOME, ALL))
)
b.rule(RELATIONAL_CONDITION).define(
CONCATENATION_EXPRESSION, RELATIONAL_OPERATOR, CONCATENATION_EXPRESSION
).skip()
b.rule(BOOLEAN_TEST_CONDITION).define(
CONCATENATION_EXPRESSION, IS, b.optional(NOT), b.firstOf(NULL_LITERAL, PlSqlGrammar.BOOLEAN_LITERAL)
)
b.rule(LIKE_CONDITION).define(
CONCATENATION_EXPRESSION,
b.optional(NOT), LIKE,
CONCATENATION_EXPRESSION,
b.optional(ESCAPE, CONCATENATION_EXPRESSION)
)
b.rule(BETWEEN_CONDITION).define(
CONCATENATION_EXPRESSION,
b.optional(NOT), BETWEEN,
CONCATENATION_EXPRESSION, AND, CONCATENATION_EXPRESSION
).skip()
b.rule(IS_A_SET_CONDITION).define(CONCATENATION_EXPRESSION, IS, b.optional(NOT), A, SET)
b.rule(IS_EMPTY_CONDITION).define(CONCATENATION_EXPRESSION, IS, b.optional(NOT), EMPTY)
b.rule(MEMBER_CONDITION)
.define(CONCATENATION_EXPRESSION, b.optional(NOT), MEMBER, b.optional(OF), CONCATENATION_EXPRESSION)
.skip()
b.rule(SUBMULTISET_CONDITION).define(
CONCATENATION_EXPRESSION,
b.optional(NOT),
SUBMULTISET,
b.optional(OF),
CONCATENATION_EXPRESSION
)
//https://docs.oracle.com/cloud/latest/db112/SQLRF/conditions006.htm#SQLRF52128
b.rule(MULTISET_CONDITION).define(
b.firstOf(
IS_A_SET_CONDITION,
IS_EMPTY_CONDITION,
MEMBER_CONDITION,
SUBMULTISET_CONDITION
)
)
b.rule(IS_OF_CONDITION).define(
CONCATENATION_EXPRESSION,
IS,
b.optional(NOT),
OF,
b.optional(TYPE),
PlSqlPunctuator.LPARENTHESIS,
b.optional(ONLY),
OBJECT_REFERENCE,
b.zeroOrMore(PlSqlPunctuator.COMMA, b.optional(ONLY), OBJECT_REFERENCE),
PlSqlPunctuator.RPARENTHESIS
)
b.rule(IS_JSON_CONDITION).define(
CONCATENATION_EXPRESSION,
IS,
b.optional(NOT),
JSON,
b.optional(JSON_MODIFIER_LIST),
IS_JSON_ARGS
)
b.rule(IS_JSON_ARGS).define(
b.firstOf(
b.sequence(
VALIDATE, b.optional(CAST), b.optional(USING), PlSqlTokenType.STRING_LITERAL
),
b.sequence(
b.optional(FORMAT, JSON),
b.optional(b.firstOf(STRICT, LAX)),
b.optional(b.firstOf(ALLOW, DISALLOW), SCALARS),
b.optional(b.firstOf(WITH, WITHOUT), UNIQUE, KEYS)
)
)
).skip()
b.rule(JSON_MODIFIER_LIST).define(
b.firstOf(
b.sequence(
PlSqlPunctuator.LPARENTHESIS,
JSON_COLUMN_MODIFIER,
b.zeroOrMore(PlSqlPunctuator.COMMA, JSON_COLUMN_MODIFIER),
PlSqlPunctuator.RPARENTHESIS
),
JSON_COLUMN_MODIFIER
)
)
b.rule(JSON_COLUMN_MODIFIER).define(
b.firstOf(
VALUE,
ARRAY,
OBJECT,
b.sequence(SCALAR, b.optional(JSON_SCALAR_MODIFIER))
)
)
b.rule(JSON_SCALAR_MODIFIER).define(
b.firstOf(
NUMBER,
STRING,
BINARY_DOUBLE,
BINARY_FLOAT,
DATE,
b.sequence(TIMESTAMP, b.optional(WITH, TIME, ZONE)),
NULL,
BOOLEAN,
BINARY,
b.sequence(INTERVAL, b.firstOf(b.sequence(YEAR, TO, MONTH), b.sequence(DAY, TO, SECOND)))
)
)
b.rule(JSON_EQUAL_CONDITION).define(
JSON_EQUAL,
PlSqlPunctuator.LPARENTHESIS,
PlSqlGrammar.EXPRESSION,
PlSqlPunctuator.COMMA,
PlSqlGrammar.EXPRESSION,
b.optional(JSON_EQUAL_ON_ERROR_CLAUSE),
PlSqlPunctuator.RPARENTHESIS
)
b.rule(JSON_EQUAL_ON_ERROR_CLAUSE).define(
b.firstOf(
ERROR,
TRUE,
FALSE
), ON, ERROR
)
b.rule(JSON_EXISTS_CONDITION).define(
JSON_EXISTS,
PlSqlPunctuator.LPARENTHESIS,
PlSqlGrammar.EXPRESSION,
b.optional(FORMAT, JSON),
PlSqlPunctuator.COMMA,
SingleRowSqlFunctionsGrammar.JSON_BASIC_PATH_EXPRESSION,
b.optional(SingleRowSqlFunctionsGrammar.JSON_PASSING_CLAUSE),
b.optional(JSON_EXISTS_ON_ERROR_CLAUSE),
b.optional(TYPE, b.firstOf(STRICT, LAX)),
b.optional(JSON_EXISTS_ON_EMPTY_CLAUSE),
PlSqlPunctuator.RPARENTHESIS
)
b.rule(JSON_EXISTS_ON_ERROR_CLAUSE).define(
b.firstOf(
ERROR,
TRUE,
FALSE
), ON, ERROR
)
b.rule(JSON_EXISTS_ON_EMPTY_CLAUSE).define(
b.firstOf(
ERROR,
TRUE,
FALSE
), ON, EMPTY
)
b.rule(JSON_TEXTCONTAINS_CONDITION).define(
JSON_TEXTCONTAINS,
PlSqlPunctuator.LPARENTHESIS,
PlSqlGrammar.EXPRESSION,
PlSqlPunctuator.COMMA,
SingleRowSqlFunctionsGrammar.JSON_BASIC_PATH_EXPRESSION,
PlSqlPunctuator.COMMA,
PlSqlGrammar.EXPRESSION,
PlSqlPunctuator.RPARENTHESIS
)
b.rule(CONDITION).define(
b.firstOf(
RELATIONAL_CONDITION,
BOOLEAN_TEST_CONDITION,
LIKE_CONDITION,
BETWEEN_CONDITION,
MULTISET_CONDITION,
IS_JSON_CONDITION,
IS_OF_CONDITION,
JSON_EQUAL_CONDITION,
JSON_EXISTS_CONDITION,
JSON_TEXTCONTAINS_CONDITION
)
).skip()
}
}
}
================================================
FILE: zpa-core/src/main/kotlin/com/felipebz/zpa/api/DclGrammar.kt
================================================
/**
* Z PL/SQL Analyzer
* Copyright (C) 2015-2026 Felipe Zorzo
* mailto:felipe AT felipezorzo DOT com DOT br
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package com.felipebz.zpa.api
import com.felipebz.flr.api.GenericTokenType
import com.felipebz.flr.grammar.GrammarRuleKey
import com.felipebz.zpa.sslr.PlSqlGrammarBuilder
import com.felipebz.zpa.api.PlSqlGrammar.IDENTIFIER_NAME
import com.felipebz.zpa.api.PlSqlGrammar.UNIT_NAME
import com.felipebz.zpa.api.PlSqlKeyword.*
import com.felipebz.zpa.api.PlSqlPunctuator.*
enum class DclGrammar : GrammarRuleKey {
IDENTIFIER_OR_KEYWORD,
GRANT_STATEMENT,
PRIVILEGE_PART,
PRIVILEGE_COLUMNS,
GRANT_SYSTEM_PRIVILEGES,
GRANT_OBJECT_PRIVILEGES,
GRANT_ROLES_TO_PROGRAMS,
DCL_COMMAND;
companion object {
fun buildOn(b: PlSqlGrammarBuilder) {
createDclCommands(b)
}
private fun createDclCommands(b: PlSqlGrammarBuilder) {
val keywords = PlSqlKeyword.entries
val rest = keywords.subList(1, keywords.size).toTypedArray()
b.rule(IDENTIFIER_OR_KEYWORD).define(b.firstOf(GenericTokenType.IDENTIFIER, keywords[0], *rest))
b.rule(PRIVILEGE_PART).define(b.nextNot(b.firstOf(COMMA, ON, TO, LPARENTHESIS)), IDENTIFIER_OR_KEYWORD)
b.rule(PRIVILEGE_COLUMNS).define(LPARENTHESIS, IDENTIFIER_NAME, b.zeroOrMore(COMMA, IDENTIFIER_NAME), RPARENTHESIS)
b.rule(GRANT_SYSTEM_PRIVILEGES).define(
b.oneOrMore(PRIVILEGE_PART),
b.zeroOrMore(COMMA, b.oneOrMore(PRIVILEGE_PART)),
TO, IDENTIFIER_OR_KEYWORD, b.zeroOrMore(COMMA, IDENTIFIER_OR_KEYWORD),
b.optional(IDENTIFIED, BY, b.anyToken(), b.zeroOrMore(COMMA, b.anyToken())),
b.optional(WITH, b.firstOf(ADMIN, DELEGATE), OPTION),
b.optional(CONTAINER, EQUALS, b.firstOf(CURRENT, ALL)))
b.rule(GRANT_OBJECT_PRIVILEGES).define(
b.oneOrMore(PRIVILEGE_PART), b.optional(PRIVILEGE_COLUMNS),
b.zeroOrMore(COMMA, b.oneOrMore(PRIVILEGE_PART, b.optional(PRIVILEGE_COLUMNS))),
b.optional(ON, b.oneOrMore(b.anyTokenButNot(TO))),
TO, IDENTIFIER_OR_KEYWORD, b.zeroOrMore(COMMA, IDENTIFIER_OR_KEYWORD),
b.optional(WITH, HIERARCHY, OPTION),
b.optional(WITH, GRANT, OPTION))
b.rule(GRANT_ROLES_TO_PROGRAMS).define(
b.oneOrMore(PRIVILEGE_PART),
b.zeroOrMore(COMMA, b.oneOrMore(PRIVILEGE_PART)),
TO, b.firstOf(FUNCTION, PROCEDURE, PACKAGE), UNIT_NAME,
b.zeroOrMore(COMMA, b.firstOf(FUNCTION, PROCEDURE, PACKAGE), UNIT_NAME)
)
b.rule(GRANT_STATEMENT).define(GRANT, b.firstOf(GRANT_ROLES_TO_PROGRAMS, GRANT_SYSTEM_PRIVILEGES, GRANT_OBJECT_PRIVILEGES), b.optional(SEMICOLON))
b.rule(DCL_COMMAND).define(GRANT_STATEMENT)
}
}
}
================================================
FILE: zpa-core/src/main/kotlin/com/felipebz/zpa/api/DdlGrammar.kt
================================================
/**
* Z PL/SQL Analyzer
* Copyright (C) 2015-2026 Felipe Zorzo
* mailto:felipe AT felipezorzo DOT com DOT br
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package com.felipebz.zpa.api
import com.felipebz.flr.api.GenericTokenType.EOF
import com.felipebz.flr.grammar.GrammarRuleKey
import com.felipebz.zpa.sslr.PlSqlGrammarBuilder
import com.felipebz.zpa.api.PlSqlGrammar.*
import com.felipebz.zpa.api.PlSqlKeyword.*
import com.felipebz.zpa.api.PlSqlPunctuator.*
import com.felipebz.zpa.api.PlSqlTokenType.INTEGER_LITERAL
enum class DdlGrammar : GrammarRuleKey {
DDL_COMMENT,
DDL_COMMAND,
ONE_OR_MORE_IDENTIFIERS,
REFERENCES_CLAUSE,
INLINE_CONSTRAINT,
OUT_OF_LINE_CONSTRAINT,
TABLE_COLUMN_DEFINITION,
TABLE_RELATIONAL_PROPERTIES,
CREATE_TABLE,
ALTER_TABLE,
COMPILE_CLAUSE,
COMPILER_PARAMETERS_CLAUSE,
ALTER_PROCEDURE,
ALTER_FUNCTION,
ALTER_TRIGGER,
ALTER_PACKAGE,
PACKAGE_COMPILE_CLAUSE,
DROP_COMMAND,
CREATE_SYNONYM,
CREATE_SEQUENCE,
PARTITION_BY_RANGE,
PARTITION_BY_HASH,
RANGE_VALUES_CLAUSE,
TABLE_PARTITION_DESCRIPTION,
SEGMENT_ATTRIBUTES_CLAUSE,
PHISICAL_ATRIBUTES_CLAUSE,
TABLE_COMPRESSION,
KEY_COMPRESSION,
LOB_STORAGE_CLAUSE,
VARRAY_COL_PROPERTIES,
PARTITION_LEVEL_SUBPARTITION,
// HASH_SUBPARTITION_QUANTITY,
SUBPARTITION_SPEC,
LIST_VALUES_CLAUSE,
PARTITIONING_STORAGE_CLAUSE,
SUBSTITUTABLE_COLUMN_CLAUSE,
LOB_PARAMETERS,
STORAGE_CLAUSE,
LOGGING_CLAUSE,
SIZE_CLAUSE,
INDIVIDUAL_HASH_PARTITIONS,
HASH_PARTITIONS_BY_QUANTITY,
PARTITION_BY_LIST,
PARTITION_COMPOSITE,
SUBPARTITION_BY_LIST,
SUBPARTITION_BY_HASH,
SUBPARTITION_TEMPLATE,
CREATE_DIRECTORY,
DROP_DIRECTORY,
TRUNCATE_TABLE,
CONSTRAINT_STATE,
PRECHECK_STATE,
EXCEPTIONS_CLAUSE;
companion object {
fun buildOn(b: PlSqlGrammarBuilder) {
createDdlCommands(b)
}
private fun createDdlCommands(b: PlSqlGrammarBuilder) {
b.rule(DDL_COMMENT).define(
COMMENT, ON,
b.firstOf(
b.sequence(
COLUMN,
IDENTIFIER_NAME,
b.optional(DOT, IDENTIFIER_NAME),
b.optional(DOT, IDENTIFIER_NAME)),
b.sequence(
b.firstOf(
TABLE,
COLUMN,
OPERATOR,
INDEXTYPE,
b.sequence(MATERIALIZED, VIEW),
b.sequence(MINING, MODEL)),
IDENTIFIER_NAME, b.optional(DOT, IDENTIFIER_NAME))
),
IS, CHARACTER_LITERAL, b.optional(SEMICOLON))
b.rule(ONE_OR_MORE_IDENTIFIERS).define(LPARENTHESIS, IDENTIFIER_NAME, b.zeroOrMore(COMMA, IDENTIFIER_NAME), RPARENTHESIS).skip()
b.rule(REFERENCES_CLAUSE).define(
REFERENCES, MEMBER_EXPRESSION,
b.optional(ONE_OR_MORE_IDENTIFIERS),
b.optional(ON, DELETE, b.firstOf(CASCADE, b.sequence(SET, NULL)))
)
b.rule(INLINE_CONSTRAINT).define(
b.optional(b.firstOf(CONSTRAINT, CONSTRAINTS), IDENTIFIER_NAME),
b.firstOf(
b.sequence(
b.firstOf(
b.sequence(b.optional(NOT), NULL),
UNIQUE,
b.sequence(PRIMARY, KEY),
REFERENCES_CLAUSE
), b.optional(CONSTRAINT_STATE)
),
b.sequence(
CHECK, LPARENTHESIS, EXPRESSION, RPARENTHESIS,
b.optional(CONSTRAINT_STATE),
b.optional(PRECHECK_STATE)
)
)
)
b.rule(CONSTRAINT_STATE).define(
b.optional(b.firstOf(
b.sequence(INITIALLY, b.firstOf(DEFERRED, IMMEDIATE), b.optional(b.optional(NOT), DEFERRABLE)),
b.sequence(b.optional(NOT), DEFERRABLE, b.optional(INITIALLY, b.firstOf(DEFERRED, IMMEDIATE))),
)),
b.optional(b.firstOf(RELY, NORELY)),
// TODO b.optional(USING_INDEX_CLAUSE),
b.optional(b.firstOf(ENABLE, DISABLE)),
b.optional(b.firstOf(VALIDATE, NOVALIDATE)),
b.optional(EXCEPTIONS_CLAUSE)
)
b.rule(PRECHECK_STATE).define(b.firstOf(PRECHECK, NOPRECHECK))
b.rule(EXCEPTIONS_CLAUSE).define(EXCEPTIONS, INTO, UNIT_NAME)
b.rule(TABLE_COLUMN_DEFINITION).define(
IDENTIFIER_NAME, DATATYPE,
b.optional(SORT),
b.optional(DEFAULT, b.optional(
b.sequence(ON, NULL,
b.optional(FOR, INSERT,
b.firstOf(ONLY, b.sequence(AND, UPDATE))))), EXPRESSION),
b.optional(ENCRYPT),
b.zeroOrMore(INLINE_CONSTRAINT))
b.rule(OUT_OF_LINE_CONSTRAINT).define(
b.optional(b.firstOf(CONSTRAINT, CONSTRAINTS), IDENTIFIER_NAME),
b.firstOf(
b.sequence(
b.firstOf(
b.sequence(UNIQUE, ONE_OR_MORE_IDENTIFIERS),
b.sequence(PRIMARY, KEY, ONE_OR_MORE_IDENTIFIERS, b.optional(b.sequence(USING, INDEX))),
b.sequence(FOREIGN, KEY, ONE_OR_MORE_IDENTIFIERS, REFERENCES_CLAUSE)
), b.optional(CONSTRAINT_STATE)
),
b.sequence(
CHECK, LPARENTHESIS, EXPRESSION, RPARENTHESIS,
b.optional(CONSTRAINT_STATE),
b.optional(PRECHECK_STATE)
)
)
)
b.rule(TABLE_RELATIONAL_PROPERTIES).define(
b.oneOrMore(b.firstOf(OUT_OF_LINE_CONSTRAINT, TABLE_COLUMN_DEFINITION), b.optional(COMMA)))
b.rule(PHISICAL_ATRIBUTES_CLAUSE).define(
b.oneOrMore(b.firstOf(
b.sequence(PCTFREE, INTEGER_LITERAL),
b.sequence(PCTUSED, INTEGER_LITERAL),
b.sequence(INITRANS, INTEGER_LITERAL),
STORAGE_CLAUSE)))
b.rule(SEGMENT_ATTRIBUTES_CLAUSE).define(
b.oneOrMore(b.firstOf(
PHISICAL_ATRIBUTES_CLAUSE,
b.sequence(TABLESPACE, IDENTIFIER_NAME),
LOGGING_CLAUSE)))
b.rule(TABLE_COMPRESSION).define(
b.firstOf(COMPRESS, NOCOMPRESS))
b.rule(KEY_COMPRESSION).define(
b.firstOf(
b.sequence(MAPPING, TABLE),
NOMAPPING))
b.rule(LOB_STORAGE_CLAUSE).define(
b.sequence(LOB,
b.firstOf(
b.sequence(
LPARENTHESIS,
b.oneOrMore(
IDENTIFIER_NAME,
b.optional(COMMA)),
RPARENTHESIS,
STORE,
AS,
LPARENTHESIS,
LOB_PARAMETERS,
RPARENTHESIS),
b.sequence(
LPARENTHESIS,
IDENTIFIER_NAME,
RPARENTHESIS,
STORE,
AS,
IDENTIFIER_NAME,
b.optional(b.sequence(
LPARENTHESIS,
LOB_PARAMETERS,
RPARENTHESIS))))))
b.rule(SUBSTITUTABLE_COLUMN_CLAUSE).define(
b.firstOf(
b.sequence(
b.optional(ELEMENT),
IS,
OF,
b.optional(TYPE),
LPARENTHESIS,
ONLY,
DATATYPE,
RPARENTHESIS),
b.sequence(
b.optional(NOT),
SUBSTITUTABLE,
AT,
ALL,
LEVELS)))
b.rule(SIZE_CLAUSE).define(
b.sequence(INTEGER_LITERAL, b.firstOf("K", "M", "G", "T", "P", "E")))
b.rule(STORAGE_CLAUSE).define(
b.sequence(STORAGE,
LPARENTHESIS,
b.firstOf(
b.sequence(INITIAL, SIZE_CLAUSE),
b.sequence(NEXT, SIZE_CLAUSE),
b.sequence(MINEXTENTS, INTEGER_LITERAL),
b.sequence(MAXEXTENTS, b.firstOf(INTEGER_LITERAL, UNLIMITED)),
b.sequence(PCTINCREASE, INTEGER_LITERAL),
b.sequence(FREELISTS, INTEGER_LITERAL),
b.sequence(FREELIST, GROUPS, INTEGER_LITERAL),
b.sequence(OPTIMAL, b.optional(b.firstOf(SIZE_CLAUSE, NULL))),
b.sequence(BUFFER_POOL, b.firstOf(KEEP, RECYCLE, DEFAULT))),
RPARENTHESIS))
b.rule(LOGGING_CLAUSE).define(
b.firstOf(LOGGING, NOLOGGING))
b.rule(LOB_PARAMETERS).define(
b.oneOrMore(b.firstOf(
b.sequence(
TABLESPACE,
IDENTIFIER_NAME),
b.sequence(
b.firstOf(
ENABLE,
DISABLE),
STORAGE,
IN,
NOW),
STORAGE_CLAUSE,
b.sequence(
CHUNK,
INTEGER_LITERAL),
b.sequence(
PCTVERSION,
INTEGER_LITERAL),
RETENTION,
b.sequence(
FREEPOOLS,
INTEGER_LITERAL),
b.firstOf(
b.sequence(CACHE,
b.optional(b.sequence(
READS,
b.optional(LOGGING_CLAUSE)))),
b.sequence(
NOCACHE,
b.optional(LOGGING_CLAUSE))))))
b.rule(VARRAY_COL_PROPERTIES).define(
b.sequence(VARRAY,
IDENTIFIER_NAME,
b.firstOf(b.sequence(
b.optional(SUBSTITUTABLE_COLUMN_CLAUSE),
STORE,
AS,
LOB,
b.firstOf(b.sequence(
b.optional(IDENTIFIER_NAME),
LPARENTHESIS,
LOB_PARAMETERS,
RPARENTHESIS),
IDENTIFIER_NAME)),
SUBSTITUTABLE_COLUMN_CLAUSE)))
b.rule(LIST_VALUES_CLAUSE).define(
b.sequence(
VALUES,
LPARENTHESIS,
b.firstOf(
b.oneOrMore(
b.firstOf(
LITERAL,
NULL),
b.optional(COMMA)),
DEFAULT),
RPARENTHESIS))
b.rule(PARTITIONING_STORAGE_CLAUSE).define(
b.optional(
b.oneOrMore(
b.firstOf(
b.sequence(
TABLESPACE,
IDENTIFIER_NAME),
b.sequence(
OVERFLOW,
b.optional(
b.sequence(
TABLESPACE,
IDENTIFIER_NAME))),
// b.sequence(
// LOB,
// LPARENTHESIS,
// IDENTIFIER_NAME,
// RPARENTHESIS,
// STORE,
// AS,
// b.firstOf(
// b.sequence(
// IDENTIFIER_NAME,
// b.optional(
// b.sequence(
// LPARENTHESIS,
// TABLESPACE,
// IDENTIFIER_NAME,
// RPARENTHESIS))),
// b.sequence(
// LPARENTHESIS,
// TABLESPACE,
// IDENTIFIER_NAME,
// RPARENTHESIS))),
LOB_STORAGE_CLAUSE,
// b.sequence(
// VARRAY,
// IDENTIFIER_NAME,
// STORE,
// AS,
// LOB,
// IDENTIFIER_NAME)))));
VARRAY_COL_PROPERTIES))))
b.rule(SUBPARTITION_SPEC).define(
b.sequence(SUBPARTITION, b.optional(IDENTIFIER_NAME), b.optional(LIST_VALUES_CLAUSE), b.optional(PARTITIONING_STORAGE_CLAUSE)))
b.rule(PARTITION_LEVEL_SUBPARTITION).define(
b.firstOf(
b.sequence(
SUBPARTITIONS,
INTEGER_LITERAL,
b.optional(
b.sequence(
STORE,
IN,
b.sequence(
LPARENTHESIS,
b.oneOrMore(
IDENTIFIER_NAME,
b.optional(COMMA)),
RPARENTHESIS)))),
b.sequence(
LPARENTHESIS,
b.oneOrMore(
SUBPARTITION_SPEC,
b.optional(COMMA)),
RPARENTHESIS)))
b.rule(RANGE_VALUES_CLAUSE).define(
b.sequence(VALUES, LESS, THAN,
b.sequence(
LPARENTHESIS,
b.oneOrMore(
b.firstOf(
METHOD_CALL,
IDENTIFIER_NAME,
MAXVALUE),
b.optional(COMMA)),
RPARENTHESIS)))
b.rule(TABLE_PARTITION_DESCRIPTION).define(
b.sequence(
b.optional(SEGMENT_ATTRIBUTES_CLAUSE),
b.optional(
b.firstOf(
TABLE_COMPRESSION,
KEY_COMPRESSION)),
b.optional(
b.sequence(
OVERFLOW,
b.optional(SEGMENT_ATTRIBUTES_CLAUSE))),
b.optional(
b.oneOrMore(
b.firstOf(
LOB_STORAGE_CLAUSE,
VARRAY_COL_PROPERTIES))),
b.optional(PARTITION_LEVEL_SUBPARTITION)))
b.rule(INDIVIDUAL_HASH_PARTITIONS).define(
b.sequence(
LPARENTHESIS,
b.oneOrMore(
b.sequence(
PARTITION,
b.optional(
b.sequence(
IDENTIFIER_NAME,
PARTITIONING_STORAGE_CLAUSE)),
b.optional(COMMA))),
RPARENTHESIS))
b.rule(HASH_PARTITIONS_BY_QUANTITY).define(
b.sequence(
PARTITIONS,
INTEGER_LITERAL,
b.optional(
b.sequence(
STORE,
IN,
LPARENTHESIS,
b.oneOrMore(b.sequence(
IDENTIFIER_NAME,
b.optional(COMMA))),
RPARENTHESIS)),
b.optional(
b.sequence(
OVERFLOW,
STORE,
IN,
LPARENTHESIS,
b.oneOrMore(b.sequence(
IDENTIFIER_NAME,
b.optional(COMMA))),
RPARENTHESIS))))
b.rule(SUBPARTITION_TEMPLATE).define(
b.sequence(
SUBPARTITION,
TEMPLATE,
b.firstOf(
b.sequence(
LPARENTHESIS,
b.oneOrMore(
b.sequence(
SUBPARTITION,
IDENTIFIER_NAME,
b.optional(LIST_VALUES_CLAUSE),
b.optional(PARTITIONING_STORAGE_CLAUSE),
b.optional(COMMA))),
RPARENTHESIS),
INTEGER_LITERAL)))
b.rule(SUBPARTITION_BY_LIST).define(
b.sequence(SUBPARTITION, BY, LIST, LPARENTHESIS, IDENTIFIER_NAME, RPARENTHESIS, b.optional(SUBPARTITION_TEMPLATE)))
b.rule(SUBPARTITION_BY_HASH).define(
b.sequence(
SUBPARTITION,
BY,
HASH,
LPARENTHESIS,
b.oneOrMore(
IDENTIFIER_NAME,
b.optional(COMMA)),
RPARENTHESIS,
b.optional(
b.firstOf(
b.sequence(
SUBPARTITIONS,
INTEGER_LITERAL,
b.optional(
b.sequence(
STORE,
IN,
LPARENTHESIS,
b.oneOrMore(
IDENTIFIER_NAME,
b.optional(COMMA)),
RPARENTHESIS))),
SUBPARTITION_TEMPLATE))))
b.rule(PARTITION_BY_RANGE).define(
b.sequence(
PARTITION,
BY,
RANGE_KEYWORD,
LPARENTHESIS,
b.oneOrMore(
IDENTIFIER_NAME,
b.optional(COMMA)),
RPARENTHESIS,
LPARENTHESIS,
b.oneOrMore(
PARTITION,
b.optional(IDENTIFIER_NAME),
RANGE_VALUES_CLAUSE,
TABLE_PARTITION_DESCRIPTION,
b.optional(COMMA)),
RPARENTHESIS))
b.rule(PARTITION_BY_HASH).define(
b.sequence(
PARTITION,
BY,
HASH,
LPARENTHESIS,
b.oneOrMore(
b.sequence(
IDENTIFIER_NAME,
b.optional(COMMA))),
RPARENTHESIS,
b.firstOf(
INDIVIDUAL_HASH_PARTITIONS,
HASH_PARTITIONS_BY_QUANTITY)))
b.rule(PARTITION_BY_LIST).define(
b.sequence(
PARTITION,
BY,
LIST,
LPARENTHESIS,
IDENTIFIER_NAME,
RPARENTHESIS,
LPARENTHESIS,
b.oneOrMore(
b.sequence(
PARTITION,
b.optional(IDENTIFIER_NAME),
LIST_VALUES_CLAUSE,
TABLE_PARTITION_DESCRIPTION,
b.optional(COMMA))),
RPARENTHESIS))
b.rule(PARTITION_COMPOSITE).define(
b.sequence(
PARTITION,
BY,
RANGE_KEYWORD,
b.oneOrMore(
LPARENTHESIS,
IDENTIFIER_NAME,
b.optional(COMMA),
RPARENTHESIS),
b.firstOf(
SUBPARTITION_BY_LIST,
SUBPARTITION_BY_HASH),
LPARENTHESIS,
b.oneOrMore(
b.sequence(
PARTITION,
b.optional(IDENTIFIER_NAME),
RANGE_VALUES_CLAUSE,
TABLE_PARTITION_DESCRIPTION,
b.optional(COMMA))),
RPARENTHESIS))
b.rule(CREATE_TABLE).define(
CREATE,
b.optional(
GLOBAL,
TEMPORARY),
TABLE,
UNIT_NAME,
b.optional(
LPARENTHESIS,
TABLE_RELATIONAL_PROPERTIES,
RPARENTHESIS),
b.optional(b.firstOf(
PARTITION_BY_RANGE,
PARTITION_BY_HASH,
PARTITION_BY_LIST,
PARTITION_COMPOSITE)),
b.optional(
TABLESPACE,
IDENTIFIER_NAME),
b.optional(
ON,
COMMIT,
b.firstOf(
DELETE,
PRESERVE),
ROWS),
b.optional(SEMICOLON))
b.rule(ALTER_TABLE).define(
ALTER, TABLE, UNIT_NAME, b.firstOf(ADD, DROP), TABLE_RELATIONAL_PROPERTIES, b.optional(SEMICOLON))
b.rule(COMPILE_CLAUSE).define(
COMPILE, b.optional(DEBUG),
b.zeroOrMore(COMPILER_PARAMETERS_CLAUSE),
b.optional(REUSE, SETTINGS))
b.rule(COMPILER_PARAMETERS_CLAUSE).define(
IDENTIFIER_NAME, EQUALS_OPERATOR, CHARACTER_LITERAL)
b.rule(ALTER_TRIGGER).define(
ALTER, TRIGGER, b.optional(IF, EXISTS), UNIT_NAME,
b.firstOf(
ENABLE,
DISABLE,
b.sequence(RENAME, TO, IDENTIFIER_NAME),
EDITIONABLE,
NONEDITIONABLE,
COMPILE_CLAUSE),
b.optional(SEMICOLON))
b.rule(ALTER_PROCEDURE).define(
ALTER, PROCEDURE, b.optional(IF, EXISTS), UNIT_NAME,
b.firstOf(
EDITIONABLE,
NONEDITIONABLE,
COMPILE_CLAUSE),
b.optional(SEMICOLON))
b.rule(ALTER_FUNCTION).define(
ALTER, FUNCTION, b.optional(IF, EXISTS), UNIT_NAME,
b.firstOf(
EDITIONABLE,
NONEDITIONABLE,
COMPILE_CLAUSE),
b.optional(SEMICOLON))
b.rule(ALTER_PACKAGE).define(
ALTER, PACKAGE, b.optional(IF, EXISTS), UNIT_NAME,
b.firstOf(
EDITIONABLE,
NONEDITIONABLE,
PACKAGE_COMPILE_CLAUSE),
b.optional(SEMICOLON))
b.rule(PACKAGE_COMPILE_CLAUSE).define(
COMPILE, b.optional(DEBUG),
b.optional(b.firstOf(PACKAGE, SPECIFICATION, BODY)),
b.zeroOrMore(COMPILER_PARAMETERS_CLAUSE),
b.optional(REUSE, SETTINGS))
b.rule(DROP_COMMAND).define(DROP, b.oneOrMore(b.anyTokenButNot(b.firstOf(SEMICOLON, DIVISION, EOF))), b.optional(SEMICOLON))
b.rule(CREATE_SYNONYM).define(
CREATE, b.optional(OR, REPLACE), b.optional(b.firstOf(EDITIONABLE, NONEDITIONABLE)),
b.optional(PUBLIC), SYNONYM, UNIT_NAME,
b.optional(SHARING, EQUALS, b.firstOf(METADATA, NONE)),
FOR, DmlGrammar.TABLE_REFERENCE, b.optional(SEMICOLON))
b.rule(CREATE_SEQUENCE).define(
CREATE, SEQUENCE, UNIT_NAME,
b.optional(START, WITH, NUMERIC_LITERAL),
b.optional(MAXVALUE, NUMERIC_LITERAL),
b.optional(MINVALUE, NUMERIC_LITERAL),
b.optional(INCREMENT, BY, NUMERIC_LITERAL),
b.optional(b.firstOf(CYCLE, NOCYCLE)),
b.optional(b.firstOf(NOCACHE, b.sequence(CACHE, NUMERIC_LITERAL)),
b.optional(b.firstOf(ORDER, NOORDER))),
b.optional(SEMICOLON))
b.rule(CREATE_DIRECTORY).define(
CREATE, b.optional(OR, REPLACE), DIRECTORY,
b.optional(IF, NOT, EXISTS), IDENTIFIER_NAME,
b.optional(SHARING, EQUALS_OPERATOR, b.firstOf(METADATA, NONE)),
AS, CHARACTER_LITERAL,
b.optional(SEMICOLON))
b.rule(DROP_DIRECTORY).define(
DROP, DIRECTORY, b.optional(IF, EXISTS), IDENTIFIER_NAME, b.optional(SEMICOLON))
b.rule(TRUNCATE_TABLE).define(
TRUNCATE, TABLE, UNIT_NAME,
b.optional(
b.firstOf(
PRESERVE, PURGE
),
MATERIALIZED, VIEW, LOG
),
b.optional(
b.firstOf(
b.sequence(
DROP, b.optional(ALL)
),
REUSE
),
STORAGE
),
b.optional(CASCADE),
b.optional(SEMICOLON)
)
b.rule(DDL_COMMAND).define(b.firstOf(
DDL_COMMENT,
CREATE_TABLE,
ALTER_TABLE,
ALTER_TRIGGER,
ALTER_PROCEDURE,
ALTER_FUNCTION,
ALTER_PACKAGE,
CREATE_SYNONYM,
CREATE_SEQUENCE,
CREATE_DIRECTORY,
DROP_DIRECTORY,
DROP_COMMAND,
TRUNCATE_TABLE))
}
}
}
================================================
FILE: zpa-core/src/main/kotlin/com/felipebz/zpa/api/DmlGrammar.kt
================================================
/**
* Z PL/SQL Analyzer
* Copyright (C) 2015-2026 Felipe Zorzo
* mailto:felipe AT felipezorzo DOT com DOT br
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package com.felipebz.zpa.api
import com.felipebz.flr.grammar.GrammarRuleKey
import com.felipebz.zpa.sslr.PlSqlGrammarBuilder
import com.felipebz.zpa.api.PlSqlGrammar.*
import com.felipebz.zpa.api.PlSqlKeyword.*
import com.felipebz.zpa.api.PlSqlPunctuator.*
import com.felipebz.zpa.api.PlSqlTokenType.INTEGER_LITERAL
import com.felipebz.zpa.api.SingleRowSqlFunctionsGrammar.*
enum class DmlGrammar : GrammarRuleKey {
TABLE_REFERENCE,
DML_TABLE_EXPRESSION_CLAUSE,
ALIAS,
VALUES_EXPRESSION_CLAUSE,
PARTITION_BY_CLAUSE,
WINDOWING_LIMIT,
WINDOWING_CLAUSE,
KEEP_CLAUSE,
ANALYTIC_CLAUSE,
ON_OR_USING_EXPRESSION,
INNER_CROSS_JOIN_CLAUSE,
OUTER_JOIN_TYPE,
QUERY_PARTITION_CLAUSE,
OUTER_JOIN_CLAUSE,
NESTED_CLAUSE,
JOIN_CLAUSE,
SELECT_COLUMN,
FROM_CLAUSE,
WHERE_CLAUSE,
INTO_CLAUSE,
GROUP_BY_CLAUSE,
HAVING_CLAUSE,
ORDER_BY_ITEM,
ORDER_BY_CLAUSE,
OFFSET_CLAUSE,
FETCH_ROW_CLAUSE,
ROW_LIMITING_CLAUSE,
FOR_UPDATE_CLAUSE,
CONNECT_BY_CLAUSE,
START_WITH_CLAUSE,
HIERARCHICAL_QUERY_CLAUSE,
WITH_CLAUSE,
SUBQUERY_FACTORING_CLAUSE,
SEARCH_CLAUSE,
CYCLE_CLAUSE,
RETURNING_INTO_CLAUSE,
QUERY_BLOCK,
SELECT_EXPRESSION,
DELETE_EXPRESSION,
UPDATE_COLUMN,
UPDATE_EXPRESSION,
INSERT_COLUMNS,
INSERT_EXPRESSION,
SINGLE_TABLE_INSERT,
INSERT_INTO_CLAUSE,
VALUES_CLAUSE,
MULTI_TABLE_INSERT,
CONDITIONAL_INSERT_CLAUSE,
MERGE_EXPRESSION,
MERGE_UPDATE_CLAUSE,
MERGE_INSERT_CLAUSE,
ERROR_LOGGING_CLAUSE,
DML_COMMAND,
GROUPING_EXPRESSION_LIST,
ROLLUP_CUBE_CLAUSE,
GROUPING_SETS_CLAUSE,
BACKED_LIST,
PIVOT_CLAUSE,
UNPIVOT_CLAUSE,
PIVOT_FOR_CLAUSE,
PIVOT_IN_CLAUSE,
UNPIVOT_IN_CLAUSE;
companion object {
fun buildOn(b: PlSqlGrammarBuilder) {
createSelectExpression(b)
createDeleteExpression(b)
createUpdateExpression(b)
createInsertExpression(b)
createMergeExpression(b)
b.rule(DML_COMMAND).define(
b.firstOf(
SELECT_EXPRESSION,
DELETE_EXPRESSION,
UPDATE_EXPRESSION,
INSERT_EXPRESSION,
MERGE_EXPRESSION),
b.optional(SEMICOLON))
}
private fun createSelectExpression(b: PlSqlGrammarBuilder) {
b.rule(TABLE_REFERENCE).define(
b.optional(IDENTIFIER_NAME, DOT),
IDENTIFIER_NAME,
b.optional(REMOTE, IDENTIFIER_NAME, b.zeroOrMore(DOT, IDENTIFIER_NAME)))
b.rule(ALIAS).define(IDENTIFIER_NAME)
b.rule(PARTITION_BY_CLAUSE).define(PARTITION, BY, EXPRESSION, b.zeroOrMore(COMMA, EXPRESSION))
b.rule(WINDOWING_LIMIT).define(b.firstOf(
b.sequence(UNBOUNDED, b.firstOf(PRECEDING, FOLLOWING)),
b.sequence(CURRENT, ROW),
b.sequence(EXPRESSION, b.firstOf(PRECEDING, FOLLOWING))))
b.rule(WINDOWING_CLAUSE).define(
b.firstOf(ROWS, RANGE_KEYWORD),
b.firstOf(
b.sequence(BETWEEN, WINDOWING_LIMIT, AND, WINDOWING_LIMIT),
WINDOWING_LIMIT))
b.rule(KEEP_CLAUSE).define(
KEEP, LPARENTHESIS,
DENSE_RANK, b.firstOf(FIRST, LAST), ORDER_BY_CLAUSE,
RPARENTHESIS)
b.rule(ANALYTIC_CLAUSE).define(
OVER, LPARENTHESIS,
b.optional(PARTITION_BY_CLAUSE), b.optional(ORDER_BY_CLAUSE, b.optional(WINDOWING_CLAUSE)),
RPARENTHESIS)
b.rule(ON_OR_USING_EXPRESSION).define(
b.firstOf(
b.sequence(ON, EXPRESSION),
b.sequence(USING, LPARENTHESIS, IDENTIFIER_NAME, b.zeroOrMore(COMMA, IDENTIFIER_NAME), RPARENTHESIS)))
b.rule(OUTER_JOIN_TYPE).define(b.firstOf(FULL, LEFT, RIGHT), b.optional(OUTER))
b.rule(QUERY_PARTITION_CLAUSE).define(
PARTITION, BY,
b.firstOf(
b.sequence(EXPRESSION, b.zeroOrMore(COMMA, EXPRESSION)),
b.sequence(LPARENTHESIS, EXPRESSION, b.zeroOrMore(COMMA, EXPRESSION), RPARENTHESIS)))
b.rule(INNER_CROSS_JOIN_CLAUSE).define(b.firstOf(
b.sequence(b.optional(INNER), JOIN, DML_TABLE_EXPRESSION_CLAUSE, ON_OR_USING_EXPRESSION),
b.sequence(
b.firstOf(
CROSS,
b.sequence(NATURAL, b.optional(INNER))),
JOIN, DML_TABLE_EXPRESSION_CLAUSE)
))
b.rule(OUTER_JOIN_CLAUSE).define(
b.optional(QUERY_PARTITION_CLAUSE),
b.firstOf(
b.sequence(OUTER_JOIN_TYPE, JOIN),
b.sequence(NATURAL, b.optional(OUTER_JOIN_TYPE), JOIN)),
b.sequence(DML_TABLE_EXPRESSION_CLAUSE, b.optional(QUERY_PARTITION_CLAUSE),
b.optional(ON_OR_USING_EXPRESSION)))
b.rule(NESTED_CLAUSE).define(
NESTED, b.optional(PATH), IDENTIFIER_NAME,
b.optional(b.firstOf(
b.sequence(DOT, JSON_RELATIVE_OBJECT_ACCESS),
b.sequence(COMMA, JSON_BASIC_PATH_EXPRESSION)
)),
b.optional(JSON_TABLE_ON_ERROR_CLAUSE),
b.optional(JSON_TABLE_ON_EMPTY_CLAUSE),
JSON_COLUMNS_CLAUSE
)
b.rule(JOIN_CLAUSE).define(
b.firstOf(
b.sequence(
b.firstOf(
b.sequence(LPARENTHESIS, JOIN_CLAUSE, RPARENTHESIS),
DML_TABLE_EXPRESSION_CLAUSE),
b.oneOrMore(b.firstOf(INNER_CROSS_JOIN_CLAUSE, OUTER_JOIN_CLAUSE))),
b.sequence(LPARENTHESIS, JOIN_CLAUSE, RPARENTHESIS)
))
b.rule(SELECT_COLUMN).define(EXPRESSION, b.optional(b.optional(AS), IDENTIFIER_NAME, b.nextNot(COLLECT)))
b.rule(DML_TABLE_EXPRESSION_CLAUSE).define(
b.firstOf(
b.sequence(
b.firstOf(
b.sequence(LPARENTHESIS, SELECT_EXPRESSION, b.optional(
b.firstOf(
PIVOT_CLAUSE,
UNPIVOT_CLAUSE
)
), RPARENTHESIS),
b.sequence(TABLE_REFERENCE, b.nextNot(LPARENTHESIS)),
OBJECT_REFERENCE
),
b.optional(NESTED_CLAUSE),
b.optional(
b.oneOrMore(
b.firstOf(
PIVOT_CLAUSE,
UNPIVOT_CLAUSE
)
)
),
b.optional(
b.nextNot(
b.firstOf(
PARTITION,
CROSS,
USING,
FULL,
NATURAL,
INNER,
LEFT,
RIGHT,
OUTER,
JOIN,
RETURN,
RETURNING,
LOG,
EXCEPT,
SET
)
),
b.optional(AS),
ALIAS
)
),
VALUES_EXPRESSION_CLAUSE
)
)
b.rule(VALUES_EXPRESSION_CLAUSE).define(
LPARENTHESIS,
VALUES,
b.oneOrMore(LPARENTHESIS, EXPRESSION, b.zeroOrMore(COMMA, EXPRESSION), RPARENTHESIS, b.optional(COMMA)),
RPARENTHESIS,
b.optional(AS),
IDENTIFIER_NAME,
b.optional(LPARENTHESIS, IDENTIFIER_NAME, b.zeroOrMore(COMMA, IDENTIFIER_NAME), RPARENTHESIS)
)
b.rule(FROM_CLAUSE).define(
FROM,
b.firstOf(JOIN_CLAUSE, DML_TABLE_EXPRESSION_CLAUSE),
b.optional(
b.firstOf(
PIVOT_CLAUSE,
UNPIVOT_CLAUSE
)
),
b.zeroOrMore(COMMA,
b.firstOf(JOIN_CLAUSE, DML_TABLE_EXPRESSION_CLAUSE),
b.optional(
b.firstOf(
PIVOT_CLAUSE,
UNPIVOT_CLAUSE
)
)
)
)
b.rule(WHERE_CLAUSE).define(WHERE, EXPRESSION)
b.rule(INTO_CLAUSE).define(
b.optional(BULK, COLLECT), INTO,
OBJECT_REFERENCE, b.zeroOrMore(COMMA, OBJECT_REFERENCE))
b.rule(GROUPING_EXPRESSION_LIST).define(
b.firstOf(
b.sequence(LPARENTHESIS, b.optional(EXPRESSION, b.zeroOrMore(COMMA, EXPRESSION)), RPARENTHESIS),
EXPRESSION, b.zeroOrMore(COMMA, EXPRESSION))
)
b.rule(ROLLUP_CUBE_CLAUSE).define(
b.firstOf(ROLLUP, CUBE), LPARENTHESIS, GROUPING_EXPRESSION_LIST, RPARENTHESIS)
b.rule(GROUPING_SETS_CLAUSE).define(
GROUPING, SETS, LPARENTHESIS,
b.firstOf(ROLLUP_CUBE_CLAUSE, GROUPING_EXPRESSION_LIST),
b.zeroOrMore(COMMA, b.firstOf(ROLLUP_CUBE_CLAUSE, GROUPING_EXPRESSION_LIST)),
RPARENTHESIS)
b.rule(GROUP_BY_CLAUSE).define(
GROUP, BY,
b.firstOf(ROLLUP_CUBE_CLAUSE, GROUPING_SETS_CLAUSE, EXPRESSION),
b.zeroOrMore(COMMA, b.firstOf(ROLLUP_CUBE_CLAUSE, GROUPING_SETS_CLAUSE, EXPRESSION)))
b.rule(HAVING_CLAUSE).define(HAVING, EXPRESSION)
b.rule(BACKED_LIST).define(
b.firstOf(
b.oneOrMore(EXPRESSION, b.optional(b.optional(AS), b.firstOf(ALIAS,LITERAL)), b.optional(COMMA)),
b.oneOrMore(
LPARENTHESIS,
b.oneOrMore(b.firstOf(LITERAL, IDENTIFIER_NAME), b.optional(COMMA)),
RPARENTHESIS,
b.optional(AS, b.oneOrMore(b.firstOf(LITERAL, IDENTIFIER_NAME), b.optional(COMMA))),
b.optional(COMMA)
))
)
b.rule(PIVOT_FOR_CLAUSE).define(
FOR,
b.firstOf(
b.sequence(LPARENTHESIS, b.oneOrMore(VARIABLE_NAME, b.optional(COMMA)), RPARENTHESIS),
VARIABLE_NAME
)
)
b.rule(PIVOT_IN_CLAUSE).define(
IN,
LPARENTHESIS,
b.firstOf(
b.oneOrMore(
b.firstOf(
EXPRESSION,
b.sequence(LPARENTHESIS, b.oneOrMore(EXPRESSION, b.optional(COMMA)), RPARENTHESIS)
),
b.optional(b.optional(AS), b.firstOf(ALIAS,LITERAL)),
b.optional(COMMA)),
SELECT_EXPRESSION,
b.oneOrMore(ANY, b.optional(COMMA))),
RPARENTHESIS
)
b.rule(UNPIVOT_IN_CLAUSE).define(
IN,
LPARENTHESIS,
b.oneOrMore(
b.firstOf(
b.sequence(LPARENTHESIS, b.oneOrMore(VARIABLE_NAME, b.optional(COMMA)), RPARENTHESIS),
VARIABLE_NAME
),
b.optional(
b.optional(AS),
b.firstOf(
b.sequence(LPARENTHESIS, b.oneOrMore(b.firstOf(ALIAS, LITERAL), b.optional(COMMA)), RPARENTHESIS),
b.firstOf(ALIAS, LITERAL)
)
),
b.optional(COMMA)
),
RPARENTHESIS
)
b.rule(PIVOT_CLAUSE).define(
b.sequence(
PIVOT,
b.optional(XML),
LPARENTHESIS,
b.oneOrMore(
b.firstOf(
b.sequence(LPARENTHESIS, b.optional(EXPRESSION), RPARENTHESIS),
EXPRESSION
),
b.optional(b.optional(AS), b.firstOf(ALIAS,LITERAL)),
b.optional(COMMA)
),
PIVOT_FOR_CLAUSE,
PIVOT_IN_CLAUSE,
RPARENTHESIS
)
)
b.rule(UNPIVOT_CLAUSE).define(
b.sequence(
UNPIVOT,
b.optional(b.firstOf(INCLUDE, EXCLUDE), NULLS),
LPARENTHESIS,
b.firstOf(
b.sequence(LPARENTHESIS, b.oneOrMore(VARIABLE_NAME, b.optional(COMMA)), RPARENTHESIS),
VARIABLE_NAME
),
PIVOT_FOR_CLAUSE,
UNPIVOT_IN_CLAUSE,
RPARENTHESIS
)
)
b.rule(ORDER_BY_ITEM).define(EXPRESSION, b.optional(b.firstOf(ASC, DESC)), b.optional(NULLS, b.firstOf(FIRST, LAST)))
b.rule(ORDER_BY_CLAUSE).define(
ORDER, b.optional(SIBLINGS), BY, ORDER_BY_ITEM, b.zeroOrMore(COMMA, ORDER_BY_ITEM))
b.rule(OFFSET_CLAUSE).define(OFFSET, EXPRESSION, b.firstOf(ROW, ROWS))
b.rule(FETCH_ROW_CLAUSE).define(FETCH, b.firstOf(FIRST, NEXT), b.optional(EXPRESSION, b.optional(PERCENT)), b.firstOf(ROW, ROWS), b.firstOf(ONLY, b.sequence(WITH, TIES)))
b.rule(ROW_LIMITING_CLAUSE).define(b.firstOf(
b.sequence(OFFSET_CLAUSE, b.optional(FETCH_ROW_CLAUSE)),
FETCH_ROW_CLAUSE))
b.rule(FOR_UPDATE_CLAUSE).define(
FOR, UPDATE,
b.optional(OF, OBJECT_REFERENCE, b.zeroOrMore(COMMA, OBJECT_REFERENCE)),
b.optional(b.firstOf(NOWAIT, b.sequence(WAIT, INTEGER_LITERAL), b.sequence(SKIP, LOCKED))))
b.rule(CONNECT_BY_CLAUSE).define(CONNECT, BY, b.optional(NOCYCLE), EXPRESSION)
b.rule(START_WITH_CLAUSE).define(START, WITH, EXPRESSION)
b.rule(HIERARCHICAL_QUERY_CLAUSE).define(b.firstOf(
b.sequence(CONNECT_BY_CLAUSE, b.optional(START_WITH_CLAUSE)),
b.sequence(START_WITH_CLAUSE, CONNECT_BY_CLAUSE)))
b.rule(WITH_CLAUSE).define(
WITH,
b.firstOf(
b.sequence(
b.oneOrMore(b.firstOf(FUNCTION_DECLARATION, PROCEDURE_DECLARATION)),
b.zeroOrMore(SUBQUERY_FACTORING_CLAUSE, b.zeroOrMore(COMMA, SUBQUERY_FACTORING_CLAUSE))
),
b.oneOrMore(SUBQUERY_FACTORING_CLAUSE, b.zeroOrMore(COMMA, SUBQUERY_FACTORING_CLAUSE))
)
)
b.rule(SUBQUERY_FACTORING_CLAUSE).define(
IDENTIFIER_NAME,
b.optional(LPARENTHESIS, IDENTIFIER_NAME, b.zeroOrMore(COMMA, IDENTIFIER_NAME), RPARENTHESIS),
AS,
b.firstOf(
b.sequence(LPARENTHESIS, SELECT_EXPRESSION, RPARENTHESIS),
VALUES_EXPRESSION_CLAUSE),
b.optional(SEARCH_CLAUSE),
b.optional(CYCLE_CLAUSE)
)
b.rule(SEARCH_CLAUSE).define(
SEARCH, b.firstOf(BREADTH, DEPTH),
FIRST, BY, ORDER_BY_ITEM, b.zeroOrMore(COMMA, ORDER_BY_ITEM),
SET, IDENTIFIER_NAME
)
b.rule(CYCLE_CLAUSE).define(
CYCLE, IDENTIFIER_NAME, b.zeroOrMore(COMMA, IDENTIFIER_NAME),
SET, IDENTIFIER_NAME, TO, EXPRESSION, DEFAULT, EXPRESSION
)
b.rule(QUERY_BLOCK).define(
b.firstOf(
b.sequence(
SELECT, b.optional(b.firstOf(ALL, DISTINCT, UNIQUE)), SELECT_COLUMN, b.zeroOrMore(COMMA, SELECT_COLUMN),
b.optional(INTO_CLAUSE),
b.optional(FROM_CLAUSE),
b.optional(WHERE_CLAUSE),
b.optional(b.firstOf(
b.sequence(GROUP_BY_CLAUSE, b.optional(HAVING_CLAUSE)),
b.sequence(HAVING_CLAUSE, b.optional(GROUP_BY_CLAUSE)))),
b.optional(HAVING_CLAUSE),
b.optional(HIERARCHICAL_QUERY_CLAUSE)),
b.sequence(LPARENTHESIS, SELECT_EXPRESSION, RPARENTHESIS)))
b.rule(SELECT_EXPRESSION).define(
b.optional(WITH_CLAUSE),
QUERY_BLOCK,
b.zeroOrMore(b.firstOf(MINUS_KEYWORD, INTERSECT, UNION, EXCEPT), b.optional(ALL), QUERY_BLOCK),
b.optional(b.firstOf(
b.sequence(ORDER_BY_CLAUSE, b.optional(b.firstOf(FOR_UPDATE_CLAUSE, ROW_LIMITING_CLAUSE))),
ROW_LIMITING_CLAUSE,
b.sequence(FOR_UPDATE_CLAUSE, b.optional(ORDER_BY_CLAUSE)))))
}
private fun createDeleteExpression(b: PlSqlGrammarBuilder) {
b.rule(RETURNING_INTO_CLAUSE).define(
b.firstOf(RETURNING, RETURN),
b.optional(EXPRESSION, b.zeroOrMore(COMMA, EXPRESSION)),
INTO_CLAUSE)
b.rule(DELETE_EXPRESSION).define(
DELETE, b.optional(FROM),
DML_TABLE_EXPRESSION_CLAUSE,
b.optional(b.firstOf(
b.sequence(WHERE, CURRENT, OF, IDENTIFIER_NAME),
WHERE_CLAUSE)),
b.optional(RETURNING_INTO_CLAUSE))
}
private fun createUpdateExpression(b: PlSqlGrammarBuilder) {
b.rule(UPDATE_COLUMN).define(OBJECT_REFERENCE, EQUALS, b.firstOf(EXPRESSION, DEFAULT))
b.rule(UPDATE_EXPRESSION).define(
UPDATE, DML_TABLE_EXPRESSION_CLAUSE, SET, UPDATE_COLUMN, b.zeroOrMore(COMMA, UPDATE_COLUMN),
b.optional(b.firstOf(
b.sequence(WHERE, CURRENT, OF, IDENTIFIER_NAME),
WHERE_CLAUSE)),
b.optional(RETURNING_INTO_CLAUSE))
}
private fun createInsertExpression(b: PlSqlGrammarBuilder) {
b.rule(INSERT_COLUMNS).define(LPARENTHESIS, MEMBER_EXPRESSION, b.zeroOrMore(COMMA, MEMBER_EXPRESSION), RPARENTHESIS)
b.rule(INSERT_EXPRESSION).define(INSERT, b.firstOf(SINGLE_TABLE_INSERT, MULTI_TABLE_INSERT))
b.rule(SINGLE_TABLE_INSERT).define(
INSERT_INTO_CLAUSE,
b.firstOf(
b.sequence(VALUES_CLAUSE, b.optional(RETURNING_INTO_CLAUSE)),
SELECT_EXPRESSION),
b.optional(ERROR_LOGGING_CLAUSE))
b.rule(INSERT_INTO_CLAUSE).define(INTO,
b.firstOf(b.sequence(LPARENTHESIS, SELECT_EXPRESSION, RPARENTHESIS), b.firstOf(
TABLE_EXPRESSION, THE_EXPRESSION, TABLE_REFERENCE)),
b.optional(IDENTIFIER_NAME), b.optional(INSERT_COLUMNS))
b.rule(VALUES_CLAUSE).define(
VALUES,
b.firstOf(
b.sequence(LPARENTHESIS, b.firstOf(EXPRESSION, DEFAULT), b.zeroOrMore(b.sequence(COMMA, b.firstOf(EXPRESSION, DEFAULT))), RPARENTHESIS),
EXPRESSION))
b.rule(MULTI_TABLE_INSERT).define(
b.firstOf(
b.sequence(ALL, b.oneOrMore(b.sequence(INSERT_INTO_CLAUSE, b.optional(VALUES_CLAUSE), b.optional(ERROR_LOGGING_CLAUSE)))),
CONDITIONAL_INSERT_CLAUSE),
SELECT_EXPRESSION)
b.rule(CONDITIONAL_INSERT_CLAUSE).define(
b.optional(b.firstOf(ALL, FIRST)),
WHEN, EXPRESSION, THEN, INSERT_INTO_CLAUSE,
b.optional(VALUES_CLAUSE),
b.optional(ERROR_LOGGING_CLAUSE),
b.zeroOrMore(INSERT_INTO_CLAUSE, b.optional(VALUES_CLAUSE), b.optional(ERROR_LOGGING_CLAUSE)),
b.zeroOrMore(WHEN, EXPRESSION, THEN, INSERT_INTO_CLAUSE,
b.optional(VALUES_CLAUSE),
b.optional(ERROR_LOGGING_CLAUSE),
b.zeroOrMore(INSERT_INTO_CLAUSE, b.optional(VALUES_CLAUSE), b.optional(ERROR_LOGGING_CLAUSE))),
b.optional(ELSE, INSERT_INTO_CLAUSE,
b.optional(VALUES_CLAUSE),
b.optional(ERROR_LOGGING_CLAUSE),
b.zeroOrMore(INSERT_INTO_CLAUSE, b.optional(VALUES_CLAUSE), b.optional(ERROR_LOGGING_CLAUSE))))
}
private fun createMergeExpression(b: PlSqlGrammarBuilder) {
b.rule(MERGE_UPDATE_CLAUSE).define(WHEN, MATCHED, THEN, UPDATE, SET, UPDATE_COLUMN, b.zeroOrMore(COMMA, UPDATE_COLUMN),
b.optional(WHERE_CLAUSE), b.optional(DELETE, WHERE_CLAUSE))
b.rule(MERGE_INSERT_CLAUSE).define(WHEN, NOT, MATCHED, THEN, INSERT,
b.optional(LPARENTHESIS, OBJECT_REFERENCE, b.zeroOrMore(COMMA, OBJECT_REFERENCE), RPARENTHESIS),
VALUES, b.firstOf(
b.sequence(LPARENTHESIS, b.firstOf(EXPRESSION, DEFAULT), b.zeroOrMore(COMMA, b.firstOf(EXPRESSION, DEFAULT)), RPARENTHESIS),
IDENTIFIER_NAME),
b.optional(WHERE_CLAUSE))
b.rule(ERROR_LOGGING_CLAUSE).define(
LOG, ERRORS,
b.optional(INTO, TABLE_REFERENCE),
b.optional(LPARENTHESIS, EXPRESSION, RPARENTHESIS),
b.optional(REJECT, LIMIT, b.firstOf(EXPRESSION, UNLIMITED)))
//https://docs.oracle.com/cd/E11882_01/server.112/e41084/statements_9016.htm#SQLRF01606
b.rule(MERGE_EXPRESSION).define(
MERGE, INTO, TABLE_REFERENCE, b.optional(b.nextNot(USING), IDENTIFIER_NAME),
USING, DML_TABLE_EXPRESSION_CLAUSE, ON, LPARENTHESIS, BOOLEAN_EXPRESSION, RPARENTHESIS,
b.firstOf(
b.sequence(MERGE_UPDATE_CLAUSE, b.optional(MERGE_INSERT_CLAUSE), b.optional(ERROR_LOGGING_CLAUSE)),
b.sequence(MERGE_INSERT_CLAUSE, b.optional(MERGE_UPDATE_CLAUSE), b.optional(ERROR_LOGGING_CLAUSE))))
}
}
}
================================================
FILE: zpa-core/src/main/kotlin/com/felipebz/zpa/api/GrammarRuleBuilderExtensions.kt
================================================
/**
* Z PL/SQL Analyzer
* Copyright (C) 2015-2026 Felipe Zorzo
* mailto:felipe AT felipezorzo DOT com DOT br
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package com.felipebz.zpa.api
import com.felipebz.flr.grammar.GrammarRuleBuilder
internal fun GrammarRuleBuilder.define(e: Any): GrammarRuleBuilder =
this.`is`(e)
internal fun GrammarRuleBuilder.define(e: Any, vararg rest: Any): GrammarRuleBuilder =
this.`is`(e, *rest)
================================================
FILE: zpa-core/src/main/kotlin/com/felipebz/zpa/api/PlSqlFile.kt
================================================
/**
* Z PL/SQL Analyzer
* Copyright (C) 2015-2026 Felipe Zorzo
* mailto:felipe AT felipezorzo DOT com DOT br
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package com.felipebz.zpa.api
import java.nio.file.Path
interface PlSqlFile {
fun contents(): String
fun fileName(): String
fun path(): Path
fun type(): Type
enum class Type {
MAIN, TEST
}
}
================================================
FILE: zpa-core/src/main/kotlin/com/felipebz/zpa/api/PlSqlGrammar.kt
================================================
/**
* Z PL/SQL Analyzer
* Copyright (C) 2015-2026 Felipe Zorzo
* mailto:felipe AT felipezorzo DOT com DOT br
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package com.felipebz.zpa.api
import com.felipebz.flr.api.GenericTokenType.EOF
import com.felipebz.flr.api.GenericTokenType.IDENTIFIER
import com.felipebz.flr.grammar.GrammarRuleKey
import com.felipebz.flr.grammar.LexerfulGrammarBuilder
import com.felipebz.zpa.grammar.ExecuteBufferExpression
import com.felipebz.zpa.sslr.ElseClause
import com.felipebz.zpa.sslr.ElsifClause
import com.felipebz.zpa.sslr.IfStatement
import com.felipebz.zpa.sslr.NullStatement
import com.felipebz.zpa.sslr.PlSqlGrammarBuilder
import com.felipebz.zpa.sslr.RaiseStatement
import com.felipebz.zpa.sslr.Statements
import com.felipebz.zpa.squid.PlSqlConfiguration
import com.felipebz.zpa.api.DclGrammar.DCL_COMMAND
import com.felipebz.zpa.api.DdlGrammar.DDL_COMMAND
import com.felipebz.zpa.api.DmlGrammar.*
import com.felipebz.zpa.api.PlSqlKeyword.*
import com.felipebz.zpa.api.PlSqlPunctuator.*
import com.felipebz.zpa.api.PlSqlTokenType.*
import com.felipebz.zpa.api.SessionControlGrammar.SESSION_CONTROL_COMMAND
import com.felipebz.zpa.api.SqlPlusGrammar.SQLPLUS_COMMAND
import com.felipebz.zpa.api.TclGrammar.*
enum class PlSqlGrammar : GrammarRuleKey {
// Data types
DATATYPE,
DATATYPE_LENGTH,
CHARACTER_SET_CLAUSE,
NUMERIC_PRECISION,
NUMERIC_SCALE,
NUMERIC_DATATYPE_CONSTRAINT,
NUMERIC_DATATYPE,
LOB_DATATYPE,
CHARACTER_DATATYPE_CONSTRAINT,
CHARACTER_DATAYPE,
BOOLEAN_DATATYPE,
DATE_DATATYPE,
CUSTOM_SUBTYPE,
ANCHORED_DATATYPE,
CUSTOM_DATATYPE,
REF_DATATYPE,
JSON_DATATYPE,
DATATYPE_NULL_CONSTRAINT,
// Literals
LITERAL,
BOOLEAN_LITERAL,
NULL_LITERAL,
NUMERIC_LITERAL,
FLOATING_POINT_LITERAL,
CHARACTER_LITERAL,
INTERVAL_YEAR_TO_MONTH_LITERAL,
INTERVAL_DAY_TO_SECOND_LITERAL,
INTERVAL_LITERAL,
INQUIRY_DIRECTIVE,
// Operators
CONCATENATION_OPERATOR,
EQUALS_OPERATOR,
NOTEQUALS_STANDARD_OPERATOR,
NOTEQUALS_NONSTANDARD_OPERATOR,
NOTEQUALS_OPERATOR,
LESSTHAN_OPERATOR,
LESSTHANOREQUALS_OPERATOR,
GREATERTHAN_OPERATOR,
GREATERTHANOREQUALS_OPERATOR,
// Expressions
EXPRESSION,
AND_EXPRESSION,
OR_EXPRESSION,
NOT_EXPRESSION,
BOOLEAN_EXPRESSION,
PRIMARY_EXPRESSION,
BRACKED_EXPRESSION,
MULTIPLE_VALUE_EXPRESSION,
MEMBER_EXPRESSION,
OUTER_JOIN_PLUS_SIGN,
OBJECT_REFERENCE,
POSTFIX_EXPRESSION,
IN_EXPRESSION,
EXISTS_EXPRESSION,
UNARY_EXPRESSION,
MULTIPLICATIVE_EXPRESSION,
ADDITIVE_EXPRESSION,
CONCATENATION_EXPRESSION,
COMPARISON_EXPRESSION,
EXPONENTIATION_EXPRESSION,
ARGUMENT,
ARGUMENTS,
METHOD_CALL,
SEQUENCE_ITERATOR_CHOICE,
POSITIONAL_CHOICE_OPTION,
POSITIONAL_CHOICE_LIST,
NAMED_CHOICE_LIST,
INDEXED_CHOICE_LIST,
BASIC_ITERATOR_CHOICE,
INDEX_ITERATOR_CHOICE,
EXPLICIT_CHOICE_OPTION,
EXPLICIT_CHOICE_LIST,
QUALIFIED_EXPRESSION,
CALL_EXPRESSION,
CASE_EXPRESSION,
AT_TIME_ZONE_EXPRESSION,
VARIABLE_NAME,
NEW_OBJECT_EXPRESSION,
MULTISET_EXPRESSION,
// Statements
LABEL,
STATEMENTS_SECTION,
BLOCK_STATEMENT,
NULL_STATEMENT,
ASSIGNMENT_STATEMENT,
ELSIF_CLAUSE,
ELSE_CLAUSE,
IF_STATEMENT,
LOOP_STATEMENT,
EXIT_STATEMENT,
CONTINUE_STATEMENT,
GOTO_STATEMENT,
ITERATOR,
ITERAND_DECLARATION,
ITERATION_CTL_SEQ,
QUAL_ITERATION_CTL,
PRED_CLAUSE_SEQ,
ITERATION_CONTROL,
STEPPED_CONTROL,
SINGLE_EXPRESSION_CONTROL,
VALUES_OF_CONTROL,
INDICES_OF_CONTROL,
PAIRS_OF_CONTROL,
DYNAMIC_SQL,
FOR_STATEMENT,
WHILE_STATEMENT,
RETURN_STATEMENT,
COMMIT_STATEMENT,
ROLLBACK_STATEMENT,
SAVEPOINT_STATEMENT,
RAISE_STATEMENT,
SELECT_STATEMENT,
INSERT_STATEMENT,
UPDATE_STATEMENT,
DELETE_STATEMENT,
CALL_STATEMENT,
UNNAMED_ACTUAL_PAMETER,
EXECUTE_IMMEDIATE_STATEMENT,
OPEN_STATEMENT,
OPEN_FOR_STATEMENT,
FETCH_STATEMENT,
CLOSE_STATEMENT,
PIPE_ROW_STATEMENT,
CASE_STATEMENT,
STATEMENT,
STATEMENTS,
FORALL_STATEMENT,
SET_TRANSACTION_STATEMENT,
MERGE_STATEMENT,
INLINE_PRAGMA_STATEMENT,
// Declarations
DEFAULT_VALUE_ASSIGNMENT,
VARIABLE_DECLARATION,
EXCEPTION_DECLARATION,
PARAMETER_DECLARATIONS,
PARAMETER_DECLARATION,
CURSOR_PARAMETER_DECLARATIONS,
CURSOR_PARAMETER_DECLARATION,
CURSOR_DECLARATION,
RECORD_FIELD_DECLARATION,
RECORD_DECLARATION,
NESTED_TABLE_DEFINITION,
TABLE_OF_DECLARATION,
VARRAY_TYPE_DEFINITION,
VARRAY_DECLARATION,
REF_CURSOR_DECLARATION,
AUTONOMOUS_TRANSACTION_PRAGMA,
EXCEPTION_INIT_PRAGMA,
SERIALLY_REUSABLE_PRAGMA,
INTERFACE_PRAGMA,
RESTRICT_REFERENCES_PRAGMA,
UDF_PRAGMA,
DEPRECATE_PRAGMA,
SUPPRESSES_WARNING_6009_PRAGMA,
COVERAGE_PRAGMA,
PRAGMA_DECLARATION,
HOST_AND_INDICATOR_VARIABLE,
JAVA_DECLARATION,
C_DECLARATION,
EXTERNAL_PARAMETER_PROPERTY,
EXTERNAL_PARAMETER,
CALL_SPECIFICATION,
DECLARE_SECTION,
EXCEPTION_HANDLERS,
EXCEPTION_HANDLER,
IDENTIFIER_NAME,
NON_RESERVED_KEYWORD,
EXECUTE_PLSQL_BUFFER,
// Triggers
SIMPLE_DML_TRIGGER,
INSTEAD_OF_DML_TRIGGER,
COMPOUND_DML_TRIGGER,
SYSTEM_TRIGGER,
DML_EVENT_CLAUSE,
REFERENCING_CLAUSE,
TRIGGER_EDITION_CLAUSE,
TRIGGER_ORDERING_CLAUSE,
COMPOUND_TRIGGER_BLOCK,
TIMING_POINT_SECTION,
TIMING_POINT,
TPS_BODY,
DDL_EVENT,
DATABASE_EVENT,
// Program units
COMPILATION_UNIT,
UNIT_NAME,
ANONYMOUS_BLOCK,
PROCEDURE_DECLARATION,
FUNCTION_DECLARATION,
CREATE_PROCEDURE,
CREATE_FUNCTION,
CREATE_PACKAGE,
CREATE_PACKAGE_BODY,
VIEW_RESTRICTION_CLAUSE,
CREATE_VIEW,
TYPE_ATTRIBUTE,
INHERITANCE_CLAUSE,
TYPE_SUBPROGRAM,
TYPE_CONSTRUCTOR,
MAP_ORDER_FUNCTION,
TYPE_ELEMENT_SPEC,
OBJECT_TYPE_DEFINITION,
CREATE_TRIGGER,
CREATE_TYPE,
CREATE_TYPE_BODY,
// Top-level components
VALID_INPUT,
RECOVERY,
FILE_INPUT;
companion object {
fun create(conf: PlSqlConfiguration): PlSqlGrammarBuilder {
val b = PlSqlGrammarBuilder(LexerfulGrammarBuilder.create())
val keywords = PlSqlKeyword.nonReservedKeywords
val rest = keywords.subList(2, keywords.size).toTypedArray()
b.rule(NON_RESERVED_KEYWORD).define(b.firstOf(keywords[0], keywords[1], *rest))
b.rule(IDENTIFIER_NAME).define(b.firstOf(IDENTIFIER, NON_RESERVED_KEYWORD))
b.rule(VALID_INPUT).define(b.firstOf(
COMPILATION_UNIT,
DCL_COMMAND,
DDL_COMMAND,
DML_COMMAND,
TCL_COMMAND,
SQLPLUS_COMMAND,
SESSION_CONTROL_COMMAND,
EXECUTE_PLSQL_BUFFER)).skip()
if (conf.isErrorRecoveryEnabled) {
b.rule(RECOVERY).define(b.oneOrMore(
b.nextNot(b.firstOf(VALID_INPUT, EOF)),
b.anyToken()))
b.rule(FILE_INPUT).define(b.zeroOrMore(b.firstOf(
VALID_INPUT,
RECOVERY)), EOF)
} else {
b.rule(RECOVERY).define(b.nothing())
b.rule(FILE_INPUT).define(b.zeroOrMore(VALID_INPUT), EOF)
}
createLiterals(b)
createOperators(b)
createDatatypes(b)
createStatements(b)
createExpressions(b)
createDeclarations(b)
createTrigger(b)
createProgramUnits(b)
DdlGrammar.buildOn(b)
DmlGrammar.buildOn(b)
DclGrammar.buildOn(b)
TclGrammar.buildOn(b)
SqlPlusGrammar.buildOn(b)
SessionControlGrammar.buildOn(b)
SingleRowSqlFunctionsGrammar.buildOn(b)
AggregateSqlFunctionsGrammar.buildOn(b)
ConditionsGrammar.buildOn(b)
b.setRootRule(FILE_INPUT)
b.buildWithMemoizationOfMatchesForAllRules()
return b
}
private fun createLiterals(b: PlSqlGrammarBuilder) {
b.rule(INTERVAL_YEAR_TO_MONTH_LITERAL).define(
INTERVAL, CHARACTER_LITERAL,
b.firstOf(YEAR, MONTH), b.optional(LPARENTHESIS, INTEGER_LITERAL, RPARENTHESIS),
b.optional(TO, b.firstOf(YEAR, MONTH)))
b.rule(INTERVAL_DAY_TO_SECOND_LITERAL).define(
INTERVAL, CHARACTER_LITERAL,
b.firstOf(
b.sequence(b.firstOf(DAY, HOUR, MINUTE), b.optional(LPARENTHESIS, INTEGER_LITERAL, RPARENTHESIS)),
b.sequence(SECOND, b.optional(LPARENTHESIS, INTEGER_LITERAL, b.optional(COMMA, INTEGER_LITERAL), RPARENTHESIS))
),
b.optional(TO,
b.firstOf(
DAY,
HOUR,
MINUTE,
b.sequence(SECOND, b.optional(LPARENTHESIS, INTEGER_LITERAL, RPARENTHESIS))
)))
b.rule(NULL_LITERAL).define(NULL)
b.rule(BOOLEAN_LITERAL).define(b.firstOf(TRUE, FALSE))
b.rule(NUMERIC_LITERAL).define(b.firstOf(INTEGER_LITERAL, NUMBER_LITERAL))
b.rule(FLOATING_POINT_LITERAL).define(b.firstOf(BINARY_DOUBLE_INFINITY, BINARY_DOUBLE_NAN, BINARY_FLOAT_INFINITY, BINARY_FLOAT_NAN))
b.rule(CHARACTER_LITERAL).define(STRING_LITERAL)
b.rule(INTERVAL_LITERAL).define(b.firstOf(INTERVAL_YEAR_TO_MONTH_LITERAL, INTERVAL_DAY_TO_SECOND_LITERAL))
b.rule(INQUIRY_DIRECTIVE).define(DOUBLEDOLLAR, IDENTIFIER_NAME)
b.rule(LITERAL).define(b.firstOf(NULL_LITERAL, BOOLEAN_LITERAL, NUMERIC_LITERAL,
FLOATING_POINT_LITERAL, CHARACTER_LITERAL, DATE_LITERAL, TIMESTAMP_LITERAL, INTERVAL_LITERAL, INQUIRY_DIRECTIVE))
}
private fun createOperators(b: PlSqlGrammarBuilder) {
b.rule(CONCATENATION_OPERATOR).define(SINGLE_PIPE, SINGLE_PIPE)
b.rule(EQUALS_OPERATOR).define(EQUALS)
b.rule(NOTEQUALS_STANDARD_OPERATOR).define(LESSTHAN, GREATERTHAN)
b.rule(NOTEQUALS_NONSTANDARD_OPERATOR).define(b.firstOf(EXCLAMATION, CARET, TILDE), EQUALS)
b.rule(NOTEQUALS_OPERATOR).define(b.firstOf(NOTEQUALS_STANDARD_OPERATOR, NOTEQUALS_NONSTANDARD_OPERATOR))
b.rule(LESSTHAN_OPERATOR).define(LESSTHAN)
b.rule(LESSTHANOREQUALS_OPERATOR).define(LESSTHAN, EQUALS)
b.rule(GREATERTHAN_OPERATOR).define(GREATERTHAN)
b.rule(GREATERTHANOREQUALS_OPERATOR).define(GREATERTHAN, EQUALS)
}
private fun createDatatypes(b: PlSqlGrammarBuilder) {
b.rule(DATATYPE_LENGTH).define(b.firstOf(EXPRESSION, INQUIRY_DIRECTIVE)).skip()
b.rule(NUMERIC_PRECISION).define(b.firstOf(MULTIPLICATION, DATATYPE_LENGTH))
b.rule(NUMERIC_SCALE).define(DATATYPE_LENGTH)
b.rule(NUMERIC_DATATYPE_CONSTRAINT).define(
LPARENTHESIS, NUMERIC_PRECISION, b.optional(COMMA, NUMERIC_SCALE), RPARENTHESIS
)
b.rule(NUMERIC_DATATYPE).define(
b.firstOf(
BINARY_DOUBLE,
BINARY_FLOAT,
BINARY_INTEGER,
DEC,
DECIMAL,
b.sequence(DOUBLE, PRECISION),
FLOAT,
INT,
INTEGER,
NATURAL,
NATURALN,
NUMBER,
NUMERIC,
PLS_INTEGER,
POSITIVE,
POSITIVEN,
REAL,
SIGNTYPE,
SMALLINT),
b.optional(NUMERIC_DATATYPE_CONSTRAINT))
b.rule(CHARACTER_SET_CLAUSE).define(CHARACTER, SET, b.firstOf(ANY_CS, b.sequence(IDENTIFIER_NAME, MOD, CHARSET)))
b.rule(LOB_DATATYPE).define(b.firstOf(BFILE, BLOB, CLOB, NCLOB), b.optional(CHARACTER_SET_CLAUSE))
b.rule(CHARACTER_DATATYPE_CONSTRAINT).define(
b.firstOf(
b.sequence(LPARENTHESIS, DATATYPE_LENGTH, b.optional(b.firstOf(BYTE, CHAR)), RPARENTHESIS, b.optional(CHARACTER_SET_CLAUSE)),
CHARACTER_SET_CLAUSE))
b.rule(CHARACTER_DATAYPE).define(
b.firstOf(
CHAR,
CHARACTER,
b.sequence(LONG, b.optional(RAW)),
NCHAR,
NVARCHAR2,
RAW,
ROWID,
STRING,
UROWID,
VARCHAR,
VARCHAR2),
b.optional(CHARACTER_DATATYPE_CONSTRAINT))
b.rule(BOOLEAN_DATATYPE).define(BOOLEAN)
b.rule(DATE_DATATYPE).define(b.firstOf(
DATE,
b.sequence(TIMESTAMP, b.optional(LPARENTHESIS, DATATYPE_LENGTH, RPARENTHESIS), b.optional(WITH, b.optional(LOCAL), TIME, ZONE)),
b.sequence(INTERVAL, YEAR, b.optional(LPARENTHESIS, DATATYPE_LENGTH, RPARENTHESIS), TO, MONTH),
b.sequence(INTERVAL, DAY, b.optional(LPARENTHESIS, DATATYPE_LENGTH, RPARENTHESIS),
TO, SECOND, b.optional(LPARENTHESIS, DATATYPE_LENGTH, RPARENTHESIS))))
b.rule(ANCHORED_DATATYPE).define(MEMBER_EXPRESSION, MOD, b.firstOf(TYPE, ROWTYPE))
b.rule(CUSTOM_DATATYPE).define(
MEMBER_EXPRESSION,
b.optional(b.firstOf(NUMERIC_DATATYPE_CONSTRAINT, CHARACTER_DATATYPE_CONSTRAINT)))
b.rule(REF_DATATYPE).define(REF, MEMBER_EXPRESSION)
b.rule(JSON_DATATYPE).define(JSON)
b.rule(DATATYPE).define(b.firstOf(
NUMERIC_DATATYPE,
LOB_DATATYPE,
CHARACTER_DATAYPE,
BOOLEAN_DATATYPE,
DATE_DATATYPE,
ANCHORED_DATATYPE,
REF_DATATYPE,
JSON_DATATYPE,
CUSTOM_DATATYPE))
b.rule(DATATYPE_NULL_CONSTRAINT).define(
b.firstOf(
b.sequence(NOT, NULL),
NULL
)
)
}
private fun createStatements(b: PlSqlGrammarBuilder) {
b.rule(HOST_AND_INDICATOR_VARIABLE).define(
b.firstOf(
b.sequence(
COLON, b.firstOf(
b.sequence(IDENTIFIER_NAME, b.optional(INDICATOR), b.optional(COLON, IDENTIFIER_NAME)),
INTEGER_LITERAL
)
),
QUESTION_MARK
)
)
b.rule(NULL_STATEMENT, NullStatement::class).define(NULL, SEMICOLON)
b.rule(EXCEPTION_HANDLER).define(
WHEN,
b.firstOf(OTHERS, OBJECT_REFERENCE),
b.zeroOrMore(OR, b.firstOf(OTHERS, OBJECT_REFERENCE)),
THEN, STATEMENTS)
b.rule(EXCEPTION_HANDLERS).define(EXCEPTION, b.oneOrMore(EXCEPTION_HANDLER))
b.rule(LABEL).define(LLABEL, IDENTIFIER_NAME, RLABEL)
b.rule(STATEMENTS_SECTION).define(
BEGIN,
STATEMENTS,
b.optional(EXCEPTION_HANDLERS),
END, b.optional(IDENTIFIER_NAME), SEMICOLON)
b.rule(BLOCK_STATEMENT).define(
b.optional(LABEL),
b.optional(DECLARE, b.optional(DECLARE_SECTION)),
STATEMENTS_SECTION)
b.rule(ASSIGNMENT_STATEMENT).define(b.optional(LABEL), OBJECT_REFERENCE, ASSIGNMENT, EXPRESSION, SEMICOLON)
b.rule(ELSIF_CLAUSE, ElsifClause::class).define(ELSIF, EXPRESSION, THEN, STATEMENTS)
b.rule(ELSE_CLAUSE, ElseClause::class).define(ELSE, STATEMENTS)
b.rule(IF_STATEMENT, IfStatement::class).define(
b.optional(LABEL),
IF, EXPRESSION, THEN,
STATEMENTS,
b.zeroOrMore(ELSIF_CLAUSE),
b.optional(ELSE_CLAUSE),
END, IF, b.optional(IDENTIFIER_NAME), SEMICOLON)
b.rule(LOOP_STATEMENT).define(b.optional(LABEL), LOOP, STATEMENTS, END, LOOP, b.optional(IDENTIFIER_NAME), SEMICOLON)
b.rule(EXIT_STATEMENT).define(b.optional(LABEL), EXIT, b.optional(IDENTIFIER_NAME), b.optional(WHEN, EXPRESSION), SEMICOLON)
b.rule(CONTINUE_STATEMENT).define(b.optional(LABEL), CONTINUE, b.optional(IDENTIFIER_NAME), b.optional(WHEN, EXPRESSION), SEMICOLON)
b.rule(GOTO_STATEMENT).define(b.optional(LABEL), GOTO, b.optional(IDENTIFIER_NAME), SEMICOLON)
b.rule(ITERATOR).define(
ITERAND_DECLARATION,
b.optional(COMMA, ITERAND_DECLARATION),
IN, ITERATION_CTL_SEQ)
b.rule(ITERAND_DECLARATION).define(
IDENTIFIER_NAME,
b.optional(b.firstOf(MUTABLE, IMMUTABLE)),
b.optional(DATATYPE),
b.optional(DATATYPE_NULL_CONSTRAINT))
b.rule(ITERATION_CTL_SEQ).define(QUAL_ITERATION_CTL, b.zeroOrMore(COMMA, QUAL_ITERATION_CTL)).skip()
b.rule(QUAL_ITERATION_CTL).define(b.optional(REVERSE), ITERATION_CONTROL, PRED_CLAUSE_SEQ)
b.rule(PRED_CLAUSE_SEQ).define(b.optional(WHILE, EXPRESSION), b.optional(WHEN, EXPRESSION)).skip()
b.rule(ITERATION_CONTROL).define(b.firstOf(
STEPPED_CONTROL,
VALUES_OF_CONTROL,
INDICES_OF_CONTROL,
PAIRS_OF_CONTROL,
SINGLE_EXPRESSION_CONTROL,
DYNAMIC_SQL)).skip()
b.rule(STEPPED_CONTROL).define(EXPRESSION, RANGE, EXPRESSION, b.optional(BY, OBJECT_REFERENCE))
b.rule(SINGLE_EXPRESSION_CONTROL).define(b.optional(REPEAT), CONCATENATION_EXPRESSION)
b.rule(VALUES_OF_CONTROL).define(VALUES, OF, b.firstOf(OBJECT_REFERENCE, DYNAMIC_SQL))
b.rule(INDICES_OF_CONTROL).define(INDICES, OF, b.firstOf(OBJECT_REFERENCE, DYNAMIC_SQL))
b.rule(PAIRS_OF_CONTROL).define(PAIRS, OF, b.firstOf(OBJECT_REFERENCE, DYNAMIC_SQL))
b.rule(DYNAMIC_SQL).define(
LPARENTHESIS,
EXECUTE, IMMEDIATE, CONCATENATION_EXPRESSION,
b.optional(USING, UNNAMED_ACTUAL_PAMETER, b.zeroOrMore(COMMA, UNNAMED_ACTUAL_PAMETER)),
RPARENTHESIS)
b.rule(FOR_STATEMENT).define(
b.optional(LABEL),
FOR, ITERATOR, LOOP,
STATEMENTS,
END, LOOP, b.optional(IDENTIFIER_NAME), SEMICOLON)
b.rule(WHILE_STATEMENT).define(
b.optional(LABEL),
WHILE, EXPRESSION, LOOP,
STATEMENTS,
END, LOOP, b.optional(IDENTIFIER_NAME), SEMICOLON)
b.rule(FORALL_STATEMENT).define(
b.optional(LABEL),
FORALL, IDENTIFIER_NAME, IN,
b.firstOf(b.sequence(EXPRESSION, RANGE, EXPRESSION),
b.sequence(VALUES, OF, IDENTIFIER_NAME),
b.sequence(INDICES, OF, IDENTIFIER_NAME, b.optional(BETWEEN, AND_EXPRESSION))),
b.optional(SAVE, EXCEPTIONS),
b.firstOf(
INSERT_STATEMENT,
UPDATE_STATEMENT,
DELETE_STATEMENT,
MERGE_STATEMENT,
EXECUTE_IMMEDIATE_STATEMENT))
b.rule(RETURN_STATEMENT).define(b.optional(LABEL), RETURN, b.optional(EXPRESSION), SEMICOLON)
b.rule(COMMIT_STATEMENT).define(b.optional(LABEL), COMMIT_EXPRESSION, SEMICOLON)
b.rule(ROLLBACK_STATEMENT).define(b.optional(LABEL), ROLLBACK_EXPRESSION, SEMICOLON)
b.rule(SAVEPOINT_STATEMENT).define(b.optional(LABEL), SAVEPOINT_EXPRESSION, SEMICOLON)
b.rule(RAISE_STATEMENT, RaiseStatement::class).define(b.optional(LABEL), RAISE, b.optional(MEMBER_EXPRESSION), SEMICOLON)
b.rule(SELECT_STATEMENT).define(b.optional(LABEL), SELECT_EXPRESSION, SEMICOLON)
b.rule(INSERT_STATEMENT).define(b.optional(LABEL), INSERT_EXPRESSION, SEMICOLON)
b.rule(UPDATE_STATEMENT).define(b.optional(LABEL), UPDATE_EXPRESSION, SEMICOLON)
b.rule(DELETE_STATEMENT).define(b.optional(LABEL), DELETE_EXPRESSION, SEMICOLON)
b.rule(MERGE_STATEMENT).define(b.optional(LABEL), MERGE_EXPRESSION, SEMICOLON)
b.rule(CALL_STATEMENT).define(b.optional(LABEL), OBJECT_REFERENCE, SEMICOLON)
b.rule(UNNAMED_ACTUAL_PAMETER).define(
b.optional(b.firstOf(b.sequence(IN, b.optional(OUT)), OUT)),
EXPRESSION)
b.rule(EXECUTE_IMMEDIATE_STATEMENT).define(
b.optional(LABEL),
b.optional(FORALL_STATEMENT),
EXECUTE, IMMEDIATE, CONCATENATION_EXPRESSION,
b.optional(INTO_CLAUSE),
b.optional(USING, UNNAMED_ACTUAL_PAMETER, b.zeroOrMore(COMMA, UNNAMED_ACTUAL_PAMETER)),
b.optional(RETURNING_INTO_CLAUSE),
SEMICOLON)
b.rule(OPEN_STATEMENT).define(
b.optional(LABEL),
OPEN, MEMBER_EXPRESSION,
b.optional(ARGUMENTS),
SEMICOLON)
b.rule(OPEN_FOR_STATEMENT).define(
b.optional(LABEL),
OPEN, MEMBER_EXPRESSION, FOR, b.firstOf(SELECT_EXPRESSION, EXPRESSION),
b.optional(USING, UNNAMED_ACTUAL_PAMETER, b.zeroOrMore(COMMA, UNNAMED_ACTUAL_PAMETER)),
SEMICOLON)
b.rule(FETCH_STATEMENT).define(
b.optional(LABEL),
FETCH, MEMBER_EXPRESSION,
INTO_CLAUSE, b.optional(LIMIT, EXPRESSION),
SEMICOLON)
b.rule(CLOSE_STATEMENT).define(b.optional(LABEL), CLOSE, MEMBER_EXPRESSION, SEMICOLON)
b.rule(PIPE_ROW_STATEMENT).define(b.optional(LABEL), PIPE, ROW, LPARENTHESIS, EXPRESSION, RPARENTHESIS, SEMICOLON)
b.rule(CASE_STATEMENT).define(
b.optional(LABEL),
CASE, b.optional(EXPRESSION),
b.oneOrMore(WHEN, EXPRESSION, THEN, STATEMENTS),
b.optional(ELSE, STATEMENTS),
END, CASE, b.optional(IDENTIFIER_NAME), SEMICOLON)
//https://docs.oracle.com/cd/E11882_01/server.112/e41084/statements_10005.htm#SQLRF01705
b.rule(SET_TRANSACTION_STATEMENT).define(b.optional(LABEL), SET_TRANSACTION_EXPRESSION, SEMICOLON)
b.rule(INLINE_PRAGMA_STATEMENT).define(PRAGMA, INLINE,
LPARENTHESIS, MEMBER_EXPRESSION, COMMA, STRING_LITERAL, RPARENTHESIS, SEMICOLON)
b.rule(STATEMENT).define(b.firstOf(NULL_STATEMENT,
BLOCK_STATEMENT,
ASSIGNMENT_STATEMENT,
IF_STATEMENT,
LOOP_STATEMENT,
EXIT_STATEMENT,
CONTINUE_STATEMENT,
GOTO_STATEMENT,
FOR_STATEMENT,
WHILE_STATEMENT,
RETURN_STATEMENT,
COMMIT_STATEMENT,
ROLLBACK_STATEMENT,
SAVEPOINT_STATEMENT,
RAISE_STATEMENT,
FORALL_STATEMENT,
SELECT_STATEMENT,
INSERT_STATEMENT,
UPDATE_STATEMENT,
DELETE_STATEMENT,
CALL_STATEMENT,
EXECUTE_IMMEDIATE_STATEMENT,
OPEN_STATEMENT,
OPEN_FOR_STATEMENT,
FETCH_STATEMENT,
CLOSE_STATEMENT,
PIPE_ROW_STATEMENT,
CASE_STATEMENT,
SET_TRANSACTION_STATEMENT,
MERGE_STATEMENT,
INLINE_PRAGMA_STATEMENT,
COVERAGE_PRAGMA))
b.rule(STATEMENTS, Statements::class).define(b.oneOrMore(STATEMENT))
}
private fun createExpressions(b: PlSqlGrammarBuilder) {
// Reference: http://docs.oracle.com/cd/B28359_01/appdev.111/b28370/expression.htm
b.rule(VARIABLE_NAME).define(b.firstOf(IDENTIFIER_NAME, HOST_AND_INDICATOR_VARIABLE))
b.rule(PRIMARY_EXPRESSION).define(
b.firstOf(LITERAL, VARIABLE_NAME, SQL, MULTIPLICATION)).skip()
b.rule(BRACKED_EXPRESSION).define(b.firstOf(
PRIMARY_EXPRESSION,
b.sequence(LPARENTHESIS, EXPRESSION, RPARENTHESIS))).skipIfOneChild()
b.rule(MULTIPLE_VALUE_EXPRESSION).define(b.firstOf(
BRACKED_EXPRESSION,
b.sequence(LPARENTHESIS, EXPRESSION, b.oneOrMore(COMMA, EXPRESSION), RPARENTHESIS))).skipIfOneChild()
b.rule(MEMBER_EXPRESSION).define(
MULTIPLE_VALUE_EXPRESSION,
b.zeroOrMore(
b.firstOf(DOT,
REMOTE,
b.sequence(MOD, b.nextNot(ROWTYPE), b.nextNot(TYPE))),
b.firstOf(
IDENTIFIER_NAME,
COUNT,
ROWCOUNT,
BULK_ROWCOUNT,
FIRST,
LAST,
LIMIT,
NEXT,
PRIOR,
EXISTS,
FOUND,
NOTFOUND,
ISOPEN,
DELETE,
TRIM,
EXTEND,
NEXTVAL,
CURRVAL)
)).skipIfOneChild()
b.rule(ARGUMENT).define(b.optional(IDENTIFIER_NAME, ASSOCIATION), b.optional(DISTINCT), EXPRESSION)
b.rule(ARGUMENTS).define(LPARENTHESIS, b.optional(ARGUMENT, b.zeroOrMore(COMMA, ARGUMENT)), RPARENTHESIS)
b.rule(METHOD_CALL).define(MEMBER_EXPRESSION, b.oneOrMore(ARGUMENTS))
b.rule(SEQUENCE_ITERATOR_CHOICE).define(FOR, ITERATOR, SEQUENCE, ASSOCIATION, EXPRESSION)
b.rule(POSITIONAL_CHOICE_OPTION).define(b.firstOf(
SEQUENCE_ITERATOR_CHOICE,
b.sequence(EXPRESSION, b.nextNot(b.firstOf(SINGLE_PIPE, ASSOCIATION))))).skip()
b.rule(POSITIONAL_CHOICE_LIST).define(
POSITIONAL_CHOICE_OPTION,
b.zeroOrMore(COMMA, POSITIONAL_CHOICE_OPTION)
)
b.rule(NAMED_CHOICE_LIST).define(
IDENTIFIER_NAME,
b.zeroOrMore(SINGLE_PIPE, IDENTIFIER_NAME),
ASSOCIATION, EXPRESSION)
b.rule(INDEXED_CHOICE_LIST).define(
EXPRESSION,
b.zeroOrMore(SINGLE_PIPE, EXPRESSION),
ASSOCIATION, EXPRESSION)
b.rule(BASIC_ITERATOR_CHOICE).define(
FOR, ITERATOR, ASSOCIATION, EXPRESSION)
b.rule(INDEX_ITERATOR_CHOICE).define(
FOR, ITERATOR, INDEX, EXPRESSION, ASSOCIATION, EXPRESSION)
b.rule(EXPLICIT_CHOICE_OPTION).define(
b.firstOf(NAMED_CHOICE_LIST, INDEXED_CHOICE_LIST, BASIC_ITERATOR_CHOICE, INDEX_ITERATOR_CHOICE)).skip()
b.rule(EXPLICIT_CHOICE_LIST).define(
EXPLICIT_CHOICE_OPTION, b.zeroOrMore(COMMA, EXPLICIT_CHOICE_OPTION))
b.rule(QUALIFIED_EXPRESSION).define(
MEMBER_EXPRESSION,
LPARENTHESIS,
b.optional(POSITIONAL_CHOICE_LIST),
b.optional(EXPLICIT_CHOICE_LIST),
RPARENTHESIS)
b.rule(CALL_EXPRESSION).define(b.firstOf(
SingleRowSqlFunctionsGrammar.SINGLE_ROW_SQL_FUNCTION,
AggregateSqlFunctionsGrammar.AGGREGATE_SQL_FUNCTION,
METHOD_CALL,
QUALIFIED_EXPRESSION)).skipIfOneChild()
b.rule(OUTER_JOIN_PLUS_SIGN).define(LPARENTHESIS, PLUS, RPARENTHESIS)
b.rule(OBJECT_REFERENCE).define(
b.firstOf(CALL_EXPRESSION, MEMBER_EXPRESSION),
b.zeroOrMore(DOT, b.firstOf(CALL_EXPRESSION, MEMBER_EXPRESSION)),
b.optional(OUTER_JOIN_PLUS_SIGN)).skipIfOneChild()
b.rule(POSTFIX_EXPRESSION).define(OBJECT_REFERENCE,
b.optional(b.firstOf(
ANALYTIC_CLAUSE,
b.sequence(KEEP_CLAUSE, b.optional(ANALYTIC_CLAUSE))))).skipIfOneChild()
b.rule(IN_EXPRESSION).define(CONCATENATION_EXPRESSION,
b.optional(b.sequence(
b.optional(NOT), IN,
b.firstOf(
b.sequence(
LPARENTHESIS,
b.firstOf(
SELECT_EXPRESSION,
b.sequence(EXPRESSION, b.zeroOrMore(COMMA, EXPRESSION)),
),
RPARENTHESIS),
EXPRESSION)))).skipIfOneChild()
b.rule(EXISTS_EXPRESSION).define(EXISTS, LPARENTHESIS, SELECT_EXPRESSION, RPARENTHESIS).skipIfOneChild()
b.rule(CASE_EXPRESSION).define(
CASE, b.optional(EXPRESSION),
b.oneOrMore(WHEN, EXPRESSION, THEN, EXPRESSION),
b.optional(ELSE, EXPRESSION),
END)
b.rule(AT_TIME_ZONE_EXPRESSION).define(AT, b.firstOf(LOCAL, b.sequence(TIME, ZONE, EXPRESSION)))
b.rule(NEW_OBJECT_EXPRESSION).define(NEW, OBJECT_REFERENCE, b.optional(ARGUMENTS))
//https://docs.oracle.com/cd/E11882_01/server.112/e41084/operators006.htm#SQLRF0032
b.rule(MULTISET_EXPRESSION).define(
OBJECT_REFERENCE,
b.oneOrMore(
MULTISET,
b.firstOf(EXCEPT, INTERSECT, UNION),
b.optional(b.firstOf(ALL, DISTINCT)),
OBJECT_REFERENCE))
b.rule(UNARY_EXPRESSION).define(b.firstOf(
b.sequence(PLUS, UNARY_EXPRESSION),
b.sequence(MINUS, UNARY_EXPRESSION),
b.sequence(PRIOR, UNARY_EXPRESSION),
b.sequence(CONNECT_BY_ROOT, UNARY_EXPRESSION),
EXISTS_EXPRESSION,
MULTISET_EXPRESSION,
NEW_OBJECT_EXPRESSION,
CASE_EXPRESSION,
POSTFIX_EXPRESSION,
b.sequence(LPARENTHESIS, SELECT_EXPRESSION, RPARENTHESIS)),
b.optional(AT_TIME_ZONE_EXPRESSION)).skipIfOneChild()
b.rule(EXPONENTIATION_EXPRESSION).define(UNARY_EXPRESSION, b.zeroOrMore(EXPONENTIATION, UNARY_EXPRESSION)).skipIfOneChild()
b.rule(MULTIPLICATIVE_EXPRESSION).define(
EXPONENTIATION_EXPRESSION, b.zeroOrMore(
b.firstOf(
MULTIPLICATION,
b.sequence(b.nextNot(EXECUTE_PLSQL_BUFFER), DIVISION),
MOD_KEYWORD
), EXPONENTIATION_EXPRESSION
)
).skipIfOneChild()
b.rule(ADDITIVE_EXPRESSION).define(MULTIPLICATIVE_EXPRESSION, b.zeroOrMore(b.firstOf(PLUS, MINUS), MULTIPLICATIVE_EXPRESSION)).skipIfOneChild()
b.rule(CONCATENATION_EXPRESSION).define(ADDITIVE_EXPRESSION, b.zeroOrMore(CONCATENATION_OPERATOR, ADDITIVE_EXPRESSION)).skipIfOneChild()
b.rule(COMPARISON_EXPRESSION).define(b.firstOf(
ConditionsGrammar.CONDITION,
IN_EXPRESSION)).skipIfOneChild()
b.rule(NOT_EXPRESSION).define(b.optional(NOT), COMPARISON_EXPRESSION).skipIfOneChild()
b.rule(AND_EXPRESSION).define(NOT_EXPRESSION, b.zeroOrMore(AND, NOT_EXPRESSION)).skipIfOneChild()
b.rule(OR_EXPRESSION).define(AND_EXPRESSION, b.zeroOrMore(OR, AND_EXPRESSION)).skipIfOneChild()
b.rule(BOOLEAN_EXPRESSION).define(OR_EXPRESSION).skip()
b.rule(EXPRESSION).define(BOOLEAN_EXPRESSION).skipIfOneChild()
}
private fun createDeclarations(b: PlSqlGrammarBuilder) {
b.rule(DEFAULT_VALUE_ASSIGNMENT).define(b.firstOf(ASSIGNMENT, DEFAULT), EXPRESSION)
b.rule(PARAMETER_DECLARATION).define(
IDENTIFIER_NAME,
b.optional(IN),
b.firstOf(
b.sequence(DATATYPE, b.optional(DEFAULT_VALUE_ASSIGNMENT)),
b.sequence(OUT, b.optional(NOCOPY), DATATYPE))
)
b.rule(PARAMETER_DECLARATIONS).define(LPARENTHESIS, b.oneOrMore(PARAMETER_DECLARATION, b.optional(COMMA)), RPARENTHESIS)
b.rule(JAVA_DECLARATION).define(LANGUAGE, JAVA, NAME, STRING_LITERAL)
b.rule(C_DECLARATION).define(
b.firstOf(b.sequence(LANGUAGE, "C"), EXTERNAL),
b.optional(NAME, IDENTIFIER_NAME), LIBRARY, IDENTIFIER_NAME, b.optional(NAME, IDENTIFIER_NAME),
b.optional(AGENT, IN, LPARENTHESIS, b.oneOrMore(IDENTIFIER_NAME, b.optional(COMMA)), RPARENTHESIS),
b.optional(WITH, CONTEXT),
b.optional(PARAMETERS, LPARENTHESIS, b.oneOrMore(EXTERNAL_PARAMETER, b.optional(COMMA)), RPARENTHESIS))
b.rule(EXTERNAL_PARAMETER_PROPERTY).define(
b.sequence(INDICATOR, b.optional(b.firstOf(STRUCT, TDO))),
LENGTH,
DURATION,
MAXLEN,
CHARSETID,
CHARSETFORM)
b.rule(EXTERNAL_PARAMETER).define(b.firstOf(
CONTEXT,
b.sequence(SELF, b.firstOf(TDO, EXTERNAL_PARAMETER_PROPERTY)),
b.sequence(
b.firstOf(RETURN, IDENTIFIER_NAME),
b.optional(EXTERNAL_PARAMETER_PROPERTY),
b.optional(BY, REFERENCE),
b.optional(DATATYPE))))
b.rule(CALL_SPECIFICATION).define(b.firstOf(JAVA_DECLARATION, C_DECLARATION), SEMICOLON)
// http://docs.oracle.com/cd/B28359_01/appdev.111/b28370/procedure.htm
b.rule(PROCEDURE_DECLARATION).define(
PROCEDURE, IDENTIFIER_NAME,
b.optional(PARAMETER_DECLARATIONS),
b.optional(b.firstOf(
SEMICOLON,
b.sequence(b.firstOf(IS, AS),
b.firstOf(
b.sequence(b.optional(DECLARE_SECTION), STATEMENTS_SECTION),
CALL_SPECIFICATION)))
))
// http://docs.oracle.com/cd/B28359_01/appdev.111/b28370/function.htm
b.rule(FUNCTION_DECLARATION).define(
FUNCTION, IDENTIFIER_NAME,
b.optional(PARAMETER_DECLARATIONS),
RETURN, DATATYPE, b.zeroOrMore(b.firstOf(DETERMINISTIC, PIPELINED, PARALLEL_ENABLE)),
b.optional(RESULT_CACHE, b.optional(RELIES_ON, LPARENTHESIS, b.oneOrMore(OBJECT_REFERENCE, b.optional(COMMA)), RPARENTHESIS)),
b.optional(b.firstOf(
SEMICOLON,
b.sequence(b.firstOf(IS, AS),
b.firstOf(
b.sequence(b.optional(DECLARE_SECTION), STATEMENTS_SECTION),
CALL_SPECIFICATION)))
))
b.rule(VARIABLE_DECLARATION).define(IDENTIFIER_NAME,
b.optional(CONSTANT),
b.firstOf(
b.sequence(
DATATYPE,
b.optional(DATATYPE_NULL_CONSTRAINT),
b.optional(DEFAULT_VALUE_ASSIGNMENT)),
EXCEPTION),
SEMICOLON)
b.rule(EXCEPTION_DECLARATION).define(IDENTIFIER_NAME, EXCEPTION, SEMICOLON)
b.rule(CUSTOM_SUBTYPE).define(
SUBTYPE, IDENTIFIER_NAME, IS, DATATYPE,
b.optional(DATATYPE_NULL_CONSTRAINT),
b.optional(RANGE_KEYWORD, NUMERIC_LITERAL, RANGE, NUMERIC_LITERAL),
SEMICOLON
)
b.rule(CURSOR_PARAMETER_DECLARATION).define(
IDENTIFIER_NAME,
b.optional(IN),
DATATYPE, b.optional(DEFAULT_VALUE_ASSIGNMENT))
b.rule(CURSOR_PARAMETER_DECLARATIONS).define(
LPARENTHESIS, b.oneOrMore(CURSOR_PARAMETER_DECLARATION, b.optional(COMMA)), RPARENTHESIS)
b.rule(CURSOR_DECLARATION).define(
CURSOR, IDENTIFIER_NAME,
b.optional(CURSOR_PARAMETER_DECLARATIONS),
b.optional(RETURN, DATATYPE),
b.optional(IS, SELECT_EXPRESSION), SEMICOLON)
b.rule(RECORD_FIELD_DECLARATION).define(
IDENTIFIER_NAME, DATATYPE,
b.optional(DATATYPE_NULL_CONSTRAINT),
b.optional(DEFAULT_VALUE_ASSIGNMENT)
)
b.rule(RECORD_DECLARATION).define(
TYPE, IDENTIFIER_NAME, IS, RECORD,
LPARENTHESIS, RECORD_FIELD_DECLARATION, b.zeroOrMore(COMMA, RECORD_FIELD_DECLARATION), RPARENTHESIS,
SEMICOLON)
b.rule(NESTED_TABLE_DEFINITION).define(TABLE, OF, DATATYPE, b.optional(DATATYPE_NULL_CONSTRAINT))
b.rule(TABLE_OF_DECLARATION).define(
TYPE, IDENTIFIER_NAME, IS, NESTED_TABLE_DEFINITION,
b.optional(INDEX, BY, DATATYPE, b.optional(DATATYPE_NULL_CONSTRAINT)),
SEMICOLON)
b.rule(VARRAY_TYPE_DEFINITION).define(
b.firstOf(VARRAY, b.sequence(b.optional(VARYING), ARRAY)),
LPARENTHESIS, INTEGER_LITERAL, RPARENTHESIS,
OF, DATATYPE, b.optional(DATATYPE_NULL_CONSTRAINT)
)
b.rule(VARRAY_DECLARATION).define(
TYPE, IDENTIFIER_NAME, IS, VARRAY_TYPE_DEFINITION, SEMICOLON)
b.rule(REF_CURSOR_DECLARATION).define(TYPE, IDENTIFIER_NAME, IS, REF, CURSOR, b.optional(RETURN, DATATYPE), SEMICOLON)
b.rule(AUTONOMOUS_TRANSACTION_PRAGMA).define(PRAGMA, AUTONOMOUS_TRANSACTION, SEMICOLON)
b.rule(EXCEPTION_INIT_PRAGMA).define(PRAGMA, EXCEPTION_INIT, LPARENTHESIS, EXPRESSION, COMMA, EXPRESSION, RPARENTHESIS, SEMICOLON)
b.rule(SERIALLY_REUSABLE_PRAGMA).define(PRAGMA, SERIALLY_REUSABLE, SEMICOLON)
b.rule(INTERFACE_PRAGMA).define(
PRAGMA, INTERFACE,
LPARENTHESIS, IDENTIFIER_NAME, COMMA, IDENTIFIER_NAME, COMMA, INTEGER_LITERAL, RPARENTHESIS, SEMICOLON)
b.rule(RESTRICT_REFERENCES_PRAGMA).define(
PRAGMA, RESTRICT_REFERENCES, LPARENTHESIS, b.oneOrMore(b.anyTokenButNot(RPARENTHESIS)), RPARENTHESIS, SEMICOLON)
b.rule(UDF_PRAGMA).define(PRAGMA, UDF, SEMICOLON)
b.rule(DEPRECATE_PRAGMA).define(PRAGMA, DEPRECATE, LPARENTHESIS, EXPRESSION, b.optional(COMMA, STRING_LITERAL), RPARENTHESIS)
b.rule(SUPPRESSES_WARNING_6009_PRAGMA)
.define(PRAGMA, SUPPRESSES_WARNING_6009, LPARENTHESIS, IDENTIFIER_NAME, RPARENTHESIS)
b.rule(COVERAGE_PRAGMA)
.define(PRAGMA, COVERAGE, LPARENTHESIS, STRING_LITERAL, RPARENTHESIS, SEMICOLON)
b.rule(PRAGMA_DECLARATION).define(
b.firstOf(
EXCEPTION_INIT_PRAGMA,
AUTONOMOUS_TRANSACTION_PRAGMA,
SERIALLY_REUSABLE_PRAGMA,
INTERFACE_PRAGMA,
RESTRICT_REFERENCES_PRAGMA,
UDF_PRAGMA,
b.sequence(DEPRECATE_PRAGMA, SEMICOLON),
b.sequence(SUPPRESSES_WARNING_6009_PRAGMA, SEMICOLON),
COVERAGE_PRAGMA
)
)
b.rule(DECLARE_SECTION).define(b.oneOrMore(b.firstOf(
PRAGMA_DECLARATION,
EXCEPTION_DECLARATION,
VARIABLE_DECLARATION,
PROCEDURE_DECLARATION,
FUNCTION_DECLARATION,
CUSTOM_SUBTYPE,
CURSOR_DECLARATION,
RECORD_DECLARATION,
TABLE_OF_DECLARATION,
VARRAY_DECLARATION,
REF_CURSOR_DECLARATION)))
}
private fun createTrigger(b: PlSqlGrammarBuilder) {
b.rule(CREATE_TRIGGER).define(
CREATE, b.optional(OR, REPLACE),
b.optional(b.firstOf(EDITIONABLE, NONEDITIONABLE)),
TRIGGER, UNIT_NAME,
b.firstOf(SIMPLE_DML_TRIGGER, INSTEAD_OF_DML_TRIGGER, COMPOUND_DML_TRIGGER, SYSTEM_TRIGGER)
)
b.rule(SIMPLE_DML_TRIGGER).define(
b.firstOf(BEFORE, AFTER),
DML_EVENT_CLAUSE, b.zeroOrMore(OR, DML_EVENT_CLAUSE), ON, UNIT_NAME,
b.optional(REFERENCING_CLAUSE),
b.optional(FOR, EACH, ROW),
b.optional(TRIGGER_EDITION_CLAUSE),
b.optional(TRIGGER_ORDERING_CLAUSE),
b.optional(b.firstOf(ENABLE, DISABLE)),
b.optional(WHEN, LPARENTHESIS, EXPRESSION, RPARENTHESIS),
b.optional(DECLARE, b.optional(DECLARE_SECTION)), STATEMENTS_SECTION
)
b.rule(INSTEAD_OF_DML_TRIGGER).define(
INSTEAD, OF,
b.firstOf(
DELETE,
INSERT,
UPDATE),
b.zeroOrMore(OR, b.firstOf(
DELETE,
INSERT,
UPDATE)),
ON,
b.optional(NESTED, TABLE, IDENTIFIER_NAME, OF),
UNIT_NAME,
b.optional(REFERENCING_CLAUSE),
b.optional(FOR, EACH, ROW),
b.optional(TRIGGER_EDITION_CLAUSE),
b.optional(TRIGGER_ORDERING_CLAUSE),
b.optional(b.firstOf(ENABLE, DISABLE)),
b.optional(DECLARE, b.optional(DECLARE_SECTION)), STATEMENTS_SECTION
)
b.rule(COMPOUND_DML_TRIGGER).define(
FOR, DML_EVENT_CLAUSE, b.zeroOrMore(OR, DML_EVENT_CLAUSE), ON, UNIT_NAME,
b.optional(REFERENCING_CLAUSE),
b.optional(TRIGGER_EDITION_CLAUSE),
b.optional(TRIGGER_ORDERING_CLAUSE),
b.optional(b.firstOf(ENABLE, DISABLE)),
b.optional(WHEN, LPARENTHESIS, EXPRESSION, RPARENTHESIS),
COMPOUND_TRIGGER_BLOCK
)
b.rule(SYSTEM_TRIGGER).define(
b.firstOf(
b.sequence(b.firstOf(BEFORE, AFTER, b.sequence(INSTEAD, OF)),
DDL_EVENT, b.zeroOrMore(OR, DDL_EVENT)),
b.sequence(DATABASE_EVENT, b.zeroOrMore(OR, DATABASE_EVENT))),
ON,
b.firstOf(
b.sequence(b.optional(IDENTIFIER_NAME, DOT), SCHEMA),
b.sequence(b.optional(PLUGGABLE), DATABASE)),
b.optional(TRIGGER_ORDERING_CLAUSE),
b.optional(b.firstOf(ENABLE, DISABLE)),
b.optional(DECLARE, b.optional(DECLARE_SECTION)), STATEMENTS_SECTION
)
b.rule(DML_EVENT_CLAUSE).define(
b.firstOf(
DELETE,
INSERT,
UPDATE),
b.optional(OF, IDENTIFIER_NAME, b.zeroOrMore(COMMA, IDENTIFIER_NAME))
)
b.rule(REFERENCING_CLAUSE).define(
REFERENCING,
b.zeroOrMore(
b.firstOf(
b.sequence(OLD, b.optional(AS), IDENTIFIER_NAME),
b.sequence(NEW, b.optional(AS), IDENTIFIER_NAME),
b.sequence(PARENT, b.optional(AS), IDENTIFIER_NAME)
)))
b.rule(TRIGGER_EDITION_CLAUSE).define(
b.optional(b.firstOf(FORWARD, REVERSE)),
CROSSEDITION)
b.rule(TRIGGER_ORDERING_CLAUSE).define(
b.firstOf(FOLLOWS, PRECEDES),
UNIT_NAME, b.zeroOrMore(COMMA, UNIT_NAME))
b.rule(COMPOUND_TRIGGER_BLOCK).define(
COMPOUND, TRIGGER,
b.optional(DECLARE_SECTION),
b.oneOrMore(TIMING_POINT_SECTION),
END, UNIT_NAME, SEMICOLON)
b.rule(TIMING_POINT_SECTION).define(
TIMING_POINT, IS, BEGIN, TPS_BODY, END, TIMING_POINT, SEMICOLON)
b.rule(TIMING_POINT).define(
b.firstOf(
b.sequence(BEFORE, STATEMENT_KEYWORD),
b.sequence(BEFORE, EACH, ROW),
b.sequence(AFTER, STATEMENT_KEYWORD),
b.sequence(AFTER, EACH, ROW),
b.sequence(INSTEAD, OF, EACH, ROW)
))
b.rule(TPS_BODY).define(
b.oneOrMore(STATEMENT),
b.optional(EXCEPTION_HANDLERS))
b.rule(DDL_EVENT).define(
b.firstOf(
ALTER,
ANALYZE,
b.sequence(ASSOCIATE, STATISTICS),
AUDIT,
COMMENT,
CREATE,
b.sequence(DISASSOCIATE, STATISTICS),
DROP,
GRANT,
NOAUDIT,
RENAME,
REVOKE,
TRUNCATE,
DDL)
)
b.rule(DATABASE_EVENT).define(
b.firstOf(
b.sequence(AFTER, STARTUP),
b.sequence(BEFORE, SHUTDOWN),
b.sequence(AFTER, DB_ROLE_CHANGE),
b.sequence(AFTER, SERVERERROR),
b.sequence(AFTER, LOGON),
b.sequence(BEFORE, LOGOFF),
b.sequence(AFTER, SUSPEND),
b.sequence(AFTER, CLONE),
b.sequence(BEFORE, UNPLUG),
b.sequence(b.firstOf(BEFORE, AFTER), SET, CONTAINER))
)
}
private fun createProgramUnits(b: PlSqlGrammarBuilder) {
b.rule(EXECUTE_PLSQL_BUFFER).define(ExecuteBufferExpression, b.next(b.firstOf(VALID_INPUT, EOF)))
b.rule(UNIT_NAME).define(b.optional(IDENTIFIER_NAME, DOT), IDENTIFIER_NAME)
// https://docs.oracle.com/en/database/oracle/oracle-database/18/lnpls/CREATE-PROCEDURE-statement.html
b.rule(CREATE_PROCEDURE).define(
CREATE, b.optional(OR, REPLACE), b.optional(b.firstOf(EDITIONABLE, NONEDITIONABLE)),
PROCEDURE, UNIT_NAME, b.optional(TIMESTAMP, STRING_LITERAL),
b.optional(PARAMETER_DECLARATIONS),
b.optional(SHARING, EQUALS, b.firstOf(METADATA, NONE)),
b.zeroOrMore(b.firstOf(
b.sequence(AUTHID, b.firstOf(CURRENT_USER, DEFINER)),
b.sequence(DEFAULT, COLLATION, USING_NLS_COMP),
b.sequence(ACCESSIBLE, BY, LPARENTHESIS,
b.firstOf(FUNCTION, PROCEDURE, PACKAGE, TRIGGER, TYPE),
UNIT_NAME,
RPARENTHESIS))
),
b.firstOf(IS, AS),
b.firstOf(
b.sequence(b.optional(DECLARE_SECTION), STATEMENTS_SECTION),
CALL_SPECIFICATION)
)
// https://docs.oracle.com/en/database/oracle/oracle-database/18/lnpls/CREATE-FUNCTION-statement.html
b.rule(CREATE_FUNCTION).define(
CREATE, b.optional(OR, REPLACE), b.optional(b.firstOf(EDITIONABLE, NONEDITIONABLE)),
FUNCTION, UNIT_NAME, b.optional(TIMESTAMP, STRING_LITERAL),
b.optional(PARAMETER_DECLARATIONS),
RETURN, DATATYPE,
b.optional(SHARING, EQUALS, b.firstOf(METADATA, NONE)),
b.zeroOrMore(b.firstOf(
DETERMINISTIC,
PIPELINED,
PARALLEL_ENABLE,
b.sequence(
RESULT_CACHE,
b.optional(RELIES_ON, LPARENTHESIS, b.oneOrMore(OBJECT_REFERENCE, b.optional(COMMA)), RPARENTHESIS)),
b.sequence(AUTHID, b.firstOf(CURRENT_USER, DEFINER)),
b.sequence(DEFAULT, COLLATION, USING_NLS_COMP),
b.sequence(ACCESSIBLE, BY, LPARENTHESIS,
b.firstOf(FUNCTION, PROCEDURE, PACKAGE, TRIGGER, TYPE),
UNIT_NAME,
RPARENTHESIS))),
b.firstOf(
b.sequence(
b.firstOf(IS, AS),
b.firstOf(
b.sequence(b.optional(DECLARE_SECTION), STATEMENTS_SECTION),
CALL_SPECIFICATION)),
b.sequence(AGGREGATE, USING, OBJECT_REFERENCE, SEMICOLON))
)
// https://docs.oracle.com/en/database/oracle/oracle-database/18/lnpls/CREATE-PACKAGE-statement.html
b.rule(CREATE_PACKAGE).define(
b.optional(CREATE), b.optional(OR, REPLACE), b.optional(b.firstOf(EDITIONABLE, NONEDITIONABLE)),
PACKAGE, UNIT_NAME, b.optional(TIMESTAMP, STRING_LITERAL),
b.optional(SHARING, EQUALS, b.firstOf(METADATA, NONE)),
b.zeroOrMore(b.firstOf(
b.sequence(AUTHID, b.firstOf(CURRENT_USER, DEFINER)),
b.sequence(DEFAULT, COLLATION, USING_NLS_COMP),
b.sequence(ACCESSIBLE, BY, LPARENTHESIS,
b.firstOf(FUNCTION, PROCEDURE, PACKAGE, TRIGGER, TYPE),
UNIT_NAME,
RPARENTHESIS))),
b.firstOf(IS, AS),
b.optional(DECLARE_SECTION),
END, b.optional(IDENTIFIER_NAME), SEMICOLON)
// https://docs.oracle.com/en/database/oracle/oracle-database/18/lnpls/CREATE-PACKAGE-BODY-statement.html
b.rule(CREATE_PACKAGE_BODY).define(
b.optional(CREATE), b.optional(OR, REPLACE), b.optional(b.firstOf(EDITIONABLE, NONEDITIONABLE)),
PACKAGE, BODY, UNIT_NAME, b.optional(TIMESTAMP, STRING_LITERAL),
b.firstOf(IS, AS),
b.optional(DECLARE_SECTION),
b.firstOf(
STATEMENTS_SECTION,
b.sequence(END, b.optional(IDENTIFIER_NAME), SEMICOLON)))
b.rule(VIEW_RESTRICTION_CLAUSE).define(
WITH, b.firstOf(
b.sequence(READ, ONLY),
b.sequence(CHECK, OPTION, b.optional(CONSTRAINT, IDENTIFIER_NAME))
)
)
// https://docs.oracle.com/en/database/oracle/oracle-database/18/sqlrf/CREATE-VIEW.html
b.rule(CREATE_VIEW).define(
CREATE, b.optional(
b.firstOf(
b.sequence(MATERIALIZED, VIEW, UNIT_NAME,
b.zeroOrMore(
b.firstOf(
b.sequence(PCTFREE, INTEGER_LITERAL),
b.sequence(PCTUSED, INTEGER_LITERAL),
b.sequence(INITRANS, INTEGER_LITERAL),
b.sequence(TABLESPACE, IDENTIFIER_NAME)
)),
b.optional(b.sequence(b.optional(NO), REFRESH, COMPLETE, b.optional(START, WITH, EXPRESSION, NEXT, EXPRESSION)))),
b.sequence(b.optional(b.sequence(OR, REPLACE)), b.optional(b.firstOf(EDITIONABLE, NONEDITIONABLE)), b.optional(b.optional(NO), FORCE), VIEW, UNIT_NAME))),
b.optional(LPARENTHESIS, IDENTIFIER_NAME, b.zeroOrMore(COMMA, IDENTIFIER_NAME), RPARENTHESIS),
AS,
SELECT_EXPRESSION,
b.optional(VIEW_RESTRICTION_CLAUSE),
b.optional(ORDER_BY_CLAUSE),
b.optional(SEMICOLON))
b.rule(TYPE_ATTRIBUTE).define(IDENTIFIER_NAME, DATATYPE, b.optional(DATATYPE_NULL_CONSTRAINT))
b.rule(INHERITANCE_CLAUSE).define(b.oneOrMore(b.optional(NOT), b.firstOf(OVERRIDING, FINAL, INSTANTIABLE)))
b.rule(TYPE_SUBPROGRAM).define(
b.optional(INHERITANCE_CLAUSE),
b.firstOf(MEMBER, STATIC),
b.firstOf(PROCEDURE_DECLARATION, FUNCTION_DECLARATION))
b.rule(TYPE_CONSTRUCTOR).define(
b.optional(FINAL),
b.optional(INSTANTIABLE),
CONSTRUCTOR, FUNCTION, IDENTIFIER_NAME,
b.optional(
LPARENTHESIS,
b.optional(SELF, IN, OUT, DATATYPE, COMMA),
b.oneOrMore(PARAMETER_DECLARATION, b.optional(COMMA)),
RPARENTHESIS),
RETURN, SELF, AS, RESULT,
b.optional(b.firstOf(IS, AS), b.optional(DECLARE_SECTION), STATEMENTS_SECTION))
b.rule(MAP_ORDER_FUNCTION).define(
b.firstOf(MAP, ORDER),
MEMBER, FUNCTION_DECLARATION)
b.rule(TYPE_ELEMENT_SPEC).define(
b.optional(INHERITANCE_CLAUSE),
b.firstOf(TYPE_SUBPROGRAM, TYPE_CONSTRUCTOR, MAP_ORDER_FUNCTION))
b.rule(OBJECT_TYPE_DEFINITION).define(
b.firstOf(
b.sequence(b.firstOf(IS, AS), OBJECT),
b.sequence(UNDER, UNIT_NAME)
),
LPARENTHESIS,
b.optional(b.firstOf(DEPRECATE_PRAGMA, SUPPRESSES_WARNING_6009_PRAGMA), COMMA),
b.oneOrMore(
b.firstOf(TYPE_ELEMENT_SPEC, TYPE_ATTRIBUTE),
b.optional(COMMA),
b.optional(b.firstOf(DEPRECATE_PRAGMA, SUPPRESSES_WARNING_6009_PRAGMA), b.optional(COMMA))
),
RPARENTHESIS,
b.zeroOrMore(b.optional(NOT), b.firstOf(FINAL, INSTANTIABLE))
)
b.rule(CREATE_TYPE).define(
CREATE, b.optional(OR, REPLACE), b.optional(b.firstOf(EDITIONABLE, NONEDITIONABLE)),
TYPE, UNIT_NAME,
b.optional(FORCE),
b.optional(SHARING, EQUALS, b.firstOf(METADATA, NONE)),
b.zeroOrMore(b.firstOf(
b.sequence(AUTHID, b.firstOf(CURRENT_USER, DEFINER)),
b.sequence(DEFAULT, COLLATION, USING_NLS_COMP),
b.sequence(ACCESSIBLE, BY, LPARENTHESIS,
b.firstOf(FUNCTION, PROCEDURE, PACKAGE, TRIGGER, TYPE),
UNIT_NAME,
RPARENTHESIS))),
b.optional(b.firstOf(
OBJECT_TYPE_DEFINITION,
b.sequence(
b.firstOf(IS, AS),
b.firstOf(
VARRAY_TYPE_DEFINITION,
NESTED_TABLE_DEFINITION)))),
b.optional(SEMICOLON))
b.rule(CREATE_TYPE_BODY).define(
CREATE, b.optional(OR, REPLACE), b.optional(b.firstOf(EDITIONABLE, NONEDITIONABLE)),
TYPE, BODY, UNIT_NAME,
b.firstOf(IS, AS),
b.oneOrMore(b.firstOf(TYPE_SUBPROGRAM, TYPE_CONSTRUCTOR, MAP_ORDER_FUNCTION), b.optional(COMMA)),
END, b.optional(SEMICOLON))
b.rule(ANONYMOUS_BLOCK).define(BLOCK_STATEMENT)
b.rule(COMPILATION_UNIT).define(b.firstOf(
ANONYMOUS_BLOCK,
CREATE_PROCEDURE,
CREATE_FUNCTION,
CREATE_PACKAGE,
CREATE_PACKAGE_BODY,
CREATE_VIEW,
CREATE_TRIGGER,
CREATE_TYPE_BODY,
CREATE_TYPE,
PROCEDURE_DECLARATION,
FUNCTION_DECLARATION))
}
}
}
================================================
FILE: zpa-core/src/main/kotlin/com/felipebz/zpa/api/PlSqlKeyword.kt
================================================
/**
* Z PL/SQL Analyzer
* Copyright (C) 2015-2026 Felipe Zorzo
* mailto:felipe AT felipezorzo DOT com DOT br
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package com.felipebz.zpa.api
import com.felipebz.flr.api.AstNode
import com.felipebz.flr.api.TokenType
enum class PlSqlKeyword(override val value: String, val isReserved: Boolean = false) : TokenType {
ALL("all", true),
ALTER("alter", true),
AND("and", true),
ANY("any", true),
AS("as", true),
ASC("asc", true),
BEGIN("begin", true),
BETWEEN("between", true),
BY("by", true),
CHAR("char"),
CHECK("check", true),
CLUSTER("cluster", true),
COMPRESS("compress", true),
CONNECT("connect", true),
CREATE("create", true),
DECLARE("declare", true),
DEFAULT("default", true),
DESC("desc", true),
DISTINCT("distinct", true),
DROP("drop", true),
ELSE("else", true),
END("end", true),
EXCEPT("except"),
EXCLUSIVE("exclusive", true),
FETCH("fetch", true),
FLOAT("float"),
FOR("for", true),
FROM("from", true),
GRANT("grant", true),
GROUP("group", true),
HAVING("having", true),
IDENTIFIED("identified", true),
IN("in", true),
INDEX("index", true),
INSERT("insert", true),
INTEGER("integer"),
INTERSECT("intersect", true),
INTO("into", true),
IS("is", true),
LIKE("like", true),
LOCK("lock", true),
LONG("long"),
MINUS_KEYWORD("minus", true),
NOCOMPRESS("nocompress", true),
NOT("not", true),
NOWAIT("nowait", true),
NULL("null", true),
OF("of", true),
ON("on", true),
OPTION("option", true),
OR("or", true),
ORDER("order", true),
OUT("out", true),
PCTFREE("pctfree"),
PRIOR("prior"),
PROCEDURE("procedure", true),
PUBLIC("public", true),
RAW("raw"),
RESOURCE("resource", true),
REVOKE("revoke", true),
SELECT("select", true),
SHARE("share", true),
SIZE("size", true),
SMALLINT("smallint"),
START("start", true),
SYNONYM("synonym"),
TABLE("table", true),
THEN("then", true),
TO("to", true),
TRIGGER("trigger", true),
UNION("union", true),
UNIQUE("unique", true),
UPDATE("update", true),
VALUES("values", true),
VIEW("view", true),
WHEN("when", true),
WHERE("where", true),
WITH("with", true),
A("a"),
ABSENT("absent"),
ACCESSIBLE("accessible"),
ADD("add"),
ADMIN("admin"),
AFTER("after"),
AGENT("agent"),
AGGREGATE("aggregate"),
ALLOW("allow"),
ANALYZE("analyze"),
ANY_CS("any_cs"),
APPEND("append"),
ARRAY("array"),
ARROW("arrow"),
ASCII("ascii"),
ASSOCIATE("associate"),
AT("at"),
AUDIT("audit"),
AUTHID("authid"),
AUTONOMOUS_TRANSACTION("autonomous_transaction"),
BATCH("batch"),
BEFORE("before"),
BFILE("bfile"),
BINARY("binary"),
BINARY_DOUBLE("binary_double"),
BINARY_DOUBLE_INFINITY("binary_double_infinity"),
BINARY_DOUBLE_NAN("binary_double_nan"),
BINARY_FLOAT("binary_float"),
BINARY_FLOAT_INFINITY("binary_float_infinity"),
BINARY_FLOAT_NAN("binary_float_nan"),
BINARY_INTEGER("binary_integer"),
BLOB("blob"),
BODY("body"),
BOOLEAN("boolean"),
BOTH("both"),
BREADTH("breadth"),
BUFFER_POOL("buffer_pool"),
BULK("bulk"),
BULK_ROWCOUNT("bulk_rowcount"),
BYTE("byte"),
CACHE("cache"),
CASCADE("cascade"),
CASE("case"),
CASE_SENSITIVE("case_sensitive"),
CAST("cast"),
CHARACTER("character"),
CHARSET("charset"),
CHARSETFORM("charsetform"),
CHARSETID("charsetid"),
CHUNK("chunk"),
CLOB("clob"),
CLONE("clone"),
CLOSE("close"),
CLUSTERS("clusters"),
COLAUTH("colauth"),
COLLATION("collation"),
COLLECT("collect"),
COLUMN("column"),
COLUMNS("columns"),
COMMENT("comment"),
COMMIT("commit"),
COMMITTED("committed"),
COMPILE("compile"),
COMPLETE("complete"),
COMPOUND("compound"),
CONDITIONAL("conditional"),
CONNECT_BY_ROOT("connect_by_root"),
CONSTANT("constant"),
CONSTRAINT("constraint"),
CONSTRAINTS("constraints"),
CONSTRUCTOR("constructor"),
CONTAINER("container"),
CONTENT("content"),
CONTEXT("context"),
CONTINUE("continue"),
CONVERSION("conversion"),
COPY("copy"),
COUNT("count"),
COVERAGE("coverage"),
CRASH("crash"),
CROSS("cross"),
CROSSEDITION("crossedition"),
CUBE("cube"),
CURRENT("current"),
CURRENT_USER("current_user"),
CURRVAL("currval"),
CURSOR("cursor"),
CYCLE("cycle"),
DATA("data"),
DATABASE("database"),
DATE("date"),
DAY("day"),
DB_ROLE_CHANGE("db_role_change"),
DDL("ddl"),
DEBUG("debug"),
DEC("dec"),
DECIMAL("decimal"),
DEFAULTS("defaults"),
DEFERRABLE("deferrable"),
DEFERRED("deferred"),
DEFINER("definer"),
DELEGATE("delegate"),
DELETE("delete"),
DENSE_RANK("dense_rank"),
DEPRECATE("deprecate"),
DEPTH("depth"),
DETERMINISTIC("deterministic"),
DIRECTORY("directory"),
DISABLE("disable"),
DISALLOW("disallow"),
DISASSOCIATE("disassociate"),
DOCUMENT("document"),
DOMAIN("domain"),
DOUBLE("double"),
DURATION("duration"),
EACH("each"),
EDITIONABLE("editionable"),
ELEMENT("element"),
ELSIF("elsif"),
EMPTY("empty"),
ENABLE("enable"),
ENCODING("encoding"),
ENCRYPT("encrypt"),
ENTITYESCAPING("entityescaping"),
ERROR("error"),
ERRORS("errors"),
ESCAPE("escape"),
EVALNAME("evalname"),
EXCEPTION("exception"),
EXCEPTIONS("exceptions"),
EXCEPTION_INIT("exception_init"),
EXCLUDE("exclude"),
EXECUTE("execute"),
EXISTING("existing"),
EXISTS("exists"),
EXIT("exit"),
EXTEND("extend"),
EXTERNAL("external"),
EXTRA("extra"),
EXTRACT("extract"),
FALSE("false"),
FINAL("final"),
FIRST("first"),
FOLLOWING("following"),
FOLLOWS("follows"),
FORALL("forall"),
FORCE("force"),
FOREIGN("foreign"),
FORM("form"),
FORMAT("format"),
FORWARD("forward"),
FOUND("found"),
FREELIST("freelist"),
FREELISTS("freelists"),
FREEPOOLS("freepools"),
FULL("full"),
FUNCTION("function"),
GLOBAL("global"),
GOTO("goto"),
GROUPING("grouping"),
GROUPS("groups"),
HASH("hash"),
HIDE("hide"),
HIERARCHY("hierarchy"),
HOUR("hour"),
IF("if"),
IGNORE("ignore"),
IMMEDIATE("immediate"),
IMMUTABLE("immutable"),
INCREMENT("increment"),
INDENT("indent"),
INDEXES("indexes"),
INDEXTYPE("indextype"),
INDICATOR("indicator"),
INDICES("indices"),
INCLUDE("include"),
INITIAL("initial"),
INITIALLY("initially"),
INITRANS("initrans"),
INLINE("inline"),
INNER("inner"),
INSTANTIABLE("instantiable"),
INSTEAD("instead"),
INT("int"),
INTERFACE("interface"),
INTERVAL("interval"),
ISOLATION("isolation"),
ISOPEN("isopen"),
JAVA("java"),
JOIN("join"),
JSON("json"),
JSON_ARRAY("json_array"),
JSON_ARRAYAGG("json_arrayagg"),
JSON_DATAGUIDE("json_dataguide"),
JSON_EQUAL("json_equal"),
JSON_EXISTS("json_exists"),
JSON_MERGEPATCH("json_mergepatch"),
JSON_OBJECT("json_object"),
JSON_OBJECTAGG("json_objectagg"),
JSON_QUERY("json_query"),
JSON_SCALAR("json_scalar"),
JSON_SERIALIZE("json_serialize"),
JSON_TABLE("json_table"),
JSON_TEXTCONTAINS("json_textcontains"),
JSON_TRANSFORM("json_transform"),
JSON_VALUE("json_value"),
KEEP("keep"),
KEY("key"),
KEYS("keys"),
LANGUAGE("language"),
LAST("last"),
LAX("lax"),
LEADING("leading"),
LEFT("left"),
LENGTH("length"),
LESS("less"),
LEVEL("level"),
LEVELS("levels"),
LIBRARY("library"),
LIMIT("limit"),
LIST("list"),
LISTAGG("listagg"),
LOB("lob"),
LOCAL("local"),
LOCKED("locked"),
LOG("log"),
LOGGING("logging"),
LOGOFF("logoff"),
LOGON("logon"),
LOOP("loop"),
MAP("map"),
MAPPING("mapping"),
MATCHED("matched"),
MATERIALIZED("materialized"),
MAXEXTENTS("maxextents"),
MAXLEN("maxlen"),
MAXVALUE("maxvalue"),
MEMBER("member"),
MERGE("merge"),
METADATA("metadata"),
MINEXTENTS("minextents"),
MINING("mining"),
MINUTE("minute"),
MINVALUE("minvalue"),
MISMATCH("mismatch"),
MISSING("missing"),
MODE("mode"),
MODEL("model"),
MOD_KEYWORD("mod"),
MONTH("month"),
MORE("more"),
MULTISET("multiset"),
MUTABLE("mutable"),
NAME("name"),
NATURAL("natural"),
NATURALN("naturaln"),
NCHAR("nchar"),
NCLOB("nclob"),
NESTED("nested"),
NEW("new"),
NEXT("next"),
NEXTVAL("nextval"),
NO("no"),
NOAUDIT("noaudit"),
NOCACHE("nocache"),
NOCOPY("nocopy"),
NOCYCLE("nocycle"),
NOENTITYESCAPING("noentityescaping"),
NOLOGGING("nologging"),
NOMAPPING("nomapping"),
NONE("none"),
NONEDITIONABLE("noneditionable"),
NOORDER("noorder"),
NOPRECHECK("noprecheck"),
NORELY("norely"),
NOSCHEMACHECK("noschemacheck"),
NOTFOUND("notfound"),
NOVALIDATE("novalidate"),
NOW("now"),
NULLS("nulls"),
NUMBER("number"),
NUMERIC("numeric"),
NVARCHAR2("nvarchar2"),
OBJECT("object"),
OFFSET("offset"),
OLD("old"),
OMIT("omit"),
ONLY("only"),
OPEN("open"),
OPERATOR("operator"),
OPTIMAL("optimal"),
ORDERED("ordered"),
ORDINALITY("ordinality"),
OTHERS("others"),
OUTER("outer"),
OVER("over"),
OVERFLOW("overflow"),
OVERLAPS("overlaps"),
OVERRIDING("overriding"),
PACKAGE("package"),
PAIRS("pairs"),
PARALLEL_ENABLE("parallel_enable"),
PARAMETERS("parameters"),
PARENT("parent"),
PARTITION("partition"),
PARTITIONS("partitions"),
PASSING("passing"),
PATH("path"),
PCTINCREASE("pctincrease"),
PCTUSED("pctused"),
PCTVERSION("pctversion"),
PERCENT("percent"),
PIPE("pipe"),
PIPELINED("pipelined"),
PIVOT("pivot"),
PLS_INTEGER("pls_integer"),
PLUGGABLE("pluggable"),
POSITIVE("positive"),
POSITIVEN("positiven"),
PRAGMA("pragma"),
PRECEDES("precedes"),
PRECEDING("preceding"),
PRECHECK("precheck"),
PRECISION("precision"),
PREPEND("prepend"),
PRESERVE("preserve"),
PRETTY("pretty"),
PRIMARY("primary"),
PURGE("purge"),
QUOTES("quotes"),
RAISE("raise"),
RANGE_KEYWORD("range"),
READ("read"),
READS("reads"),
REAL("real"),
RECORD("record"),
RECYCLE("recycle"),
REF("ref"),
REFERENCE("reference"),
REFERENCES("references"),
REFERENCING("referencing"),
REFRESH("refresh"),
REJECT("reject"),
RELIES_ON("relies_on"),
RELY("rely"),
REMOVE("remove"),
RENAME("rename"),
REPEAT("repeat"),
REPLACE("replace"),
RESTRICT_REFERENCES("restrict_references"),
RESULT("result"),
RESULT_CACHE("result_cache"),
RETENTION("retention"),
RETURN("return"),
RETURNING("returning"),
REUSE("reuse"),
REVERSE("reverse"),
RIGHT("right"),
ROLE("role"),
ROLLBACK("rollback"),
ROLLUP("rollup"),
ROW("row"),
ROWCOUNT("rowcount"),
ROWID("rowid"),
ROWNUM("rownum"),
ROWS("rows"),
ROWTYPE("rowtype"),
SAVE("save"),
SAVEPOINT("savepoint"),
SCALAR("scalar"),
SCALARS("scalars"),
SCHEMA("schema"),
SCHEMACHECK("schemacheck"),
SDO_GEOMETRY("sdo_geometry"),
SEARCH("search"),
SECOND("second"),
SEGMENT("segment"),
SELF("self"),
SEQUENCE("sequence"),
SERIALIZABLE("serializable"),
SERIALLY_REUSABLE("serially_reusable"),
SERVERERROR("servererror"),
SESSION("session"),
SET("set"),
SETS("sets"),
SETTINGS("settings"),
SHARING("sharing"),
SHOW("show"),
SHUTDOWN("shutdown"),
SIBLINGS("siblings"),
SIGNTYPE("signtype"),
SKIP("skip"),
SOME("some"),
SORT("sort"),
SPECIFICATION("specification"),
SQL("sql"),
SQLERRM("sqlerrm"),
STANDALONE("standalone"),
STARTUP("startup"),
STATEMENT_KEYWORD("statement"),
STATIC("static"),
STATISTICS("statistics"),
STORAGE("storage"),
STORE("store"),
STRICT("strict"),
STRING("string"),
STRUCT("struct"),
SUBMULTISET("submultiset"),
SUBPARTITION("subpartition"),
SUBPARTITIONS("subpartitions"),
SUBSTITUTABLE("substitutable"),
SUBTYPE("subtype"),
SUPPRESSES_WARNING_6009("suppresses_warning_6009"),
SUSPEND("suspend"),
SYSDATE("sysdate"),
TABAUTH("tabauth"),
TABLESPACE("tablespace"),
TDO("tdo"),
TEMPLATE("template"),
TEMPORARY("temporary"),
THAN("than"),
THE("the"),
TIES("ties"),
TIME("time"),
TIMESTAMP("timestamp"),
TO_BINARY_DOUBLE("to_binary_double"),
TO_BINARY_FLOAT("to_binary_float"),
TO_BOOLEAN("to_boolean"),
TO_DATE("to_date"),
TO_DSINTERVAL("to_dsinterval"),
TO_NUMBER("to_number"),
TO_TIMESTAMP("to_timestamp"),
TO_TIMESTAMP_TZ("to_timestamp_tz"),
TO_YMINTERVAL("to_yminterval"),
TRAILING("trailing"),
TRANSACTION("transaction"),
TREAT("treat"),
TRIM("trim"),
TRUE("true"),
TRUNCATE("truncate"),
TYPE("type"),
TYPENAME("typename"),
UDF("udf"),
UNBOUNDED("unbounded"),
UNCONDITIONAL("unconditional"),
UNDER("under"),
UNLIMITED("unlimited"),
UNPIVOT("unpivot"),
UNPLUG("unplug"),
UROWID("urowid"),
USE("use"),
USING("using"),
USING_NLS_COMP("using_nls_comp"),
VALIDATE("validate"),
VALUE("value"),
VARCHAR("varchar"),
VARCHAR2("varchar2"),
VARRAY("varray"),
VARYING("varying"),
VECTOR("vector"),
VERSION("version"),
VIEWS("views"),
WAIT("wait"),
WELLFORMED("wellformed"),
WHILE("while"),
WITHIN("within"),
WITHOUT("without"),
WORK("work"),
WRAPPER("wrapper"),
WRITE("write"),
XML("xml"),
XMLAGG("xmlagg"),
XMLATTRIBUTES("xmlattributes"),
XMLCAST("xmlcast"),
XMLCDATA("xmlcdata"),
XMLCOLATTVAL("xmlcolattval"),
XMLCOMMENT("xmlcomment"),
XMLCONCAT("xmlconcat"),
XMLDIFF("xmldiff"),
XMLELEMENT("xmlelement"),
XMLEXISTS("xmlexists"),
XMLFOREST("xmlforest"),
XMLISVALID("xmlisvalid"),
XMLNAMESPACES("xmlnamespaces"),
XMLPARSE("xmlparse"),
XMLPATCH("xmlpatch"),
XMLPI("xmlpi"),
XMLQUERY("xmlquery"),
XMLROOT("xmlroot"),
XMLSEQUENCE("xmlsequence"),
XMLSERIALIZE("xmlserialize"),
XMLTABLE("xmltable"),
XMLTRANSFORM("xmltransform"),
XMLTYPE("xmltype"),
YEAR("year"),
YES("yes"),
ZONE("zone");
override fun hasToBeSkippedFromAst(node: AstNode?) = false
companion object {
val keywordValues: List =
entries.map { it.value }
val nonReservedKeywords: List =
entries.filter { !it.isReserved }
}
}
================================================
FILE: zpa-core/src/main/kotlin/com/felipebz/zpa/api/PlSqlPunctuator.kt
================================================
/**
* Z PL/SQL Analyzer
* Copyright (C) 2015-2026 Felipe Zorzo
* mailto:felipe AT felipezorzo DOT com DOT br
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package com.felipebz.zpa.api
import com.felipebz.flr.api.AstNode
import com.felipebz.flr.api.TokenType
enum class PlSqlPunctuator(override val value: String) : TokenType {
// Based on http://docs.oracle.com/cd/B19306_01/appdev.102/b14261/fundamentals.htm#sthref297
COMMA(","),
PLUS("+"),
MINUS("-"),
MOD("%"),
DOT("."),
DIVISION("/"),
LPARENTHESIS("("),
RPARENTHESIS(")"),
COLON(":"),
SEMICOLON(";"),
MULTIPLICATION("*"),
EQUALS("="),
LESSTHAN("<"),
GREATERTHAN(">"),
REMOTE("@"),
SUBTRACTION("-"),
ASSIGNMENT(":="),
SINGLE_PIPE("|"),
EXPONENTIATION("**"),
LLABEL("<<"),
RLABEL(">>"),
RANGE(".."),
DOUBLEDOLLAR("$$"),
ASSOCIATION("=>"),
EXCLAMATION("!"),
TILDE("~"),
CARET("^"),
LBRACKET("["),
RBRACKET("]"),
LBRACE("{"),
RBRACE("}"),
QUESTION_MARK("?");
override fun hasToBeSkippedFromAst(node: AstNode?) = false
}
================================================
FILE: zpa-core/src/main/kotlin/com/felipebz/zpa/api/PlSqlTokenType.kt
================================================
/**
* Z PL/SQL Analyzer
* Copyright (C) 2015-2026 Felipe Zorzo
* mailto:felipe AT felipezorzo DOT com DOT br
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package com.felipebz.zpa.api
import com.felipebz.flr.api.AstNode
import com.felipebz.flr.api.TokenType
enum class PlSqlTokenType : TokenType {
STRING_LITERAL,
INTEGER_LITERAL,
NUMBER_LITERAL,
DATE_LITERAL,
TIMESTAMP_LITERAL;
override val value = name
override fun hasToBeSkippedFromAst(node: AstNode?) = false
}
================================================
FILE: zpa-core/src/main/kotlin/com/felipebz/zpa/api/PlSqlVisitorContext.kt
================================================
/**
* Z PL/SQL Analyzer
* Copyright (C) 2015-2026 Felipe Zorzo
* mailto:felipe AT felipezorzo DOT com DOT br
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package com.felipebz.zpa.api
import com.felipebz.flr.api.AstNode
import com.felipebz.flr.api.RecognitionException
import com.felipebz.zpa.metadata.FormsMetadata
import com.felipebz.zpa.symbols.SymbolTableImpl
import com.felipebz.zpa.api.symbols.Scope
import com.felipebz.zpa.api.symbols.SymbolTable
open class PlSqlVisitorContext private constructor(private val rootTree: AstNode?,
private val plSqlFile: PlSqlFile?,
private val parsingException: RecognitionException?,
var formsMetadata: FormsMetadata?) {
var symbolTable: SymbolTable = SymbolTableImpl()
var currentScope: Scope? = null
constructor(rootTree: AstNode,
plsqlFile: PlSqlFile?,
metadata: FormsMetadata?) :
this(rootTree, plsqlFile, null, metadata)
constructor(plsqlFile: PlSqlFile?,
parsingException: RecognitionException,
metadata: FormsMetadata?) :
this(null, plsqlFile, parsingException, metadata)
fun rootTree() = rootTree
fun plSqlFile() = plSqlFile
fun parsingException() = parsingException
}
================================================
FILE: zpa-core/src/main/kotlin/com/felipebz/zpa/api/SessionControlGrammar.kt
================================================
/**
* Z PL/SQL Analyzer
* Copyright (C) 2015-2026 Felipe Zorzo
* mailto:felipe AT felipezorzo DOT com DOT br
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package com.felipebz.zpa.api
import com.felipebz.flr.api.GenericTokenType.EOF
import com.felipebz.flr.grammar.GrammarRuleKey
import com.felipebz.zpa.sslr.PlSqlGrammarBuilder
import com.felipebz.zpa.api.PlSqlGrammar.IDENTIFIER_NAME
import com.felipebz.zpa.api.PlSqlKeyword.*
import com.felipebz.zpa.api.PlSqlPunctuator.*
enum class SessionControlGrammar : GrammarRuleKey {
ALTER_SESSION,
SET_ROLE,
SESSION_CONTROL_COMMAND;
companion object {
fun buildOn(b: PlSqlGrammarBuilder) {
b.rule(ALTER_SESSION).define(ALTER, SESSION, b.oneOrMore(b.anyTokenButNot(b.firstOf(SEMICOLON, DIVISION, EOF))))
b.rule(SET_ROLE).define(SET, ROLE,
b.firstOf(
NONE,
b.sequence(ALL, b.optional(EXCEPT, b.oneOrMore(IDENTIFIER_NAME, b.optional(COMMA)))),
b.oneOrMore(IDENTIFIER_NAME, b.optional(IDENTIFIED, BY, b.anyToken()), b.optional(COMMA))
))
b.rule(SESSION_CONTROL_COMMAND).define(b.firstOf(ALTER_SESSION, SET_ROLE), b.optional(SEMICOLON))
}
}
}
================================================
FILE: zpa-core/src/main/kotlin/com/felipebz/zpa/api/SingleRowSqlFunctionsGrammar.kt
================================================
/**
* Z PL/SQL Analyzer
* Copyright (C) 2015-2026 Felipe Zorzo
* mailto:felipe AT felipezorzo DOT com DOT br
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package com.felipebz.zpa.api
import com.felipebz.flr.grammar.GrammarRuleKey
import com.felipebz.zpa.sslr.PlSqlGrammarBuilder
import com.felipebz.zpa.api.PlSqlGrammar.*
import com.felipebz.zpa.api.PlSqlKeyword.*
import com.felipebz.zpa.api.PlSqlPunctuator.*
import com.felipebz.zpa.api.PlSqlTokenType.STRING_LITERAL
enum class SingleRowSqlFunctionsGrammar : GrammarRuleKey {
// internals
JSON_PASSING_CLAUSE,
JSON_ON_NULL_CLAUSE,
JSON_ON_ERROR_CLAUSE,
JSON_RETURNING_CLAUSE,
JSON_ARRAY_ENUMERATION_CONTENT,
JSON_ARRAY_QUERY_CONTENT,
JSON_ARRAY_ELEMENT,
JSON_ARRAY_OPTIONS,
JSON_OBJECT_ENTRY,
JSON_QUERY_RETURNING_CLAUSE,
JSON_QUERY_WRAPPER_CLAUSE,
JSON_QUERY_QUOTES_CLAUSE,
JSON_QUERY_ON_ERROR_CLAUSE,
JSON_QUERY_ON_EMPTY_CLAUSE,
JSON_QUERY_ON_MISMATCH_CLAUSE,
JSON_BASIC_PATH_EXPRESSION,
JSON_PATH_EXPRESSION,
JSON_RELATIVE_OBJECT_ACCESS,
JSON_TABLE_ON_ERROR_CLAUSE,
JSON_TABLE_ON_EMPTY_CLAUSE,
JSON_TABLE_COLUMNS_CLAUSE,
JSON_COLUMNS_CLAUSE,
JSON_COLUMN_DEFINITION,
JSON_EXISTS_COLUMN,
JSON_QUERY_COLUMN,
JSON_VALUE_COLUMN,
JSON_NESTED_PATH,
JSON_ORDINALITY_COLUMN,
JSON_PATH,
JSON_ARRAY_STEP,
JSON_VALUE_RETURN_TYPE,
JSON_VALUE_ON_ERROR_CLAUSE,
JSON_VALUE_ON_EMPTY_CLAUSE,
JSON_VALUE_ON_MISMATCH_CLAUSE,
JSON_VALUE_RETURN_OBJECT_INSTANCE,
JSON_TRANSFORM_OPERATION,
JSON_TRANSFORM_RETURNING_CLAUSE,
JSON_RHS_EXPRESSION,
JSON_APPEND_OPERATION,
JSON_CASE_OPERATION,
JSON_COPY_OPERATION,
JSON_INSERT_OPERATION,
JSON_INTERSECT_OPERATION,
JSON_KEEP_OPERATION,
JSON_MERGE_OPERATION,
JSON_MINUS_OPERATION,
JSON_NESTED_PATH_OPERATION,
JSON_OBJECT_OPTIONS,
JSON_PREPEND_OPERATION,
JSON_REMOVE_OPERATION,
JSON_RENAME_OPERATION,
JSON_REPLACE_OPERATION,
JSON_SET_OPERATION,
JSON_SORT_OPERATION,
JSON_UNION_OPERATION,
JSON_VALUE_RETURNING_CLAUSE,
XML_COLUMN,
XML_NAMESPACE,
XMLNAMESPACES_CLAUSE,
XMLTABLE_OPTIONS,
XML_PASSING_CLAUSE,
XML_TABLE_COLUMN,
// functions
EXTRACT_DATETIME_EXPRESSION,
JSON_CONSTRUCTOR,
JSON_ARRAY_EXPRESSION,
JSON_DATAGUIDE_EXPRESSION,
JSON_MERGEPATCH_EXPRESSION,
JSON_OBJECT_EXPRESSION,
JSON_SCALAR_EXPRESSION,
JSON_SERIALIZE_EXPRESSION,
JSON_QUERY_EXPRESSION,
JSON_TABLE_EXPRESSION,
JSON_TRANSFORM_EXPRESSION,
JSON_VALUE_EXPRESSION,
XMLATTRIBUTES_EXPRESSION,
XMLCAST_EXPRESSION,
XMLCDATA_EXPRESSION,
XMLCOLATTVAL_EXPRESSION,
XMLCOMMENT_EXPRESSION,
XMLCONCAT_EXPRESSION,
XMLDIFF_EXPRESSION,
XMLELEMENT_EXPRESSION,
XMLEXISTS_EXPRESSION,
XMLFOREST_EXPRESSION,
XMLISVALID_EXPRESSION,
XMLPARSE_EXPRESSION,
XMLPATCH_EXPRESSION,
XMLPI_EXPRESSION,
XMLQUERY_EXPRESSION,
XMLROOT_EXPRESSION,
XMLSEQUENCE_EXPRESSION,
XMLSERIALIZE_EXPRESSION,
XMLTABLE_EXPRESSION,
XMLTRANSFORM_EXPRESSION,
DEFAULT_ON_ERROR_CLAUSE,
TREAT_AS_EXPRESSION,
SET_EXPRESSION,
CAST_EXPRESSION,
TO_BINARY_DOUBLE_EXPRESSION,
TO_BINARY_FLOAT_EXPRESSION,
TO_BOOLEAN_EXPRESSION,
TO_DATE_EXPRESSION,
TO_DSINTERVAL_EXPRESSION,
TO_NUMBER_EXPRESSION,
TO_TIMESTAMP_EXPRESSION,
TO_TIMESTAMP_TZ_EXPRESSION,
TO_YMINTERVAL_EXPRESSION,
TRIM_EXPRESSION,
TABLE_EXPRESSION,
THE_EXPRESSION,
CURSOR_EXPRESSION,
SINGLE_ROW_SQL_FUNCTION;
companion object {
fun buildOn(b: PlSqlGrammarBuilder) {
createCharacterFunctions(b)
createConversionFunctions(b)
createDateFunctions(b)
createXmlFunctions(b)
createJsonFunctions(b)
b.rule(SINGLE_ROW_SQL_FUNCTION).define(
b.firstOf(
EXTRACT_DATETIME_EXPRESSION,
JSON_CONSTRUCTOR,
JSON_ARRAY_EXPRESSION,
JSON_DATAGUIDE_EXPRESSION,
JSON_MERGEPATCH_EXPRESSION,
JSON_OBJECT_EXPRESSION,
JSON_SCALAR_EXPRESSION,
JSON_SERIALIZE_EXPRESSION,
JSON_QUERY_EXPRESSION,
JSON_TABLE_EXPRESSION,
JSON_TRANSFORM_EXPRESSION,
JSON_VALUE_EXPRESSION,
XMLATTRIBUTES_EXPRESSION,
XMLCAST_EXPRESSION,
XMLCDATA_EXPRESSION,
XMLCOLATTVAL_EXPRESSION,
XMLCOMMENT_EXPRESSION,
XMLCONCAT_EXPRESSION,
XMLDIFF_EXPRESSION,
XMLELEMENT_EXPRESSION,
XMLEXISTS_EXPRESSION,
XMLFOREST_EXPRESSION,
XMLISVALID_EXPRESSION,
XMLPARSE_EXPRESSION,
XMLPATCH_EXPRESSION,
XMLPI_EXPRESSION,
XMLQUERY_EXPRESSION,
XMLROOT_EXPRESSION,
XMLSEQUENCE_EXPRESSION,
XMLSERIALIZE_EXPRESSION,
XMLTABLE_EXPRESSION,
XMLTRANSFORM_EXPRESSION,
TREAT_AS_EXPRESSION,
SET_EXPRESSION,
CAST_EXPRESSION,
TO_BINARY_DOUBLE_EXPRESSION,
TO_BINARY_FLOAT_EXPRESSION,
TO_BOOLEAN_EXPRESSION,
TO_DATE_EXPRESSION,
TO_DSINTERVAL_EXPRESSION,
TO_NUMBER_EXPRESSION,
TO_TIMESTAMP_EXPRESSION,
TO_TIMESTAMP_TZ_EXPRESSION,
TO_YMINTERVAL_EXPRESSION,
TRIM_EXPRESSION,
TABLE_EXPRESSION,
THE_EXPRESSION,
CURSOR_EXPRESSION
)
)
}
private fun createCharacterFunctions(b: PlSqlGrammarBuilder) {
b.rule(TRIM_EXPRESSION).define(
TRIM, LPARENTHESIS,
b.optional(b.optional(b.firstOf(LEADING, TRAILING, BOTH)), EXPRESSION, FROM),
EXPRESSION, RPARENTHESIS)
}
private fun createConversionFunctions(b: PlSqlGrammarBuilder) {
b.rule(DEFAULT_ON_ERROR_CLAUSE).define(DEFAULT, EXPRESSION, ON, CONVERSION, ERROR)
b.rule(TREAT_AS_EXPRESSION).define(
b.optional(TREAT),
LPARENTHESIS,
EXPRESSION,
AS,
b.optional(REF),
OBJECT_REFERENCE,
RPARENTHESIS
)
b.rule(SET_EXPRESSION).define(SET, LPARENTHESIS, EXPRESSION, RPARENTHESIS)
b.rule(CAST_EXPRESSION).define(
CAST, LPARENTHESIS,
b.firstOf(b.sequence(MULTISET, EXPRESSION), EXPRESSION),
AS, b.optional(DOMAIN), DATATYPE, b.optional(b.firstOf(VALIDATE, NOVALIDATE)),
b.optional(DEFAULT_ON_ERROR_CLAUSE),
b.optional(COMMA, EXPRESSION, b.optional(COMMA, EXPRESSION)),
RPARENTHESIS
)
b.rule(TO_BINARY_DOUBLE_EXPRESSION).define(
TO_BINARY_DOUBLE, LPARENTHESIS,
ARGUMENT,
b.optional(DEFAULT_ON_ERROR_CLAUSE),
b.optional(COMMA, ARGUMENT, b.optional(COMMA, ARGUMENT)),
RPARENTHESIS
)
b.rule(TO_BINARY_FLOAT_EXPRESSION).define(
TO_BINARY_FLOAT, LPARENTHESIS,
ARGUMENT,
b.optional(DEFAULT_ON_ERROR_CLAUSE),
b.optional(COMMA, ARGUMENT, b.optional(COMMA, ARGUMENT)),
RPARENTHESIS
)
b.rule(TO_BOOLEAN_EXPRESSION).define(
TO_BOOLEAN, LPARENTHESIS,
ARGUMENT,
b.optional(DEFAULT_ON_ERROR_CLAUSE),
RPARENTHESIS
)
b.rule(TO_DATE_EXPRESSION).define(
TO_DATE, LPARENTHESIS,
ARGUMENT,
b.optional(DEFAULT_ON_ERROR_CLAUSE),
b.optional(COMMA, ARGUMENT, b.optional(COMMA, ARGUMENT)),
RPARENTHESIS
)
b.rule(TO_DSINTERVAL_EXPRESSION).define(
TO_DSINTERVAL, LPARENTHESIS,
ARGUMENT,
b.optional(DEFAULT_ON_ERROR_CLAUSE),
RPARENTHESIS
)
b.rule(TO_NUMBER_EXPRESSION).define(
TO_NUMBER, LPARENTHESIS,
ARGUMENT,
b.optional(DEFAULT_ON_ERROR_CLAUSE),
b.optional(COMMA, ARGUMENT, b.optional(COMMA, ARGUMENT)),
RPARENTHESIS
)
b.rule(TO_TIMESTAMP_EXPRESSION).define(
TO_TIMESTAMP, LPARENTHESIS,
ARGUMENT,
b.optional(DEFAULT_ON_ERROR_CLAUSE),
b.optional(COMMA, ARGUMENT, b.optional(COMMA, ARGUMENT)),
RPARENTHESIS
)
b.rule(TO_TIMESTAMP_TZ_EXPRESSION).define(
TO_TIMESTAMP_TZ, LPARENTHESIS,
ARGUMENT,
b.optional(DEFAULT_ON_ERROR_CLAUSE),
b.optional(COMMA, ARGUMENT, b.optional(COMMA, ARGUMENT)),
RPARENTHESIS
)
b.rule(TO_YMINTERVAL_EXPRESSION).define(
TO_YMINTERVAL, LPARENTHESIS,
ARGUMENT,
b.optional(DEFAULT_ON_ERROR_CLAUSE),
RPARENTHESIS
)
b.rule(TABLE_EXPRESSION).define(
TABLE, LPARENTHESIS,
b.firstOf(DmlGrammar.SELECT_EXPRESSION, EXPRESSION),
RPARENTHESIS
)
b.rule(THE_EXPRESSION).define(
THE, LPARENTHESIS,
b.firstOf(DmlGrammar.SELECT_EXPRESSION, EXPRESSION),
RPARENTHESIS
)
b.rule(CURSOR_EXPRESSION).define(CURSOR, LPARENTHESIS, DmlGrammar.SELECT_EXPRESSION, RPARENTHESIS)
}
private fun createDateFunctions(b: PlSqlGrammarBuilder) {
b.rule(EXTRACT_DATETIME_EXPRESSION).define(EXTRACT, LPARENTHESIS, IDENTIFIER_NAME, FROM, EXPRESSION, RPARENTHESIS)
}
private fun createXmlFunctions(b: PlSqlGrammarBuilder) {
b.rule(XMLCDATA_EXPRESSION).define(XMLCDATA, LPARENTHESIS, EXPRESSION, RPARENTHESIS)
b.rule(XMLCOMMENT_EXPRESSION).define(XMLCOMMENT, LPARENTHESIS, EXPRESSION, RPARENTHESIS)
b.rule(XMLCONCAT_EXPRESSION).define(XMLCONCAT, LPARENTHESIS, EXPRESSION, b.zeroOrMore(COMMA, EXPRESSION), RPARENTHESIS)
b.rule(XMLDIFF_EXPRESSION).define(
XMLDIFF,
LPARENTHESIS,
EXPRESSION, COMMA, EXPRESSION,
b.optional(COMMA, EXPRESSION, COMMA, EXPRESSION),
RPARENTHESIS)
b.rule(XMLISVALID_EXPRESSION).define(
XMLISVALID,
LPARENTHESIS,
EXPRESSION,
b.optional(COMMA, EXPRESSION, b.optional(COMMA, EXPRESSION)),
RPARENTHESIS)
b.rule(XMLPATCH_EXPRESSION).define(
XMLPATCH,
LPARENTHESIS,
EXPRESSION,
COMMA,
EXPRESSION,
RPARENTHESIS
)
b.rule(XMLSEQUENCE_EXPRESSION).define(
XMLSEQUENCE,
LPARENTHESIS,
EXPRESSION,
b.zeroOrMore(COMMA, EXPRESSION),
RPARENTHESIS
)
b.rule(XMLTRANSFORM_EXPRESSION).define(
XMLTRANSFORM,
LPARENTHESIS,
EXPRESSION,
COMMA,
EXPRESSION,
RPARENTHESIS
)
b.rule(XMLSERIALIZE_EXPRESSION).define(
XMLSERIALIZE, LPARENTHESIS,
b.firstOf(DOCUMENT, CONTENT), EXPRESSION,
b.optional(AS, DATATYPE),
b.optional(ENCODING, EXPRESSION),
b.optional(VERSION, STRING_LITERAL),
b.optional(b.firstOf(b.sequence(NO, INDENT), b.sequence(INDENT, b.optional(SIZE, EQUALS, EXPRESSION)))),
b.optional(b.firstOf(HIDE, SHOW), DEFAULTS),
RPARENTHESIS)
b.rule(XML_COLUMN).define(
EXPRESSION, b.optional(b.optional(AS), b.firstOf(b.sequence(EVALNAME, EXPRESSION), IDENTIFIER_NAME)))
b.rule(XMLATTRIBUTES_EXPRESSION).define(
XMLATTRIBUTES, LPARENTHESIS,
b.optional(b.firstOf(ENTITYESCAPING, NOENTITYESCAPING)),
b.optional(b.firstOf(SCHEMACHECK, NOSCHEMACHECK)),
XML_COLUMN, b.zeroOrMore(COMMA, XML_COLUMN),
RPARENTHESIS)
b.rule(XMLELEMENT_EXPRESSION).define(
XMLELEMENT, LPARENTHESIS,
b.optional(b.firstOf(ENTITYESCAPING, NOENTITYESCAPING)),
b.firstOf(
b.sequence(EVALNAME, EXPRESSION),
b.sequence(b.optional(NAME), IDENTIFIER_NAME)
),
b.optional(COMMA, XMLATTRIBUTES_EXPRESSION),
b.zeroOrMore(COMMA, EXPRESSION, b.optional(b.optional(AS), IDENTIFIER_NAME)),
RPARENTHESIS)
b.rule(XMLFOREST_EXPRESSION).define(
XMLFOREST, LPARENTHESIS,
XML_COLUMN, b.zeroOrMore(COMMA, XML_COLUMN),
RPARENTHESIS)
b.rule(XML_PASSING_CLAUSE).define(
PASSING, b.optional(BY, VALUE),
EXPRESSION, b.optional(AS, IDENTIFIER_NAME),
b.zeroOrMore(COMMA, IDENTIFIER_NAME, b.optional(AS, IDENTIFIER_NAME)))
b.rule(XMLEXISTS_EXPRESSION).define(
XMLEXISTS, LPARENTHESIS, STRING_LITERAL,
b.optional(XML_PASSING_CLAUSE),
RPARENTHESIS)
b.rule(XMLQUERY_EXPRESSION).define(
XMLQUERY, LPARENTHESIS, STRING_LITERAL,
b.optional(XML_PASSING_CLAUSE),
RETURNING, CONTENT,
b.optional(NULL, ON, EMPTY),
RPARENTHESIS)
b.rule(XMLROOT_EXPRESSION).define(
XMLROOT, LPARENTHESIS,
EXPRESSION, COMMA,
VERSION, b.firstOf(b.sequence(NO, VALUE), EXPRESSION),
b.optional(COMMA, STANDALONE, b.firstOf(YES, b.sequence(NO, b.optional(VALUE)))),
RPARENTHESIS)
b.rule(XMLCAST_EXPRESSION).define(
XMLCAST, LPARENTHESIS,
EXPRESSION, AS, DATATYPE,
RPARENTHESIS)
b.rule(XMLCOLATTVAL_EXPRESSION).define(
XMLCOLATTVAL, LPARENTHESIS,
XML_COLUMN, b.zeroOrMore(COMMA, XML_COLUMN),
RPARENTHESIS)
b.rule(XMLPARSE_EXPRESSION).define(
XMLPARSE, LPARENTHESIS,
b.firstOf(DOCUMENT, CONTENT), EXPRESSION, b.optional(WELLFORMED),
RPARENTHESIS)
b.rule(XMLPI_EXPRESSION).define(
XMLPI, LPARENTHESIS,
b.firstOf(
b.sequence(EVALNAME, EXPRESSION),
b.sequence(b.optional(NAME), IDENTIFIER_NAME)),
b.optional(COMMA, EXPRESSION),
RPARENTHESIS)
b.rule(XML_NAMESPACE).define(
b.firstOf(
b.sequence(DEFAULT, STRING_LITERAL),
b.sequence(STRING_LITERAL, AS, IDENTIFIER_NAME)))
b.rule(XMLNAMESPACES_CLAUSE).define(
XMLNAMESPACES, LPARENTHESIS,
XML_NAMESPACE, b.zeroOrMore(COMMA, XML_NAMESPACE),
RPARENTHESIS)
b.rule(XML_TABLE_COLUMN).define(
IDENTIFIER_NAME,
b.firstOf(
b.sequence(FOR, ORDINALITY),
b.sequence(
b.firstOf(
DATATYPE,
b.sequence(XMLTYPE, b.optional(LPARENTHESIS, SEQUENCE, RPARENTHESIS, BY, REF))),
b.optional(PATH, STRING_LITERAL),
b.optional(DEFAULT, STRING_LITERAL))))
b.rule(XMLTABLE_OPTIONS).define(
b.optional(XML_PASSING_CLAUSE),
b.optional(RETURNING, SEQUENCE, BY, REF),
b.optional(COLUMNS, XML_TABLE_COLUMN, b.zeroOrMore(COMMA, XML_TABLE_COLUMN))).skip()
b.rule(XMLTABLE_EXPRESSION).define(
XMLTABLE, LPARENTHESIS,
b.optional(XMLNAMESPACES_CLAUSE, COMMA), STRING_LITERAL, XMLTABLE_OPTIONS,
RPARENTHESIS)
}
private fun createJsonFunctions(b: PlSqlGrammarBuilder) {
b.rule(JSON_CONSTRUCTOR).define(JSON, LPARENTHESIS, EXPRESSION, RPARENTHESIS)
b.rule(JSON_ARRAY_OPTIONS).define(
b.firstOf(JSON_ARRAY_ENUMERATION_CONTENT, JSON_ARRAY_QUERY_CONTENT)
).skip()
b.rule(JSON_ARRAY_EXPRESSION).define(
b.firstOf(
b.sequence(JSON_ARRAY, LPARENTHESIS, JSON_ARRAY_OPTIONS, RPARENTHESIS),
b.sequence(b.optional(JSON), LBRACKET, JSON_ARRAY_OPTIONS, RBRACKET)
)
)
b.rule(JSON_ARRAY_ENUMERATION_CONTENT).define(
JSON_ARRAY_ELEMENT,
b.zeroOrMore(COMMA, JSON_ARRAY_ELEMENT),
b.optional(JSON_ON_NULL_CLAUSE),
b.optional(JSON_RETURNING_CLAUSE),
b.optional(STRICT)
)
b.rule(JSON_ARRAY_ELEMENT).define(
EXPRESSION,
b.optional(FORMAT, JSON)
)
b.rule(JSON_ON_NULL_CLAUSE).define(b.firstOf(NULL, ABSENT), ON, NULL)
b.rule(JSON_ON_ERROR_CLAUSE).define(b.firstOf(NULL, ERROR), ON, ERROR)
b.rule(JSON_RETURNING_CLAUSE).define(
RETURNING,
b.firstOf(
b.sequence(
CHARACTER_DATAYPE,
b.optional(WITH, TYPENAME)
),
b.sequence(
b.firstOf(CLOB, BLOB),
b.optional(b.firstOf(REFERENCE, VALUE))
),
JSON
)
)
b.rule(JSON_DATAGUIDE_EXPRESSION).define(
JSON_DATAGUIDE,
LPARENTHESIS,
EXPRESSION,
b.optional(COMMA, EXPRESSION, b.optional(COMMA, EXPRESSION)),
RPARENTHESIS
)
b.rule(JSON_MERGEPATCH_EXPRESSION).define(
JSON_MERGEPATCH,
LPARENTHESIS,
EXPRESSION,
COMMA,
EXPRESSION,
b.optional(JSON_RETURNING_CLAUSE),
b.optional(PRETTY),
b.optional(ASCII),
b.optional(TRUNCATE),
b.optional(JSON_ON_ERROR_CLAUSE),
RPARENTHESIS
)
b.rule(JSON_ARRAY_QUERY_CONTENT).define(
DmlGrammar.SELECT_EXPRESSION,
b.optional(JSON_ON_NULL_CLAUSE),
b.optional(JSON_RETURNING_CLAUSE),
b.optional(STRICT)
)
b.rule(JSON_OBJECT_OPTIONS).define(
JSON_OBJECT_ENTRY, b.zeroOrMore(COMMA, JSON_OBJECT_ENTRY),
b.optional(JSON_ON_NULL_CLAUSE),
b.optional(JSON_RETURNING_CLAUSE),
b.optional(STRICT),
b.optional(WITH, UNIQUE, KEYS)
).skip()
b.rule(JSON_OBJECT_EXPRESSION).define(
b.firstOf(
b.sequence(JSON_OBJECT, LPARENTHESIS, JSON_OBJECT_OPTIONS, RPARENTHESIS),
b.sequence(b.optional(JSON), LBRACE, JSON_OBJECT_OPTIONS, RBRACE)
)
)
b.rule(JSON_OBJECT_ENTRY).define(
b.firstOf(
b.sequence(b.optional(KEY), EXPRESSION, VALUE, EXPRESSION),
b.sequence(STRING_LITERAL, COLON, EXPRESSION),
EXPRESSION
),
b.optional(FORMAT, JSON)
)
b.rule(JSON_SCALAR_EXPRESSION).define(
JSON_SCALAR,
LPARENTHESIS,
EXPRESSION,
b.optional(b.firstOf(
b.sequence(b.firstOf(JSON, SQL), NULL),
b.sequence(EMPTY, STRING)
), ON, NULL),
b.optional(b.firstOf(NULL, ERROR), ON, ERROR),
RPARENTHESIS
)
b.rule(JSON_SERIALIZE_EXPRESSION).define(
JSON_SERIALIZE,
LPARENTHESIS,
EXPRESSION,
b.optional(JSON_RETURNING_CLAUSE),
b.optional(PRETTY),
b.optional(ASCII),
b.optional(ORDERED),
b.optional(TRUNCATE),
b.optional(
b.firstOf(
NULL,
ERROR,
b.sequence(EMPTY, b.optional(b.firstOf(ARRAY, OBJECT)))
),
ON, ERROR
),
RPARENTHESIS
)
b.rule(JSON_QUERY_EXPRESSION).define(
JSON_QUERY,
LPARENTHESIS,
EXPRESSION,
b.optional(FORMAT, JSON),
COMMA,
STRING_LITERAL,
b.optional(JSON_PASSING_CLAUSE),
b.optional(JSON_QUERY_RETURNING_CLAUSE),
b.optional(JSON_QUERY_WRAPPER_CLAUSE),
b.optional(JSON_QUERY_QUOTES_CLAUSE),
b.optional(JSON_QUERY_ON_ERROR_CLAUSE),
b.optional(JSON_QUERY_ON_EMPTY_CLAUSE),
b.optional(JSON_QUERY_ON_MISMATCH_CLAUSE),
b.optional(TYPE, b.firstOf(STRICT, LAX)),
RPARENTHESIS
)
b.rule(JSON_PASSING_CLAUSE).define(
PASSING, EXPRESSION, AS, IDENTIFIER_NAME, b.zeroOrMore(COMMA, EXPRESSION, AS, IDENTIFIER_NAME)
)
b.rule(JSON_QUERY_RETURNING_CLAUSE).define(
b.optional(RETURNING, DATATYPE),
b.optional(b.firstOf(ALLOW, DISALLOW), SCALARS),
b.optional(PRETTY),
b.optional(ASCII)
).skip()
b.rule(JSON_QUERY_WRAPPER_CLAUSE).define(
b.firstOf(
WITHOUT,
b.sequence(WITH, b.optional(b.firstOf(UNCONDITIONAL, CONDITIONAL)))
),
b.optional(ARRAY), WRAPPER
)
b.rule(JSON_QUERY_QUOTES_CLAUSE).define(
b.firstOf(KEEP, OMIT),
QUOTES,
b.optional(ON, SCALAR, STRING)
)
b.rule(JSON_QUERY_ON_ERROR_CLAUSE).define(
b.firstOf(
ERROR,
NULL,
b.sequence(EMPTY, b.optional(b.firstOf(ARRAY, OBJECT)))
),
ON, ERROR
)
b.rule(JSON_QUERY_ON_EMPTY_CLAUSE).define(
b.firstOf(
ERROR,
NULL,
b.sequence(EMPTY, b.optional(b.firstOf(ARRAY, OBJECT)))
),
ON, EMPTY
)
b.rule(JSON_QUERY_ON_MISMATCH_CLAUSE).define(
b.firstOf(ERROR, NULL), ON, MISMATCH
)
b.rule(JSON_TABLE_EXPRESSION).define(
JSON_TABLE,
LPARENTHESIS,
EXPRESSION,
b.optional(FORMAT, JSON),
b.optional(COMMA, JSON_BASIC_PATH_EXPRESSION),
b.optional(JSON_TABLE_ON_ERROR_CLAUSE),
b.optional(TYPE, b.firstOf(STRICT, LAX)),
b.optional(JSON_TABLE_ON_EMPTY_CLAUSE),
JSON_TABLE_COLUMNS_CLAUSE,
RPARENTHESIS
)
b.rule(JSON_TABLE_ON_ERROR_CLAUSE).define(
b.firstOf(ERROR, NULL),
ON, ERROR
)
b.rule(JSON_TABLE_ON_EMPTY_CLAUSE).define(
b.firstOf(ERROR, NULL),
ON, EMPTY
)
b.rule(JSON_TABLE_COLUMNS_CLAUSE).define(
COLUMNS,
b.firstOf(
b.sequence(
LPARENTHESIS,
JSON_COLUMN_DEFINITION,
b.zeroOrMore(COMMA, JSON_COLUMN_DEFINITION),
RPARENTHESIS
),
b.sequence(
JSON_COLUMN_DEFINITION,
b.zeroOrMore(COMMA, JSON_COLUMN_DEFINITION),
),
)
)
b.rule(JSON_COLUMN_DEFINITION).define(
b.firstOf(
JSON_NESTED_PATH,
JSON_EXISTS_COLUMN,
JSON_ORDINALITY_COLUMN,
JSON_VALUE_COLUMN,
JSON_QUERY_COLUMN
)
)
b.rule(JSON_EXISTS_COLUMN).define(
IDENTIFIER_NAME,
b.optional(JSON_VALUE_RETURN_TYPE),
EXISTS,
b.optional(PATH, JSON_PATH),
b.optional(ConditionsGrammar.JSON_EXISTS_ON_ERROR_CLAUSE),
b.optional(ConditionsGrammar.JSON_EXISTS_ON_EMPTY_CLAUSE)
)
b.rule(JSON_QUERY_COLUMN).define(
IDENTIFIER_NAME,
b.optional(JSON_VALUE_RETURN_TYPE),
b.optional(FORMAT, JSON),
b.optional(b.firstOf(ALLOW, DISALLOW), SCALARS),
b.optional(JSON_QUERY_WRAPPER_CLAUSE),
b.optional(PATH, JSON_PATH),
b.optional(JSON_QUERY_ON_ERROR_CLAUSE)
)
b.rule(JSON_VALUE_COLUMN).define(
IDENTIFIER_NAME,
b.optional(JSON_VALUE_RETURN_TYPE),
b.nextNot(FORMAT),
b.optional(TRUNCATE),
b.optional(PATH, JSON_PATH),
b.optional(JSON_VALUE_ON_ERROR_CLAUSE),
b.optional(JSON_VALUE_ON_EMPTY_CLAUSE),
b.optional(JSON_VALUE_ON_MISMATCH_CLAUSE)
)
b.rule(JSON_NESTED_PATH).define(
NESTED, b.optional(PATH),
JSON_PATH,
JSON_COLUMNS_CLAUSE
)
b.rule(JSON_COLUMNS_CLAUSE).define(
COLUMNS,
LPARENTHESIS,
JSON_COLUMN_DEFINITION,
b.zeroOrMore(COMMA, JSON_COLUMN_DEFINITION),
RPARENTHESIS
)
b.rule(JSON_ORDINALITY_COLUMN).define(IDENTIFIER_NAME, FOR, ORDINALITY)
b.rule(JSON_PATH).define(
b.firstOf(
JSON_BASIC_PATH_EXPRESSION,
JSON_RELATIVE_OBJECT_ACCESS
)
)
b.rule(JSON_BASIC_PATH_EXPRESSION).define(STRING_LITERAL).skip()
b.rule(JSON_PATH_EXPRESSION).define(STRING_LITERAL).skip()
b.rule(JSON_RELATIVE_OBJECT_ACCESS).define(
IDENTIFIER_NAME, b.optional(JSON_ARRAY_STEP),
b.zeroOrMore(DOT, IDENTIFIER_NAME, b.optional(JSON_ARRAY_STEP))
)
b.rule(JSON_ARRAY_STEP).define(
LBRACKET,
b.firstOf(
b.oneOrMore(PlSqlTokenType.INTEGER_LITERAL, b.optional(TO, PlSqlTokenType.INTEGER_LITERAL), b.optional(COMMA)),
MULTIPLICATION
),
RBRACKET
)
b.rule(JSON_VALUE_RETURN_TYPE).define(
b.firstOf(
b.sequence(
CHARACTER_DATAYPE,
b.optional(TRUNCATE)
),
CLOB,
NUMERIC_DATATYPE,
b.sequence(b.firstOf(ALLOW, DISALLOW), b.optional(BOOLEAN), TO, NUMBER, b.optional(CONVERSION)),
b.sequence(DATE, b.optional(b.firstOf(TRUNCATE, PRESERVE), TIME)),
b.sequence(TIMESTAMP, b.optional(WITH, TIME, ZONE)),
BOOLEAN,
SDO_GEOMETRY,
JSON_VALUE_RETURN_OBJECT_INSTANCE,
VECTOR
)
)
b.rule(JSON_VALUE_RETURN_OBJECT_INSTANCE).define(
b.nextNot(NON_RESERVED_KEYWORD),
CUSTOM_DATATYPE, b.optional(USING, CASE_SENSITIVE, MAPPING))
b.rule(JSON_VALUE_ON_ERROR_CLAUSE).define(
b.firstOf(
ERROR,
NULL,
b.sequence(DEFAULT, LITERAL)
), ON, ERROR
)
b.rule(JSON_VALUE_ON_EMPTY_CLAUSE).define(
b.firstOf(
ERROR,
NULL,
b.sequence(DEFAULT, LITERAL)
), ON, EMPTY
)
b.rule(JSON_VALUE_ON_MISMATCH_CLAUSE).define(
b.firstOf(IGNORE, ERROR, NULL),
ON, MISMATCH,
b.optional(
LPARENTHESIS,
b.oneOrMore(
b.firstOf(
b.sequence(MISSING, DATA),
b.sequence(EXTRA, DATA),
b.sequence(TYPE, ERROR)
), b.optional(COMMA)
),
RPARENTHESIS
)
)
b.rule(JSON_VALUE_EXPRESSION).define(
JSON_VALUE,
LPARENTHESIS,
EXPRESSION,
b.optional(FORMAT, JSON),
COMMA,
STRING_LITERAL,
b.optional(JSON_PASSING_CLAUSE),
b.optional(JSON_VALUE_RETURNING_CLAUSE),
b.optional(JSON_VALUE_ON_ERROR_CLAUSE),
b.optional(JSON_VALUE_ON_EMPTY_CLAUSE),
b.zeroOrMore(JSON_VALUE_ON_MISMATCH_CLAUSE),
b.optional(TYPE, b.firstOf(STRICT, LAX)),
RPARENTHESIS
)
b.rule(JSON_VALUE_RETURNING_CLAUSE).define(RETURNING, JSON_VALUE_RETURN_TYPE, b.optional(ASCII))
b.rule(JSON_TRANSFORM_EXPRESSION).define(
JSON_TRANSFORM,
LPARENTHESIS,
EXPRESSION,
COMMA,
JSON_TRANSFORM_OPERATION,
b.zeroOrMore(COMMA, JSON_TRANSFORM_OPERATION),
b.optional(JSON_TRANSFORM_RETURNING_CLAUSE),
b.optional(TYPE, b.firstOf(STRICT, LAX)),
b.optional(JSON_PASSING_CLAUSE),
RPARENTHESIS
)
b.rule(JSON_TRANSFORM_RETURNING_CLAUSE).define(
RETURNING,
b.firstOf(
CHARACTER_DATAYPE,
b.sequence(
b.firstOf(CLOB, BLOB),
b.optional(b.firstOf(REFERENCE, VALUE))
),
JSON,
BOOLEAN,
VECTOR
)
)
b.rule(JSON_RHS_EXPRESSION).define(
b.firstOf(
b.sequence(PATH, JSON_BASIC_PATH_EXPRESSION),
b.sequence(EXPRESSION, b.optional(FORMAT, JSON))
)
)
b.rule(JSON_TRANSFORM_OPERATION).define(
b.firstOf(
JSON_APPEND_OPERATION,
JSON_CASE_OPERATION,
JSON_COPY_OPERATION,
JSON_INSERT_OPERATION,
JSON_INTERSECT_OPERATION,
JSON_KEEP_OPERATION,
JSON_MERGE_OPERATION,
JSON_MINUS_OPERATION,
JSON_NESTED_PATH_OPERATION,
JSON_PREPEND_OPERATION,
JSON_REMOVE_OPERATION,
JSON_RENAME_OPERATION,
JSON_REPLACE_OPERATION,
JSON_SET_OPERATION,
JSON_SORT_OPERATION,
JSON_UNION_OPERATION
)
)
b.rule(JSON_APPEND_OPERATION).define(
APPEND, JSON_PATH_EXPRESSION, EQUALS, JSON_RHS_EXPRESSION,
b.optional(b.firstOf(IGNORE, ERROR, CREATE, NULL), ON, MISSING),
b.optional(b.firstOf(IGNORE, ERROR, REPLACE, NULL), ON, MISMATCH),
b.optional(b.firstOf(IGNORE, ERROR, NULL), ON, NULL),
b.optional(b.firstOf(IGNORE, ERROR), ON, EMPTY),
)
b.rule(JSON_CASE_OPERATION).define(
CASE,
WHEN, JSON_PATH_EXPRESSION, THEN,
LPARENTHESIS,
JSON_TRANSFORM_OPERATION, b.zeroOrMore(COMMA, JSON_TRANSFORM_OPERATION),
RPARENTHESIS,
b.optional(
ELSE,
LPARENTHESIS,
JSON_TRANSFORM_OPERATION, b.zeroOrMore(COMMA, JSON_TRANSFORM_OPERATION),
RPARENTHESIS
),
END
)
b.rule(JSON_COPY_OPERATION).define(
COPY, JSON_PATH_EXPRESSION, EQUALS, JSON_RHS_EXPRESSION,
b.optional(b.firstOf(IGNORE, ERROR, CREATE, NULL), ON, MISSING),
b.optional(b.firstOf(IGNORE, ERROR, NULL), ON, NULL),
b.optional(b.firstOf(IGNORE, ERROR), ON, EMPTY)
)
b.rule(JSON_INSERT_OPERATION).define(
INSERT, JSON_PATH_EXPRESSION, EQUALS, JSON_RHS_EXPRESSION,
b.optional(b.firstOf(IGNORE, ERROR, REPLACE, NULL), ON, EXISTING),
b.optional(b.firstOf(IGNORE, ERROR, REMOVE, NULL), ON, NULL),
b.optional(b.firstOf(IGNORE, ERROR, NULL), ON, EMPTY),
b.optional(b.firstOf(IGNORE, ERROR), ON, ERROR)
)
b.rule(JSON_INTERSECT_OPERATION).define(
INTERSECT, JSON_PATH_EXPRESSION, EQUALS, JSON_RHS_EXPRESSION,
b.optional(b.firstOf(IGNORE, ERROR, CREATE, NULL), ON, MISSING),
b.optional(b.firstOf(IGNORE, ERROR, NULL), ON, NULL)
)
b.rule(JSON_KEEP_OPERATION).define(
KEEP, JSON_PATH_EXPRESSION, b.zeroOrMore(COMMA, JSON_PATH_EXPRESSION),
b.optional(b.firstOf(IGNORE, ERROR), ON, MISSING)
)
b.rule(JSON_MERGE_OPERATION).define(
MERGE, JSON_PATH_EXPRESSION, EQUALS, JSON_RHS_EXPRESSION,
b.optional(b.firstOf(IGNORE, ERROR, CREATE, NULL), ON, MISSING),
b.optional(b.firstOf(IGNORE, ERROR), ON, MISMATCH),
b.optional(b.firstOf(IGNORE, ERROR, NULL), ON, NULL),
b.optional(b.firstOf(IGNORE, ERROR), ON, EMPTY)
)
b.rule(JSON_MINUS_OPERATION).define(
MINUS_KEYWORD, JSON_PATH_EXPRESSION, EQUALS, JSON_RHS_EXPRESSION,
b.optional(b.firstOf(IGNORE, ERROR, CREATE, NULL), ON, MISSING),
b.optional(b.firstOf(IGNORE, ERROR, NULL), ON, NULL)
)
b.rule(JSON_NESTED_PATH_OPERATION).define(
NESTED, PATH, JSON_PATH_EXPRESSION, LPARENTHESIS,
JSON_TRANSFORM_OPERATION, b.zeroOrMore(COMMA, JSON_TRANSFORM_OPERATION),
RPARENTHESIS
)
b.rule(JSON_PREPEND_OPERATION).define(
PREPEND, JSON_PATH_EXPRESSION, EQUALS, JSON_RHS_EXPRESSION,
b.optional(b.firstOf(IGNORE, ERROR, CREATE, NULL), ON, MISSING),
b.optional(b.firstOf(IGNORE, ERROR, REPLACE, CREATE), ON, MISMATCH),
b.optional(b.firstOf(IGNORE, ERROR, NULL), ON, NULL),
b.optional(b.firstOf(IGNORE, ERROR), ON, EMPTY)
)
b.rule(JSON_REMOVE_OPERATION).define(
REMOVE, JSON_PATH_EXPRESSION,
b.optional(b.firstOf(IGNORE, ERROR), ON, MISSING)
)
b.rule(JSON_RENAME_OPERATION).define(
RENAME, JSON_PATH_EXPRESSION, WITH, STRING_LITERAL,
b.optional(b.firstOf(IGNORE, ERROR), ON, MISSING)
)
b.rule(JSON_REPLACE_OPERATION).define(
REPLACE, JSON_PATH_EXPRESSION, EQUALS, JSON_RHS_EXPRESSION,
b.optional(b.firstOf(IGNORE, ERROR, CREATE, NULL), ON, MISSING),
b.optional(b.firstOf(IGNORE, ERROR, REMOVE, NULL), ON, NULL),
b.optional(b.firstOf(IGNORE, ERROR, NULL), ON, EMPTY),
b.optional(b.firstOf(IGNORE, ERROR), ON, ERROR)
)
b.rule(JSON_SET_OPERATION).define(
SET, JSON_PATH_EXPRESSION, EQUALS, JSON_RHS_EXPRESSION,
b.optional(b.firstOf(IGNORE, ERROR, REPLACE), ON, EXISTING),
b.optional(b.firstOf(IGNORE, ERROR, CREATE), ON, MISSING),
b.optional(b.firstOf(IGNORE, ERROR, REMOVE, NULL), ON, NULL),
b.optional(b.firstOf(IGNORE, ERROR, NULL), ON, EMPTY),
b.optional(b.firstOf(IGNORE, ERROR), ON, ERROR)
)
b.rule(JSON_SORT_OPERATION).define(
SORT, JSON_PATH_EXPRESSION,
b.optional(
b.firstOf(
REVERSE,
b.sequence(
b.optional(REMOVE, NULLS),
ORDER, BY,
JSON_PATH_EXPRESSION, b.optional(b.firstOf(ASC, DESC)),
b.zeroOrMore(
COMMA,
JSON_PATH_EXPRESSION, b.optional(b.firstOf(ASC, DESC))
)
),
b.sequence(
b.optional(b.firstOf(ASC, DESC)),
b.optional(UNIQUE),
b.optional(REMOVE, NULLS)
)
)
),
b.optional(b.firstOf(IGNORE, ERROR, NULL), ON, MISSING),
b.optional(b.firstOf(IGNORE, ERROR, NULL), ON, MISMATCH),
b.optional(b.firstOf(IGNORE, ERROR), ON, EMPTY),
b.optional(b.firstOf(IGNORE, ERROR), ON, ERROR)
)
b.rule(JSON_UNION_OPERATION).define(
UNION, JSON_PATH_EXPRESSION, EQUALS, JSON_RHS_EXPRESSION,
b.optional(b.firstOf(IGNORE, ERROR, CREATE, NULL), ON, MISSING),
b.optional(b.firstOf(IGNORE, ERROR, NULL), ON, NULL)
)
}
}
}
================================================
FILE: zpa-core/src/main/kotlin/com/felipebz/zpa/api/SqlPlusGrammar.kt
================================================
/**
* Z PL/SQL Analyzer
* Copyright (C) 2015-2026 Felipe Zorzo
* mailto:felipe AT felipezorzo DOT com DOT br
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package com.felipebz.zpa.api
import com.felipebz.flr.api.GenericTokenType
import com.felipebz.flr.grammar.GrammarRuleKey
import com.felipebz.zpa.sslr.PlSqlGrammarBuilder
enum class SqlPlusGrammar : GrammarRuleKey {
SQLPLUS_COMMAND;
companion object {
fun buildOn(b: PlSqlGrammarBuilder) {
createSqlPlusCommands(b)
}
private fun createSqlPlusCommands(b: PlSqlGrammarBuilder) {
b.rule(SQLPLUS_COMMAND).define(
b.firstOf(
"@",
"A", "APPEND",
"ACC", "ACCEPT",
"ARCHIVE",
"ATTR", "ATTRIBUTE",
"BRE", "BREAK",
"BTI", "BTITLE",
"C", "CHANGE",
"CL", "CLEAR",
"COL", "COLUMN",
"COMP", "COMPUTE",
"CONN", "CONNECT",
"COPY",
"DEF", "DEFINE",
"DEL",
"DESC", "DESCRIBE",
"DISC", "DISCONNECT",
"ED", "EDIT",
"EXEC", "EXECUTE",
"EXIT", "QUIT",
"GET",
"HELP", "?",
"HO", "HOST",
"I", "INPUT",
"L", "LIST",
"PASSW", "PASSWORD",
"PAU", "PAUSE",
"PRINT",
"PRO", "PROMPT",
"RECOVER",
"REM", "REMARK",
"REPF", "REPFOOTER",
"REPH", "REPHEADER",
"R", "RUN",
"SAV", "SAVE",
"SET",
"SHO", "SHOW",
"SHUTDOWN",
"SPO", "SPOOL",
"STA", "START",
"STARTUP",
"STORE",
"TIMI", "TIMING",
"TTI", "TTITLE",
"UNDEF", "UNDEFINE",
"VAR", "VARIABLE",
"WHENEVER",
"XQUERY"),
b.firstOf(b.tillNewLine(), b.till(GenericTokenType.EOF)))
}
}
}
================================================
FILE: zpa-core/src/main/kotlin/com/felipebz/zpa/api/TclGrammar.kt
================================================
/**
* Z PL/SQL Analyzer
* Copyright (C) 2015-2026 Felipe Zorzo
* mailto:felipe AT felipezorzo DOT com DOT br
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package com.felipebz.zpa.api
import com.felipebz.flr.api.GenericTokenType.IDENTIFIER
import com.felipebz.flr.grammar.GrammarRuleKey
import com.felipebz.zpa.sslr.PlSqlGrammarBuilder
import com.felipebz.zpa.api.PlSqlGrammar.IDENTIFIER_NAME
import com.felipebz.zpa.api.PlSqlKeyword.*
import com.felipebz.zpa.api.PlSqlPunctuator.COMMA
import com.felipebz.zpa.api.PlSqlPunctuator.SEMICOLON
import com.felipebz.zpa.api.PlSqlTokenType.INTEGER_LITERAL
import com.felipebz.zpa.api.PlSqlTokenType.STRING_LITERAL
enum class TclGrammar : GrammarRuleKey {
TRANSACTION_NAME,
COMMIT_EXPRESSION,
ROLLBACK_EXPRESSION,
SAVEPOINT_EXPRESSION,
SET_TRANSACTION_EXPRESSION,
TCL_COMMAND;
companion object {
fun buildOn(b: PlSqlGrammarBuilder) {
b.rule(COMMIT_EXPRESSION).define(
COMMIT,
b.optional(WORK),
b.optional(b.firstOf(
b.sequence(FORCE, STRING_LITERAL, b.optional(COMMA, INTEGER_LITERAL)),
b.sequence(
b.optional(COMMENT, STRING_LITERAL),
b.optional(WRITE, b.optional(b.firstOf(IMMEDIATE, BATCH)), b.optional(b.firstOf(WAIT, NOWAIT))))))).skip()
b.rule(ROLLBACK_EXPRESSION).define(
ROLLBACK,
b.optional(WORK),
b.optional(b.firstOf(
b.sequence(FORCE, STRING_LITERAL),
b.sequence(TO, b.optional(SAVEPOINT), IDENTIFIER_NAME)))).skip()
b.rule(SAVEPOINT_EXPRESSION).define(SAVEPOINT, IDENTIFIER_NAME).skip()
b.rule(TRANSACTION_NAME).define(NAME, STRING_LITERAL)
//https://docs.oracle.com/cd/E11882_01/server.112/e41084/statements_10005.htm#SQLRF01705
b.rule(SET_TRANSACTION_EXPRESSION).define(
SET, TRANSACTION,
b.firstOf(
b.sequence(
b.firstOf(b.sequence(READ, b.firstOf(ONLY, WRITE)),
b.sequence(ISOLATION, LEVEL, b.firstOf(SERIALIZABLE, b.sequence(READ, COMMITTED))),
b.sequence(USE, ROLLBACK, SEGMENT, IDENTIFIER)),
b.optional(TRANSACTION_NAME)),
TRANSACTION_NAME))
b.rule(TCL_COMMAND).define(
b.firstOf(
COMMIT_EXPRESSION,
ROLLBACK_EXPRESSION,
SAVEPOINT_EXPRESSION,
SET_TRANSACTION_EXPRESSION),
b.optional(SEMICOLON))
}
}
}
================================================
FILE: zpa-core/src/main/kotlin/com/felipebz/zpa/api/ZpaRulesDefinition.kt
================================================
/**
* Z PL/SQL Analyzer
* Copyright (C) 2015-2026 Felipe Zorzo
* mailto:felipe AT felipezorzo DOT com DOT br
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package com.felipebz.zpa.api
interface ZpaRulesDefinition {
fun repositoryName(): String
fun repositoryKey(): String
fun checkClasses(): Array>
}
================================================
FILE: zpa-core/src/main/kotlin/com/felipebz/zpa/api/annotations/ActivatedByDefault.kt
================================================
/**
* Z PL/SQL Analyzer
* Copyright (C) 2015-2026 Felipe Zorzo
* mailto:felipe AT felipezorzo DOT com DOT br
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package com.felipebz.zpa.api.annotations
@Retention
@Target(AnnotationTarget.CLASS, AnnotationTarget.FILE)
annotation class ActivatedByDefault
================================================
FILE: zpa-core/src/main/kotlin/com/felipebz/zpa/api/annotations/ConstantRemediation.kt
================================================
/**
* Z PL/SQL Analyzer
* Copyright (C) 2015-2026 Felipe Zorzo
* mailto:felipe AT felipezorzo DOT com DOT br
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package com.felipebz.zpa.api.annotations
@Retention
@Target(AnnotationTarget.CLASS, AnnotationTarget.FILE)
annotation class ConstantRemediation(
/**
* Value of the remediation
* @return e.g. "10min" or "2h"
*/
val value: String)
================================================
FILE: zpa-core/src/main/kotlin/com/felipebz/zpa/api/annotations/Priority.kt
================================================
/**
* Z PL/SQL Analyzer
* Copyright (C) 2015-2026 Felipe Zorzo
* mailto:felipe AT felipezorzo DOT com DOT br
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package com.felipebz.zpa.api.annotations
enum class Priority {
INFO,
MINOR,
MAJOR,
CRITICAL,
BLOCKER
}
================================================
FILE: zpa-core/src/main/kotlin/com/felipebz/zpa/api/annotations/Rule.kt
================================================
/**
* Z PL/SQL Analyzer
* Copyright (C) 2015-2026 Felipe Zorzo
* mailto:felipe AT felipezorzo DOT com DOT br
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package com.felipebz.zpa.api.annotations
@Retention
@Target(AnnotationTarget.CLASS, AnnotationTarget.FILE)
annotation class Rule(val key: String = "",
val name: String = "",
val description: String = "",
val priority: Priority = Priority.MAJOR,
val tags: Array = [],
val status: String = "READY")
================================================
FILE: zpa-core/src/main/kotlin/com/felipebz/zpa/api/annotations/RuleInfo.kt
================================================
/**
* Z PL/SQL Analyzer
* Copyright (C) 2015-2026 Felipe Zorzo
* mailto:felipe AT felipezorzo DOT com DOT br
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package com.felipebz.zpa.api.annotations
@Retention
@Target(AnnotationTarget.CLASS, AnnotationTarget.FILE)
annotation class RuleInfo(val scope: Scope = Scope.MAIN) {
enum class Scope {
ALL, MAIN, TEST
}
}
================================================
FILE: zpa-core/src/main/kotlin/com/felipebz/zpa/api/annotations/RuleProperty.kt
================================================
/**
* Z PL/SQL Analyzer
* Copyright (C) 2015-2026 Felipe Zorzo
* mailto:felipe AT felipezorzo DOT com DOT br
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package com.felipebz.zpa.api.annotations
@Retention
@Target(AnnotationTarget.FIELD)
annotation class RuleProperty(val key: String = "",
val description: String = "",
val defaultValue: String = "",
val type: String = "")
================================================
FILE: zpa-core/src/main/kotlin/com/felipebz/zpa/api/annotations/RuleTemplate.kt
================================================
/**
* Z PL/SQL Analyzer
* Copyright (C) 2015-2026 Felipe Zorzo
* mailto:felipe AT felipezorzo DOT com DOT br
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package com.felipebz.zpa.api.annotations
@Retention
@Target(AnnotationTarget.CLASS, AnnotationTarget.FILE)
annotation class RuleTemplate
================================================
FILE: zpa-core/src/main/kotlin/com/felipebz/zpa/api/checks/PlSqlCheck.kt
================================================
/**
* Z PL/SQL Analyzer
* Copyright (C) 2015-2026 Felipe Zorzo
* mailto:felipe AT felipezorzo DOT com DOT br
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package com.felipebz.zpa.api.checks
import com.felipebz.flr.api.AstNode
import com.felipebz.flr.api.Token
import com.felipebz.zpa.checks.IssueLocation
import com.felipebz.zpa.sslr.Tree
import com.felipebz.zpa.api.PlSqlVisitorContext
import com.felipebz.zpa.api.squid.SemanticAstNode
import java.text.MessageFormat
import java.util.*
open class PlSqlCheck : PlSqlVisitor() {
private val issues = ArrayList()
override fun startScan() {
issues.clear()
}
fun semantic(node: AstNode) = node as SemanticAstNode
fun issues(): List = Collections.unmodifiableList(issues)
fun scanFileForIssues(context: PlSqlVisitorContext): List {
issues.clear()
scanFile(context)
return issues()
}
fun addIssue(node: AstNode, message: String): PreciseIssue {
val newIssue = PreciseIssue(IssueLocation.preciseLocation(node, message))
issues.add(newIssue)
return newIssue
}
fun addIssue(node: AstNode, message: String, vararg messageParameters: Any): PreciseIssue {
return addIssue(node, MessageFormat.format(message, *messageParameters))
}
fun addIssue(tree: Tree, message: String): PreciseIssue {
val newIssue = PreciseIssue(IssueLocation.preciseLocation(tree.astNode, message))
issues.add(newIssue)
return newIssue
}
fun addIssue(tree: Tree, message: String, vararg messageParameters: Any): PreciseIssue {
return addIssue(tree, MessageFormat.format(message, *messageParameters))
}
fun addIssue(primaryLocation: IssueLocation): PreciseIssue {
val newIssue = PreciseIssue(primaryLocation)
issues.add(newIssue)
return newIssue
}
fun addLineIssue(message: String, lineNumber: Int): PreciseIssue {
val newIssue = PreciseIssue(IssueLocation.atLineLevel(message, lineNumber))
issues.add(newIssue)
return newIssue
}
fun addLineIssue(message: String, lineNumber: Int, vararg messageParameters: Any): PreciseIssue {
return addLineIssue(MessageFormat.format(message, *messageParameters), lineNumber)
}
fun addFileIssue(message: String): PreciseIssue {
val newIssue = PreciseIssue(IssueLocation.atFileLevel(message))
issues.add(newIssue)
return newIssue
}
fun addFileIssue(message: String, vararg messageParameters: Any): PreciseIssue {
return addFileIssue(MessageFormat.format(message, *messageParameters))
}
fun addIssue(token: Token, message: String): PreciseIssue {
return addIssue(AstNode(token), message)
}
fun addIssue(token: Token, message: String, vararg messageParameters: Any): PreciseIssue {
return addIssue(token, MessageFormat.format(message, *messageParameters))
}
class PreciseIssue(private val primaryLocation: IssueLocation) {
private var cost: Int? = null
private val secondaryLocations = mutableListOf()
fun cost() = cost
fun withCost(cost: Int) = apply {
this.cost = cost
}
fun primaryLocation() = primaryLocation
fun secondary(node: AstNode, message: String) = apply {
secondaryLocations.add(IssueLocation.preciseLocation(node, message))
}
fun secondary(issueLocation: IssueLocation)= apply {
secondaryLocations.add(issueLocation)
}
fun secondaryLocations(): List = secondaryLocations
}
}
================================================
FILE: zpa-core/src/main/kotlin/com/felipebz/zpa/api/checks/PlSqlVisitor.kt
================================================
/**
* Z PL/SQL Analyzer
* Copyright (C) 2015-2026 Felipe Zorzo
* mailto:felipe AT felipezorzo DOT com DOT br
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package com.felipebz.zpa.api.checks
import com.felipebz.flr.api.AstNode
import com.felipebz.flr.api.AstNodeType
import com.felipebz.flr.api.Token
import com.felipebz.flr.api.Trivia
import com.felipebz.zpa.rules.ZpaActiveRule
import com.felipebz.zpa.squid.PlSqlAstWalker
import com.felipebz.zpa.api.PlSqlVisitorContext
open class PlSqlVisitor {
lateinit var context: PlSqlVisitorContext
lateinit var activeRule: ZpaActiveRule
internal set
private val astNodeTypesToVisit = mutableSetOf()
fun subscribedKinds(): Set = astNodeTypesToVisit
open fun startScan() {
// default implementation does nothing
}
open fun init() {
// default implementation does nothing
}
open fun visitFile(node: AstNode) {
// default implementation does nothing
}
open fun leaveFile(node: AstNode) {
// default implementation does nothing
}
open fun visitNode(node: AstNode) {
// default implementation does nothing
}
open fun visitToken(token: Token) {
// default implementation does nothing
}
open fun visitComment(trivia: Trivia, content: String) {
// default implementation does nothing
}
open fun leaveNode(node: AstNode) {
// default implementation does nothing
}
fun subscribeTo(vararg astNodeTypes: AstNodeType) {
astNodeTypesToVisit.addAll(astNodeTypes)
}
fun scanFile(context: PlSqlVisitorContext) {
val walker = PlSqlAstWalker(setOf(this))
walker.walk(context)
}
}
================================================
FILE: zpa-core/src/main/kotlin/com/felipebz/zpa/api/matchers/MethodMatcher.kt
================================================
/**
* Z PL/SQL Analyzer
* Copyright (C) 2015-2026 Felipe Zorzo
* mailto:felipe AT felipezorzo DOT com DOT br
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package com.felipebz.zpa.api.matchers
import com.felipebz.flr.api.AstNode
import com.felipebz.zpa.api.PlSqlGrammar
import com.felipebz.zpa.api.squid.SemanticAstNode
import com.felipebz.zpa.api.symbols.PlSqlType
class MethodMatcher private constructor()
{
private var methodNameCriteria: NameCriteria? = null
private var packageNameCriteria: NameCriteria? = null
private var schemaNameCriteria: NameCriteria? = null
private var shouldCheckParameters = true
private var schemaIsOptional = false
var methodName: String = ""
private set
private val expectedArgumentTypes = ArrayList()
fun name(methodNameCriteria: String) =
name(NameCriteria.`is`(methodNameCriteria))
fun name(methodNameCriteria: NameCriteria) = apply {
check(this.methodNameCriteria == null)
this.methodNameCriteria = methodNameCriteria
}
fun packageName(packageNameCriteria: String) =
packageName(NameCriteria.`is`(packageNameCriteria))
fun packageName(packageNameCriteria: NameCriteria) = apply {
check(this.packageNameCriteria == null)
this.packageNameCriteria = packageNameCriteria
}
fun schema(schemaNameCriteria: String) =
schema(NameCriteria.`is`(schemaNameCriteria))
fun schema(schemaNameCriteria: NameCriteria) = apply {
check(this.schemaNameCriteria == null)
this.schemaNameCriteria = schemaNameCriteria
}
fun withNoParameterConstraint() = apply {
check(this.expectedArgumentTypes.isEmpty())
this.shouldCheckParameters = false
}
fun schemaIsOptional() = apply {
this.schemaIsOptional = true
}
fun addParameter() =
addParameter(PlSqlType.UNKNOWN)
fun addParameter(type: PlSqlType) = apply {
check(this.shouldCheckParameters)
expectedArgumentTypes.add(type)
}
fun addParameters(quantity: Int) = apply {
for (i in 0 until quantity) {
addParameter(PlSqlType.UNKNOWN)
}
}
fun addParameters(vararg types: PlSqlType) = apply {
check(this.shouldCheckParameters)
for (type in types) {
addParameter(type)
}
}
fun getArguments(node: AstNode): List {
val arguments = node.getFirstChildOrNull(PlSqlGrammar.ARGUMENTS)
return arguments?.getChildren(PlSqlGrammar.ARGUMENT) ?: ArrayList()
}
fun getArgumentsValues(node: AstNode) =
getArguments(node).map { it.lastChild }.toList()
fun matches(originalNode: AstNode): Boolean {
val node = normalize(originalNode)
var i = -1
val nodes = arrayOfNulls(3)
for (child in node.children) {
if (i < 2 && (child.type === PlSqlGrammar.VARIABLE_NAME || child.type === PlSqlGrammar.IDENTIFIER_NAME)) {
nodes[++i] = child.tokenValue
}
}
fun hasMoreItensToCheck() = i > -1
fun nextNode() = nodes[i--]
if (!hasMoreItensToCheck()) {
return false
}
var matches = methodNameCriteria?.let { nameAcceptable(nextNode(), it) } ?: true
packageNameCriteria?.let {
matches = matches and (hasMoreItensToCheck() && nameAcceptable(nextNode(), it))
}
schemaNameCriteria?.let {
matches = matches and (schemaIsOptional && !hasMoreItensToCheck() ||
hasMoreItensToCheck() && nameAcceptable(nextNode(), it))
}
return matches && !hasMoreItensToCheck() && argumentsAcceptable(originalNode)
}
private fun nameAcceptable(name: String?, criteria: NameCriteria): Boolean {
methodName = name ?: ""
return criteria.matches(methodName)
}
private fun argumentsAcceptable(node: AstNode): Boolean {
val arguments = getArguments(node)
return !shouldCheckParameters || arguments.size == expectedArgumentTypes.size && argumentTypesAreCorrect(arguments)
}
private fun argumentTypesAreCorrect(arguments: List): Boolean {
var result = true
for ((i, type) in expectedArgumentTypes.withIndex()) {
val actualArgument = arguments[i].firstChild
result = result and (type === PlSqlType.UNKNOWN || type === semantic(actualArgument).plSqlType)
}
return result
}
private fun normalize(node: AstNode): AstNode {
if (node.type === PlSqlGrammar.METHOD_CALL || node.type === PlSqlGrammar.CALL_STATEMENT) {
var child = normalize(node.firstChild)
if (child.firstChild.type === PlSqlGrammar.HOST_AND_INDICATOR_VARIABLE) {
child = child.firstChild
}
return child
}
return node
}
companion object {
@JvmStatic
fun create(): MethodMatcher {
return MethodMatcher()
}
fun semantic(node: AstNode): SemanticAstNode {
return node as SemanticAstNode
}
}
}
================================================
FILE: zpa-core/src/main/kotlin/com/felipebz/zpa/api/matchers/NameCriteria.kt
================================================
/**
* Z PL/SQL Analyzer
* Copyright (C) 2015-2026 Felipe Zorzo
* mailto:felipe AT felipezorzo DOT com DOT br
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package com.felipebz.zpa.api.matchers
import java.util.*
fun interface NameCriteria {
fun matches(name: String?): Boolean
companion object {
@JvmStatic
fun any(): NameCriteria =
NameCriteria { true }
@JvmStatic
fun `is`(exactName: String): NameCriteria =
NameCriteria { name -> exactName.equals(name, ignoreCase = true) }
@JvmStatic
fun startsWith(prefix: String): NameCriteria =
NameCriteria { name ->
name != null &&
name.uppercase(Locale.getDefault())
.startsWith(prefix.uppercase(Locale.getDefault()))
}
@JvmStatic
fun `in`(vararg prefix: String): NameCriteria =
NameCriteria { name -> prefix.any { name.equals(it, ignoreCase = true) } }
}
}
================================================
FILE: zpa-core/src/main/kotlin/com/felipebz/zpa/api/squid/PlSqlCommentAnalyzer.kt
================================================
/**
* Z PL/SQL Analyzer
* Copyright (C) 2015-2026 Felipe Zorzo
* mailto:felipe AT felipezorzo DOT com DOT br
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package com.felipebz.zpa.api.squid
object PlSqlCommentAnalyzer {
fun getContents(comment: String) =
when (comment[0]) {
'-' -> {
comment.substring(2)
}
'/' -> {
comment.substring(2, comment.length - 2)
}
else -> {
throw IllegalArgumentException()
}
}
}
================================================
FILE: zpa-core/src/main/kotlin/com/felipebz/zpa/api/squid/SemanticAstNode.kt
================================================
/**
* Z PL/SQL Analyzer
* Copyright (C) 2015-2026 Felipe Zorzo
* mailto:felipe AT felipezorzo DOT com DOT br
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package com.felipebz.zpa.api.squid
import com.felipebz.flr.api.AstNode
import com.felipebz.flr.api.AstNodeType
import com.felipebz.flr.api.Token
import com.felipebz.zpa.sslr.PlSqlGrammarBuilder
import com.felipebz.zpa.sslr.Tree
import com.felipebz.zpa.sslr.TreeImpl
import com.felipebz.zpa.api.symbols.PlSqlType
import com.felipebz.zpa.api.symbols.Symbol
import com.felipebz.zpa.api.symbols.datatype.PlSqlDatatype
import com.felipebz.zpa.api.symbols.datatype.UnknownDatatype
class SemanticAstNode(type: AstNodeType, name: String, token: Token?) : AstNode(type, name, token) {
constructor(token: Token) : this(token.type, token.type.name, token)
private var internalTree: Tree? = null
var symbol: Symbol? = null
set(symbol) {
field = symbol
val child = if (children.count() == 1) children[0] else return
(child as SemanticAstNode).symbol = symbol
}
var plSqlDatatype: PlSqlDatatype = UnknownDatatype
get() = this.symbol?.datatype ?: field
val plSqlType: PlSqlType
get() = plSqlDatatype.type
val tree: Tree
get() {
internalTree?.let { return it }
var classType = PlSqlGrammarBuilder.classForType(super.type)
if (classType == TreeImpl::class.java) {
var node = this
while (classType == TreeImpl::class.java && node.numberOfChildren == 1) {
node = node.firstChild as SemanticAstNode
classType = PlSqlGrammarBuilder.classForType(node.type)
}
}
val instance = classType.getDeclaredConstructor(SemanticAstNode::class.java)
.newInstance(this)
internalTree = instance
return instance
}
val allTokensToString: String
get() = tokens.joinToString(" ") { it.originalValue }
override fun toString(): String {
return buildString {
append(name)
if (tokenOrNull != null) {
append(" value='").append(token.value).append("'")
append(" line=").append(token.line)
append(" column=").append(token.column)
}
if (plSqlDatatype !is UnknownDatatype) {
append(" datatype=")
append(plSqlDatatype)
}
}
}
}
================================================
FILE: zpa-core/src/main/kotlin/com/felipebz/zpa/api/symbols/PlSqlType.kt
================================================
/**
* Z PL/SQL Analyzer
* Copyright (C) 2015-2026 Felipe Zorzo
* mailto:felipe AT felipezorzo DOT com DOT br
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package com.felipebz.zpa.api.symbols
enum class PlSqlType {
UNKNOWN,
CHARACTER,
NUMERIC,
DATE,
LOB,
BOOLEAN,
ROWTYPE,
ASSOCIATIVE_ARRAY,
NULL,
RECORD,
JSON,
EXCEPTION;
val isCharacter: Boolean
get() = this == CHARACTER
val isNumeric: Boolean
get() = this == NUMERIC
val isUnknown: Boolean
get() = this == UNKNOWN
}
================================================
FILE: zpa-core/src/main/kotlin/com/felipebz/zpa/api/symbols/Scope.kt
================================================
/**
* Z PL/SQL Analyzer
* Copyright (C) 2015-2026 Felipe Zorzo
* mailto:felipe AT felipezorzo DOT com DOT br
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package com.felipebz.zpa.api.symbols
import com.felipebz.flr.api.AstNode
import com.felipebz.flr.api.AstNodeType
import com.felipebz.flr.api.Token
import com.felipebz.zpa.api.PlSqlFile
import java.util.*
interface Scope {
val isAutonomousTransaction: Boolean
val isOverridingMember: Boolean
val symbols: List
val tree: AstNode?
val outer: Scope?
val identifier: String?
val hasExceptionHandler: Boolean
val path: List
val innerScopes: List
val type: AstNodeType?
val isGlobal: Boolean
val plSqlFile: PlSqlFile?
val firstToken: Token?
val lastToken: Token?
/**
* @param kind of the symbols to look for
* @return the symbols corresponding to the given kind
*/
fun getSymbols(kind: Symbol.Kind): List
fun getSymbolsAcessibleInScope(name: String, vararg kinds: Symbol.Kind): Deque
fun addSymbol(symbol: Symbol)
fun getSymbol(name: String, vararg kinds: Symbol.Kind): Symbol?
fun getSymbol(name: String, path: List, vararg kinds: Symbol.Kind): Symbol?
fun addInnerScope(scope: Scope)
}
================================================
FILE: zpa-core/src/main/kotlin/com/felipebz/zpa/api/symbols/Symbol.kt
================================================
/**
* Z PL/SQL Analyzer
* Copyright (C) 2015-2026 Felipe Zorzo
* mailto:felipe AT felipezorzo DOT com DOT br
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package com.felipebz.zpa.api.symbols
import com.felipebz.flr.api.AstNode
import com.felipebz.zpa.api.PlSqlGrammar
import com.felipebz.zpa.api.symbols.datatype.PlSqlDatatype
import com.felipebz.zpa.api.symbols.datatype.UnknownDatatype
import java.util.*
open class Symbol(val node: AstNode?,
val kind: Kind,
val scope: Scope,
datatype: PlSqlDatatype?,
name: String = "") {
private val internalUsages = mutableListOf()
private var internalModifiers = mutableListOf()
enum class Kind(val value: String) {
VARIABLE("variable"),
PARAMETER("parameter"),
CURSOR("cursor"),
TYPE("type"),
PACKAGE("package"),
PROCEDURE("procedure"),
FUNCTION("function"),
TRIGGER("trigger"),
}
val declaration by lazy { node ?: throw IllegalStateException("Symbol must have a declaration") }
val name: String = node?.tokenValue ?: name
val type: PlSqlType = datatype?.type ?: PlSqlType.UNKNOWN
val datatype: PlSqlDatatype = datatype ?: UnknownDatatype
val modifiers: List
get() = Collections.unmodifiableList(internalModifiers)
val usages: List
get() = Collections.unmodifiableList(internalUsages)
val isGlobal: Boolean = if (kind in arrayOf(Kind.VARIABLE, Kind.CURSOR, Kind.TYPE)) {
scope.isGlobal && scope.type == PlSqlGrammar.CREATE_PACKAGE
} else {
scope.isGlobal
}
var innerScope: Scope? = null
fun hasModifier(modifier: String): Boolean {
for (syntaxToken in modifiers) {
if (syntaxToken.tokenValue.equals(modifier, ignoreCase = true)) {
return true
}
}
return false
}
fun addModifiers(modifiers: List) {
internalModifiers.addAll(modifiers)
}
fun addUsage(usage: AstNode) {
internalUsages.add(usage)
}
fun `is`(kind: Kind) = kind == this.kind
fun called(name: String) = if (name.startsWith('"')) {
name == this.name
} else {
name.equals(this.name, ignoreCase = true)
}
override fun toString() = "Symbol name=$name kind=$kind datatype=$datatype"
}
================================================
FILE: zpa-core/src/main/kotlin/com/felipebz/zpa/api/symbols/SymbolTable.kt
================================================
/**
* Z PL/SQL Analyzer
* Copyright (C) 2015-2026 Felipe Zorzo
* mailto:felipe AT felipezorzo DOT com DOT br
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package com.felipebz.zpa.api.symbols
import com.felipebz.flr.api.AstNode
interface SymbolTable {
val symbols: List
val scopes: Set
fun getScopeFor(symbol: AstNode): Scope?
}
================================================
FILE: zpa-core/src/main/kotlin/com/felipebz/zpa/api/symbols/datatype/AssociativeArrayDatatype.kt
================================================
/**
* Z PL/SQL Analyzer
* Copyright (C) 2015-2026 Felipe Zorzo
* mailto:felipe AT felipezorzo DOT com DOT br
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package com.felipebz.zpa.api.symbols.datatype
import com.felipebz.flr.api.AstNode
import com.felipebz.zpa.api.PlSqlGrammar
import com.felipebz.zpa.api.symbols.PlSqlType
import com.felipebz.zpa.api.symbols.Scope
class AssociativeArrayDatatype(node: AstNode? = null, currentScope: Scope?, val nestedType: PlSqlDatatype) : PlSqlDatatype {
override val type = PlSqlType.ASSOCIATIVE_ARRAY
override val name: String = currentScope?.let {
if (it.identifier != null && it.type == PlSqlGrammar.CREATE_PACKAGE)
it.identifier + "."
else "" } +
node?.getFirstChild(PlSqlGrammar.IDENTIFIER_NAME)?.tokenValue
override fun toString(): String {
return "AssociativeArray{nestedType=$nestedType}"
}
}
================================================
FILE: zpa-core/src/main/kotlin/com/felipebz/zpa/api/symbols/datatype/BooleanDatatype.kt
================================================
/**
* Z PL/SQL Analyzer
* Copyright (C) 2015-2026 Felipe Zorzo
* mailto:felipe AT felipezorzo DOT com DOT br
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package com.felipebz.zpa.api.symbols.datatype
import com.felipebz.zpa.api.symbols.PlSqlType
class BooleanDatatype : PlSqlDatatype {
override val type = PlSqlType.BOOLEAN
override val name: String = "BOOLEAN"
override fun toString(): String {
return "Boolean"
}
}
================================================
FILE: zpa-core/src/main/kotlin/com/felipebz/zpa/api/symbols/datatype/CharacterDatatype.kt
================================================
/**
* Z PL/SQL Analyzer
* Copyright (C) 2015-2026 Felipe Zorzo
* mailto:felipe AT felipezorzo DOT com DOT br
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package com.felipebz.zpa.api.symbols.datatype
import com.felipebz.flr.api.AstNode
import com.felipebz.zpa.api.PlSqlGrammar
import com.felipebz.zpa.api.symbols.PlSqlType
class CharacterDatatype : PlSqlDatatype {
override val type = PlSqlType.CHARACTER
override val name: String
get() = if (this.length == null)
"VARCHAR2"
else
"VARCHAR2(${this.length})"
val length: Int?
constructor() {
length = null
}
constructor(length: Int?) {
this.length = if (length != null && length > 0) length else null
}
constructor(node: AstNode? = null) {
val constraint = node?.firstChildOrNull?.getFirstChildOrNull(PlSqlGrammar.CHARACTER_DATATYPE_CONSTRAINT)
length = constraint
?.getFirstChildOrNull(PlSqlGrammar.LITERAL)
?.tokenValue?.toInt()
}
override fun toString(): String {
return "Character{length=$length}"
}
}
================================================
FILE: zpa-core/src/main/kotlin/com/felipebz/zpa/api/symbols/datatype/DateDatatype.kt
================================================
/**
* Z PL/SQL Analyzer
* Copyright (C) 2015-2026 Felipe Zorzo
* mailto:felipe AT felipezorzo DOT com DOT br
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package com.felipebz.zpa.api.symbols.datatype
import com.felipebz.zpa.api.symbols.PlSqlType
class DateDatatype : PlSqlDatatype {
override val type = PlSqlType.DATE
override val name: String = "DATE"
override fun toString(): String {
return "Date"
}
}
================================================
FILE: zpa-core/src/main/kotlin/com/felipebz/zpa/api/symbols/datatype/ExceptionDatatype.kt
================================================
/**
* Z PL/SQL Analyzer
* Copyright (C) 2015-2026 Felipe Zorzo
* mailto:felipe AT felipezorzo DOT com DOT br
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package com.felipebz.zpa.api.symbols.datatype
import com.felipebz.zpa.api.symbols.PlSqlType
class ExceptionDatatype : PlSqlDatatype {
override val type = PlSqlType.EXCEPTION
override val name: String = "EXCEPTION"
override fun toString(): String {
return "Exception"
}
}
================================================
FILE: zpa-core/src/main/kotlin/com/felipebz/zpa/api/symbols/datatype/JsonDatatype.kt
================================================
/**
* Z PL/SQL Analyzer
* Copyright (C) 2015-2026 Felipe Zorzo
* mailto:felipe AT felipezorzo DOT com DOT br
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package com.felipebz.zpa.api.symbols.datatype
import com.felipebz.zpa.api.symbols.PlSqlType
class JsonDatatype : PlSqlDatatype {
override val type = PlSqlType.JSON
override val name: String = "JSON"
override fun toString(): String {
return "Json"
}
}
================================================
FILE: zpa-core/src/main/kotlin/com/felipebz/zpa/api/symbols/datatype/LobDatatype.kt
================================================
/**
* Z PL/SQL Analyzer
* Copyright (C) 2015-2026 Felipe Zorzo
* mailto:felipe AT felipezorzo DOT com DOT br
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package com.felipebz.zpa.api.symbols.datatype
import com.felipebz.zpa.api.symbols.PlSqlType
class LobDatatype : PlSqlDatatype {
override val type = PlSqlType.LOB
override val name: String = "LOB"
override fun toString(): String {
return "Lob"
}
}
================================================
FILE: zpa-core/src/main/kotlin/com/felipebz/zpa/api/symbols/datatype/NullDatatype.kt
================================================
/**
* Z PL/SQL Analyzer
* Copyright (C) 2015-2026 Felipe Zorzo
* mailto:felipe AT felipezorzo DOT com DOT br
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package com.felipebz.zpa.api.symbols.datatype
import com.felipebz.zpa.api.symbols.PlSqlType
class NullDatatype : PlSqlDatatype {
override val type = PlSqlType.NULL
override val name: String = "NULL"
override fun toString(): String {
return "Null"
}
}
================================================
FILE: zpa-core/src/main/kotlin/com/felipebz/zpa/api/symbols/datatype/NumericDatatype.kt
================================================
/**
* Z PL/SQL Analyzer
* Copyright (C) 2015-2026 Felipe Zorzo
* mailto:felipe AT felipezorzo DOT com DOT br
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package com.felipebz.zpa.api.symbols.datatype
import com.felipebz.flr.api.AstNode
import com.felipebz.zpa.api.PlSqlGrammar
import com.felipebz.zpa.api.symbols.PlSqlType
class NumericDatatype : PlSqlDatatype {
override val type = PlSqlType.NUMERIC
override val name: String
get() = if (this.length == null)
"NUMBER()"
else if (this.scale == null)
"NUMBER(${this.length})"
else
"NUMBER(${this.length}, ${this.scale})"
val length: Int?
val scale: Int?
constructor() {
length = null
scale = null
}
constructor(length: Int?, scale: Int?) {
this.length = if (length != null && length > 0) length else null
this.scale = if (scale != null && scale > 0) scale else null
}
constructor(node: AstNode? = null) {
val constraint = node?.firstChildOrNull?.getFirstChildOrNull(PlSqlGrammar.NUMERIC_DATATYPE_CONSTRAINT)
if (constraint != null) {
val precisionNode = constraint.getFirstChildOrNull(PlSqlGrammar.NUMERIC_PRECISION)
length = if (precisionNode != null && precisionNode.hasDirectChildren(PlSqlGrammar.LITERAL)) {
precisionNode.tokenValue.toInt()
} else {
null
}
val scaleNode = constraint.getFirstChildOrNull(PlSqlGrammar.NUMERIC_SCALE)
scale = if (scaleNode != null && scaleNode.hasDirectChildren(PlSqlGrammar.LITERAL)) {
scaleNode.tokenValue.toInt()
} else {
null
}
} else {
length = null
scale = null
}
}
override fun toString(): String {
return "Numeric{length=$length, scale=$scale}"
}
}
================================================
FILE: zpa-core/src/main/kotlin/com/felipebz/zpa/api/symbols/datatype/PlSqlDatatype.kt
================================================
/**
* Z PL/SQL Analyzer
* Copyright (C) 2015-2026 Felipe Zorzo
* mailto:felipe AT felipezorzo DOT com DOT br
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package com.felipebz.zpa.api.symbols.datatype
import com.felipebz.zpa.api.symbols.PlSqlType
interface PlSqlDatatype {
val type: PlSqlType
val name: String?
}
================================================
FILE: zpa-core/src/main/kotlin/com/felipebz/zpa/api/symbols/datatype/RecordDatatype.kt
================================================
/**
* Z PL/SQL Analyzer
* Copyright (C) 2015-2026 Felipe Zorzo
* mailto:felipe AT felipezorzo DOT com DOT br
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package com.felipebz.zpa.api.symbols.datatype
import com.felipebz.flr.api.AstNode
import com.felipebz.zpa.api.PlSqlGrammar
import com.felipebz.zpa.api.symbols.PlSqlType
import com.felipebz.zpa.api.symbols.Scope
import com.felipebz.zpa.api.symbols.Symbol
class RecordDatatype(node: AstNode? = null, currentScope: Scope?, val fields: List) : PlSqlDatatype {
override val type = PlSqlType.RECORD
override val name: String = currentScope?.let {
if (it.identifier != null && it.type == PlSqlGrammar.CREATE_PACKAGE)
it.identifier + "."
else "" } +
node?.getFirstChild(PlSqlGrammar.IDENTIFIER_NAME)?.tokenValue
override fun toString(): String {
return "Record"
}
}
================================================
FILE: zpa-core/src/main/kotlin/com/felipebz/zpa/api/symbols/datatype/RowtypeDatatype.kt
================================================
/**
* Z PL/SQL Analyzer
* Copyright (C) 2015-2026 Felipe Zorzo
* mailto:felipe AT felipezorzo DOT com DOT br
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package com.felipebz.zpa.api.symbols.datatype
import com.felipebz.zpa.api.symbols.PlSqlType
class RowtypeDatatype : PlSqlDatatype {
override val type = PlSqlType.ROWTYPE
override val name: String? = null
override fun toString(): String {
return "Rowtype"
}
}
================================================
FILE: zpa-core/src/main/kotlin/com/felipebz/zpa/api/symbols/datatype/UnknownDatatype.kt
================================================
/**
* Z PL/SQL Analyzer
* Copyright (C) 2015-2026 Felipe Zorzo
* mailto:felipe AT felipezorzo DOT com DOT br
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package com.felipebz.zpa.api.symbols.datatype
import com.felipebz.zpa.api.symbols.PlSqlType
object UnknownDatatype : PlSqlDatatype {
override val type = PlSqlType.UNKNOWN
override val name: String? = null
override fun toString(): String {
return "Unknown"
}
}
================================================
FILE: zpa-core/src/main/kotlin/com/felipebz/zpa/checks/IssueLocation.kt
================================================
/**
* Z PL/SQL Analyzer
* Copyright (C) 2015-2026 Felipe Zorzo
* mailto:felipe AT felipezorzo DOT com DOT br
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package com.felipebz.zpa.checks
import com.felipebz.flr.api.AstNode
import com.felipebz.flr.api.Token
abstract class IssueLocation private constructor(private val message: String) {
fun message() = message
abstract fun startLine(): Int
abstract fun startLineOffset(): Int
abstract fun endLine(): Int
abstract fun endLineOffset(): Int
private class PreciseIssueLocation : IssueLocation {
private val firstToken: Token
private val lastToken: Token
constructor(node: AstNode, message: String) : super(message) {
this.firstToken = node.token
this.lastToken = node.lastToken
}
constructor(startNode: AstNode, endNode: AstNode, message: String) : super(message) {
this.firstToken = startNode.token
this.lastToken = endNode.lastToken
}
override fun startLine() = firstToken.line
override fun startLineOffset() = firstToken.column
override fun endLine() = lastToken.endLine
override fun endLineOffset() = lastToken.endColumn
}
private class LineLevelIssueLocation(message: String, private val lineNumber: Int) : IssueLocation(message) {
override fun startLine() = lineNumber
override fun startLineOffset() = UNDEFINED_OFFSET
override fun endLine() = lineNumber
override fun endLineOffset() = UNDEFINED_OFFSET
}
private class FileLevelIssueLocation(message: String) : IssueLocation(message) {
override fun startLine() = UNDEFINED_LINE
override fun startLineOffset() = UNDEFINED_OFFSET
override fun endLine() = UNDEFINED_LINE
override fun endLineOffset() = UNDEFINED_OFFSET
}
companion object {
const val UNDEFINED_OFFSET = -1
const val UNDEFINED_LINE = 0
fun atFileLevel(message: String): IssueLocation =
FileLevelIssueLocation(message)
fun atLineLevel(message: String, lineNumber: Int): IssueLocation =
LineLevelIssueLocation(message, lineNumber)
fun preciseLocation(startNode: AstNode, endNode: AstNode, message: String): IssueLocation =
PreciseIssueLocation(startNode, endNode, message)
fun preciseLocation(startNode: AstNode, message: String): IssueLocation =
PreciseIssueLocation(startNode, message)
}
}
================================================
FILE: zpa-core/src/main/kotlin/com/felipebz/zpa/grammar/ExecutePlSqlBufferExpression.kt
================================================
/**
* Z PL/SQL Analyzer
* Copyright (C) 2015-2026 Felipe Zorzo
* mailto:felipe AT felipezorzo DOT com DOT br
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package com.felipebz.zpa.grammar
import com.felipebz.flr.api.GenericTokenType
import com.felipebz.flr.internal.matchers.Matcher
import com.felipebz.flr.internal.vm.Machine
import com.felipebz.flr.internal.vm.NativeExpression
import com.felipebz.zpa.api.PlSqlPunctuator
public object ExecuteBufferExpression : NativeExpression(), Matcher {
override fun execute(machine: Machine) {
if (machine.length < 2) {
machine.backtrack()
return
}
val previousTokenLine = if (machine.index == 0) 0 else machine.tokenAt(-1).line
val token = machine.tokenAt(0)
val nextToken = machine.tokenAt(1)
if (token.type == PlSqlPunctuator.DIVISION && token.column == 0
&& (token.line != previousTokenLine || previousTokenLine == 0)
&& (token.line != nextToken.line || nextToken.type == GenericTokenType.EOF)
) {
machine.createLeafNode(this, 1)
machine.jump(1)
} else {
machine.backtrack()
}
}
override fun toString(): String {
return "ExecuteBuffer"
}
}
================================================
FILE: zpa-core/src/main/kotlin/com/felipebz/zpa/lexer/CommentChannel.kt
================================================
/**
* Z PL/SQL Analyzer
* Copyright (C) 2015-2026 Felipe Zorzo
* mailto:felipe AT felipezorzo DOT com DOT br
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package com.felipebz.zpa.lexer
import com.felipebz.flr.channel.Channel
import com.felipebz.flr.channel.CodeReader
import com.felipebz.flr.impl.LexerOutput
import com.felipebz.flr.impl.channel.CommentRegexpChannel
private const val inlineComment = "--[^\\n\\r]*+"
private const val multiLineComment = "/\\*[\\s\\S]*?\\*/"
class CommentChannel private constructor(private val commentRegexpChannel: CommentRegexpChannel)
: Channel by commentRegexpChannel {
constructor(): this(CommentRegexpChannel("(?:$inlineComment|$multiLineComment)"))
override fun consume(code: CodeReader, output: LexerOutput): Boolean {
val nextChar = code.peek().toChar()
if (nextChar != '-' && nextChar != '/') {
return false
}
return commentRegexpChannel.consume(code, output)
}
}
================================================
FILE: zpa-core/src/main/kotlin/com/felipebz/zpa/lexer/DateChannel.kt
================================================
/**
* Z PL/SQL Analyzer
* Copyright (C) 2015-2026 Felipe Zorzo
* mailto:felipe AT felipezorzo DOT com DOT br
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package com.felipebz.zpa.lexer
import com.felipebz.flr.channel.Channel
import com.felipebz.flr.channel.CodeReader
import com.felipebz.flr.impl.LexerOutput
import com.felipebz.flr.impl.channel.RegexpChannel
class DateChannel(private val regexpChannel: RegexpChannel)
: Channel by regexpChannel {
override fun consume(code: CodeReader, output: LexerOutput): Boolean {
val nextChar = code.peek().toChar().lowercaseChar()
if (nextChar != 'd' && nextChar != 't') {
return false
}
return regexpChannel.consume(code, output)
}
}
================================================
FILE: zpa-core/src/main/kotlin/com/felipebz/zpa/lexer/DiscardWhitespaceChannel.kt
================================================
/**
* Z PL/SQL Analyzer
* Copyright (C) 2015-2026 Felipe Zorzo
* mailto:felipe AT felipezorzo DOT com DOT br
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package com.felipebz.zpa.lexer
import com.felipebz.flr.channel.Channel
import com.felipebz.flr.channel.CodeReader
import com.felipebz.flr.impl.LexerOutput
class DiscardWhitespaceChannel : Channel {
override fun consume(code: CodeReader, output: LexerOutput): Boolean {
if (code[0].isWhitespace() && code[1] != '&') {
code.pop()
return true
}
return false
}
}
================================================
FILE: zpa-core/src/main/kotlin/com/felipebz/zpa/lexer/IdentifierChannel.kt
================================================
/**
* Z PL/SQL Analyzer
* Copyright (C) 2015-2026 Felipe Zorzo
* mailto:felipe AT felipezorzo DOT com DOT br
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package com.felipebz.zpa.lexer
import com.felipebz.flr.channel.Channel
import com.felipebz.flr.channel.CodeReader
import com.felipebz.flr.impl.LexerOutput
import com.felipebz.flr.impl.channel.IdentifierAndKeywordChannel
class IdentifierChannel(private val channel: IdentifierAndKeywordChannel)
: Channel by channel {
override fun consume(code: CodeReader, output: LexerOutput): Boolean {
val nextChar = code.peek().toChar()
if (!nextChar.isLetter()) {
return false
}
return channel.consume(code, output)
}
}
================================================
FILE: zpa-core/src/main/kotlin/com/felipebz/zpa/lexer/IntegerChannel.kt
================================================
/**
* Z PL/SQL Analyzer
* Copyright (C) 2015-2026 Felipe Zorzo
* mailto:felipe AT felipezorzo DOT com DOT br
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package com.felipebz.zpa.lexer
import com.felipebz.flr.api.Token
import com.felipebz.flr.channel.Channel
import com.felipebz.flr.channel.CodeReader
import com.felipebz.flr.impl.LexerOutput
import com.felipebz.zpa.api.PlSqlTokenType
class IntegerChannel : Channel {
override fun consume(code: CodeReader, output: LexerOutput): Boolean {
var tmpBuilder: StringBuilder? = null
var pos = 0
var nextChar = code.intAt(pos++).toChar()
while (nextChar.isDigit()) {
tmpBuilder = tmpBuilder ?: StringBuilder(5)
tmpBuilder.append(nextChar)
nextChar = code.intAt(pos++).toChar()
}
if (tmpBuilder.isNullOrEmpty()) {
return false
}
val value = tmpBuilder.toString()
val token = Token.builder()
.setType(PlSqlTokenType.INTEGER_LITERAL)
.setValueAndOriginalValue(value)
.setLine(code.getLinePosition())
.setColumn(code.getColumnPosition())
.build()
output.addToken(token)
/* Advance the CodeReader stream by the length of the punctuator */
for (j in value.indices) {
code.pop()
}
return true
}
}
================================================
FILE: zpa-core/src/main/kotlin/com/felipebz/zpa/lexer/NumericChannel.kt
================================================
/**
* Z PL/SQL Analyzer
* Copyright (C) 2015-2026 Felipe Zorzo
* mailto:felipe AT felipezorzo DOT com DOT br
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package com.felipebz.zpa.lexer
import com.felipebz.flr.channel.Channel
import com.felipebz.flr.channel.CodeReader
import com.felipebz.flr.impl.LexerOutput
import com.felipebz.flr.impl.channel.RegexpChannel
class NumericChannel(private val regexpChannel: RegexpChannel)
: Channel by regexpChannel {
override fun consume(code: CodeReader, output: LexerOutput): Boolean {
val nextChar = code.peek().toChar()
if (nextChar !in '0'..'9' && nextChar != '.') {
return false
}
return regexpChannel.consume(code, output)
}
}
================================================
FILE: zpa-core/src/main/kotlin/com/felipebz/zpa/lexer/PlSqlLexer.kt
================================================
/**
* Z PL/SQL Analyzer
* Copyright (C) 2015-2026 Felipe Zorzo
* mailto:felipe AT felipezorzo DOT com DOT br
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package com.felipebz.zpa.lexer
import com.felipebz.flr.impl.Lexer
import com.felipebz.flr.impl.channel.BlackHoleChannel
import com.felipebz.flr.impl.channel.IdentifierAndKeywordChannel
import com.felipebz.flr.impl.channel.PunctuatorChannel
import com.felipebz.flr.impl.channel.RegexpChannelBuilder.and
import com.felipebz.flr.impl.channel.RegexpChannelBuilder.g
import com.felipebz.flr.impl.channel.RegexpChannelBuilder.o2n
import com.felipebz.flr.impl.channel.RegexpChannelBuilder.or
import com.felipebz.flr.impl.channel.RegexpChannelBuilder.regexp
import com.felipebz.flr.impl.channel.UnknownCharacterChannel
import com.felipebz.zpa.squid.PlSqlConfiguration
import com.felipebz.zpa.api.PlSqlKeyword
import com.felipebz.zpa.api.PlSqlPunctuator
import com.felipebz.zpa.api.PlSqlTokenType
object PlSqlLexer {
private val NUMBER_LITERAL = "(?is)(?:" + or(
"""(?:(?:\d++(?![.][.])[.]\d*+)|(?![.][.])[.]\d++)(?:e[+-]?\d++)?[fd]?""", // decimal value in floating-point literal
"""\d++(?:e[+-]?\d++)?[fd]""", // integer value in floating-point literal
"""\d++(?:e[+-]?\d++)""" // number literal in scientific notation
) + ")"
private const val CUSTOM_DELIMITER_START = """[^\s{\[<\(]""" // any except spacing
private const val CUSTOM_DELIMITER_END = """\1""" // same as the start
private val STRING_LITERAL = ("(?is)(?:"
+ or("""?:n?'(?:[^']|'')*+'""", // simple text literal
"n?q?'" + or("?:" + g("?:" + g(CUSTOM_DELIMITER_START) + ".*?(?:" + CUSTOM_DELIMITER_END + "')"),
g("""?:\(.*?\)'"""),
g("""?:\[.*?\]'"""),
g("""?:<.*?>'"""),
g("""?:\{.*?\}'"""))) // text with user-defined delimiter
+ ")")
private const val DATE_LITERAL = """(?i)(?:DATE\s*?'\d{4}-\d{2}-\d{2}')"""
private const val TIMESTAMP_LITERAL = """(?i)TIMESTAMP\s*?'\d{4}-\d{2}-\d{2}\s++\d{1,2}:\d{2}:\d{2}(?:.\d{1,9})?(?:\s++[A-Z0-9_/+-:]++(?:\s++[A-Z0-9_/+-]{1,5})?)?'"""
private val SIMPLE_IDENTIFIER = and("""[\w\p{L}]""", o2n("""[\w\p{L}#$]"""))
private const val QUOTED_IDENTIFIER = """".+?""""
fun create(conf: PlSqlConfiguration): Lexer =
Lexer.builder()
.withCharset(conf.charset)
.withFailIfNoChannelToConsumeOneCharacter(true)
.withChannel(DiscardWhitespaceChannel())
.withChannel(CommentChannel())
.withChannel(NumericChannel(regexp(PlSqlTokenType.NUMBER_LITERAL, NUMBER_LITERAL)))
.withChannel(IntegerChannel())
.withChannel(StringChannel(regexp(PlSqlTokenType.STRING_LITERAL, STRING_LITERAL)))
.withChannel(DateChannel(regexp(PlSqlTokenType.DATE_LITERAL, DATE_LITERAL)))
.withChannel(DateChannel(regexp(PlSqlTokenType.TIMESTAMP_LITERAL, TIMESTAMP_LITERAL)))
.withChannel(IdentifierChannel(IdentifierAndKeywordChannel(SIMPLE_IDENTIFIER, false,
PlSqlKeyword.entries.toTypedArray()
)))
.withChannel(QuotedIdentifierChannel(QUOTED_IDENTIFIER, SIMPLE_IDENTIFIER))
.withChannel(PunctuatorChannel(*PlSqlPunctuator.entries.toTypedArray()))
.withChannel(BlackHoleChannel("(?is)" + or(
"\\s&&?$SIMPLE_IDENTIFIER",
"\\\$if.*?\\\$then",
"\\\$else.*?\\\$end",
"\\\$error.*?\\\$end",
"\\\$end"
)))
.withChannel(UnknownCharacterChannel())
.build()
}
================================================
FILE: zpa-core/src/main/kotlin/com/felipebz/zpa/lexer/QuotedIdentifierChannel.kt
================================================
/**
* Z PL/SQL Analyzer
* Copyright (C) 2015-2026 Felipe Zorzo
* mailto:felipe AT felipezorzo DOT com DOT br
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package com.felipebz.zpa.lexer
import com.felipebz.flr.api.GenericTokenType
import com.felipebz.flr.api.Token
import com.felipebz.flr.channel.Channel
import com.felipebz.flr.channel.CodeReader
import com.felipebz.flr.impl.LexerOutput
import java.util.regex.Pattern
class QuotedIdentifierChannel(quotedIdentifierRegexp: String, simpleIdentifierRegexp: String) : Channel {
private val quotedPattern = Pattern.compile(quotedIdentifierRegexp)
private val quotedSimplePattern = Pattern.compile(""""$simpleIdentifierRegexp"""")
override fun consume(code: CodeReader, output: LexerOutput): Boolean {
val nextChar = code.peek().toChar()
if (nextChar != '"') {
return false
}
val tmpBuilder = StringBuilder()
val matcher = quotedPattern.matcher("")
if (code.popTo(matcher, tmpBuilder) > 0) {
var word = tmpBuilder.toString()
val wordOriginal = word
if (quotedSimplePattern.matcher(word).matches() && word == word.uppercase()) {
word = word.substring(1, word.length - 1)
}
val token = Token.builder()
.setType(GenericTokenType.IDENTIFIER)
.setValueAndOriginalValue(word, wordOriginal)
.setLine(code.previousCursor.line)
.setColumn(code.previousCursor.column)
.build()
output.addToken(token)
return true
}
return false
}
}
================================================
FILE: zpa-core/src/main/kotlin/com/felipebz/zpa/lexer/StringChannel.kt
================================================
/**
* Z PL/SQL Analyzer
* Copyright (C) 2015-2026 Felipe Zorzo
* mailto:felipe AT felipezorzo DOT com DOT br
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package com.felipebz.zpa.lexer
import com.felipebz.flr.channel.Channel
import com.felipebz.flr.channel.CodeReader
import com.felipebz.flr.impl.LexerOutput
import com.felipebz.flr.impl.channel.RegexpChannel
class StringChannel(private val regexpChannel: RegexpChannel)
: Channel by regexpChannel {
override fun consume(code: CodeReader, output: LexerOutput): Boolean {
val nextChar = code.peek().toChar().lowercaseChar()
if (nextChar != '\'' && nextChar != 'n' && nextChar != 'q') {
return false
}
return regexpChannel.consume(code, output)
}
}
================================================
FILE: zpa-core/src/main/kotlin/com/felipebz/zpa/metadata/FormsMetadata.kt
================================================
/**
* Z PL/SQL Analyzer
* Copyright (C) 2015-2026 Felipe Zorzo
* mailto:felipe AT felipezorzo DOT com DOT br
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package com.felipebz.zpa.metadata
import com.fasterxml.jackson.databind.ObjectMapper
import com.felipebz.zpa.utils.log.Loggers
import java.io.File
import java.io.FileNotFoundException
import java.io.IOException
class Block @JvmOverloads constructor(val name: String = "", val items: Array = emptyArray())
class FormsMetadata {
var alerts = listOf()
var blocks = listOf()
var lovs = listOf()
companion object {
private val LOG = Loggers.getLogger(FormsMetadata::class.java)
fun loadFromFile(path: String?): FormsMetadata? {
if (!path.isNullOrEmpty()) {
try {
val mapper = ObjectMapper()
val formsMetadata: FormsMetadata = mapper.readValue(File(path), FormsMetadata::class.java)
LOG.info("Loaded Oracle Forms metadata from {}.", path)
return formsMetadata
} catch (e: FileNotFoundException) {
LOG.warn("The metadata file {} was not found.", path, e)
} catch (e: IOException) {
LOG.error("Error reading the metadata file at {}.", path, e)
}
}
return null
}
}
}
================================================
FILE: zpa-core/src/main/kotlin/com/felipebz/zpa/metrics/ComplexityVisitor.kt
================================================
/**
* Z PL/SQL Analyzer
* Copyright (C) 2015-2026 Felipe Zorzo
* mailto:felipe AT felipezorzo DOT com DOT br
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package com.felipebz.zpa.metrics
import com.felipebz.flr.api.AstNode
import com.felipebz.zpa.api.PlSqlGrammar
import com.felipebz.zpa.api.PlSqlKeyword
import com.felipebz.zpa.api.checks.PlSqlCheck
open class ComplexityVisitor : PlSqlCheck() {
var complexity: Int = 0
private set
override fun init() {
subscribeTo(
PlSqlGrammar.CREATE_PROCEDURE,
PlSqlGrammar.CREATE_FUNCTION,
PlSqlGrammar.ANONYMOUS_BLOCK,
PlSqlGrammar.PROCEDURE_DECLARATION,
PlSqlGrammar.FUNCTION_DECLARATION,
PlSqlGrammar.LOOP_STATEMENT,
PlSqlGrammar.CONTINUE_STATEMENT,
PlSqlGrammar.FOR_STATEMENT,
PlSqlGrammar.EXIT_STATEMENT,
PlSqlGrammar.IF_STATEMENT,
PlSqlGrammar.RAISE_STATEMENT,
PlSqlGrammar.RETURN_STATEMENT,
PlSqlGrammar.WHILE_STATEMENT,
// this includes WHEN in exception handlers, exit/continue statements and CASE expressions
PlSqlKeyword.WHEN,
PlSqlKeyword.ELSIF)
}
override fun visitFile(node: AstNode) {
complexity = 0
}
override fun visitNode(node: AstNode) {
complexity++
}
}
================================================
FILE: zpa-core/src/main/kotlin/com/felipebz/zpa/metrics/FunctionComplexityVisitor.kt
================================================
/**
* Z PL/SQL Analyzer
* Copyright (C) 2015-2026 Felipe Zorzo
* mailto:felipe AT felipezorzo DOT com DOT br
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package com.felipebz.zpa.metrics
import com.felipebz.flr.api.AstNode
import com.felipebz.zpa.api.PlSqlGrammar
import com.felipebz.zpa.api.checks.PlSqlCheck
class FunctionComplexityVisitor : PlSqlCheck() {
var numberOfFunctions: Int = 0
private set
override fun init() {
subscribeTo(PlSqlGrammar.CREATE_PROCEDURE,
PlSqlGrammar.CREATE_FUNCTION,
PlSqlGrammar.PROCEDURE_DECLARATION,
PlSqlGrammar.FUNCTION_DECLARATION)
}
override fun visitNode(node: AstNode) {
numberOfFunctions++
}
}
================================================
FILE: zpa-core/src/main/kotlin/com/felipebz/zpa/metrics/MetricsVisitor.kt
================================================
/**
* Z PL/SQL Analyzer
* Copyright (C) 2015-2026 Felipe Zorzo
* mailto:felipe AT felipezorzo DOT com DOT br
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package com.felipebz.zpa.metrics
import com.felipebz.flr.api.AstNode
import com.felipebz.flr.api.Token
import com.felipebz.flr.api.Trivia
import com.felipebz.zpa.api.PlSqlGrammar
import com.felipebz.zpa.api.checks.PlSqlCheck
class MetricsVisitor : PlSqlCheck() {
var numberOfStatements: Int = 0
private set
private val linesOfCode = HashSet()
private val linesOfComments = HashSet()
private val noSonar = HashSet()
private val executableLines = HashSet()
val linesWithNoSonar: Set
get() = noSonar
override fun init() {
subscribeTo(PlSqlGrammar.STATEMENT)
}
override fun visitNode(node: AstNode) {
if (node.hasDirectChildren(PlSqlGrammar.BLOCK_STATEMENT))
return
numberOfStatements++
executableLines.add(node.tokenLine)
}
override fun visitToken(token: Token) {
for (line in token.line .. token.endLine) {
linesOfCode.add(line)
}
}
override fun visitComment(trivia: Trivia, content: String) {
val comment = trivia.token.value
val line = trivia.token.line
val endLine = trivia.token.endLine
val firstLineContainsNoSonar = comment.indexOfAny(newlineChars).let {
if (it == -1) {
comment.contains("NOSONAR")
} else {
comment.regionMatches(0, "NOSONAR", 0, it)
}
}
for (i in line .. endLine) {
linesOfComments.add(i)
}
if (firstLineContainsNoSonar) {
linesOfComments.remove(line)
noSonar.add(line)
}
}
fun getLinesOfCode(): Set = linesOfCode
fun getLinesOfComments(): Set = linesOfComments
fun getExecutableLines(): Set = executableLines
companion object {
private val newlineChars = charArrayOf('\n', '\r')
}
}
================================================
FILE: zpa-core/src/main/kotlin/com/felipebz/zpa/parser/PlSqlParser.kt
================================================
/**
* Z PL/SQL Analyzer
* Copyright (C) 2015-2026 Felipe Zorzo
* mailto:felipe AT felipezorzo DOT com DOT br
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package com.felipebz.zpa.parser
import com.felipebz.flr.api.Grammar
import com.felipebz.flr.impl.Parser
import com.felipebz.zpa.lexer.PlSqlLexer
import com.felipebz.zpa.squid.PlSqlConfiguration
import com.felipebz.zpa.api.PlSqlGrammar
import com.felipebz.zpa.api.squid.SemanticAstNode
object PlSqlParser {
fun create(conf: PlSqlConfiguration): Parser =
Parser.builder(PlSqlGrammar.create(conf).build())
.withLexer(PlSqlLexer.create(conf))
.withNonTerminalNodeBuilder(::SemanticAstNode)
.withTerminalNodeBuilder(::SemanticAstNode)
.build()
}
================================================
FILE: zpa-core/src/main/kotlin/com/felipebz/zpa/rules/ActiveRule.kt
================================================
/**
* Z PL/SQL Analyzer
* Copyright (C) 2015-2026 Felipe Zorzo
* mailto:felipe AT felipezorzo DOT com DOT br
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package com.felipebz.zpa.rules
class ActiveRule(
private val repository: ZpaRepository,
private val rule: ZpaRule,
private val configuration: ActiveRuleConfiguration?
) : ZpaActiveRule {
override val internalKey: String
get() = rule.key
override val language: String
get() = "plsqlopen"
override fun param(key: String): String = configuration?.parameters?.get(key) ?: ""
override val params: Map
get() = configuration?.parameters ?: emptyMap()
override val ruleKey: ZpaRuleKey
get() = RuleKey(repository.key, rule.key)
override val severity: String
get() = configuration?.severity ?: rule.severity
override val templateRuleKey: String?
get() = null
override val tags: Array
get() = rule.tags
override val remediationConstant: String
get() = rule.remediationConstant
override val name: String
get() = rule.name
}
================================================
FILE: zpa-core/src/main/kotlin/com/felipebz/zpa/rules/ActiveRuleConfiguration.kt
================================================
/**
* Z PL/SQL Analyzer
* Copyright (C) 2015-2026 Felipe Zorzo
* mailto:felipe AT felipezorzo DOT com DOT br
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package com.felipebz.zpa.rules
class ActiveRuleConfiguration(
val repositoryKey: String,
val key: String,
var severity: String? = null,
var parameters: MutableMap = mutableMapOf()
) {
fun keyIs(repositoryKey: String, key: String): Boolean {
return this.repositoryKey == repositoryKey && this.key == key
}
}
================================================
FILE: zpa-core/src/main/kotlin/com/felipebz/zpa/rules/ActiveRuleConfigurer.kt
================================================
/**
* Z PL/SQL Analyzer
* Copyright (C) 2015-2026 Felipe Zorzo
* mailto:felipe AT felipezorzo DOT com DOT br
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package com.felipebz.zpa.rules
fun interface ActiveRuleConfigurer {
fun apply(repo: Repository, rule: ZpaRule, configuration: ActiveRuleConfiguration): Boolean
}
================================================
FILE: zpa-core/src/main/kotlin/com/felipebz/zpa/rules/ActiveRules.kt
================================================
/**
* Z PL/SQL Analyzer
* Copyright (C) 2015-2026 Felipe Zorzo
* mailto:felipe AT felipezorzo DOT com DOT br
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package com.felipebz.zpa.rules
class ActiveRules : ZpaActiveRules {
private val repositories = mutableListOf()
private val activeRuleConfigurers = mutableListOf()
fun addRepository(repository: Repository): ActiveRules = apply {
repositories.add(repository)
}
fun addRuleConfigurer(filter: ActiveRuleConfigurer): ActiveRules = apply {
activeRuleConfigurers.add(filter)
}
override fun findByRepository(repository: String): Collection {
val repo = this.repositories.first { it.key == repository }
return repo.availableRules
.mapNotNull { rule ->
val activeRuleConfiguration = ActiveRuleConfiguration(repo.key, rule.key)
if (activeRuleConfigurers.all { it.apply(repo, rule, activeRuleConfiguration) }) {
ActiveRule(repo, rule, activeRuleConfiguration)
} else {
null
}
}
}
}
================================================
FILE: zpa-core/src/main/kotlin/com/felipebz/zpa/rules/Repository.kt
================================================
/**
* Z PL/SQL Analyzer
* Copyright (C) 2015-2026 Felipe Zorzo
* mailto:felipe AT felipezorzo DOT com DOT br
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package com.felipebz.zpa.rules
class Repository(override val key: String) : ZpaRepository {
private val rules = mutableMapOf()
override fun createRule(ruleKey: String): ZpaRule {
val rule = Rule(ruleKey)
rules[ruleKey] = rule
return rule
}
override fun rule(ruleKey: String): ZpaRule? = rules[ruleKey]
val availableRules: List
get() = rules.values.toList()
override fun toString(): String = key
}
================================================
FILE: zpa-core/src/main/kotlin/com/felipebz/zpa/rules/Rule.kt
================================================
/**
* Z PL/SQL Analyzer
* Copyright (C) 2015-2026 Felipe Zorzo
* mailto:felipe AT felipezorzo DOT com DOT br
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package com.felipebz.zpa.rules
import com.felipebz.zpa.api.annotations.RuleInfo
class Rule(override val key: String) : ZpaRule {
private val parameters = mutableListOf()
override var htmlDescription: String = ""
override var name: String = ""
override val params: List = parameters
override var remediationConstant: String = ""
set(value) {
if (!REMEDIATION_PATTERN.matches(value)) {
throw IllegalArgumentException("Invalid base effort: $value")
}
field = value
}
override var scope: RuleInfo.Scope = RuleInfo.Scope.ALL
override var severity: String = ""
override var status: RuleStatus = RuleStatus.READY
override var tags: Array = emptyArray()
override var template: Boolean = false
override var isActivatedByDefault = false
override fun createParam(fieldKey: String): ZpaRuleParam {
val param = RuleParam(fieldKey)
parameters.add(param)
return param
}
companion object {
private const val DAY = "d"
private const val HOUR = "h"
private const val MINUTE = "min"
private val REMEDIATION_PATTERN = Regex("\\s*+(?:(\\d++)\\s*+$DAY)?+\\s*+(?:(\\d++)\\s*+$HOUR)?+\\s*+(?:(\\d++)\\s*+$MINUTE)?+\\s*+")
}
}
================================================
FILE: zpa-core/src/main/kotlin/com/felipebz/zpa/rules/RuleData.kt
================================================
/**
* Z PL/SQL Analyzer
* Copyright (C) 2015-2026 Felipe Zorzo
* mailto:felipe AT felipezorzo DOT com DOT br
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package com.felipebz.zpa.rules
import com.felipebz.zpa.api.annotations.Priority
import com.felipebz.zpa.api.annotations.Rule
class RuleData(val key: String,
val name: String,
val description: String,
val priority: Priority,
val tags: Array,
val status: String) {
companion object {
fun from(rule: Rule?): RuleData? =
if (rule == null) null
else RuleData(rule.key,
rule.name,
rule.description,
rule.priority,
rule.tags,
rule.status)
}
}
================================================
FILE: zpa-core/src/main/kotlin/com/felipebz/zpa/rules/RuleKey.kt
================================================
/**
* Z PL/SQL Analyzer
* Copyright (C) 2015-2026 Felipe Zorzo
* mailto:felipe AT felipezorzo DOT com DOT br
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package com.felipebz.zpa.rules
class RuleKey(override val repository: String, private val key: String) : ZpaRuleKey {
override val rule: String
get() = key
override fun toString(): String = "$repository:$key"
override fun equals(other: Any?): Boolean {
if (this === other) return true
if (other?.javaClass != javaClass) return false
other as RuleKey
return this.key == other.key && this.repository == other.repository
}
override fun hashCode(): Int {
var result = repository.hashCode()
result = 31 * result + key.hashCode()
return result
}
}
================================================
FILE: zpa-core/src/main/kotlin/com/felipebz/zpa/rules/RuleMetadataLoader.kt
================================================
/**
* Z PL/SQL Analyzer
* Copyright (C) 2015-2026 Felipe Zorzo
* mailto:felipe AT felipezorzo DOT com DOT br
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package com.felipebz.zpa.rules
import com.felipebz.zpa.utils.getAnnotation
import com.felipebz.zpa.api.annotations.Rule
import com.felipebz.zpa.api.annotations.RuleProperty
import java.lang.reflect.Field
open class RuleMetadataLoader {
open fun getRuleAnnotation(annotatedClassOrObject: Any) : RuleData? =
RuleData.from(getAnnotation(annotatedClassOrObject, Rule::class.java))
open fun getRulePropertyAnnotation(field: Field) : RulePropertyData? =
RulePropertyData.from(field.getAnnotation(RuleProperty::class.java))
}
================================================
FILE: zpa-core/src/main/kotlin/com/felipebz/zpa/rules/RuleParam.kt
================================================
/**
* Z PL/SQL Analyzer
* Copyright (C) 2015-2026 Felipe Zorzo
* mailto:felipe AT felipezorzo DOT com DOT br
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package com.felipebz.zpa.rules
class RuleParam(override val key: String) : ZpaRuleParam {
override var defaultValue: String = ""
override var description: String = ""
}
================================================
FILE: zpa-core/src/main/kotlin/com/felipebz/zpa/rules/RulePropertyData.kt
================================================
/**
* Z PL/SQL Analyzer
* Copyright (C) 2015-2026 Felipe Zorzo
* mailto:felipe AT felipezorzo DOT com DOT br
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package com.felipebz.zpa.rules
import com.felipebz.zpa.api.annotations.RuleProperty
class RulePropertyData(val key: String,
val description: String,
val defaultValue: String,
val type: String) {
companion object {
fun from(ruleProperty: RuleProperty?) =
if (ruleProperty == null) null
else
RulePropertyData(ruleProperty.key,
ruleProperty.description,
ruleProperty.defaultValue,
ruleProperty.type)
}
}
================================================
FILE: zpa-core/src/main/kotlin/com/felipebz/zpa/rules/RuleStatus.kt
================================================
/**
* Z PL/SQL Analyzer
* Copyright (C) 2015-2026 Felipe Zorzo
* mailto:felipe AT felipezorzo DOT com DOT br
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package com.felipebz.zpa.rules
enum class RuleStatus {
BETA, DEPRECATED, READY, REMOVED;
companion object {
fun defaultStatus(): RuleStatus {
return READY
}
}
}
================================================
FILE: zpa-core/src/main/kotlin/com/felipebz/zpa/rules/RulesDefinitionAnnotationLoader.kt
================================================
/**
* Z PL/SQL Analyzer
* Copyright (C) 2015-2026 Felipe Zorzo
* mailto:felipe AT felipezorzo DOT com DOT br
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package com.felipebz.zpa.rules
import com.felipebz.zpa.CustomAnnotationBasedRulesDefinition.Companion.convertCheckClassName
import com.felipebz.zpa.utils.getFields
import com.felipebz.zpa.utils.log.Loggers
import java.lang.reflect.Field
class RulesDefinitionAnnotationLoader(private val ruleMetadataLoader: RuleMetadataLoader) {
fun load(repo: ZpaRepository, vararg annotatedClasses: Class<*>) {
for (annotatedClass in annotatedClasses) {
loadRule(repo, annotatedClass)
}
}
private fun loadRule(repo: ZpaRepository, clazz: Class<*>): ZpaRule? {
val ruleAnnotation = ruleMetadataLoader.getRuleAnnotation(clazz)
return if (ruleAnnotation != null) {
loadRule(repo, clazz, ruleAnnotation)
} else {
LOG.warn("The class " + clazz.canonicalName + " should be annotated with @Rule")
null
}
}
private fun loadRule(repo: ZpaRepository, clazz: Class<*>, ruleAnnotation: RuleData): ZpaRule {
val ruleKey = ruleAnnotation.key.ifEmpty { convertCheckClassName(clazz) }
val ruleName = ruleAnnotation.name
val description = ruleAnnotation.description
val rule = repo.createRule(ruleKey)
rule.name = ruleName
rule.htmlDescription = description
rule.severity = ruleAnnotation.priority.name
rule.status = RuleStatus.valueOf(ruleAnnotation.status)
rule.tags = ruleAnnotation.tags
val fields = getFields(clazz, true)
for (field in fields) {
loadParameters(rule, field)
}
return rule
}
private fun loadParameters(rule: ZpaRule, field: Field) {
val propertyAnnotation = ruleMetadataLoader.getRulePropertyAnnotation(field)
if (propertyAnnotation != null) {
val fieldKey = propertyAnnotation.key.ifEmpty { field.name }
val param = rule.createParam(fieldKey)
param.description = propertyAnnotation.description
param.defaultValue = propertyAnnotation.defaultValue
}
}
companion object {
private val LOG = Loggers.getLogger(RulesDefinitionAnnotationLoader::class.java)
}
}
================================================
FILE: zpa-core/src/main/kotlin/com/felipebz/zpa/rules/ZpaActiveRule.kt
================================================
/**
* Z PL/SQL Analyzer
* Copyright (C) 2015-2026 Felipe Zorzo
* mailto:felipe AT felipezorzo DOT com DOT br
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package com.felipebz.zpa.rules
interface ZpaActiveRule {
val ruleKey: ZpaRuleKey
val severity: String
val language: String
fun param(key: String): String?
val params: Map
val internalKey: String?
val templateRuleKey: String?
val tags: Array
val remediationConstant: String
val name: String
}
================================================
FILE: zpa-core/src/main/kotlin/com/felipebz/zpa/rules/ZpaActiveRules.kt
================================================
/**
* Z PL/SQL Analyzer
* Copyright (C) 2015-2026 Felipe Zorzo
* mailto:felipe AT felipezorzo DOT com DOT br
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package com.felipebz.zpa.rules
interface ZpaActiveRules {
fun findByRepository(repository: String): Collection
}
================================================
FILE: zpa-core/src/main/kotlin/com/felipebz/zpa/rules/ZpaChecks.kt
================================================
/**
* Z PL/SQL Analyzer
* Copyright (C) 2015-2026 Felipe Zorzo
* mailto:felipe AT felipezorzo DOT com DOT br
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package com.felipebz.zpa.rules
import com.felipebz.zpa.CustomAnnotationBasedRulesDefinition.Companion.getRuleKey
import com.felipebz.zpa.utils.getFields
import com.felipebz.zpa.api.checks.PlSqlVisitor
import java.lang.reflect.Field
import java.util.*
open class ZpaChecks constructor(private val activeRules: ZpaActiveRules,
private val repository: String,
private val ruleMetadataLoader: RuleMetadataLoader) {
private val checkByRule = HashMap()
private val ruleByCheck = IdentityHashMap()
fun of(ruleKey: ZpaRuleKey): PlSqlVisitor? {
return checkByRule[ruleKey]
}
fun all(): Collection {
return checkByRule.values
}
fun ruleKey(check: PlSqlVisitor): ZpaRuleKey? {
return ruleByCheck[check]
}
private fun add(ruleKey: ZpaRuleKey, obj: PlSqlVisitor) {
checkByRule[ruleKey] = obj
ruleByCheck[obj] = ruleKey
}
fun addAnnotatedChecks(checkClassesOrObjects: Iterable>): ZpaChecks {
val checksByEngineKey = HashMap>()
for (checkClassesOrObject in checkClassesOrObjects) {
val engineKey = getRuleKey(ruleMetadataLoader, checkClassesOrObject)
checksByEngineKey[engineKey] = checkClassesOrObject
}
for (activeRule in activeRules.findByRepository(repository)) {
val engineKey = if (activeRule.templateRuleKey.isNullOrBlank())
activeRule.ruleKey.rule
else
activeRule.templateRuleKey
val checkClassesOrObject = checksByEngineKey[engineKey]
if (checkClassesOrObject != null) {
val obj = instantiate(activeRule, checkClassesOrObject)
obj.activeRule = activeRule
add(activeRule.ruleKey, obj)
}
}
return this
}
private fun instantiate(activeRule: ZpaActiveRule, checkClassOrInstance: Any): PlSqlVisitor {
try {
var check = checkClassOrInstance
if (check is Class<*>) {
check = (checkClassOrInstance as Class<*>).getDeclaredConstructor().newInstance()
}
configureFields(activeRule, check)
return check as PlSqlVisitor
} catch (e: InstantiationException) {
throw failToInstantiateCheck(activeRule, checkClassOrInstance, e)
} catch (e: IllegalAccessException) {
throw failToInstantiateCheck(activeRule, checkClassOrInstance, e)
}
}
private fun failToInstantiateCheck(activeRule: ZpaActiveRule, checkClassOrInstance: Any, e: Exception): RuntimeException {
throw IllegalStateException(String.format("Fail to instantiate class %s for rules %s", checkClassOrInstance, activeRule.ruleKey), e)
}
private fun configureFields(activeRule: ZpaActiveRule, check: Any) {
for ((key, value) in activeRule.params) {
val field = getField(check, key) ?: throw IllegalStateException(
String.format("The field '%s' does not exist or is not annotated with @RuleProperty in the class %s", key, check.javaClass.name))
if (value.isNotBlank()) {
configureField(check, field, value)
}
}
}
private fun getField(check: Any, key: String): Field? {
val fields = getFields(check.javaClass, true)
for (field in fields) {
val propertyAnnotation = ruleMetadataLoader.getRulePropertyAnnotation(field)
if (propertyAnnotation != null && ((key == field.name) || (key == propertyAnnotation.key))) {
return field
}
}
return null
}
private fun configureField(check: Any, field: Field, value: String) {
try {
field.isAccessible = true
when(field.type) {
String::class.java -> field.set(check, value)
Int::class.javaPrimitiveType -> field.setInt(check, Integer.parseInt(value))
Short::class.javaPrimitiveType -> field.setShort(check, java.lang.Short.parseShort(value))
Long::class.javaPrimitiveType -> field.setLong(check, java.lang.Long.parseLong(value))
Double::class.javaPrimitiveType -> field.setDouble(check, java.lang.Double.parseDouble(value))
Boolean::class.javaPrimitiveType -> field.setBoolean(check, java.lang.Boolean.parseBoolean(value))
Byte::class.javaPrimitiveType -> field.setByte(check, java.lang.Byte.parseByte(value))
Int::class.java -> field.set(check, Integer.parseInt(value))
Long::class.java -> field.set(check, java.lang.Long.parseLong(value))
Double::class.java -> field.set(check, java.lang.Double.parseDouble(value))
Boolean::class.java -> field.set(check, java.lang.Boolean.parseBoolean(value))
else -> throw IllegalStateException("The type of the field " + field + " is not supported: " + field.type)
}
} catch (e: IllegalAccessException) {
throw IllegalStateException("Can not set the value of the field " + field + " in the class: " + check.javaClass.name, e)
}
}
}
================================================
FILE: zpa-core/src/main/kotlin/com/felipebz/zpa/rules/ZpaRepository.kt
================================================
/**
* Z PL/SQL Analyzer
* Copyright (C) 2015-2026 Felipe Zorzo
* mailto:felipe AT felipezorzo DOT com DOT br
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package com.felipebz.zpa.rules
interface ZpaRepository {
val key: String
fun createRule(ruleKey: String): ZpaRule
fun rule(ruleKey: String): ZpaRule?
}
================================================
FILE: zpa-core/src/main/kotlin/com/felipebz/zpa/rules/ZpaRule.kt
================================================
/**
* Z PL/SQL Analyzer
* Copyright (C) 2015-2026 Felipe Zorzo
* mailto:felipe AT felipezorzo DOT com DOT br
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package com.felipebz.zpa.rules
import com.felipebz.zpa.api.annotations.RuleInfo
interface ZpaRule {
val key: String
val params: List
var name: String
var remediationConstant: String
var scope: RuleInfo.Scope
var template: Boolean
var tags: Array
var status: RuleStatus
var severity: String
var htmlDescription: String
var isActivatedByDefault: Boolean
fun createParam(fieldKey: String): ZpaRuleParam
}
================================================
FILE: zpa-core/src/main/kotlin/com/felipebz/zpa/rules/ZpaRuleKey.kt
================================================
/**
* Z PL/SQL Analyzer
* Copyright (C) 2015-2026 Felipe Zorzo
* mailto:felipe AT felipezorzo DOT com DOT br
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package com.felipebz.zpa.rules
interface ZpaRuleKey {
val rule: String
val repository: String
}
================================================
FILE: zpa-core/src/main/kotlin/com/felipebz/zpa/rules/ZpaRuleParam.kt
================================================
/**
* Z PL/SQL Analyzer
* Copyright (C) 2015-2026 Felipe Zorzo
* mailto:felipe AT felipezorzo DOT com DOT br
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package com.felipebz.zpa.rules
interface ZpaRuleParam {
val key: String
var description: String
var defaultValue: String
}
================================================
FILE: zpa-core/src/main/kotlin/com/felipebz/zpa/squid/AnalysisException.kt
================================================
/**
* Z PL/SQL Analyzer
* Copyright (C) 2015-2026 Felipe Zorzo
* mailto:felipe AT felipezorzo DOT com DOT br
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package com.felipebz.zpa.squid
class AnalysisException(string: String, e: Throwable) : RuntimeException(string, e)
================================================
FILE: zpa-core/src/main/kotlin/com/felipebz/zpa/squid/AstScanner.kt
================================================
/**
* Z PL/SQL Analyzer
* Copyright (C) 2015-2026 Felipe Zorzo
* mailto:felipe AT felipezorzo DOT com DOT br
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package com.felipebz.zpa.squid
import com.felipebz.flr.api.Grammar
import com.felipebz.flr.api.RecognitionException
import com.felipebz.flr.impl.Parser
import com.felipebz.zpa.FormsMetadataAwareCheck
import com.felipebz.zpa.metadata.FormsMetadata
import com.felipebz.zpa.metrics.ComplexityVisitor
import com.felipebz.zpa.metrics.FunctionComplexityVisitor
import com.felipebz.zpa.metrics.MetricsVisitor
import com.felipebz.zpa.parser.PlSqlParser
import com.felipebz.zpa.symbols.DefaultTypeSolver
import com.felipebz.zpa.symbols.ScopeImpl
import com.felipebz.zpa.symbols.SymbolVisitor
import com.felipebz.zpa.utils.getAnnotation
import com.felipebz.zpa.utils.log.Loggers
import com.felipebz.zpa.api.PlSqlFile
import com.felipebz.zpa.api.PlSqlVisitorContext
import com.felipebz.zpa.api.annotations.RuleInfo
import com.felipebz.zpa.api.checks.PlSqlCheck
import com.felipebz.zpa.api.checks.PlSqlVisitor
import java.io.InterruptedIOException
import java.nio.charset.Charset
import java.nio.charset.StandardCharsets
import java.util.concurrent.locks.ReentrantLock
import kotlin.concurrent.withLock
class AstScanner(private val checks: Collection,
private val formsMetadata: FormsMetadata?,
isErrorRecoveryEnabled: Boolean,
charset: Charset = StandardCharsets.UTF_8) {
private val parser: Parser = PlSqlParser.create(PlSqlConfiguration(charset, isErrorRecoveryEnabled))
val globalScope = ScopeImpl()
fun scanFile(inputFile: PlSqlFile, extraVisitors: List = emptyList()) : AstScannerResult {
val newVisitorContext = getPlSqlVisitorContext(inputFile)
val metricsVisitor = MetricsVisitor()
val complexityVisitor = ComplexityVisitor()
val functionComplexityVisitor = FunctionComplexityVisitor()
val symbolVisitor = SymbolVisitor(DefaultTypeSolver(), globalScope)
val checksToRun = mutableListOf()
checksToRun.add(symbolVisitor)
if (inputFile.type() == PlSqlFile.Type.MAIN) {
checksToRun.addAll(
checks.filter { check -> formsMetadata != null || check !is FormsMetadataAwareCheck }
.filterIsInstance()
.filter { check -> ruleHasScope(check, RuleInfo.Scope.MAIN) }
.toList())
} else {
checksToRun.addAll(
checks.filterIsInstance()
.filter { check -> ruleHasScope(check, RuleInfo.Scope.TEST) }
.toList())
}
checksToRun.add(metricsVisitor)
checksToRun.add(complexityVisitor)
checksToRun.add(functionComplexityVisitor)
checksToRun.addAll(extraVisitors)
val issues = lock.withLock {
val newWalker = PlSqlAstWalker(checksToRun)
newWalker.walk(newVisitorContext)
checksToRun.flatMap {
(it as PlSqlCheck).issues().map { issue -> ZpaIssue(inputFile, it, issue) }
}
}
return AstScannerResult(
executedChecks = checksToRun,
linesWithNoSonar = metricsVisitor.linesWithNoSonar,
symbols = symbolVisitor.symbols,
numberOfStatements = metricsVisitor.numberOfStatements,
linesOfCode = metricsVisitor.getLinesOfCode().size,
linesOfComments = metricsVisitor.getLinesOfComments().size,
complexity = complexityVisitor.complexity,
numberOfFunctions = functionComplexityVisitor.numberOfFunctions,
executableLines = metricsVisitor.getExecutableLines(),
issues = issues
)
}
private fun ruleHasScope(check: PlSqlVisitor, scope: RuleInfo.Scope): Boolean {
val ruleInfo = getAnnotation(check, RuleInfo::class.java)
if (ruleInfo != null) {
return ruleInfo.scope === RuleInfo.Scope.ALL || ruleInfo.scope === scope
}
return scope === RuleInfo.Scope.MAIN
}
private fun getPlSqlVisitorContext(inputFile: PlSqlFile): PlSqlVisitorContext {
var visitorContext: PlSqlVisitorContext
try {
val root = parser.parse(inputFile.contents())
visitorContext = PlSqlVisitorContext(root, inputFile, formsMetadata)
} catch (e: RecognitionException) {
visitorContext = PlSqlVisitorContext(inputFile, e, formsMetadata)
LOG.error("Unable to parse file: $inputFile\n${e.message}")
} catch (e: Exception) {
checkInterrupted(e)
throw AnalysisException("Unable to analyze file: $inputFile", e)
} catch (e: Throwable) {
throw AnalysisException("Unable to analyze file: $inputFile", e)
}
return visitorContext
}
private fun checkInterrupted(e: Exception) {
val cause = getRootCause(e)
if (cause is InterruptedException || cause is InterruptedIOException) {
throw AnalysisException("Analysis cancelled", e)
}
}
private fun getRootCause(exception: Throwable?): Throwable? {
var rootException = exception
while (rootException?.cause != null) {
rootException = rootException.cause
}
return rootException
}
companion object {
private val LOG = Loggers.getLogger(AstScanner::class.java)
private val lock = ReentrantLock()
}
}
================================================
FILE: zpa-core/src/main/kotlin/com/felipebz/zpa/squid/AstScannerResult.kt
================================================
/**
* Z PL/SQL Analyzer
* Copyright (C) 2015-2026 Felipe Zorzo
* mailto:felipe AT felipezorzo DOT com DOT br
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package com.felipebz.zpa.squid
import com.felipebz.zpa.api.PlSqlFile
import com.felipebz.zpa.api.checks.PlSqlCheck
import com.felipebz.zpa.api.checks.PlSqlVisitor
import com.felipebz.zpa.api.symbols.Symbol
data class AstScannerResult internal constructor(
val executedChecks: List,
val linesWithNoSonar: Set,
val symbols: List,
val numberOfStatements: Int,
val linesOfCode: Int,
val linesOfComments: Int,
val complexity: Int,
val numberOfFunctions: Int,
val executableLines: Set,
val issues: List
)
data class ZpaIssue internal constructor(
val file: PlSqlFile,
val check: PlSqlCheck,
private val issue: PlSqlCheck.PreciseIssue
) {
val cost = issue.cost()
val primaryLocation = issue.primaryLocation()
val secondaryLocations = issue.secondaryLocations()
}
================================================
FILE: zpa-core/src/main/kotlin/com/felipebz/zpa/squid/PlSqlAstWalker.kt
================================================
/**
* Z PL/SQL Analyzer
* Copyright (C) 2015-2026 Felipe Zorzo
* mailto:felipe AT felipezorzo DOT com DOT br
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package com.felipebz.zpa.squid
import com.felipebz.flr.api.AstNode
import com.felipebz.flr.api.AstNodeType
import com.felipebz.flr.api.Token
import com.felipebz.zpa.api.PlSqlVisitorContext
import com.felipebz.zpa.api.checks.PlSqlVisitor
import com.felipebz.zpa.api.squid.PlSqlCommentAnalyzer
import java.util.*
class PlSqlAstWalker(private val checks: Collection) {
private val visitorsByNodeType = IdentityHashMap>()
private var lastVisitedToken: Token? = null
fun walk(context: PlSqlVisitorContext) {
for (check in checks) {
check.context = context
check.startScan()
check.init()
for (type in check.subscribedKinds()) {
visitorsByNodeType.getOrPut(type) { mutableListOf() }.add(check)
}
}
val tree = context.rootTree()
if (tree != null) {
try {
for (check in checks) {
check.visitFile(tree)
}
visit(tree)
for (check in checks) {
check.leaveFile(tree)
}
} catch (e: Exception) {
val plsqlFile = context.plSqlFile()
if (plsqlFile != null) {
throw AnalysisException("Error executing checks on file ${plsqlFile.fileName()}: ${e.message}", e)
} else {
throw AnalysisException("Error executing checks: ${e.message}", e)
}
}
}
}
private fun visit(ast: AstNode) {
val nodeVisitors = getNodeVisitors(ast)
visitNode(ast, nodeVisitors)
visitToken(ast)
visitChildren(ast)
leaveNode(ast, nodeVisitors)
}
private fun leaveNode(ast: AstNode, nodeVisitors: List) {
for (i in nodeVisitors.indices.reversed()) {
nodeVisitors[i].leaveNode(ast)
}
}
private fun visitChildren(ast: AstNode) {
for (child in ast.children) {
visit(child)
}
}
private fun visitToken(ast: AstNode) {
if (ast.hasToken() && lastVisitedToken !== ast.token) {
lastVisitedToken = ast.token
for (astAndTokenVisitor in checks) {
astAndTokenVisitor.visitToken(ast.token)
for (trivia in ast.token.trivia) {
astAndTokenVisitor.visitComment(trivia,
PlSqlCommentAnalyzer.getContents(trivia.token.originalValue))
}
}
}
}
private fun visitNode(ast: AstNode, nodeVisitors: List) {
for (nodeVisitor in nodeVisitors) {
nodeVisitor.visitNode(ast)
}
}
private fun getNodeVisitors(ast: AstNode) =
visitorsByNodeType[ast.type] ?: emptyList()
}
================================================
FILE: zpa-core/src/main/kotlin/com/felipebz/zpa/squid/PlSqlConfiguration.kt
================================================
/**
* Z PL/SQL Analyzer
* Copyright (C) 2015-2026 Felipe Zorzo
* mailto:felipe AT felipezorzo DOT com DOT br
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package com.felipebz.zpa.squid
import java.nio.charset.Charset
class PlSqlConfiguration @JvmOverloads constructor(val charset: Charset, val isErrorRecoveryEnabled: Boolean = false)
================================================
FILE: zpa-core/src/main/kotlin/com/felipebz/zpa/squid/ProgressReport.kt
================================================
/**
* Z PL/SQL Analyzer
* Copyright (C) 2015-2026 Felipe Zorzo
* mailto:felipe AT felipezorzo DOT com DOT br
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package com.felipebz.zpa.squid
import com.felipebz.zpa.utils.log.Logger
import com.felipebz.zpa.utils.log.Loggers
import java.util.concurrent.atomic.AtomicBoolean
import java.util.concurrent.locks.Condition
import java.util.concurrent.locks.ReentrantLock
import kotlin.concurrent.withLock
class ProgressReport @JvmOverloads constructor(threadName: String,
private val period: Long,
private val logger: Logger = Loggers.getLogger(ProgressReport::class.java)) :
Runnable {
internal val lock = ReentrantLock()
internal val condition: Condition = lock.newCondition()
private var count: Int = 0
private var currentFileNumber = -1
private var currentFile: String? = null
private lateinit var iterator: Iterator
private val thread: Thread = Thread(this, threadName).apply { isDaemon = true }
private var success = false
private val interrupted = AtomicBoolean().apply { set(false) }
override fun run() {
while (!(interrupted.get() || Thread.currentThread().isInterrupted)) {
try {
Thread.sleep(period)
lock.withLock {
log("$currentFileNumber/$count files analyzed, current file: $currentFile")
}
} catch (e: InterruptedException) {
interrupted.set(true)
thread.interrupt()
break
}
}
lock.withLock {
if (success) {
log("$count/$count source files have been analyzed")
}
}
}
@Synchronized
fun start(files: Collection) {
count = files.size
iterator = files.iterator()
nextFile()
log("$count source files to be analyzed")
thread.start()
}
@Synchronized
fun nextFile() {
if (iterator.hasNext()) {
currentFileNumber++
currentFile = iterator.next()
}
}
@Synchronized
fun stop() {
interrupted.set(true)
success = true
thread.interrupt()
join()
}
@Synchronized
fun cancel() {
interrupted.set(true)
thread.interrupt()
join()
}
fun join() {
try {
thread.join()
} catch (e: InterruptedException) {
Thread.currentThread().interrupt();
}
}
private fun log(message: String) {
lock.withLock {
logger.info(message)
condition.signalAll()
}
}
}
================================================
FILE: zpa-core/src/main/kotlin/com/felipebz/zpa/sslr/ElseClause.kt
================================================
/**
* Z PL/SQL Analyzer
* Copyright (C) 2015-2026 Felipe Zorzo
* mailto:felipe AT felipezorzo DOT com DOT br
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package com.felipebz.zpa.sslr
import com.felipebz.zpa.api.squid.SemanticAstNode
class ElseClause(override val astNode: SemanticAstNode) : TreeWithStatements(astNode)
================================================
FILE: zpa-core/src/main/kotlin/com/felipebz/zpa/sslr/ElsifClause.kt
================================================
/**
* Z PL/SQL Analyzer
* Copyright (C) 2015-2026 Felipe Zorzo
* mailto:felipe AT felipezorzo DOT com DOT br
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package com.felipebz.zpa.sslr
import com.felipebz.zpa.asSemantic
import com.felipebz.zpa.api.squid.SemanticAstNode
class ElsifClause(override val astNode: SemanticAstNode) : TreeWithStatements(astNode) {
val condition : SemanticAstNode by lazy {
astNode.children[1].asSemantic()
}
}
================================================
FILE: zpa-core/src/main/kotlin/com/felipebz/zpa/sslr/IfStatement.kt
================================================
/**
* Z PL/SQL Analyzer
* Copyright (C) 2015-2026 Felipe Zorzo
* mailto:felipe AT felipezorzo DOT com DOT br
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package com.felipebz.zpa.sslr
import com.felipebz.zpa.asSemantic
import com.felipebz.zpa.asTree
import com.felipebz.zpa.api.PlSqlGrammar
import com.felipebz.zpa.api.squid.SemanticAstNode
class IfStatement(override val astNode: SemanticAstNode) : TreeWithStatements(astNode) {
val condition : SemanticAstNode by lazy {
astNode.children[1].asSemantic()
}
val elsifClauses : List by lazy {
astNode.getChildren(PlSqlGrammar.ELSIF_CLAUSE).asTree()
}
val elseClause : ElseClause? by lazy {
astNode.getFirstChildOrNull(PlSqlGrammar.ELSE_CLAUSE)?.asTree()
}
}
================================================
FILE: zpa-core/src/main/kotlin/com/felipebz/zpa/sslr/NullStatement.kt
================================================
/**
* Z PL/SQL Analyzer
* Copyright (C) 2015-2026 Felipe Zorzo
* mailto:felipe AT felipezorzo DOT com DOT br
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package com.felipebz.zpa.sslr
import com.felipebz.zpa.api.squid.SemanticAstNode
class NullStatement(astNode: SemanticAstNode) : TreeImpl(astNode)
================================================
FILE: zpa-core/src/main/kotlin/com/felipebz/zpa/sslr/PlSqlGrammarBuilder.kt
================================================
/**
* Z PL/SQL Analyzer
* Copyright (C) 2015-2026 Felipe Zorzo
* mailto:felipe AT felipezorzo DOT com DOT br
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package com.felipebz.zpa.sslr
import com.felipebz.flr.api.AstNodeType
import com.felipebz.flr.api.Grammar
import com.felipebz.flr.api.TokenType
import com.felipebz.flr.grammar.GrammarRuleBuilder
import com.felipebz.flr.grammar.GrammarRuleKey
import com.felipebz.flr.grammar.LexerfulGrammarBuilder
import kotlin.reflect.KClass
class PlSqlGrammarBuilder(private val builder: LexerfulGrammarBuilder) {
fun build(): Grammar = builder.build()
fun rule(ruleKey: GrammarRuleKey): GrammarRuleBuilder = rule(ruleKey, TreeImpl::class)
fun rule(ruleKey: GrammarRuleKey, clazz: KClass): GrammarRuleBuilder {
typedClasses[ruleKey] = clazz.java
return builder.rule(ruleKey)
}
fun setRootRule(ruleKey: GrammarRuleKey) {
builder.setRootRule(ruleKey)
}
fun sequence(e1: Any, e2: Any): Any = builder.sequence(e1, e2)
fun sequence(e1: Any, e2: Any, vararg rest: Any): Any = builder.sequence(e1, e2, *rest)
fun firstOf(e1: Any, e2: Any): Any = builder.firstOf(e1, e2)
fun firstOf(e1: Any, e2: Any, vararg rest: Any): Any = builder.firstOf(e1, e2, *rest)
fun optional(e: Any): Any = builder.optional(e)
fun optional(e1: Any, vararg rest: Any): Any = builder.optional(e1, *rest)
fun oneOrMore(e: Any): Any = builder.oneOrMore(e)
fun oneOrMore(e1: Any, vararg rest: Any): Any = builder.oneOrMore(e1, *rest)
fun zeroOrMore(e: Any): Any = builder.zeroOrMore(e)
fun zeroOrMore(e1: Any, vararg rest: Any): Any = builder.zeroOrMore(e1, *rest)
fun next(e: Any): Any = builder.next(e)
fun next(e1: Any, vararg rest: Any): Any = builder.next(e1, *rest)
fun nextNot(e: Any): Any = builder.nextNot(e)
fun nextNot(e1: Any, vararg rest: Any): Any = builder.nextNot(e1, *rest)
fun nothing(): Any = builder.nothing()
fun buildWithMemoizationOfMatchesForAllRules(): Grammar = builder.buildWithMemoizationOfMatchesForAllRules()
fun adjacent(e: Any): Any = builder.adjacent(e)
fun anyTokenButNot(e: Any): Any = builder.anyTokenButNot(e)
fun isOneOfThem(t1: TokenType, vararg rest: TokenType): Any = builder.isOneOfThem(t1, *rest)
fun bridge(from: TokenType, to: TokenType): Any = builder.bridge(from, to)
fun anyToken(): Any = builder.anyToken()
fun tillNewLine(): Any = builder.tillNewLine()
fun till(e: Any): Any = builder.till(e)
fun exclusiveTill(e: Any): Any = builder.exclusiveTill(e)
fun exclusiveTill(e1: Any, vararg rest: Any): Any = builder.exclusiveTill(e1, *rest)
companion object {
private val typedClasses = mutableMapOf>()
fun classForType(key: AstNodeType): Class = typedClasses.getOrDefault(key, TreeImpl::class.java)
}
}
================================================
FILE: zpa-core/src/main/kotlin/com/felipebz/zpa/sslr/RaiseStatement.kt
================================================
/**
* Z PL/SQL Analyzer
* Copyright (C) 2015-2026 Felipe Zorzo
* mailto:felipe AT felipezorzo DOT com DOT br
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package com.felipebz.zpa.sslr
import com.felipebz.zpa.asSemantic
import com.felipebz.zpa.api.PlSqlKeyword
import com.felipebz.zpa.api.squid.SemanticAstNode
class RaiseStatement(override val astNode: SemanticAstNode) : TreeImpl(astNode) {
val exception : SemanticAstNode? by lazy {
astNode.getFirstChildOrNull(PlSqlKeyword.RAISE)?.nextSibling?.asSemantic()
}
}
================================================
FILE: zpa-core/src/main/kotlin/com/felipebz/zpa/sslr/Statements.kt
================================================
/**
* Z PL/SQL Analyzer
* Copyright (C) 2015-2026 Felipe Zorzo
* mailto:felipe AT felipezorzo DOT com DOT br
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package com.felipebz.zpa.sslr
import com.felipebz.zpa.asSemantic
import com.felipebz.zpa.api.squid.SemanticAstNode
class Statements(override val astNode: SemanticAstNode) : TreeImpl(astNode), List {
private val children by lazy { astNode.children.asSemantic() }
override val size: Int =
children.size
override fun contains(element: SemanticAstNode): Boolean =
children.contains(element)
override fun containsAll(elements: Collection): Boolean =
children.containsAll(elements)
override fun get(index: Int): SemanticAstNode =
children[index]
override fun indexOf(element: SemanticAstNode): Int =
children.indexOf(element)
override fun isEmpty(): Boolean =
children.isEmpty()
override fun iterator(): Iterator =
children.iterator()
override fun lastIndexOf(element: SemanticAstNode): Int =
children.lastIndexOf(element)
override fun listIterator(): ListIterator =
children.listIterator()
override fun listIterator(index: Int): ListIterator