It could be that you're doing the same thing wrong. You don't have to set the DataType manually.
Just assign a value to it. The datatype will be set to the same type as the value. Thus, if it should be a string, use: tparam.asstring := 'hello', if it's a integer, use: tparam.asinteger := 4; just as in the example. Joost > How does it refer to my problem with parameterized queries? > I tried with fpc 2.0.4 (rc3) and the problem still remains... > When I click on "Params" in Object Inspector/Properties, and select my > parameter in the parameters dialog, I should be able to set the DataType > property of the parameter, through the Object inspector. The default value > is "ftUnknown". I change it to "ftString", but Lazarus doesn't save it. When > I open it next time it is "ftUnknown" again, and when I try to set > SQLQuery1.Active:=True, I have the error: "PQConnection1: Unknown fieldtype > for parameter "Parameter"". The parameter is in where clause, of course.... > ----- Original Message ----- > From: <[EMAIL PROTECTED]> > To: <[EMAIL PROTECTED]> > Sent: Friday, August 25, 2006 11:11 PM > Subject: [FPC 0007205]: Parameterized SQL queries to PostgreSQL backend > return incorrect date[time] values > > > > The following issue has been RESOLVED. > ====================================================================== > http://www.freepascal.org/mantis/view.php?id=7205 > ====================================================================== > Reported By: ivankob > Assigned To: Joost > ====================================================================== > Project: FPC > Issue ID: 7205 > Category: FCL > Reproducibility: always > Severity: major > Priority: normal > Status: resolved > Fixed in Revision: r4332 > Old bug id: 0 > Resolution: fixed > Fixed in Version: 2.1.1 > ====================================================================== > Date Submitted: 2006-07-26 09:46 CEST > Last Modified: 2006-08-25 23:07 CEST > ====================================================================== > Summary: Parameterized SQL queries to PostgreSQL backend > return incorrect date[time] values > Description: > See the test program in "additional information" area. > > There're also suspicion on : > > 1) "unprepare" having no action; > > 2) "prepare" not detecting param field types correctly ( a "try..except" > frame around "prepare" is needed to assign the correct type manually after > the exception ) > ====================================================================== > Relationships ID Summary > ---------------------------------------------------------------------- > has duplicate 0007258 Has "7205: Parameterized SQL queri... > ====================================================================== > > ---------------------------------------------------------------------- > Joost - 2006-07-26 14:07 > ---------------------------------------------------------------------- > Yeah, I know this. I'll fix it when I've time, it's not very difficult. > > About the automatic recognition of the parameters: that isn't implemented > at all. And you won't need it, you only have to set a value to the > parameter, and you're done. Try this: > > params[0].asinteger := 1; > open; > > That'll do it. The type is not collected from the db-server, but it's set > if you set a value to the parameter. So you don't need to call the > .prepare seperately. > > ---------------------------------------------------------------------- > ivankob - 2006-07-26 20:29 > ---------------------------------------------------------------------- > >>About the automatic recognition of the parameters: that isn't implemented > at >>all. And you won't need it, you only have to set a value to the > parameter, >>and you're done. Try this: > >> > >>params[0].asinteger := 1; > >>open; > > IDE tools having a SQL editor to prepare & test the prepared query ( with > params in format ":NAME" ) rely on the recognition to fill the "Params" > property upon the test attempt.But you're right - it's hardly possible to > detect data type of a parameter in WHERE clause etc. And informative > exception dialogue is better that nothing. > > Issue History > Date Modified Username Field Change > ====================================================================== > 2006-07-26 09:46 ivankob New Issue > 2006-07-26 09:52 Florian Status new => assigned > 2006-07-26 09:53 Florian Assigned To => Joost > 2006-07-26 14:07 Joost Note Added: 0008554 > 2006-07-26 20:29 ivankob Note Added: 0008563 > 2006-08-03 00:17 Joost Fixed in Revision => r4332 > 2006-08-03 00:17 Joost Status assigned => > resolved > 2006-08-03 00:17 Joost Fixed in Version => 2.0.4-rc3 > 2006-08-03 00:17 Joost Resolution open => fixed > 2006-08-25 23:07 Joost Status resolved => > assigned > 2006-08-25 23:07 Joost Status assigned => > resolved > 2006-08-25 23:07 Joost Fixed in Version 2.0.4-rc3 => 2.1.1 > 2006-08-25 23:08 Joost Relationship added has duplicate > 0007258 > ====================================================================== > > _________________________________________________________________ > To unsubscribe: mail [EMAIL PROTECTED] with > "unsubscribe" as the Subject > archives at http://www.lazarus.freepascal.org/mailarchives > -- Met vriendelijke groeten, Joost van der Sluis CNOC Informatiesystemen en Netwerken http://www.cnoc.nl _________________________________________________________________ To unsubscribe: mail [EMAIL PROTECTED] with "unsubscribe" as the Subject archives at http://www.lazarus.freepascal.org/mailarchives