Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 4 of 4 total
Thread CAST in my SQL
Tue, Apr 7 2009 8:15 PMPermanent Link

Pat
Hi all,

this works fine in dbsys  (v4)

SELECT DISTINCT CAST(Payroll.PayrollCode AS Integer) AS "Integer
Payroll Code"
FROM PayTran
LEFT JOIN Payroll  ON PayTran.PayrollID = Payroll.PayrollID
ORDER BY "Integer Payroll Code"

but when I put the following in my app I get error #11949 - expect
column name but found 'Payroll Code'.

SQL.Add('SELECT DISTINCT CAST(Payroll.PayrollCode AS Integer) AS ' +
QuotedStr('Payroll Code') + ' ');
SQL.Add('FROM PayTran');
SQL.Add('LEFT JOIN Payroll  ON PayTran.PayrollID =
Payroll.PayrollID');
SQL.Add('ORDER BY ' + QuotedStr('Payroll Code') + ' ');

I have tried variations of ) and ( and ' around the CAST, but still
cannot get it to compile Frown     Any ideas?

Thanks.

Regards,
Pat
Tue, Apr 7 2009 8:46 PMPermanent Link

"Jeff Cook"
Kia Orana Pat

> ORDER BY "Integer Payroll Code"
>
> SQL.Add('ORDER BY ' + QuotedStr('Payroll Code') + ' ');
>

It's because these give you different strings:-

1. "Integer Payroll Code"
2. 'Integer Payroll Code'

DBISAM treats things in double quotes as column names and things in
single quotes as literals.

You need either

SQL.Add('ORDER BY "Payroll Code" ');

or simply

SQL.Add('ORDER BY 1');

Kia Manuia

Jeff

--
Jeff Cook
Aspect Systems Ltd
www.aspect.co.nz
+
Joan and Jeff Cook
The Cooks Oasis
www.cookislandsoasis.com
Tue, Apr 7 2009 10:28 PMPermanent Link

Pat
Hi Jeff,

>1. "Integer Payroll Code"
>2. 'Integer Payroll Code'
>
>DBISAM treats things in double quotes as column names and things in
>single quotes as literals.

Jackpot!! that's the reason, thanks Jeff.

Pat

PS. you're not in this are you?
http://www.youtube.com/watch?v=R0QQIDJ2j30  Wink
Wed, Apr 8 2009 4:19 AMPermanent Link

"Jeff Cook"
Pat wrote:
>
> PS. you're not in this are you?
> http://www.youtube.com/watch?v=R0QQIDJ2j30  Wink

Nope!  I'd love to be in it but the old legs aren't up to it!


--
Jeff Cook
Aspect Systems Ltd
www.aspect.co.nz
+
Joan and Jeff Cook
The Cooks Oasis
www.cookislandsoasis.com
Image