I'm converting a web-based app to SQL (The backend is currently a DBM file. A big one).
I have arranged (for minimum pain) for my SQL tables to be automatically created based on a simple config file, which represents the current data structures. So far so good.
I had this bright idea that instead of users just being able to type in '25/12/2002' for dates, they could also type in '+1 month' or '-3 weeks'. What a great idea (I thought).
I duly wrote the logic which would convert +1 month to DATE(NOW() + INTERVAL '+1 month').
It doesn't work, and I bet you're all laughing at me right now.
(Pause to let laughter subside)
So if a user types '25/12/2002', then DBI does something like:
INSERT INTO table (thisdate) VALUES('2002-12-25') WHERE id = 1;
(My function has converted it to YYYY-MM-DD format).
In the interval style one, DBI does:
INSERT INTO table (thisdate) VALUES ('DATE(NOW() + INTERVAL \'+1 month\')') WHERE id =1
You can see why I think I'm probably out of luck :-)
Anyone see an elegant way around this? Like 'DBI, don't autoquote if it looks like this, otherwise do'. :-|
Otherwise, I have to do some sort of lookup for each element as I build the SQL statement.
<sigh>
In reply to DBI quoting when I don't want it to by Tardis
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |