Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Include SQL in XML

Tags:

android

sql

xml

Is it possible to include an SQL query inside an XML into raw/ directory? For example:

<query name ="mainQuery">SELECT e.*, et.name as name FROM employee e, employee_type et where e.type = et._id and et._id < et._id</query>

or

<query name ="mainQuery" value="SELECT e.*, et.name as name FROM employee e, employee_type et where e.type = et._id and et._id < et._id" />

Both these give errors on XML structure. One workaround is using &lt; and friends, but this really makes no sense as SQL syntax.

Thanks in advance.

like image 839
m0skit0 Avatar asked Mar 04 '26 20:03

m0skit0


2 Answers

Have you looked into putting the query in a comment and then reading the comment from within your activity?

See here: http://www.codeproject.com/Articles/11178/Writing-SQL-queries-in-XML-A-support-intensive-app

like image 136
Adrian Avatar answered Mar 07 '26 09:03

Adrian


You can use CDATA. Example:

<query name ="mainQuery"><![CDATA[SELECT e.*, et.name as name FROM employee e, employee_type et where e.type = et._id and et._id < et._id]]></query>
like image 23
Brais Gabin Avatar answered Mar 07 '26 08:03

Brais Gabin



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!