Page 1 of 1

PostgreSQL SUBSTRING Macro

Posted: Tue 31 Jul 2012 12:10
by eduardomendes
Hi,

when trying use SUBSTRING macro occurs error.

"No argument for format '%s'."
UniQuery.add('SELECT {fn SUBSTRING(FIELD,1,2)} FROM TABLE');
UniQuery.Open();

But if I execute query like this, the problem not occurs:

UniQuery.add('SELECT {fn SUBSTRING(FIELD, 1, 2)} FROM TABLE');
UniQuery.Open();


How can I fix this problem?

Thanks!

Re: PostgreSQL SUBSTRING Macro

Posted: Tue 31 Jul 2012 14:29
by AlexP
hello,

This problem is due to the fact that the "1,2" symbols are perceived as a number 1.2 when parsing the string. To make your statement correct even without spaces, you should change the DecimalSeparator fractional part separator, i.e.

DecimalSeparator := '.';
UniQuery2.SQL.Add('SELECT {fn SUBSTRING(DNAME,1,2)} FROM DEPT');
UniQuery2.Open;

Re: PostgreSQL SUBSTRING Macro

Posted: Tue 31 Jul 2012 14:44
by eduardomendes
Hi AlexP,

this problem not occours with SQL Server, only with PostgreSQL.

Why?

Thanks!

Re: PostgreSQL SUBSTRING Macro

Posted: Wed 01 Aug 2012 10:30
by AlexP
hello,

We will fix the behaviour of the PostgreSQL provider for corerct work with such parameters in the next version.
For the time being, you can either change DecimalSeparator or surround numeric parameters with spaces.

Re: PostgreSQL SUBSTRING Macro

Posted: Wed 01 Aug 2012 11:43
by eduardomendes
Thanks AlexP!