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: PLSQL BLOCK: Subquery In Select Clause Returns ERR
Next Topic: Partition Type??
Goto Forum:
  


Current Time: Sun Dec 11 04:10:35 CST 2016

Total time taken to generate the page: 0.05183 seconds