开发者

How do I execute queries with multiple lines using QOCI (the Qt Oracle binding)?

I am using the QOCI binding to connect Qt with an Oracle 10g database. The code is really simple:

QSQLQuery sqlQuery = QSQLQuery(database);
sqlquery.prepare(querystring);
sqlQuery.exec();

Now if querystring is only one line, it works:

select * from dual

But if it contains multiple lines, I get an ORA-911 invali开发者_运维技巧d character:

select *
from dual

I have a lot of queries spanning multiple lines, so this is quite a problem. Just removing newlines in Qt is not an option, because the queries contain end-of-line comments ("--").

Any suggestions how I can execute these multi-line queries?


Answering my own question: The newline character was the unicode U+2029 paragraph seperator instead of a normal newline (\n). This triggered the ORA-911.

querystring.replace(QChar(0x2029), QChar('\n'));

does the trick.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜