HOW TO ESCAPE SINGLE QUOTES IN PL/SQL

I AM WRITE A VIEW THROUGH DYNAMIC SQL


V_CURSOR:= DBMS_SQL.OPEN_CURSOR;
V_STRING:= 'CREATE or replace VIEW v_BANNER_STUDENTS AS';
V_STRING:=v_string||'SELECT distinct'||'P'||'||SPR.SPRIDEN_ID Person_id,';

HOW DO I ESCAPE THE SINGLE QUOTES
NUTAKKIPRASHANTHAsked:
Who is Participating?
 
DanielztConnect With a Mentor Commented:
use two single('' no space) for a single(').
0
 
MikeOM_DBACommented:
Try this:

V_STRING:=v_string||'SELECT distinct ''P'''||' SPR.SPRIDEN_ID Person_id,';
0
 
TannerCCommented:
To make your code more readible I always use CHR(39) instead of trying to count the single qoutes

V_STRING:=v_string||'SELECT distinct '|| CHR(39) || 'P' || CHR(39) ||' SPR.SPRIDEN_ID Person_id,';
0
 
TannerCCommented:
oops I forgot a space before the select  
V_STRING:=v_string||' SELECT distinct '|| CHR(39) || 'P' || CHR(39) ||' SPR.SPRIDEN_ID Person_id,';

Hope this helps
0
All Courses

From novice to tech pro — start learning today.