Wednesday, November 14, 2007

Inserting Data Containing "&" Without Being Prompted

There are two ways to make an "&" be treated as text and not cause a prompt.
1)
The first turns all variable substitution off:

set define off;
insert into table values(' a & b');

2)
The second method is useful for ignoring individual occurrences of "&" while allowing others to prefix substitution variables:
set escape \
insert into table values(' a \& b');

More info at
http://www.oracle.com/technology/support/tech/sql_plus/htdocs/sub_var9.html

3)DB Link example

CREATE DATABASE LINK weblnkp_db_link
CONNECT TO tiw IDENTIFIED BY tiw
USING '(DESCRIPTION=
(ADDRESS_LIST=
(ADDRESS=(PROTOCOL=TCP)(HOST=prac01.gpi.com)(PORT=1521))
(ADDRESS=(PROTOCOL=TCP)(HOST=prac02.gpi.com)(PORT=1521)))
(LOAD_BALANCE = yes)(CONNECT_DATA=(SERVICE_NAME=WEBLNKP)))';

drop DATABASE LINK weblnkp_db_link

select * from line@weblnkp_db_link