Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

insert string with " ' " to oracle

Hey I'm using oracle DB with Iron Python and I'm having trouble with strings that contains the char " ' " like in Mc'donalds. (I know it is looking for the closing ' ) The string is accepted from the user input and I want to add it to my DB as it is, meaning without omitting or changing any character. How can I do it?

like image 509
user3501645 Avatar asked Apr 01 '26 17:04

user3501645


1 Answers

Try using the "q" (quote) function:

INSERT INTO restaurantTable (name) 
VALUES (q'[O'Reilly and Conway's Irish Pub]');

You can also double-up the single apostrophes (O''Reilly and Conway''s Irish Pub). But in your case you'd have to parse them out, so either using the quote function or query parameters would work the best.

For more information: Q-quote operator introduced in Oracle 10g

like image 96
Aaron Avatar answered Apr 03 '26 08:04

Aaron



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!