Helpex - Trao đổi & giúp đỡ Đăng nhập

Is there an easy way in Oracle to escape special characters in a SQL statement? (i.e. %, &, ') I saw this link in regard to manually escaping characters, but I thought Oracle may have provided an easier way to do so.

Note: I'm generating dynamic SQL select statements through an ORM.

7 hữu ích 2 bình luận 29k xem chia sẻ

If using bind variables and ORM, embedded single quotes and ampersands should be handed automatically; those are special characters in SQL*Plus or SQL*Developer.

To use LIKE where looking for the literal characters % and _ (not their multi- and single-character wildcard versions), you'd use the escape clause of the like condition:

select * from my_table where some_text like '/%%' escape '/';

will only return the rows where some_text begins with a percent sign.

16 hữu ích 0 bình luận chia sẻ

It seems you're looking for something like the command SET DEFINE OFF, which you can run and it affects the whole SQL session. This command, however, only prevents Oracle from giving special meaning to the ampersand character. It doesn't affect other special characters such as the single quote.

A couple of links to additional information regarding escaping characters follow:

2 hữu ích 1 bình luận chia sẻ

here's the definitive answer page on tech on the net. Even provides examples and exercises

0 hữu ích 0 bình luận chia sẻ
Không tìm thấy câu trả lời bạn tìm kiếm? Duyệt qua các câu hỏi được gắn thẻ sql oracle11g , hoặc hỏi câu hỏi của bạn.

Có thể bạn quan tâm