SQL & PL/SQL :: Escape Character For Single Quote?
May 6, 2011
I have a simple update statement. Sometimes the data in this statement has single quotes in it (like shown below).
Update table1 set account = 'CD'S NOT MINE' WHERE NUMBER = '0027201'
When I run this SQL, I get SQL Error: ORA-01756: quoted string not properly terminated
01756. 00000 - "quoted string not properly terminated"
Is there an escape charecter that I can use?
View 9 Replies
ADVERTISEMENT
Apr 5, 2011
I wish to replace the string "Benutzername&Kontakt" with nothing.
SELECT REPLACE (role_owner, 'Benutzername&Kontakt', '')
FROM JC_NAME_62
WHERE jc_name LIKE 'SAP_R4_BIN5\_%' ESCAPE ''
But my Toad prompts me always to fill in the variable. I don't wish to do that, I wish to escape the &
View 5 Replies
View Related
Nov 21, 2012
I have an script.sql that receives as a parameter an string.
example:
@C:/myscript.sql "o'connor"
user_account_value varchar2(120) := '&1';
EXECUTE IMMEDIATE "Select * from Table where column = :1 " USING user_account_value I am not sure how to deal with string that contains single quotes.
If the parameter were passed as : "o''connor" this will work
If the parameter is pass as: "o'connor" this will not work.
so my question is what options do I have to deal with dynamic queries and single quotes.
I tried replacing replace(myParameter,'''',''''''); but not working well.
View 11 Replies
View Related
Jul 6, 2010
i want to understand each and every concept of oracle.in this book they explained about escape character, but stiil i cant get it..i want to understand why used escape character in 2nd query and whats its effects...
1. SQL> SELECT first_name, last_name
FROM employees
WHERE first_name LIKE 'Su%'
AND last_name NOT LIKE 'S%';
2. SELECT job_id, job_title
FROM jobs
WHERE job_id like 'AC\_%' ESCAPE '';
View 9 Replies
View Related
Jul 11, 2013
I am creating a dynamic sql and to do so I want to concat this string:
v_consulta := v_listado_condiciones || 'UPPER(nombre) like UPPER(''/%'' '|| PRAZONSOCIAL ||' ''/%'') escape ''/'' '
But I get errors when I try to escape % operator, how could I do that ?
View 9 Replies
View Related
Aug 28, 2012
I'm trying to replace the variable value v_tblname in dynamic SQL. But not able to escape the single quotes character.
DECLARE
v_sqlcols VARCHAR2(2000);
v_sqlcols1 VARCHAR2(2000);
v_tblname VARCHAR2(50) := 'DEPT';
BEGIN
v_sqlcols := q'[SELECT LISTAGG(COL,',' ||CHR(10)) WITHIN GROUP (ORDER BY COL)
FROM (
[code]....
View 5 Replies
View Related
Jan 7, 2011
E1 Table Data
Job_id
Sa_Clerk
Sa_Manager
Sahil
select job_id from E1 where instr(job_id,'_')>0;
returns output
Sa_Clerk
Sa_Manager
same as
select job_id from E1 where job_id like 'Sa_\%' escape '';
resturns
Sa_Clerk
Sa_Manager
Same Result , Then What is exact need of Escape
View 4 Replies
View Related
Jul 2, 2012
I have got a requirement where i need to export data from oracle with escape character.
eg. I am using a delimiter 237(í) and if the same character is present in data it should be escaped by escape character eg. /.
Once this file will get created i need to load this file in Netezza database which supports escape character.
Data in oracle table
FirstName Lastname Designation
abc xyz mnz
def ghío pqr
Data should be exported like below
FirstnameíLastnameíDesignation
abcíxyzímnz
defígh/íoípqr
View 3 Replies
View Related
Jan 9, 2013
create table test_g(x date);
insert into test_g values (to_date('01-NOV-2001','DD-MON-YYYY'));
insert into test_g values (to_date('02-NOV-2011','DD-MON-YYYY'));
insert into test_g values (to_date('03-DEC-2012','DD-MON-YYYY'));
insert into test_g values (to_date('12-DEC-2012','DD-MON-YYYY'));
insert into test_g values (to_date('31-DEC-2012','DD-MON-YYYY'));
[code].....
I wrote below procedure
create or replace procedure p_testq(p_in_date in date) is
v_comp date;
v_strg varchar2(200);
i number:=1;
type t_trc is ref cursor;
trc t_trc;
v_sql varchar2(2000);
-- record to which data goes into
type t_prec is record(x date);
prec t_prec;
-- plsql table to store data
type t_frec is table of t_prec index by binary_integer;
frec t_frec;
-- flow of data, is from v_sql --> plsql record --> plsql table
begin
dbms_output.put_line(' month of paramter '|| P_IN_DATE ||' is '||to_char(P_IN_DATE,'MON'));
select min(x)
into v_comp
from test_g
where x <= P_IN_DATE
[code].....
how do I store v_strg values so that the dates are included in single quotes
begin
p_testq('12-DEC-2012');
end;
v_strg: 06-Nov-2012,09-Nov-2012
I want values to be '06-Nov-2012',''09-Nov-2012'
View 3 Replies
View Related
Mar 7, 2012
I have to load a fixed width file using sql loader utility. But the records have multiple special characters. writing / modifying the loader utility to load the data.
--Script to create the table
create table t1 (
ip1 varchar2(2),
ip2 number,
ip3 number);
--loader utility
LOAD DATA
INFILE 'c:inputfile.dat'
BADFILE 'c:adfile.bad'
REPLACE
INTO TABLE t1
FIELDS TERMINATED BY '' OPTIONALLY ENCLOSED BY '°'
(
ip1POSITION(1:2) CHAR,
ip2POSITION(3:17) INTEGER EXTERNAL ":ip2/100",
ip3POSITION(18:32) INTEGER EXTERNAL ":ip3/100",
)
--data file
9900000000000000000000059762160°
9900009694635473¶00009693856712-
99000024383898654000025664467904
--sql version i am using
SQL*Loader: Release 9.2.0.1.0 - Production on Wed Mar 7 18:32:33 2012
Copyright (c) 1982, 2002, Oracle Corporation. All rights reserved.
In the above mentioned data file, records has multiple special characters like '°','¶' ,'-'.
All these special characters have some meaning.
eg: '°' specifies the above column needs to be multiplied by -1
'¶' specifies the above column needs to be multiplied by -0.1
what changes need to be made in loader utility for the same? Also, will there be any change in the utility if I am using higher version of oracle?
View 13 Replies
View Related
Dec 1, 2006
I have a text file which is comma separated with values enclosed in double quotes.
In my text file which I have to load into database, one of the field have the value like
Your "offspring"
When I run my normal sqlloader ctl file, it gives the error as
Record 304: Rejected - Error on table BUYER, column BUYERS_NAME.
no terminator found after TERMINATED and ENCLOSED field
Is there any way I can use some escape character for loading this type of data.
View 16 Replies
View Related
Sep 26, 2013
how do we know database character set is either single character set or multi character set?
While changing character-set from AL32UTF8 to WE8MSWIN1252 got "ORA-12712: new character set must be a superset of old character set".
Below are steps taken to resolve the issue -
ALTER DATABASE CHARACTER SET WE8MSWIN1252;
i got this error: ORA-12712: new character set must be a superset of old character set
below are the commands executed by me:
SQL> SHUTDOWN IMMEDIATE;
SQL> CONNECT SYS/password AS SYSDBA;
SQL> STARTUP MOUNT;
SQL> ALTER SYSTEM ENABLE RESTRICTED SESSION;
SQL> ALTER DATABASE OPEN;
SQL> ALTER DATABASE CHARACTER SET INTERNAL_USE WE8MSWIN1252;
SQL> SHUTDOWN;
SQL> STARTUP;
SQL> QUIT;
And its working...
I have not done it in proper order. Neither have done ccsscan. Still, no user reported any issues. Do my changes truncated the data?
View 11 Replies
View Related
Sep 4, 2013
The description field in the item table has the single quote used as the symbol for feet. I have the same issue pulling from a last name field in other tables. (Like O'Connor)
select descrip into v_result
from c_ship_hist
where shipment_dtl_id = :SDID;
exception when others then null;
The error I get is "Missing right quote". How do I code around this issue without having to change the data?
View 8 Replies
View Related
Jan 5, 2013
I have table say Messages. In which there is a column msg_text varchar2(900).My requirement is to fetch the very last character of the msg_text for a single row identified by its msg_code(primary key).
The problem is, whenever msg_text contain second last character as single quote( ' ), it doesn't give me the last character i.e. after the single quote.For example if msg_text is "Congratulations, you opted for 'A'." and if its message_code is 10 then query
SQL> SELECT SUBSTR(msg_text,LENGTH(msg_text),LENGTH(msg_text)) AS LAST_CHAR
FROM messages
WHERE msg_code = 10;
returns nothing.
Whereas if msg_text is "Are you sure to continue?" and if its message_code is 20 then query
SQL> SELECT SUBSTR(msg_text,LENGTH(msg_text),LENGTH(msg_text)) AS LAST_CHAR
FROM messages
WHERE msg_code = 20;
returns character '?'.
View 4 Replies
View Related
Feb 20, 2013
This package is generating excel file which contains cursor result.In excel data is populated like below.Column name is Zip_code .My concern is how to remove that single quote from excel file.
eg:
Zip_
'01234
'12567
'23432
'00234
create or replace
PACKAGE BODY PKG_MONTH_END_AUTOMATION AS
PROCEDURE PROC_ZIP_CODE_MONTHEND (directoryOrPath IN VARCHAR2 default 'LOC_PHASE1_WHOUSE_SALES_ADMIN')
[code]...
-- main body
BEGIN
-- Generating Zip Files
SELECT last_day(add_months(sysdate,-1))
INTO v_last_date
[code]...
View 6 Replies
View Related
Feb 24, 2012
INSERT INTO LKP_ASSET_LOCATION (LOCATION) VALUES ('AMERICA'S CUP VILLAGE')
View 2 Replies
View Related
Mar 19, 2012
How can we get 'space in every character of a string with Single select query'
for example:-
string 'INDIA'
result should be 'I N D I A'
View 1 Replies
View Related
Feb 28, 2011
1) Can we set a different symbol other than '' for escape operator.
2) If yes, how to see the current escape operator symbol.
3) How to find out the below name with escape operator?
Employee name ----> rama_krishna_raj
View 2 Replies
View Related
Sep 7, 2011
I have a issue on running the query with quote operator . When I am executing the SQL query I am getting error "Quoted String not properly Ended".
select q'[Oracle's world ]'
from dual
But The following query works.
select q'[It's Oracle's world ]'
from dual
View 4 Replies
View Related
Nov 10, 2010
i have table contains a column of var char type i want to insert a value
'1 mmTHICK GI SHEET 4' X 8' X 1MM THICH' in to the coulmn but m getting error
I tried set scan off but its not worrking for the below query.
ERROR at line 1:
ORA-00923: FROM keyword not found where expected
my query is
Insert into Inventory select
'N1280000015',
'1 mmTHICK GI SHEET 4''' X 8''' X 1MM THICH',
[code]....
View 8 Replies
View Related
Apr 13, 2006
which is the better option to use when the quote needs to be concatenated to a varchar2 value i.e.
In order to insert 'test' into a column exactly as yet see I used:
chr(39)||'test'||chr(39)
However, the DBA (OCP) says that is not a good way to do it and should be changed to:
''''||'test'||''''
View 24 Replies
View Related
Dec 30, 2011
I'd like to use escape sequences in plsql but it didn't work.I have to use a variable 'v_jahr'..This is what I like to do:
SELECT COUNT(TABLE_NAME) FROM USER_TABLES
WHERE TABLE_NAME = 'TABLE' || v_jahr;
But I think I should use an 'EXECUTE IMMEDIATE' like this:
EXECUTE IMMEDIATE 'SELECT COUNT(TABLE_NAME) FROM USER_TABLES
WHERE TABLE_NAME = 'TABLE' || v_jahr';
But then I have to escape my tics. How can I do this?
I tried this:
EXECUTE IMMEDIATE 'SELECT COUNT(TABLE_NAME) FROM USER_TABLES
WHERE TABLE_NAME = '||''''||'TABELLE_'||'''' || v_jahr ||'''';
View 3 Replies
View Related
Jul 4, 2013
How can I escape HTML content without escaping the HTML tags?
View 4 Replies
View Related
Dec 6, 2012
create or replace procedure ab(a in varchar2, b in varchar2)
is
test varcha2(8);
begin
if (a is not null) then
for i in(select c
from t
where c between ||'''||a||'''|| and ||'''||b||'''||)
loop
test:=i.c
end loop;
end if;
end;
I want both parameter input values to be enclosed in quotes so that it considers both parameter values as char.Receiving ora 00936 missing expression error.
View 7 Replies
View Related
Apr 9, 2012
How we can escape comma while exporting data from table into csv file.
CREATE TABLE emp
(
EMPNO NUMBER(4) NOT NULL,
ENAME VARCHAR2(10 BYTE),
JOB VARCHAR2(9 BYTE),
MGR NUMBER(4),
HIREDATE DATE,
address varchar2(100),
[code].......
i have to export data from emp table which has address column and address column contain comma, when i am running below script, the comma part in address field comes in next tab in csv file, is there any way we can avoid shifting to next tab and can have complete address in one tab.
set echo off
set verify off
set termout on
set heading off
set pages 50000
[code]....
View 9 Replies
View Related
May 25, 2010
We have Oracle 10g and user trying to Insert following in one of our table field and getting error:
'REVOLUCIÃ"N Historical Corruptions Agenda'
Getting follwoing error:
ORA-00911: invalid character
create table Employee
(Emp_ID Varchar2 (10),
Company_Name Varchar2 (40)
)
Insert into Employee
values ('Emp1', 'REVOLUCIÃ"N Historical Corruptions Agenda');
View 5 Replies
View Related
Mar 8, 2007
I'm trying to insert a character from the extended ascii character set. Specifically, there's a company that has an accented e (�) in the name. Right now, the company name doesn't have the e at all, accent or no accent. So I'm trying to do an update, something like
update table1 set company_name='blah�" where company='blah'
It runs, but doesn't do the update. Even when I try to forcefully do an insert (instead of an update) I get nowhere; the accented is simply dropped. So the basic question is, how do you insert extended ascii characters into oracle?
View 3 Replies
View Related
Aug 9, 2012
I have one string 'SWAP_20120224_MEGAMART_MAR_Sales.csv'
I want to get the string between second underscore and third underscore i.e. 'MEGAMART'
How to achieve this in sql statement?
View 4 Replies
View Related
Feb 9, 2013
I am using C++ OCI LIB, to insert some report data from remote OCI client to oracle 11 server. This data is read by another process to create the report.The DB CHARSET is UTF-8. But the report tool expects the data to be ISO08859-1 encoded. So while inserting the data into the database i specify the following LANG and CHARSET for my table colulmn in client:
The TARGET DB CHARSET is UTF-8
NLS_LANG=AMERICAN_AMERICA.WE8ISO8859P1
size_t csid = 871; // UTF-8
OCIAtrSet((void *) bnd1p, (ub4) OCI_HTYPE_BIND,
*(void *)&csid*,
(ub4) 0,
(ub4)OCI_ATTR_CHARSET_ID, errhp);
This solution works for almost every case of ASCII and Extended ASCII Charest but we are facing issues if we have few specific characters to be inserted.f we are trying to insert single beta character [β] through client, the data goes empty to the column.
Beta Character details:
DEC OCT HEX BIN Symbol Description
223 337 DF 11011111 ß Latin small letter sharp s - ess-zed
DB Output after insert single β:
select rawtohex(NAME) from PERSONS where EID=333;
RAWTOHEX(NAME)
---------------------------
But if the string is *"ββ"* everything work fine:
DB Output for "ββ":
select rawtohex(NAME) from PERSONS where EID=333;
RAWTOHEX(NAME)
---------------------------
DFDF
View 6 Replies
View Related
Feb 8, 2011
The documentation for v$database says: QUOTE V$DATABASE displays information about the database from the control file. Is it safe to assume that there will only ever be one row queried from this view?
View 2 Replies
View Related