Jim
Jim

Reputation: 16002

Datagrip: execute sql statements in oracle with a parameter

I routinely execute this statement using Ctrl - Shift - F10 in datagrip. Is there any way to create a SQL or pl/SQL set of statements that contain a variable, and execute the file with DataGrip.

Datagrip's variable handling is not great - or I am missing something.

// somehow set $(jobName?) to a value in the file and re-use it.

update t_msg_log l
set l.job_status = 'FinishedSuccess'
where l.source_detail = $(jobName?)
  and created =
      (select max(created) from t_msg_log li where li.source_detail = l.source_detail);

Upvotes: 4

Views: 3456

Answers (1)

moscas
moscas

Reputation: 10335

This is called user parameters. The parameter pattern you use isn't described in DataGrip by default. You need to do this yourself.

  1. Go to Settings/Preferences | Database | User Parameters
  2. Add new parameter with this regexp: \$\([^\)\?]+\?\)
  3. Don't forget to check 'Enable in console', 'In scripts'.
  4. Enjoy!

enter image description here

Upvotes: 3

Related Questions