Salfii Salfii - 9 days ago 5
SQL Question

Oracle Insert Special Characters and Function Names

I´m currently struggling to insert a value into a varchar2 column off an Oracle Database. The value is (and full of special characters....):

'Data\QVD\QVD_'& replace(v_sc_val_ExecutionEnvironment, chr(39),'') &'\VTB_MOD1_RESULT\'


(Its a QlikView Formular which should be stored in the Database. Afterwards I can extract and evaluate it with QlikView, but I need the exact given format.)

I already tried to escape all ' with '' and so on, but It didn´t work so far. Define off didn´t work too.

I also found:
https://docs.oracle.com/cd/B10501_01/text.920/a96518/cqspcl.htm
but didn´t find a solution there.

Hopefully someone had the same problems or knows the solution.

Thanks in advance!

Answer

Maybe you can try the q quote operator:

insert into yourTable(c)
values ( q'['Data\QVD\QVD_'& replace(v_sc_val_ExecutionEnvironment, chr(39),'') &'\VTB_MOD1_RESULT\']').

This way you should need no escape and the text should be inserted exactly as you typed it.

Comments