Watch, Follow, &
Connect with Us

For forums, blogs and more please visit our
Developer Tools Community.


Welcome, Guest
Guest Settings
Help

Thread: TIBDataset Field "CAST" not found



Permlink Replies: 1 - Last Post: Mar 7, 2018 10:48 PM Last Post By: Adalberto Baldini Threads: [ Previous | Next ]
Adalberto Baldini

Posts: 139
Registered: 1/31/12
TIBDataset Field "CAST" not found
Click to report abuse...   Click to reply to this thread Reply
  Posted: Mar 7, 2018 6:21 AM
Delphi® XE5 Version 19.0.14356.6604

I build at run time this sql :
'Select (Case when O_ABINP = '''' then ''Sede'' else O_ABINP end) ABINP, O_DECIMAL_SCALETOT DECIMAL_SCALENAZ, sum(O_SDOEX) SDOTOT '#$D#$A', sum(case when o_fil = ''CAST'' then O_SDOEX else 0 end) as "CAST" '#$D#$A'from SDICOGE_COMPUTE_GLOBAL_ABFIL_CONTI (:i_csoc, :i_lastdata, :i_daabinp, :i_aabinp, :i_daconto, :i_aconto, :allamb, :allfil )'#$D#$A'WHERE'#$D#$A'O_MASTRO = :MASTRO and O_DSPCTO = :DSPCTO and O_CURCYNAZ = :CURCYNAZ'#$D#$A'GROUP BY'#$D#$A'O_ABINP, O_DECIMAL_SCALETOT'#$D#$A'ORDER BY'#$D#$A'O_ABINP'#$D#$A

that should be read like :
Select (Case when O_ABINP = '' then 'Sede' else O_ABINP end) ABINP, O_DECIMAL_SCALETOT DECIMAL_SCALENAZ, sum(O_SDOEX) SDOTOT
, sum(case when o_fil = 'CAST' then O_SDOEX else 0 end) as "CAST"
from SDICOGE_COMPUTE_GLOBAL_ABFIL_CONTI (:i_csoc, :i_lastdata, :i_daabinp, :i_aabinp, :i_daconto, :i_aconto, :allamb, :allfil )
WHERE
O_MASTRO = :MASTRO and O_DSPCTO = :DSPCTO and O_CURCYNAZ = :CURCYNAZ
GROUP BY
O_ABINP, O_DECIMAL_SCALETOT
ORDER BY
O_ABINP

at run time I am inserting from line 2, one or more lines like this :

, sum(case when o_fil = 'CAST' then O_SDOEX else 0 end) as "CAST"

as user inserted data with word CAST that is a reserved word I set instruction above adding " " to the name of field

In IBConsole and IBExpert it works fine but in TIBDataset it raises error : Field "CAST" not found

I cant change user data, how can I build expression to accept a sql reserved work as field name ?

Adalberto Baldini
Adalberto Baldini

Posts: 139
Registered: 1/31/12
Re: TIBDataset Field "CAST" not found
Click to report abuse...   Click to reply to this thread Reply
  Posted: Mar 7, 2018 10:48 PM   in response to: Adalberto Baldini in response to: Adalberto Baldini
It works. no error from sql text, it came from an event code.

Adalberto
Legend
Helpful Answer (5 pts)
Correct Answer (10 pts)

Server Response from: ETNAJIVE02