Executing A SQL Query Using 4GL Language
Executing A SQL Query Using 4GL Language
Format:
Local char REQSTR(250)(10)
For [Table name] where document no
REQSTR(0) = “SQL query ”
For fields_0 from Databasetyp Sql REQSTR(0…10) as tablename
Databasetyp: it is a database type for this we have create function so it will identify that
current database uses by X3 server
We have applied this with example.
Local Char REQSTR(250)(10)
For [Z3T] Where 1=1
For [ZQRY] Where DOCNO = [F:Z3T]DOCNO
REQSTR(0) = “SELECT DOCDATE_0, QRNO_0 FROM ZETIQUERY WHERE ROWID
=”+num$([F:ZQRY] ROWID)+””
For (Date DOCDATE, Char QRNO) From func GETDBTYP Sql REQSTR(0..10) As
[ZYOP]
Update [Z3T] Where DOCNO = [ZQRY]DOCNO With DOCDATE = [F:ZYOP]DOCDATE
Update [Z3T] Where DOCNO = [ZQRY]DOCNO With QRNO = [F:ZYOP]QRNO
Update [Z3T] Where DOCNO = [ZQRY]DOCNO With MARK = 2
Next
Next
Next
OTHER EXAMPLE
$GETBANKRECORDS
#**
#* Use this technique of a SQL_CLOB and Setlob to be able to write your sql easier.
#* Append works nicely here to save valuable keystrokes on your keyboard
#*!
Local Clbfile SQL_CLOB(5)
Local Char SQL_REQ(255)(20)
Local Char RES1
SQL_CLOB = "SELECT BAN_0 FROM SEED.ABANK"
Append SQL_CLOB, " ORDER BY BAN_0"
The “TYPDBA” column in “ADOSSIER” table holds the value which will help to identify the
Database type.
The above logic will return which database type is used to store the data.