Solved

escape characters

Posted on 2002-03-12
5
8,543 Views
Last Modified: 2013-12-03
I am using oracle 8.1.6 on win NT4. I want to know escape characters for all keyboard
characters. What I mean is insert into emp(empno,ename) values(1111,'br'o'neal'); will fail.
But insert into emp(empno,ename) values(1111,'br''o''neal'); will succeed.
I know select ascii('&') from dual;
ascii('&')
----------
   38
insert into emp(empno,ename) values(2222,'P' || chr(38) || 'G'); works.
Also, rpad, lpad or both can be used to get around the problem.
So, ' is escape character for '. I want these type of escape characters for all keyboard
characters. More important and urgent need is for hyphen('-') and ampersand('&'). Can we make
use of default or set escape character of SQL*Plus i.e. '\' etc. while selecting OR inserting.
If so how. Also, can we make it database based with a setting in parameter files so that it is
permanent and applies to all client windows and application programs that use oracle as
backend. Will it help if I use replace and translate functions to avoid prompting for value when inserting '&' and other such problems. -----sesh2002
0
Comment
Question by:sesh2002
  • 2
  • 2
5 Comments
 
LVL 34

Expert Comment

by:Mark Geerlings
Comment Utility
Yes, you can change the escape character in SQL*Plus and you can "set define off" if you want to, so SQL*Plus will not treat the ampersand (&) as a substitution variable marker.

No, you cannot do this in the database and have it apply to any/all clients.  Oracle client programs always over-ride database defaults if the value can be specified in both the server and the client.

Also these SQL*Plus settings only apply to SQL*Plus, but that is not the tool most people use for data entry and queries with an Oracle database.  Sure, developers and DBA's use it, but your users don't, do they?
0
 
LVL 7

Accepted Solution

by:
yoren earned 50 total points
Comment Utility
Hi sesh,

The problems you describe with escape sequences and ampersands don't appear in non-sqlplus applications (when you use bind variables). Here's what to do for SQL*Plus:

Edit the global login file which is executed for all SQL*Plus sessions: [orahome]/sqlplus/admin/glogin.sql

In that file, add the command "set scan off". That will prevent any '&' prompting for users of sqlplus.

-Yuval
0
 
LVL 7

Expert Comment

by:yoren
Comment Utility
Clarification to my previous comment: you will have to modify the glogin.sql file on every client machine.
0
 

Author Comment

by:sesh2002
Comment Utility
Dear Experts, I will give it to the one who gives me a escape character like ' for ' for as many characters as possible OR at least circumventing the problem using replace, translate functions and '\' etc.
0
 

Author Comment

by:sesh2002
Comment Utility
Sorry markgeer, your answer also worked, but it goes to one only. Yoren, read my earlier comment and pleave give me an answer - sesh2002
0

Featured Post

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Introduction A previously published article on Experts Exchange ("Joins in Oracle", http://www.experts-exchange.com/Database/Oracle/A_8249-Joins-in-Oracle.html) makes a statement about "Oracle proprietary" joins and mixes the join syntax with gen…
Configuring and using Oracle Database Gateway for ODBC Introduction First, a brief summary of what a Database Gateway is.  A Gateway is a set of driver agents and configurations that allow an Oracle database to communicate with other platforms…
This video shows how to copy a database user from one database to another user DBMS_METADATA.  It also shows how to copy a user's permissions and discusses password hash differences between Oracle 10g and 11g.
This video shows information on the Oracle Data Dictionary, starting with the Oracle documentation, explaining the different types of Data Dictionary views available by group and permissions as well as giving examples on how to retrieve data from th…

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now