• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Error in Oracle like clause

 
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

Need help!

Here the like clause is not working,since the sql is itself in sinle quotes.
I don't know how to make the like clause work.
The error it is giving me is:

ORA-00920: invalid relational operator
ORA-06512: at "TABCOUNT", line 10
ORA-06512: at line 2


The code is
CREATE OR REPLACE FUNCTION tabcount (
tab IN VARCHAR2, field IN VARCHAR2 ,whr IN VARCHAR2)

RETURN INTEGER
IS
retval INTEGER;
BEGIN
DBMS_OUTPUT.PUT_LINE ('whr' ||whr);
DBMS_OUTPUT.PUT_LINE ('field1' ||field);
EXECUTE IMMEDIATE
' SELECT COUNT(*) FROM ' || tab ||
' WHERE ' || field || 'like ''%'||whr ||'%'''
INTO retval;
DBMS_OUTPUT.PUT_LINE ('countis!' ||retVal);

RETURN retval;
END tabcount;
/

Looking for some answer.

Thanks
 
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
shital580@rediffmail.com

Hello preethinj,

the bug in ur query is the statement whatever u have written as || 'like ''%'||whr ||'%'''

should b

|| ' like ''%'||whr ||'%'''

u have skipped the blank space between the field values & like keyword
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic