Topic: Split the Select statement on several rows

Hello guys,

I have a long Select statement which is only on one row and I have to scroll horizontally to get to the end of the statement.
How could I split the statement on several rows, to be able to view it without scrolling?

Thank you.
Best regards,
Alin

Best regards,
Alin

Re: Split the Select statement on several rows

Hello.


Yes, you can, example:

sql := 'SELECT fieldname ' +
           'FROM tablename';
Dmitry.

Re: Split the Select statement on several rows

Thank you, is working.
Another question is, in my select statement I have Boolean values. I show those values in a tablegrid, but I get values 1 and 0 and I need to show them as yes or No.
how can I achieve that?

Thank you so much for your reply.

Best regards,
Alin

Best regards,
Alin

Re: Split the Select statement on several rows

Place this inside your SELECT

Case Bool_Field When 1 then 'Yes' When 0 then 'No' End

Re: Split the Select statement on several rows

Good morning,

I get an error message which says 'OF' expected:


frmArticoleAdd.grdBOM.dbSQL:='SELECT tblBom.id,BOMName,ArticleNo, ArticleName,Quantity,UmNo,Active, Fixed from tblBOM ' +
   'left join tblArticol on tblBom.id_tblArticol1=tblArticol.id ' +
   'left join tblBomType on tblBom.id_tblBomType=tblBomType.id ' +
   'left join tblUm on tblBom.id_tblUM=tblUm.id ' +
   'where id_tblArticol= '+ frmArticoleAdd.txtArticolID.text ;

   Case Active when 1 then 'Yes' when 0 then 'No' End
   Case Fixed when 1 then 'Yes' when 0 then 'No' End

   frmArticoleAdd.grdBOM.dbListFieldsNames:='ID,Tip BOM, Nr. Articol, Nume Articol, Cantitate,UM, Activ? ,Fix?';
   frmArticoleAdd.grdBOM.dbSQLExecute;

Thanks.

Best regards,
Alin

6 (edited by ehwagner 2020-03-20 16:26:49)

Re: Split the Select statement on several rows

Try this

frmArticoleAdd.grdBOM.dbSQL:='SELECT tblBom.id,BOMName,ArticleNo, ArticleName,Quantity,UmNo, '
   + 'Case Active when 1 then "Yes" when 0 then "No" End,'
   + 'Case Fixed when 1 then "Yes" when 0 then "No" End '  + 
   'from tblBOM ' +
   'left join tblArticol on tblBom.id_tblArticol1=tblArticol.id ' +
   'left join tblBomType on tblBom.id_tblBomType=tblBomType.id ' +
   'left join tblUm on tblBom.id_tblUM=tblUm.id ' +
   'where id_tblArticol= '+ frmArticoleAdd.txtArticolID.text ;

   frmArticoleAdd.grdBOM.dbListFieldsNames:='ID,Tip BOM, Nr. Articol, Nume Articol, Cantitate,UM, Activ? ,Fix?';
   frmArticoleAdd.grdBOM.dbSQLExecute;

Re: Split the Select statement on several rows

Thank you ehwagner,

it's working.

Best regards,Alin.

Best regards,
Alin