From: molsson_NO_SPAM@vip.cybercity.dk   
      
   "Rohit Dhawan" wrote in message   
   news:c76d1c78.0404171637.1365adf0@posting.google.com...   
   > I have one query similar to the following:-   
   >   
   > select coursenum,sectionnum,instructor from   
   > SECTION s where (sectionnum = '001')   
   > and coursenum LIKE 'MATH%'   
   >   
   >   
   > but is it possible to add another 'and' condition to the above query   
   > provided a certain user parameter = 'add'   
   >   
   > for e.g   
   >   
   > select coursenum,sectionnum,instructor from   
   > SECTION s where (sectionnum = '001')   
   > and coursenum LIKE 'MATH%'   
   > and instructor LIKE 'L%' i.e. only and only if :parameter = 'add' else   
   > the above query gets executed.   
   >   
   > I do not want to use procedure for the above as I think everyting can   
   > be done using and,or,not   
      
   I hope you have a better reason for not doing this in pl/sql than that you   
   "do not want to use a procedure".   
   IMO the pure sql solution is doable (using case or decode/nvl) but "ugly"   
   due to the fact, that some developers   
   will find it hard to grasp easily and maintain if they take over the project   
   later.   
   Personally I'd solve this using a ref-cursor which would   
   a: give you complete flexibility allowing you to construct your query at   
   runtime, meaning you'd be able to change   
    more than just the "and" parts of the query   
   b: give you much of the functionality inherent in explicit cursors   
      
   Bear in mind that I haven't been working with Oracle-stuff for that long and   
   am still learning new stuff everyday...   
      
   Cheers   
      
   Morten Olsson   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   
|