SQL and nested strings

Started by
1 comment, last by ju2wheels 18 years, 8 months ago
I have an issue with sending an oracle database a key value with substrings in it. For example: String 1: "SELECT sometable WHERE somecolumn <> 'somestring'" Now I need to store string 1 in one of the fields in my table, so I do the following...

INSERT INTO anothertable (inToThisColumn) VALUES ('SELECT sometable WHERE somecolumn <> 'somestring' ')


The issue with this is the way it scans for the beginning and end of a string value. It gives me an error saying that Im missing commas because it assumes the value im passing it is actually two: 'SELECT sometable WHERE somecolumn <> ' and somestring'' Anyone know of how I can fix this?
Advertisement
Why not just use?

insert anothertable (inToThisColumn)select someColumn from sometable where somecolumn <> 'somestring'


Unless you need the select statement stored in the table, if this is the case then you will need to double quote your strings:-

INSERT INTO anothertable (inToThisColumn) VALUES ('SELECT * from sometable WHERE somecolumn <> '''somestring''' ' )
Second option was it.... thanks a lot.

This topic is closed to new replies.

Advertisement