<p>Ok, this is bit of an obscure question, but hopefully someone can help me out with it.</p>

<p>The system I'm working on builds a dynamic SQL string for execution inside a stored procedure, and part of that dynamic SQL defining column aliases, which themselves are actually values retrieved from another table of user generated data.</p>

<p>So, for example, the string might look something like;</p>

<pre><code>SELECT table1.Col1 AS "This is an alias" FROM table1
</code></pre>

<p>This works fine. However, the value that is used for the alias can potentially contain a double quote character, which breaks the outer quotes. I thought that I could maybe escape double quotes inside the alias somehow, but I've had no luck figuring out how to do so. Backslash doesn't work, and using two double quotes in a row results in this error;</p>

<pre><code>SQL Error: ORA-03001: unimplemented feature
03001. 00000 -  "unimplemented feature"
*Cause:    This feature is not implemented.
</code></pre>

<p>Has anyone had any experience with this issue before?
Cheers for any insight anyone has.</p>

<p>p.s. the quotes are needed around the aliases because they can contain spaces.</p>

[{'answer_id': 56636, 'author': 'JosephStyons', 'author_id': 672, 'author_profile': 'https://Stackoverflow.com/users/672', 'pm_score': 1, 'selected': False, 'text': '<p>When I run this:</p>\n\n<pre><code>select \'test"columnname"\' from dual\n</code></pre>\n\n<p>Oracle returns this (notice the Oracle-generated column name):</p>\n\n<pre><code>\'TESTCOLUMNNAME\'\n--------------------------------\ntest"columnname\n</code></pre>\n\n<p>The fact that Oracle\'s column name doesn\'t include my double-quote tells me that Oracle probably cannot represent that.</p>\n\n<p>Best bet as far as I can see is to strip double-quotes from your data prior to using column names.  Sadly, that will also require that you do the same filtering when you <em>select</em> those columns, but I don\'t see another way.</p>\n'}, {'answer_id': 56711, 'author': 'ibz', 'author_id': 5475, 'author_profile': 'https://Stackoverflow.com/users/5475', 'pm_score': 3, 'selected': True, 'text': '<p>Can you just put another character instead of double quotes and replace that with double quotes in the code?</p>\n\n<p>Something like this:</p>\n\n<pre><code>SELECT table1.Col1 AS "This is |not| an alias" FROM table1\n</code></pre>\n\n<p>Then just replace | with ".</p>\n\n<p>I know it\'s a hack, but I can\'t think of any better solution... And what you are doing there is a hack anyway. The "nice" way would be to select the values and the column names separately and associate them in your code. That would make things much cleaner.</p>\n'}, {'answer_id': 75473, 'author': 'EvilTeach', 'author_id': 7734, 'author_profile': 'https://Stackoverflow.com/users/7734', 'pm_score': 0, 'selected': False, 'text': '<p>a possibly fruitful area of investigation would be to look into the quote method. <br></p>\n\n<p><strong>my $quotedString = $dbh->quote( $string );</strong> <br></p>\n'}, {'answer_id': 2182542, 'author': 'swissunix', 'author_id': 251361, 'author_profile': 'https://Stackoverflow.com/users/251361', 'pm_score': 2, 'selected': False, 'text': "<p>use the Oracle quote operator:</p>\n\n<pre><code>select q'#someone's quote#' from dual;\n</code></pre>\n\n<p>the '#' can be replaced by any character</p>\n"}, {'answer_id': 18954073, 'author': 'Artem', 'author_id': 2806242, 'author_profile': 'https://Stackoverflow.com/users/2806242', 'pm_score': 0, 'selected': False, 'text': '<p>Try this, two single quotes actually look like one double quote in output:<br>\n<code>select 1 as "University \'\'John Smith\'\'" from dual;</code></p>\n'}]
['https://Stackoverflow.com/questions/56591', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/5827/']