Home » RDBMS Server » Server Administration » Inserting list of string values which has &'s into a columns.
Inserting list of string values which has &'s into a columns. [message #369909] Mon, 06 November 2000 12:17 Go to next message
Nirmal
Messages: 39
Registered: November 2000
Member
I have a list of string values eg.:

'asdasdj&asd&kasl'
'kjasdj&lasdk%lkas&kasjd'kjasd'

When i try to insert it into the table let's say table a:

insert into a values('asdasdj&asd&kasl');

this prompts me to enter the values:

How do I get around this..

Please don't tell me to do this :
insert into a values('asdasdj'||'&'||'asd'||'&'||'kasl');

Because these string values comes from a file, and i generate the insert script on the fly..

Thanks in adv.

Nirmal
Re: Inserting list of string values which has &'s into a columns. [message #369911 is a reply to message #369909] Mon, 06 November 2000 14:35 Go to previous messageGo to next message
Suresh
Messages: 189
Registered: December 1998
Senior Member
execute set command
SET DEFINE OFF
before running your insert statement

Suresh
Re: Inserting list of string values which has &'s into a columns. [message #369913 is a reply to message #369911] Mon, 06 November 2000 15:34 Go to previous messageGo to next message
Nirmal
Messages: 39
Registered: November 2000
Member
Thanks..

And how about inserting :

ajsda&kjdjd'jskd

I mean the ' withint the string..
Re: Inserting list of string values which has &'s into a columns. [message #369914 is a reply to message #369911] Mon, 06 November 2000 15:34 Go to previous messageGo to next message
Nirmal
Messages: 39
Registered: November 2000
Member
Thanks..

And how about inserting :

ajsda&kjdjd'jskd

I mean the ' withint the string..
Re: Inserting list of string values which has &'s into a columns. [message #369915 is a reply to message #369914] Mon, 06 November 2000 15:41 Go to previous messageGo to next message
Suresh
Messages: 189
Registered: December 1998
Senior Member
replace single quote with double single quotes

e.g :
if you want to insert abcd'efgh then use
insert into xxx values ('abcd''efghi');

[b]Suresh[b]
Re: Inserting list of string values which has &'s into a columns. [message #369916 is a reply to message #369914] Mon, 06 November 2000 15:52 Go to previous messageGo to next message
Nirmal
Messages: 39
Registered: November 2000
Member
I know that Suresh, but these values are coming
from a file. So what do i do
Re: Inserting list of string values which has &'s into a columns. [message #369984 is a reply to message #369913] Wed, 22 November 2000 09:17 Go to previous messageGo to next message
Madhav Kasojjala
Messages: 42
Registered: November 2000
Member
Hi Nirmal,
I don't know how you are doing inserts.
But if ur situation allows u to use a PLSQL block or function which will give u clean string then
u can do this way....
vStr is ur input string,
From ASCII Char set 39 is for '.
Let me know if u have diff. situation
declare
vStr varchar2(2000):=NULL;
vLen Number(10) :=0;
begin
vLen := length(vStr);
for i in 1..vLen
loop
if ascii(substr(vStr,i,1)) = 39 then
vStr :=substr(vStr,1,i-1)||''||substr(vStr,i+1,length(vStr));
end if;
end loop;
end;
Re: Inserting list of string values which has &'s into a columns. [message #369986 is a reply to message #369913] Wed, 22 November 2000 12:54 Go to previous messageGo to next message
Nirmal
Messages: 39
Registered: November 2000
Member
Thanks. I appricate your response..

Nirmal
Re: Inserting list of string values which has &'s into a columns. [message #370023 is a reply to message #369913] Thu, 30 November 2000 10:53 Go to previous messageGo to next message
Mohammad Syed
Messages: 18
Registered: November 2000
Junior Member
On a similar note. Can anyone tell how to use a column which contains '&' character in the WHERE clause of a query??
Re: Inserting list of string values which has &'s into a columns. [message #370026 is a reply to message #369913] Thu, 30 November 2000 12:27 Go to previous messageGo to next message
Nirmal
Messages: 39
Registered: November 2000
Member
Zee elaborate please with example..

Nirmal
Re: Inserting list of string values which has &'s into a columns. [message #370027 is a reply to message #369913] Thu, 30 November 2000 12:36 Go to previous messageGo to next message
Mohammad Syed
Messages: 18
Registered: November 2000
Junior Member
Ok lets say that your working on a database for a a food wholesale distributer. You want to run the following query
SELECT
item,
price,
quantity,
bulkdiscount
FROM
wholesales
WHERE shipdate = sysdate
AND customer = 'A&P'; -- The string in question

..In this silly example, the where clause would prompt a value for the client rather than find 'A&P'. I want the string and not the prompt.
Re: Inserting list of string values which has &'s into a columns. [message #370028 is a reply to message #369913] Thu, 30 November 2000 12:43 Go to previous messageGo to next message
Nirmal
Messages: 39
Registered: November 2000
Member
try with setting on sqlplus as :
SQL>set default off;
SQL> <your sql statement>

Good Luck

Nirmal
Re: Inserting list of string values which has &'s into a columns. [message #370030 is a reply to message #369913] Thu, 30 November 2000 15:37 Go to previous messageGo to next message
Mohammad Syed
Messages: 18
Registered: November 2000
Junior Member
I got an error...

SQL> set default off
unknown SET option "default"
SQL>
Re: Inserting list of string values which has &'s into a columns. [message #370031 is a reply to message #370028] Thu, 30 November 2000 15:45 Go to previous messageGo to next message
Nirmal
Messages: 39
Registered: November 2000
Member
Sorry it's SET DEFINE OFF;

Good Luck

Nirmal
Re: Inserting list of string values which has &'s into a columns. [message #370032 is a reply to message #370028] Thu, 30 November 2000 15:47 Go to previous message
Mohammad Syed
Messages: 18
Registered: November 2000
Junior Member
Thank you very very much!! it worked!!
Previous Topic: Re: Oracle 8i Error Message
Next Topic: help ..URGENT !!
Goto Forum:
  


Current Time: Fri May 03 09:16:32 CDT 2024