Skip to content

A MERGE statement must be terminated with a semicolon #318

Closed
@skostrewa

Description

@skostrewa

The Merge-Statmentent written in my .sql-file can not be executed due to a missing semicolon, even though the semicolon is specified just like the examples all over the internet require. The query also runs fine in ssms if you alter the part where the values are grabbed from SQLPage.

index.sql:

select
    'form'                       as component,
    'Edit user'                 as title,
    'insert_user.sql' || COALESCE('?id=' || $id, '') as action;

select
    'firstname'                   as name,
    (select firstname from "Ressource" where Ressource_ID = cast($id as int)) as value;

select
    'lastname'                  as name,
    (select lastname from "Ressource" where Ressource_ID = cast($id as int)) as value;

insert_user.sql:

MERGE Ressource as target
USING  (select CAST($id AS INT) as id, :firstname as new_firstname, :lastname as new_lastname) as source
ON (target.Ressource_ID = source.id)
WHEN MATCHED
    THEN UPDATE SET
        target.Vorname = source.new_firstname,
        target.Nachname = source.new_lastname
WHEN NOT MATCHED
    THEN INSERT (RessourceTyp_ID, Vorname, Nachname)
    VALUES (1, source.new_firstname, source.new_lastname)
;

There is an error-message being displayed when you execute the presented code

error returned from database: Eine MERGE-Anweisung muss durch ein Semikolon (;) abgeschlossen werden. (translates to "A MERGE statement must be terminated with a semicolon (;)")

i expect the database-table to be updated or inserted according to the data submitted by the form

  • OS: Windows 11
  • Database: MSSQL
  • SQLPage Version: 0.20.4

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions