Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> Re: INSERTing string containing character '&'
'&' is the default character for DEFINE (to use parameters in SQL+)
You can change it for a while in SQL+, so you can use another character that
you're sure is not
in your file (µ for example).
SET DEFINE µ
INSERT INTO names VALUES ( '00001', 'Bartles&James' );
SET DEFINE & (if necessary)
If the names are in a file, you can read this file in a PL/SQL block and
insert all the names in a table
with no trouble. For that you can use the build-in package UTL_FILE.
An example for Windows :
DECLARE
sname VARCHAR2(45); file UTL_FILE.FILE_TYPE;
INSERT INTO names VALUES (SUBSTR(sname,1,5),SUBSTR(sname,6,40)); UTL_FILE.GET_LINE(file,sname);
UTL_FILE.FCLOSE(file); COMMIT; WHEN OTHERS THEN DBMS_OUTPUT.PUT_LINE(SQLERRM); UTL_FILE.FCLOSE_ALL;
MFGCO MFGNAME
----- ----------------------------------------00001 TRUC&MUCHE
Don't forget UTL_FILE_DIR in the INIT.ORA file For example : UTL_FILE_DIR = * (all directories)
abray_at_club-internet.fr
Howard Lee Harkness a écrit dans le message <7hkq9f$kfv$1_at_nnrp1.deja.com>...
>I have a table defined as:
>CREATE TABLE NAMES
>(
>MFGCODE VARCHAR2(5),
>MFGNAME VARCHAR2(40)
>);
>
>I tried to do an insert similar to the following:
>
>INSERT INTO NAMES
>( '00001', 'Bartles&James' );
>
>and SQL*Plus responded with:
>
>Enter value for James:
>
>Which is a good indicator that the '&' is some sort of special
>character, presumably used for passing parameters interactively. So
>how do I defeat the special nature of this character? Are there other
>characters I need to defeat? I have about 7 Mb of names in a file to
>import, many of which contain '&' in the name.
>
>--
>Replies send to this email address are automatically discarded. To
>reply, please post in this newsgroup, or send to harkness at skeptics
>dot org. Thank-you.
>
>
>--== Sent via Deja.com http://www.deja.com/ ==--
>---Share what you know. Learn what you don't.---
Received on Sun May 16 1999 - 20:29:10 CDT