In xbase++ It would be written

Procedure Main()
   Local ID_TAB_AGENTI := "TAB_AGENTI"
   Local ID_TAB_CODDSP := "TAB_AGENTI"
   Local cSql          := "select 'Hello' as fld"
   Local cAnnDsp       := "2000"
   Local cFrmSQL

TEXT INTO cFrmSQL

select ( select substr( crectab, 1, 20 ) as crectab
   from tabtab where ctiptab = %1$t
   and ckeytab = ccodage order by 1 ) as cdesage, ;
   sum( case when ( select substr( crectab, 35, 1 ) from tabtab
   where ctiptab = %2$t and ckeytab = ccoddsp ) = '' or
   ( select substr( crectab, 35, 1 ) from tabtab
   where ctiptab = %2$t and ckeytab = ccoddsp ) is null
   then nimpdsp
   else 0 end) as ntotfat0,
   sum( case when ( select substr( crectab, 35,1 ) from tabtab
   where ctiptab = %2$t and ckeytab = ccoddsp ) = '1'
   then nimpdsp
   else 0 end) as ntotfat1,sum(nimpdsp) as ntotdsp,
   %3$s from tabtotdsp
   left join tabtab on tabtab.ctiptab= %2$t and ccoddsp=tabtab.ckeytab
   where canndoc = %4$t

END TEXT

   ? sql_Sprintf( cFrmSQL, ID_TAB_AGENTI, ID_TAB_CODDSP, cSql, cAnnDsp )

   Wait
return

Very usefull for long embebed SQL commands
Xavi's suggestion copuld be easily translated to that command

HTH
Angel

_______________________________________________
Harbour mailing list (attachment size limit: 40KB)
[email protected]
http://lists.harbour-project.org/mailman/listinfo/harbour

Reply via email to