home bbs files messages ]

Forums before death by AOL, social media and spammers... "We can't have nice things"

   comp.databases.oracle      Overblown overpriced overengineered SHIT      2,288 messages   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]

   Message 2,223 of 2,288   
   Heini =?ISO-8859-2?B?Tm9sc/hl?= to All   
   SELECT ... WHERE column LIKE parameter||   
   11 Aug 06 11:46:56   
   
   From: HNO@dlg.dk   
      
   I have a database containing alot of procedures with this kind of coding logic:   
      
      
   BigTable   
     column1 varchar2(40);   
      
      
   Procedure SomeProcedure (in_parameter varchar2)   
    SELECT column1   
    FROM BigTable   
    WHERE column1 LIKE in_parameter||'%';   
   END;   
      
      
   The procedure is called like this:   
      
   SomeProcedure('abc');   
      
      
   Although this coding logic selects the correct rows, there is a big problem -   
   it does not use the index on BigTable.   
   But if you do perform at little test and change the procedure like this:   
      
      
   Procedure SomeProcedure (in_parameter varchar2)   
    SELECT column1   
    FROM BigTable   
    WHERE column1 LIKE 'abc'||'%';   
   END;   
      
   Then it uses the index. But ofcourse now there is not the desired flexibility   
   of using a parameter.   
      
      
   QUESTIONS:   
     1. Why does Oracle not use the index when a parameter is used in the   
   LIKE-statement?   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]


(c) 1994,  bbs@darkrealms.ca