DBAsupport.com Forums - Powered by vBulletin
Results 1 to 6 of 6

Thread: Escape character for &

Hybrid View

  1. #1
    Join Date
    Sep 2002
    Posts
    376

    Escape character for &

    Hi,

    I want to insert & into a column; Can somebody tell me what is the Escape char for the same.
    ------------------------------------------------------------------------
    The most enjoyable things in the world are either Immoral or too Expensive or otherwise Inaccessible anyway

  2. #2
    Join Date
    Sep 2002
    Location
    England
    Posts
    7,334
    well if you are using sqlplus, set define off at the start

    but you really should provide all the details then you might get a better answer, you have posted enough questions here to know that.

  3. #3
    Join Date
    Feb 2003
    Location
    London
    Posts
    170
    Like Davey said, in sqlplus, you can use set define off

    Otherwise, you can use '\' character to escape.

    eg:

    insert into test_table values ('C\&G');
    thomasp

  4. #4
    Join Date
    Aug 2002
    Location
    Colorado Springs
    Posts
    5,253
    Quote Originally Posted by thomasp
    Like Davey said, in sqlplus, you can use set define off

    Otherwise, you can use '\' character to escape.

    eg:

    insert into test_table values ('C\&G');
    Doesn't work for me

    Code:
    SQL> create table g (col1 varchar2(30));
    
    Table created.
    
    SQL> insert into g values ('C\&G');
    Enter value for g: ?
    old   1: insert into g values ('C\&G')
    new   1: insert into g values ('C\?')
    
    1 row created.
    
    SQL> select * from g;
    
    COL1
    ------------------------------
    C\?
    David Aldridge,
    "The Oracle Sponge"

    Senior Manager, Business Intelligence Development
    XM Satellite Radio
    Washington, DC

    Oracle ACE

  5. #5
    Join Date
    Feb 2003
    Location
    London
    Posts
    170
    Sorry for not being specific. It does not work in sqlplus.
    My otherwise meant outside of sqlplus. the '\' would work.
    thomasp

  6. #6
    Join Date
    Jun 2005
    Location
    London, UK
    Posts
    159
    Substitution variables are a SQL*Plus feature, although other tools such as TOAD and PL/SQL Developer may implement something similar.

    In SQL*Plus the '&' character is just the default but can be set to anything you like, or the feature can be disabled as mentioned above. Similarly an escape character can be defined using SET ESCAPE, '\' being the default character.

    Outside of tools that provide a substitution variable syntax, the '&' character has no special meaning in SQL or PL/SQL.
    Last edited by WilliamR; 06-03-2006 at 06:01 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Click Here to Expand Forum to Full Width