Skip to content

PL/SQL is not fully supported #355

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
bence-takacs opened this issue Feb 27, 2015 · 10 comments
Closed

PL/SQL is not fully supported #355

bence-takacs opened this issue Feb 27, 2015 · 10 comments

Comments

@bence-takacs
Copy link
Contributor

Currently the Oracle PL/SQL blocks are not fully supported by ScriptRunner.

There is a common workaround:

ALTER TABLE TAB1
  ADD CONSTRAINT PK_TAB1
PRIMARY KEY (TAB1_ID)
/

CREATE OR REPLACE PROCEDURE UPDATE_TAB1 AS
BEGIN
  UPDATE TAB1 SET NUMBER_FIELD = NUMBER_FIELD + 1;
  COMMIT;
END;
/

using:

send_full_script=false
delimiter=/
full_line_delimiter=true

...but this is not a clean solution:

  • we need to modify a bunch of SQLs for the sake of a few PL/SQL
  • not standard

There is a suggested solution that modifies the ScriptRunner (https://code.google.com/p/mybatis/source/diff?spec=svn4001&r=4001&format=side&path=/trunk/src/main/java/org/apache/ibatis/jdbc/ScriptRunner.java) but it has been rejected.

Is it possible to annotate the PL/SQLs instead of the SQLs and keep the common delimiters?

ALTER TABLE TAB1
  ADD CONSTRAINT PK_TAB1
PRIMARY KEY (TAB1_ID);

-- //@PLSQL
CREATE OR REPLACE PROCEDURE UPDATE_TAB1 AS
BEGIN
  UPDATE TAB1 SET NUMBER_FIELD = NUMBER_FIELD + 1;
  COMMIT;
END;
/
@bence-takacs
Copy link
Contributor Author

@emacarron
Copy link
Member

Can this work for you?
#241

@bence-takacs
Copy link
Contributor Author

Seems to be FINE
We would like to check it.

When will that change be available at mybatis-migrations?

Currently the fix is present in master (3.3.0-SNAPSHOT), and migrations uses 3.2.8

@bence-takacs
Copy link
Contributor Author

It's working using:
mybatis-migrations [master]
using: mybatis 3.3.0-SNAPSHOT

The working code:

ALTER TABLE TAB1
  ADD CONSTRAINT PK_TAB1
PRIMARY KEY (TAB1_ID);

DELIMITER /
CREATE OR REPLACE PROCEDURE UPDATE_TAB1 AS
BEGIN
  UPDATE TAB1 SET NUMBER_FIELD = NUMBER_FIELD + 1;
  COMMIT;
END;
/
DELIMITER ;

One more suggestion is: putting the word 'DELIMITER' in SQL comment block like:

ALTER TABLE TAB1
  ADD CONSTRAINT PK_TAB1
PRIMARY KEY (TAB1_ID);

--DELIMITER /
CREATE OR REPLACE PROCEDURE UPDATE_TAB1 AS
BEGIN
  UPDATE TAB1 SET NUMBER_FIELD = NUMBER_FIELD + 1;
  COMMIT;
END;
/
--DELIMITER ;

or:
-- //@delimiter /
-- //@delimiter ;

@bence-takacs
Copy link
Contributor Author

The current solution is working but not production-ready: we should remain between the frames of SQL-standard.
Please change the format of deimiter declaration to something starting with SQL comment.

Like one of:
-- DELIMITER
-- //DELIMITER
-- //@delimiter

@emacarron
Copy link
Member

Good catch. Would you mind changing it yourself?

@bence-takacs
Copy link
Contributor Author

Sure, I can do it.

Which solution do you prefer? (-- or --// or --//@)
Where should I commit (push) my changes?

bence-takacs added a commit to bence-takacs/mybatis-3 that referenced this issue Mar 5, 2015
declarative changing of delimiter support
using standard SQL comment characters, e.g.:
--/@delimiter /
--/@delimiter ;
@bence-takacs
Copy link
Contributor Author

Pull request created:
#363

emacarron added a commit that referenced this issue Mar 5, 2015
 mybatis #355 PL/SQL is not fully supported
bence-takacs added a commit to bence-takacs/mybatis-3 that referenced this issue Mar 6, 2015
fix for using with mybatis-migrations
MigrationReader does  line.replaceFirst("--\\s*//", "-- ");
so we need to be prepared for that
@bence-takacs
Copy link
Contributor Author

there is a fix to be compliant with mybatis migrations

emacarron added a commit that referenced this issue Mar 6, 2015
mybatis #355 PL/SQL is not fully suppported
@bence-takacs
Copy link
Contributor Author

I'm wondering when this is going to be released and downstreamed into migrations and maven-migrations-plugin...

pulllock pushed a commit to pulllock/mybatis-3 that referenced this issue Oct 19, 2023
declarative changing of delimiter support
using standard SQL comment characters, e.g.:
--/@delimiter /
--/@delimiter ;
pulllock pushed a commit to pulllock/mybatis-3 that referenced this issue Oct 19, 2023
pulllock pushed a commit to pulllock/mybatis-3 that referenced this issue Oct 19, 2023
fix for using with mybatis-migrations
MigrationReader does  line.replaceFirst("--\\s*//", "-- ");
so we need to be prepared for that
pulllock pushed a commit to pulllock/mybatis-3 that referenced this issue Oct 19, 2023
mybatis mybatis#355 PL/SQL is not fully suppported
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants