Home » SQL & PL/SQL » SQL & PL/SQL » How to include single quotes as character?
How to include single quotes as character? [message #216948] Wed, 31 January 2007 00:40 Go to next message
fortunethiyagu
Messages: 94
Registered: December 2006
Member

Hi..

How to include single quotes as character?

declare
temp varchar2(5) := 'i';
c number;
begin
select count(cr...) 
into c 
from g... 
where cr... like '||temp||'%';
dbms_output.put_line(c);
end;


for cr... i want to select those records that starts with 'i'. how to substitute the same thru temp variable.

thanks in advance.

[Updated on: Fri, 01 June 2007 18:07] by Moderator

Report message to a moderator

Re: How to include single quotes as character? [message #216949 is a reply to message #216948] Wed, 31 January 2007 00:47 Go to previous messageGo to next message
Mohammad Taj
Messages: 2412
Registered: September 2006
Location: Dubai, UAE
Senior Member

hi,
you can use simple sql for that.
select count(cr...)
from g... 
where cr... like 'I%';


regards
Taj

[Updated on: Fri, 01 June 2007 18:08] by Moderator

Report message to a moderator

Re: How to include single quotes as character? [message #216951 is a reply to message #216948] Wed, 31 January 2007 00:50 Go to previous messageGo to next message
fortunethiyagu
Messages: 94
Registered: December 2006
Member

Hi,

Thanx for reply. Embarassed

actuly i have given the test anynmus proc.
in actual case it will be coming thru in parameter.

so there i need substitute thru the temp variable.
Re: How to include single quotes as character? [message #216953 is a reply to message #216951] Wed, 31 January 2007 00:56 Go to previous messageGo to next message
Mohammad Taj
Messages: 2412
Registered: September 2006
Location: Dubai, UAE
Senior Member

Try
SQL> set serveroutput on
SQL> ed
Wrote file afiedt.buf

  1  declare
  2  temp varchar2(5) := 'V$PX';
  3  c number;
  4  begin
  5  select count(*)
  6  into c
  7  from big
  8  where object_name like [B]'[/B]'||temp||'%'
  9  dbms_output.put_line(c);
 10* end;
SQL> /
2000

PL/SQL procedure successfully completed.








Re: How to include single quotes as character? [message #217016 is a reply to message #216948] Wed, 31 January 2007 06:01 Go to previous messageGo to next message
ebrian
Messages: 2794
Registered: April 2006
Senior Member
It's unclear of your intention since you mention "How to include single quotes as character?"

If you are looking for values that simply start with the letter 'i' (without quotes), then you could use:

declare
temp varchar2(5) := 'i';
c number;
begin
select count(cr...) 
into c 
from g... 
where cr... like temp||'%';
dbms_output.put_line(c);
end;

[Updated on: Fri, 01 June 2007 18:11] by Moderator

Report message to a moderator

Re: How to include single quotes as character? [message #217017 is a reply to message #217016] Wed, 31 January 2007 06:07 Go to previous message
fortunethiyagu
Messages: 94
Registered: December 2006
Member

Thanks Yaar... Razz

Got the result...
Previous Topic: How to get Client IP?
Next Topic: How to break a string
Goto Forum:
  


Current Time: Fri Dec 02 16:44:40 CST 2016

Total time taken to generate the page: 0.44847 seconds