Skip to content

Commit c1c38fe

Browse files
authored
compound statement tests (#1545)
1 parent fc5a9a3 commit c1c38fe

File tree

3 files changed

+79
-0
lines changed

3 files changed

+79
-0
lines changed
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
---
2+
-- #%L
3+
-- JSQLParser library
4+
-- %%
5+
-- Copyright (C) 2004 - 2022 JSQLParser
6+
-- %%
7+
-- Dual licensed under GNU LGPL 2.1 or Apache License 2.0
8+
-- #L%
9+
---
10+
DECLARE
11+
PK_NAME VARCHAR(200);
12+
13+
BEGIN
14+
EXECUTE IMMEDIATE ('CREATE SEQUENCE "untitled_table3_seq"');
15+
16+
SELECT
17+
cols.column_name INTO PK_NAME
18+
FROM
19+
all_constraints cons,
20+
all_cons_columns cols
21+
WHERE
22+
cons.constraint_type = 'P'
23+
AND cons.constraint_name = cols.constraint_name
24+
AND cons.owner = cols.owner
25+
AND cols.table_name = 'untitled_table3';
26+
27+
execute immediate (
28+
'create or replace trigger "untitled_table3_autoinc_trg" BEFORE INSERT on "untitled_table3" for each row declare checking number := 1; begin if (:new."' || PK_NAME || '" is null) then while checking >= 1 loop select "untitled_table3_seq".nextval into :new."' || PK_NAME || '" from dual; select count("' || PK_NAME || '") into checking from "untitled_table3" where "' || PK_NAME || '" = :new."' || PK_NAME || '"; end loop; end if; end;'
29+
);
30+
END
31+
32+
--@FAILURE: Encountered unexpected token: "PK_NAME" <S_IDENTIFIER> recorded first on May 27, 2022, 10:27:41 PM
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
---
2+
-- #%L
3+
-- JSQLParser library
4+
-- %%
5+
-- Copyright (C) 2004 - 2022 JSQLParser
6+
-- %%
7+
-- Dual licensed under GNU LGPL 2.1 or Apache License 2.0
8+
-- #L%
9+
---
10+
DECLARE
11+
n_emp_id EMPLOYEES.EMPLOYEE_ID%TYPE := &emp_id1;
12+
BEGIN
13+
DECLARE
14+
n_emp_id employees.employee_id%TYPE := &emp_id2;
15+
v_name employees.first_name%TYPE;
16+
BEGIN
17+
SELECT first_name, CASE foo WHEN 'a' THEN 1 ELSE 2 END CASE as other
18+
INTO v_name
19+
FROM employees
20+
WHERE employee_id = n_emp_id;
21+
22+
DBMS_OUTPUT.PUT_LINE('First name of employee ' || n_emp_id ||
23+
' is ' || v_name);
24+
EXCEPTION
25+
WHEN no_data_found THEN
26+
DBMS_OUTPUT.PUT_LINE('Employee ' || n_emp_id || ' not found');
27+
END;
28+
END
29+
30+
--@FAILURE: Encountered unexpected token: "n_emp_id" <S_IDENTIFIER> recorded first on May 27, 2022, 10:29:48 PM
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
---
2+
-- #%L
3+
-- JSQLParser library
4+
-- %%
5+
-- Copyright (C) 2004 - 2022 JSQLParser
6+
-- %%
7+
-- Dual licensed under GNU LGPL 2.1 or Apache License 2.0
8+
-- #L%
9+
---
10+
BEGIN
11+
SELECT
12+
cols.column_name INTO :variable
13+
FROM
14+
example_table;
15+
END
16+
17+
--@FAILURE: Encountered unexpected token: "BEGIN" "BEGIN" recorded first on May 27, 2022, 10:29:48 PM

0 commit comments

Comments
 (0)