Monday, March 18, 2019

Inserting and retrieving ampersand(&) in Oracle

SQL> create table amp_test (no number,value varchar2(100));

Table created.

SQL> insert into amp_test values (1,'hyd');

1 row created.

SQL> insert into amp_test values (2,'at&t');
Enter value for t:
old   1: insert into amp_test values (2,'at&t')
new   1: insert into amp_test values (2,'at')

1 row created.

SQL> commit;

Commit complete.

SQL> select * from amp_test;

        NO VALUE
---------- ----------------------------------------------------------------------------------------------------
         1 hyd
         2 at

SQL>  insert into amp_test values (3,'at"&"t');

1 row created.

SQL> select * from amp_test;

        NO VALUE
---------------------------------------
         1 hyd
         2 at
         3 at"&"t

SQL> insert into amp_test values (4,'at'||'&'||'t');

1 row created.

SQL> select * from amp_test;

        NO VALUE
-----------------------------------------------------
         1 hyd
         2 at
         3 at"&"t
         4 at&t
SQL> SELECT NO, REPLACE (VALUE, '&', CHR (ASCII ('&')) || 'amp;') as value FROM amp_test;

   NO VALUE1

   2 at&t
  
   PLSQL:
---------------------------------
BEGIN
  IF v_ats = 'AT'||CHR (ASCII ('&'))|| 'T'  THEN
   logic...
 END IF; 
END;
/

No comments:

Post a Comment

Delete Row Button to all records of Interactive Report in Oracle Apex

 1. add 'Delete' Del column to Report Query 2. Set the Following Properties for the DEL Column Type: Link Heading: Delete Targ...