-1
I’m trying to manipulate the return of a string where I always need to get the block Where do select the problem is that my method always returns different strings.
For example:
SELECT.....
FROM.....
WHERE
(
(
UPPER(INDICADO.IND_DESCRI) IS NULL AND
UPPER(CASE WHEN IND_PERIOD = 0 THEN 'LABELDIARIA' WHEN IND_PERIOD = 1 THEN 'LABELSEMANAL' WHEN IND_PERIOD = 2 THEN 'LABELQUINZENAL' WHEN IND_PERIOD = 3 THEN 'LABELMENSAL' WHEN IND_PERIOD = 4 THEN 'LABELBIMESTRAL' WHEN IND_PERIOD = 5 THEN 'LABELTRIMESTRAL' WHEN IND_PERIOD = 6 THEN 'LABELSEMESTRAL' WHEN IND_PERIOD = 7 THEN 'LABELANUAL' END) = @PERIODICIDADE1
)
)
Order by ......
Would need to get in a variable only with the Where.
I couldn’t understand your problem. Try to be a little more specific...
– Jéf Bueno
You’ll always have a
order by
afterward?– Jéf Bueno
Not only ADO.NET
– Al Unser Albuquerque
Yes can so I need something dynamic because I do not know what can contain later.
– Al Unser Albuquerque
You’d have to have everything possible statements that may come after a
where
and validate for it...– Jéf Bueno
You’ll just have to copy the string from Where until you find something that might look like
GROUP BY
,ORDER BY
, etc. or the end of the string, whichever comes first.– DH.
You can use REGEX but you will always need to have Where on a single separate line. https://regex101.com/r/nA3kO7/1
– KhaosDoctor
Can there be more than one query in the same code? That is (they are usually separated by a comma point, as in the example)
select.....; select...
– GilCarvalhoDev
@Khaosdoctor worked his example most when it has line break or "(" does not catch.
– Al Unser Albuquerque
Precisely, in the case of this example the Where query has to be inline and only have it on the line. If we didn’t have to take other examples to be able to develop a more complex regex
– KhaosDoctor
@Khaosdoctor So I thought I’d take everything including the Where until the order by is possible?
– Al Unser Albuquerque