Home » SQL & PL/SQL » SQL & PL/SQL » i need to know hows this happening?
i need to know hows this happening? [message #182993] Wed, 19 July 2006 02:33 Go to next message
amul
Messages: 252
Registered: April 2001
Location: Chennai
Senior Member
Embarassed forgive me for being ignorant but i need to know how is this being executed?

select ('senthil''s') from dual;
when i execute this command the output is senthil's
how is this possible?please reply
Re: i need to know hows this happening? [message #182997 is a reply to message #182993] Wed, 19 July 2006 02:39 Go to previous messageGo to next message
Littlefoot
Messages: 21439
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
Using the DUAL table is a way to select something from the database; you could even calculate something, for example

SELECT 2.4 * 4.2 FROM dual;

Dual is a good choice as it contains only 1 row; the same could be done using, for example,

SELECT ('senthil''s') FROM EMP;

but that would give as many "senthil's"s as there are records in the EMP table. To restrict it, you could use

SELECT ('senthil''s') FROM EMP WHERE rownum < 2;

but - as you can see - using the DUAL table it gets very simple.
Re: i need to know hows this happening? [message #183003 is a reply to message #182997] Wed, 19 July 2006 02:51 Go to previous messageGo to next message
amul
Messages: 252
Registered: April 2001
Location: Chennai
Senior Member
i think u got me wrong.
what i need to know is
as a string if we execute this select ('senthil') from dual
its going to display as senthil
but when i execute this statement
select('senthil''s') from dual i get an output like senthil's
but it shud come like senthils.so i need to know wats wrong..can n e one reply?

Re: i need to know hows this happening? [message #183006 is a reply to message #183003] Wed, 19 July 2006 02:57 Go to previous messageGo to next message
Littlefoot
Messages: 21439
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
No, it shouldn't. It is about use of two consecutive apostrophes, which enables you to display a string which contains an apostrophe.
Re: i need to know hows this happening? [message #183007 is a reply to message #183003] Wed, 19 July 2006 02:58 Go to previous messageGo to next message
JRowbottom
Messages: 5933
Registered: June 2006
Location: Sunny North Yorkshire, ho...
Senior Member
In SQL, if a string contains two single quotes next to each other, these are converted into a single quote that is contained in the string.
It is a way of getting string delimiters into strings.
SQL> select 'abcd' from dual;

'ABC
----
abcd

SQL> select 'abc'd' from dual;
ERROR:
ORA-01756: quoted string not properly terminated


SQL> select 'abc''d' from dual;

'ABC'
-----
abc'd


Is this what you are looking for?
Re: i need to know hows this happening? [message #183011 is a reply to message #183007] Wed, 19 July 2006 03:06 Go to previous messageGo to next message
amul
Messages: 252
Registered: April 2001
Location: Chennai
Senior Member
yup thnx a lot
Re: i need to know hows this happening? [message #183013 is a reply to message #183011] Wed, 19 July 2006 03:09 Go to previous messageGo to next message
JRowbottom
Messages: 5933
Registered: June 2006
Location: Sunny North Yorkshire, ho...
Senior Member
Could you, as a favour, keep the txt speak to a minimum.

Guidelines
Re: i need to know hows this happening? [message #183021 is a reply to message #183013] Wed, 19 July 2006 03:29 Go to previous messageGo to next message
ehegagoka
Messages: 493
Registered: July 2005
Senior Member
hi!
in 10g you can also used q or Q followed by a character to use as the marker for the quote, like [,( and then close it at the end ),] followed by another ', like this =)


SQL> select q'(silenthill's)' quote from dual
  2  /

QUOTE
------------
silenthill's

Re: i need to know hows this happening? [message #667157 is a reply to message #182993] Mon, 11 December 2017 09:30 Go to previous message
appailoveyou
Messages: 1
Registered: December 2017
Junior Member
Thank you!
Previous Topic: Temporary LOBs, temp space, PGA
Next Topic: ORA-01502: index or partition of such index is in usable
Goto Forum:
  


Current Time: Mon Oct 15 20:25:48 CDT 2018