PostgreSQL SUBSTRING Macro

Discussion of open issues, suggestions and bugs regarding UniDAC (Universal Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
eduardomendes
Posts: 28
Joined: Wed 24 Feb 2010 14:08

PostgreSQL SUBSTRING Macro

Post by eduardomendes » Tue 31 Jul 2012 12:10

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!

AlexP
Devart Team
Posts: 5530
Joined: Tue 10 Aug 2010 11:35

Re: PostgreSQL SUBSTRING Macro

Post by AlexP » Tue 31 Jul 2012 14:29

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;

eduardomendes
Posts: 28
Joined: Wed 24 Feb 2010 14:08

Re: PostgreSQL SUBSTRING Macro

Post by eduardomendes » Tue 31 Jul 2012 14:44

Hi AlexP,

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

Why?

Thanks!

AlexP
Devart Team
Posts: 5530
Joined: Tue 10 Aug 2010 11:35

Re: PostgreSQL SUBSTRING Macro

Post by AlexP » Wed 01 Aug 2012 10:30

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.

eduardomendes
Posts: 28
Joined: Wed 24 Feb 2010 14:08

Re: PostgreSQL SUBSTRING Macro

Post by eduardomendes » Wed 01 Aug 2012 11:43

Thanks AlexP!

Post Reply