Page 1 of 1

inconsistent types deduced for parameter

Posted: Tue 19 May 2009 18:03
by adroege
I am getting the following error when I try to run a query using a TUniSQL with the postgresql provider:

'inconsistent types deduced for parameter $3'

The query is:

INSERT INTO ugmem( groupnum, usernum, grouptype )
SELECT :groupnum, :usernum, :grouptype
WHERE NOT EXISTS( SELECT id FROM ugmem WHERE groupnum = :groupnum AND usernum = :usernum AND grouptype = :grouptype )

If I comment out the WHERE clause, the query runs fine (however it is incorrect).

I noticed a forum post detailing this issue on the TpgQuery and the new UseParamTypes option. Is this option available in the UniDac (TUniSQL) components? If not, how do I get this to work?

Thanks

Posted: Wed 20 May 2009 07:10
by Plash
We have added this option to UniDAC. But the build with the UseParamTypes option is not yet released. We are planning to release the new build in a week.

Posted: Thu 28 May 2009 18:53
by adroege
I've downloaded the 2.7 UniDAC (for Delphi 7) and I'm still having an issue. I've added the following to a TUniSQL component:

Code: Select all

SpecificOptions.Add( 'PostgreSQL.UseParamTypes=True' )
Given the following query:

Code: Select all

INSERT INTO emailheaders_13( AccountName, MailboxName, UID, Sender, ToList, CCList, DateSent, Subject, Flags, MsgRead, AttachmentIndex, RequestReceipt, Deleted )
SELECT :AccountName, :MailboxName, :UID, :Sender, :ToList, :CCList, :DateSent, :Subject, :Flags, :MsgRead, :AttachmentIndex, :RequestReceipt, :Deleted
WHERE NOT EXISTS( 
	SELECT UID FROM emailheaders_13 
	WHERE UID = :uid 
	AND AccountName ilike :accountname 
	AND MailboxName ilike :mailboxname 
)
I now get the error:
"operator does not exist: integer = character varying"

when I call prepare.

If I take the AccountName and MailboxName conditions out of the subselect, I don't get the error. If I set the UserParamTypes = False, I'm back to the "Inconsistent Types deduced..." error.

I'm using Delphi 7, PostgreSQL 8.3

Any ideas on how I can get this to work properly?

Thanks

Posted: Fri 29 May 2009 06:13
by Plash
You should set the DataType property of parameters to the correct values. (Set it to ftInteger for the UID parameter.)