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 

Parameterized Query No rows effected

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi Databases (ADO)
View previous topic :: View next topic  
Author Message
Dave Blake
Guest





PostPosted: Wed Jul 27, 2005 8:36 am    Post subject: Parameterized Query No rows effected Reply with quote



I have a parameterized query of the following form

UPDATE MyTable
SET field1 = :Param1
WHERE field2 = :Param2 AND
NOT EXISTS (SELECT field21 FROM MyTable2
WHERE (field21=field1) AND (field22 <> :Param3) )

but it mysteriously does not update anything when executed.
All parameters are ftInteger, input direction, set to integer values before
ExecSql. Executed within a transaction after another query that updates
MyTable2 - could there be an issue of it not seeing these changes? Yet a
similar query with Param1, and Param3 replaced by fixed numeric values in
the SQL works perfectly (updates the records expected), as does a
non-parameterized query building the SQL text dymanically.

I just can't see what is wrong with it. Any ideas? ADO onto mdb file via Jet
4.

Dave


Back to top
Vitali Kalinin
Guest





PostPosted: Wed Jul 27, 2005 9:46 am    Post subject: Re: Parameterized Query No rows effected Reply with quote



Do you use the same ADOConnection for both Updates? If not then you should
be aware of Jet Latency problem.


Back to top
Dave Blake
Guest





PostPosted: Wed Jul 27, 2005 2:29 pm    Post subject: Re: Parameterized Query No rows effected Reply with quote




Quote:
Do you use the same ADOConnection for both Updates? If not then you should
be aware of Jet Latency problem.

Yes, same connection. I am aware of Jet latency too, I don't think it
applies to this.

A query with fewer parameters works even when have just updated field22 e.g.

UPDATE MyTable
SET field1 = 9
WHERE field2 = :Param2 AND
NOT EXISTS (SELECT field21 FROM MyTable2
WHERE (field21=field1) AND (field22 <> 11) )

but pass "9" and "11" as a parameters and nothing gets updated.

Are there limits on using parameters within a subquery or SET statement?

Dave



Back to top
Dave Blake
Guest





PostPosted: Wed Jul 27, 2005 2:51 pm    Post subject: Re: Parameterized Query No rows affected Reply with quote

It is the parameter in the subquery that is causing the problem. Can anyone
tell me what ADO (or Jet data provider) does with parameters that would
explain this?

This sucessfully affects rows

UPDATE MyTable
SET field1 = :Param1
WHERE field2 = :Param2 AND
NOT EXISTS (SELECT field21 FROM MyTable2
WHERE (field21=field1) AND (field22 <> 11) )

parameters[0].value := 9;
parameters[1].value := 3000;

but

UPDATE MyTable
SET field1 = :Param1
WHERE field2 = :Param2 AND
NOT EXISTS (SELECT field21 FROM MyTable2
WHERE (field21=field1) AND (field22 <> :Param3) )

parameters[0].value := 9;
parameters[1].value := 3000;
parameters[2].value := 11;

does not. Why?

Dave


Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi Databases (ADO) 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.