Page 1 of 1

Help for sql select statement

Posted: Mon Mar 30, 2020 2:42 pm
by Horizon
Hi,

I have this code:

Code: Select all

        xTARIH = CTOD("30/03/2020")
        USE AJANDA ORDER "BAGNO" ALIAS "AJANDA_Array_Guncelle" READONLY
        SET SCOPE TO "HY00000000", "HY99999999"
        SSART :=  'xTARIH >= AJ_BTAR .AND. xTARIH <= AJ_TARIH'
        SET FILTER TO &SSART
I use MariaDB. How can I convert this to sql select for using oCn:RowSet method?

Thanks.

Re: Help for sql select statement

Posted: Mon Mar 30, 2020 4:11 pm
by nageswaragunupudi

Code: Select all

SELECT * FROM ajanda WHERE BAGNO BETWEEN 'HY00000000' AND 'HY99999999' AND AJ_BTAR >= '2020-03-30' AND AJ_TARIH <= '2020-03-30'
 
OR

Code: Select all

SELECT * FROM ajanda WHERE BAGNO LIKE 'HY%' AND AJ_BTAR >= '2020-03-30' AND AJ_TARIH <= '2020-03-30'

Re: Help for sql select statement

Posted: Mon Mar 30, 2020 4:19 pm
by nageswaragunupudi
With FWH MariaDB, it is not necessary to hard code all the values

Code: Select all

xTARIH = CTOD("30/03/2020")
cSql := "SELECT * FROM ajanda WHERE BAGNO BETWEEN ? AND ? AND AJ_BTAR >= ? AND AJ_TARIH <= ?"

oRs := oCn:RowSet( cSql, { "HY00000000", "HY99999999", xTARIH } )
 

Re: Help for sql select statement

Posted: Mon Mar 30, 2020 6:19 pm
by Horizon
Thank you Mr. Rao.