A quick proposal example for a preprocessor.
Input file "some-sql.pwn":
stock doSomeSQL() {
@SQL(mysql_pqueryf, 10, 20) {
SELECT *
FROM table
WHERE x=y
AND a=b
GROUP BY m
HAVING n
LIMIT %d
OFFSET %d
}
}
Output files:
stock doSomeSQL() {
mysql_pqueryf_file("some-sql-2.sql", 10, 20);
// SELECT *
// FROM table
// WHERE x=y
// AND a=b
// GROUP BY m
// HAVING n
// LIMIT %d
// OFFSET %d
// }
}
"some-sql-2.sql":
SELECT *
FROM table
WHERE x=y
AND a=b
GROUP BY m
HAVING n
LIMIT %d
OFFSET %d
In this example, the SQL
type macro mysql_pqueryf
results in the contained text being moved copied to a .sql file and the source code generating a call to a function. mysql_pqueryf
is also defined to put this file in scriptfiles
and it also takes n variadic arguments for formatting.