Hi,
I'm trying to put together a snippet that will add an entry into a table in Data Blaze if it does not already exist, but will not add the entry if it does exist and will give me a notification to say so.
I've created the below snippet, but it's giving me "Row Already Exists" notification no matter if the row already exists or not when I press the "Add record" button, and it adds the entry all the time when I hit Insert.
Can anyone help with this one?
[snippet]
{note}
Name:
{formtext: name=Name}{button: existing_row_id = catch({dbselect: SELECT Name FROM HC KB Worknotes
WHERE Name=@name; space=7cez1rFxLQMzc7RWj26t9v}, "NONE")
if existing_row_id <> "NONE"
notify("Row already exists")
return
endif
{dbinsert: INSERT INTO HC KBs
SET name=@name, kb title
=@kb title
, kb overview
=@kb overview
, worknote=@worknote; space=7cez1rFxLQMzc7RWj26t9v; autoaddfields=yes; instant=yes}
; label=Add record}
Details:
{formparagraph: name=KB title; cols=80; rows=1}
{formparagraph: name=KB overview; cols=80; rows=2}
{formparagraph: name=Worknote; cols=80; rows=6}
{dbinsert: INSERT INTO HC KB Worknotes
SET name=@name, worknote=@worknote, kb title
=@kb title
, kb overview
=@kb overview
; space=7cez1rFxLQMzc7RWj26t9v; autoaddfields=yes}{endnote}[/snippet]