-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
SqlScriptLexer/SqlScriptParser: Enhance to properly deal with BEGIN..…
….END blocks in sql scripts Add JUnit test testOracleScriptWithBeginEndBlock Add test script received by bug reporter (amended) Clarify JavaDoc Fixes jdbi#2021 Incorporate pr feedback by Steven Schlansker
- Loading branch information
Showing
5 changed files
with
130 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
core/src/test/resources/script/oracle-with-begin-end-blocks.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
-- | ||
-- Licensed under the Apache License, Version 2.0 (the "License"); | ||
-- you may not use this file except in compliance with the License. | ||
-- You may obtain a copy of the License at | ||
-- | ||
-- http://www.apache.org/licenses/LICENSE-2.0 | ||
-- | ||
-- Unless required by applicable law or agreed to in writing, software | ||
-- distributed under the License is distributed on an "AS IS" BASIS, | ||
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
-- See the License for the specific language governing permissions and | ||
-- limitations under the License. | ||
-- | ||
|
||
CREATE TABLE EXAMPLE | ||
( | ||
ID NUMBER PRIMARY KEY, | ||
USERNAME VARCHAR2(128) NOT NULL, | ||
CREATED_AT TIMESTAMP WITH TIME ZONE NOT NULL | ||
); | ||
|
||
CREATE SEQUENCE EXAMPLE_ID_SEQUENCE | ||
START WITH 1 | ||
INCREMENT BY 1; | ||
|
||
CREATE OR REPLACE TRIGGER EXAMPLE_TRIGGER | ||
BEFORE INSERT | ||
ON EXAMPLE | ||
FOR EACH ROW | ||
BEGIN | ||
SELECT sys_context('USERENV', 'SESSION_USER') INTO :new.USERNAME FROM DUAL; -- JDBI STOPS HERE! | ||
IF :new.USERNAME = 'something' THEN | ||
raise_application_error(-20000, 'Some error'); | ||
END IF; | ||
BEGIN -- a comment that includes BEGIN | ||
SELECT EXAMPLE_ID_SEQUENCE.nextval INTO :new.ID FROM DUAL; | ||
SELECT CURRENT_TIMESTAMP INTO :new.CREATED_AT FROM DUAL; | ||
SELECT CURRENT_TIMESTAMP INTO :new.UPDATED_AT FROM DUAL; | ||
END -- another comment that includes END and end in lower-case as well ;) | ||
END; |