Conversion of SQL command into Servoy

I have the following statement (Oracle SQL) that I want to realize in Servoy:
insert into table
values (id_1, val_1)
where not exists
(select null from table where id = id_1 and val = val_1);
Basically, it’s the realization of unique constraint…

Of course, I can do a search in the table and if no record is found i can create a new one and insert the values there. This seems a bit complicated, however. Maybe someone experienced out there has a much easier way to do this sort of thing.

Maybe also possible: a unique constaint on the two columns (I’m using MySQL 4.0, don’t know, if it’s possible in that version…) and in case of a constaint violation do nothing (error handling in the method).

Thanks for any suggestions!

I am not a SQL expert but imho you could do:

SELECT * FROM table WHERE uniquefield = uniquevalue

If this statement return a NULL value you know the value is not present…

xtsr:
Maybe also possible: a unique constaint on the two columns (I’m using MySQL 4.0, don’t know, if it’s possible in that version…) and in case of a constaint violation do nothing (error handling in the method).
Thanks for any suggestions!

We don’t have error trapping on constraint violation in the current version, we are planning to offer that asap. Until then I think IT2BE’s solution attached to an onSave event (if it’s on a record, otherwise in your script) is the best solution.