Quantcast
Viewing all articles
Browse latest Browse all 10045

swap value of parameters before run a PL-SQL query

I have a SSRS report that taps data from an Oracle DB.

I like to compare two parameters and swap values (if need) before the query uses them.

Can't get it work. Please give me any hint.

Scenario:

parameter :Year1 and :Year2; :Year1 value must be smaller than :Year2

if :Year1 > :Year2 then swap values

run the query

DECLARE
    Y1 INT := :YEAR1;
    Y2 INT := :YEAR2;

BEGIN

     IF (Y1 > Y2) THEN
         SELECT Y1, Y2 INTO Y2, Y1 FROM dual;
    END IF;

    SELECT     AA, BB, CC
          FROM       MYTABLE
          WHERE      (MYYEAR BETWEEN Y1 AND Y2)

END;


duke


Viewing all articles
Browse latest Browse all 10045

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>