Home » SQL & PL/SQL » SQL & PL/SQL » whats wrong in the below code.
whats wrong in the below code. [message #208528] Mon, 11 December 2006 04:00 Go to next message
vjeedigunta
Messages: 201
Registered: March 2005
Location: Hyderabad
Senior Member

Can you please let me know what is wrong in the below code.


Declare
x varchar2(10):='SCOTT';
Vuser varchar2(20);
begin
select distinct username into vuser  from sampletab
where trim(upper(username)) like  ''''||'%'||X||'%'||'''';
dbms_output.put_line(Vuser);
end;
/



It gives me output as " No data found " though I see that there is a SCOTT record in the table ..

Regards
-Sai
Re: whats wrong in the below code. [message #208537 is a reply to message #208528] Mon, 11 December 2006 04:25 Go to previous messageGo to next message
tahpush
Messages: 961
Registered: August 2006
Location: Stockholm/Sweden
Senior Member

just try

select distinct username into vuser from sampletab
where trim(upper(username)) like '%'||x||'%';
Re: whats wrong in the below code. [message #208548 is a reply to message #208537] Mon, 11 December 2006 05:12 Go to previous messageGo to next message
vjeedigunta
Messages: 201
Registered: March 2005
Location: Hyderabad
Senior Member

Thanks a lot man .. it worked.
Re: whats wrong in the below code. [message #208562 is a reply to message #208548] Mon, 11 December 2006 05:56 Go to previous message
tahpush
Messages: 961
Registered: August 2006
Location: Stockholm/Sweden
Senior Member

Goody Smile
Previous Topic: Spool file query
Next Topic: MeSSaGe from a Trigger
Goto Forum:
  


Current Time: Mon Aug 21 16:42:55 CDT 2017

Total time taken to generate the page: 0.04507 seconds