BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

MySQL, MyODBC 3.51 Params as TDateTime

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi Databases (SQL Servers)
View previous topic :: View next topic  
Author Message
Guenther Wimpassinger
Guest





PostPosted: Thu Aug 14, 2003 3:26 pm    Post subject: MySQL, MyODBC 3.51 Params as TDateTime Reply with quote



Hi!

I have a small problem with MySQL and the MyODBC driver (via BDE) in
D7. If i have a TQuery with an SQL statment and use Parameters with
TDateTime type i get the BDE Message
"Operation not applicable"/"Operation nicht anwendbar".

Have anybody encountered the problem and solved it?
And if, how?

any ideas?
Guenther


Back to top
Rodrigo Hjort
Guest





PostPosted: Thu Aug 14, 2003 7:03 pm    Post subject: Re: MySQL, MyODBC 3.51 Params as TDateTime Reply with quote



Sometimes I got an error when executing instructions with ":" parameters
inside comments. Isn't it the case? However, some DBMS can handle it
successfully. i.g.:

select *
from customers
where
--id = :p_id
/* id = :p_id */
id = 5

Best regards,

Rodrigo Hjort
[email]rodrigo_hjort (AT) yahoo (DOT) com[/email]
Curitiba, PR, Brazil


"Guenther Wimpassinger" <gwspam (AT) pickem (DOT) at> escreveu na mensagem
news:3f3ba9df$1 (AT) newsgroups (DOT) borland.com...
Quote:
Hi!

I have a small problem with MySQL and the MyODBC driver (via BDE) in
D7. If i have a TQuery with an SQL statment and use Parameters with
TDateTime type i get the BDE Message
"Operation not applicable"/"Operation nicht anwendbar".

Have anybody encountered the problem and solved it?
And if, how?

any ideas?
Guenther



Back to top
Guenther Wimpassinger
Guest





PostPosted: Fri Aug 15, 2003 11:38 am    Post subject: Re: MySQL, MyODBC 3.51 Params as TDateTime Reply with quote




"Rodrigo Hjort" <rodrigo.hjort (AT) actumplus (DOT) com.br> schrieb

Quote:
Sometimes I got an error when executing instructions with ":" parameters
inside comments. Isn't it the case

Thanks for your help Rodrigo, but I do not have comments inside my
SQL-Statement.

it looks something like that (have not the source on the hand)

'select * from proto_data where pd_date between :start and :end'
Params[0].AsDateTime := MyStartDate;
Params[1].AsDateTime := MyEndDate;

If I replace the :start :end with some dates and remove the Params[.]
assignment the statement works very well
otherwise i get the BDE-Errormessage

someone else have some ideas?
Guenther



Back to top
Jeremy Collins
Guest





PostPosted: Fri Aug 15, 2003 12:02 pm    Post subject: Re: MySQL, MyODBC 3.51 Params as TDateTime Reply with quote

Guenther Wimpassinger wrote:

Quote:
it looks something like that (have not the source on the hand)

'select * from proto_data where pd_date between :start and :end'
Params[0].AsDateTime := MyStartDate;
Params[1].AsDateTime := MyEndDate;

If I replace the :start :end with some dates and remove the Params[.]
assignment the statement works very well
otherwise i get the BDE-Errormessage

someone else have some ideas?

Post the SQL statement where you put the dates in manually, I'm
thinking there's maybe a date format problem. Sometimes this:

Params[0].AsString := FormatDateTime('DD/MM/YYYY HH:NN:SS',
MyStartDate);

is more flexible. The actual date format is just an example.


Also, I always name my parameters like this:

select * from proto_data
where pd_date between :start_param and :end_param

Just to make sure I *never* get a conflict between a parameter name
and an obscure reserved word.

--
jc

Remove the -not from email


Back to top
Eduardo Andrade Bahiense
Guest





PostPosted: Sun Aug 17, 2003 4:02 am    Post subject: Re: MySQL, MyODBC 3.51 Params as TDateTime Reply with quote

Maybe BDE is not implementing the YYYY-MM-DD date format required by MYSQL

One Solution should be replace :Start and :end with something like
StringReplace function
instead of using parameters.

I would use:

OriginalQuery := MyQuery.Sql.Text;

MyQuery.Sql.Text := StrReplace(MyQuery.Sql.Text, ':Start',
QuotedStr(FormatDateTime('YYYY-MM-DD', MyStartDate), [rfReplaceAll,
rfIgnoreCase]);

MyQuery.Sql.Text := StrReplace(MyQuery.Sql.Text, ':End',
QuotedStr(FormatDateTime('YYYY-MM-DD', MyEndDate), [rfReplaceAll,
rfIgnoreCase]);

MyQuery.Open;
do what you need

MyQuery.SQL.Text := OriginalQuery;

or build the entire query concatenating date format strings;

MyQuery.SQL.Text := 'select * from proto_data where pd_date between '+
QuotedStr(FormatDateTime('YYYY-MM-DD',
MyStartDate)+
' and '+
QuotedStr(FormatDateTime('YYYY-MM-DD',
MyEndDate);
MyQuery.Open;

HTH, Eduardo



Back to top
Guenther Wimpassinger
Guest





PostPosted: Mon Aug 18, 2003 6:42 am    Post subject: Re: MySQL, MyODBC 3.51 Params as TDateTime Reply with quote


"Eduardo Andrade Bahiense" <eduardo (AT) fdv (DOT) com.br> schrieb


Quote:
Maybe BDE is not implementing the YYYY-MM-DD date format required by MYSQL


But with the mySQL-ODBC-driver 2.50 everything works fine. So i don't think it
is the BDE alone.

Thanks anyway.
Guenther



Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi Databases (SQL Servers) All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.