Using update, Insert and select query in a single named query on same database

Take a look at the MERGE command for your database.
e.g. SQL Server MERGE
That will give you either INSERT or UPDATE but take a look at the reference posted by @Transistor; With NamedQueries, you need to choose between Query and Update Query; you won't be able to cross that line.

As a personal preference, I create folders (SELECT, INSERT, UPDATE, DELETE) and create a NamedQuery of the table name I'm working with inside each folder. That way, calling a NamedQuery it feels more natural and SQL like as well as providing a little self-documentation of what you are doing when you call:

  • SELECT/TableName
  • INSERT/TableName
  • UPDATE/TableName
1 Like