Can I set variable for sql statement in script report?

Hi Developers

When i execute sql statement “SET @VARIABLE = 0;” in script report.

I get error

ProgrammingError: (1064, “You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near ‘select\n\t\t\torder_year,\n\t\t\tproject_type,\n\t\t\tproject_number,\n\t\t\tproject_name,\n\t\t\tit’ at line 3”)

After that, I removed it and execute passed.
Can I set variable in sql statment ?

image

Kind Regards,
Worawat Pansawat

You may find this link helpful

1 Like

Thank you.

Link is broken Please Update Link or answer No information found about the error ! Please Reply ASAP

Hey I found this link, probably it would help you

https://www.agiliq.com/blog/2018/07/frappe-database/

Eeven better here is a cached version of the link above :

https://webcache.googleusercontent.com/search?q=cache:vrQjqQqt3tQJ:https://frappe.io/docs/current/api/frappe.database+&cd=1&hl=en&ct=clnk&gl=in&client=ubuntu

thank you so much for the link . it helped a lot
i figured out it is a python mysql issue not a frappe one.
run them as two queries first to set variable and the next one where u used it. it may help to other people

1 Like