-
Notifications
You must be signed in to change notification settings - Fork 108
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
A MERGE statement must be terminated with a semicolon #318
Comments
Hello and welcome to SQLPage! |
Hi, Furthermore i noticed that the link to your blog on the sqlpage-website is not working as intended: |
I'm now temporarily got it running using a upsert statement. I am still looking forward to your answer 😄. |
It sounds like you have an old version of the page in cache ? Can you hard-refresh the page (with ctrl-shift-R) ? |
I am glad i did not open an issue for that. Hard refreshing the page fixed this issue. Thanks! |
I'll change SQLPage's behavior to include trailing semicolons in what we send to the database in the next release. Currently, the easiest is probably to do an update followed by an insert with a condition. SELECT 'text' as component, @@VERSION as contents;
--drop table Ressource;
--create table Ressource (Ressource_ID INTEGER PRIMARY KEY, firstname varchar(50), lastname varchar(50));
-- In the next sqlpage, you will be able to run:
-- merge into Ressource as target
-- using (select $firstname as firstname, $lastname as lastname) as source
-- on target.Ressource_ID = $id
-- when matched then
-- update set firstname = source.firstname, lastname = source.lastname
-- when not matched then
-- insert (Ressource_ID, firstname, lastname) values ($id, source.firstname, source.lastname);
-- Currently, we do it manually. Update and then insert if necessary.
update Ressource set firstname = $firstname, lastname = $lastname where Ressource_ID = $id;
insert into Ressource (Ressource_ID, firstname, lastname) select $id, $firstname, $lastname where @@ROWCOUNT = 0;
select 'list' as component;
select CONCAT(firstname, ' ', lastname) as title, Ressource_ID as description
from Ressource; |
Thank you very much! |
Let's keep this opened until the semicolon fix is pushed |
0.21 is now live, with the fix |
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:
insert_user.sql:
There is an error-message being displayed when you execute the presented code
i expect the database-table to be updated or inserted according to the data submitted by the form
The text was updated successfully, but these errors were encountered: