0

Basically I was trying to replace the part of string with its actual value which comes immediately after oracle operators. I can do this for limited operators list like {=,>,<} but I wonder that is there any way out to gather all the operators rather than giving them by hands? For instance, I have this string; "a = xyz", then I will replace xyz with lets say 3. But as you know we have bunch of operator namely "like,in,exists etc". So my string can also be this: "a like xyz".

So what do you suggest me?

Thanks.

Bart Kiers
  • 166,582
  • 36
  • 299
  • 288
haluk
  • 1,148
  • 2
  • 9
  • 19
  • 1
    So basically you're writing your own Oracle SQL statement parser? You'd better have a pretty good reason. – Welbog Mar 30 '10 at 12:32

2 Answers2

1

So what do you suggest me?

I suggest not to do this with regex (regex are not able to do so), but use an existing, proven SQL parser.

Have a look at this question on SO: SQL parser library for Java

Community
  • 1
  • 1
Bart Kiers
  • 166,582
  • 36
  • 299
  • 288
0

Make your job simpler - require a very strict syntax on behalf of the caller.

For example, require that the string be in the form "target operator #variable#", e.g. "a = #xyz#".

Then, all you need to do is use REPLACE(input, '#xyz#', 3).

As noted above, you probably don't want to reinvent the Oracle SQL statement parser.

Jeffrey Kemp
  • 59,135
  • 14
  • 106
  • 158