GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Added support for SET TERMINATOR instruction by Cybso · Pull Request #51 · squirrel-sql-client/squirrel-sql-code

Conversation

@Cybso

@Cybso Cybso commented Nov 28, 2024 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

This allows to temporarily change the statement separator with an inline comment and thus supports to execute statements that uses the semicolon within their expression, for example triggers or procedures with BEGIN..END blocks.

Example:

DROP PROCEDURE foobar;

CREATE PROCEDURE foobar
BEGIN
    --#SET TERMINATOR !
    declare v char(10);
    select value into v from sometable;
    if v = 'test' then
        update sometable set value = '';
    end if;
    --#SET TERMINATOR ;
END;

LABEL ON PROCEDURE foobar IS 'Example';

This commit fixes feature request 433 on sourceforge (https://sourceforge.net/p/squirrel-sql/feature-requests/433/).

It currently only supports the default QueryTokenizer. The statement separator is only changed for the current execution.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Cybso added 2 commits November 28, 2024 17:22
@Cybso
Added support for SET TERMINATOR instruction
f5fd2dd
This allows to temporarily change the statement separator with an inline comment and thus supports to execute statements that uses the semicolon within their expression, for example triggers or procedures with `BEGIN..END` blocks.

Example:

```sql
DROP PROCEDURE foobar;

--#SET TERMINATOR !
CREATE PROCEDURE foobar
BEGIN
    declare v char(10);
    select value into v from sometable;
    if v = 'test' then
        update sometable set value = '';
    end if;
END!

--#SET TERMINATOR ;
LABEL ON PROCEDURE foobar IS 'Example';
```

This commit fixes feature request 433 on sourceforge (https://sourceforge.net/p/squirrel-sql/feature-requests/433/).

It currently only supports the default QueryTokenizer. The statement separator is only changed for the current execution.
@Cybso
Fixed check for 'newLinePos' when using a custom line comment prefix …
0894f47
…with other length than 2
@Cybso
Cybso force-pushed the add-support-for-SET_TERMINATOR-inline branch from 514893b to 0894f47 Compare November 28, 2024 16:36
@Cybso
Allow leading space or tab characters before instruction.
48f499d
This makes this feature compatible to IBM CLP and Data Architect.
The documentation states:

> The statement must be uppercase and in a comment. There can be leading spaces before the --, but there cannot be spaces between -- and #SET TERMINATOR x

https://www.ibm.com/docs/en/ida/9.1.2?topic=terminators-changing-sql-statement-terminator
gerdwagner pushed a commit that referenced this pull request Nov 30, 2024
@Cybso @gerdwagner
Feature: Pull request: #51
368a60e
  To change the statement separator during SQL execution, use the following command on a separate line:
  --#SET TERMINATOR <separator>
  This command does not change the separator permanently but for a single SQL execution only.
  See also menu File --> New Session Properties --> tab SQL --> section "Statement separator"
  Thanks to Roland Tapken for the pull request
@gerdwagner

gerdwagner commented Nov 30, 2024

Copy link
Copy Markdown
Member

Was merged with several adjustments. Please take a look if it still works for you. Most of your code is now in the new ChangeStatementSeparatorSupport class.

Thanks for your pull request.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@Cybso

Cybso commented Dec 1, 2024 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor Author

Was merged with several adjustments. Please take a look if it still works for you. Most of your code is now in the new ChangeStatementSeparatorSupport class.

I haven't completely figured out the integration, but it looks pretty good at first glance. I have added three small notes to the commit. In particular, the method isCommandPrecededBySpacesOrTabsOnly is named incorrectly or the return value is the wrong way around. However, since the call also takes this into account, it still works at the moment, it's just not intuitive:

      if(isCommandPrecededBySpacesOrTabsOnly(_script, searchStartPos))
      {
         return null;
      }
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

gerdwagner added a commit that referenced this pull request Dec 1, 2024
@gerdwagner
Refactoring: Changes suggested in pull request: #51
91c32bb
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

No reviews

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

2 participants

@Cybso @gerdwagner
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.