I have a string like this :

string := ' (sum(x) = 12 and 
             sum(y) = 13 and
             sum(z) = 14
            ) and
             w = 'p'   AND 
             q = 'p'   AND 
             l = 'p''

and I need to separate all sum(...) from the rest of the query:

where_Clause:=   w = 'p'   AND 
                 q = 'p'   AND 
                 l = 'p'

having_Clause :=  sum(x) = 12 and 
                  sum(y) = 13 and
                  sum(z) = 14 and

I'm sure there is a way to do that by regular_expression but cause I'm very new to oracle pl-sql , I need some help. I was wondering if you could help me with that.

  • 1
    This might be an XY Problem. It looks like you need a language processor. Check Alexadria Library. I thought i ran across one that might meet your needs. May 26 '20 at 17:14
  • @MichaelKutz Isn't it possible to do that with regular expression? what if we put all the sum clause in one parenthesis? I have edited the code . Could you check it again please?
    – Pantea
    May 26 '20 at 18:01
  • @MichaelKutz and could you please explain a little bit more about the library you've just mentioned ?
    – Pantea
    May 26 '20 at 18:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.