?
Solved

HOW TO ESCAPE SINGLE QUOTES IN PL/SQL

Posted on 2003-02-26
4
Medium Priority
?
1,864 Views
Last Modified: 2008-03-06
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
0
Comment
Question by:NUTAKKIPRASHANTH
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 29

Expert Comment

by:MikeOM_DBA
ID: 8028486
Try this:

V_STRING:=v_string||'SELECT distinct ''P'''||' SPR.SPRIDEN_ID Person_id,';
0
 
LVL 8

Accepted Solution

by:
Danielzt earned 200 total points
ID: 8029206
use two single('' no space) for a single(').
0
 

Expert Comment

by:TannerC
ID: 8030586
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
 

Expert Comment

by:TannerC
ID: 8030596
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

Featured Post

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Why doesn't the Oracle optimizer use my index? Querying too much data Most Oracle developers know that an index is useful when you can use it to restrict your result set to a small number of the total rows in a table. So, the obvious side…
Cursors in Oracle: A cursor is used to process individual rows returned by database system for a query. In oracle every SQL statement executed by the oracle server has a private area. This area contains information about the SQL statement and the…
This video shows how to Export data from an Oracle database using the Original Export Utility.  The corresponding Import utility, which works the same way is referenced, but not demonstrated.
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function
Suggested Courses

741 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question