Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
29 views

Executing A SQL Query Using 4GL Language

Uploaded by

Axl Axl
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
29 views

Executing A SQL Query Using 4GL Language

Uploaded by

Axl Axl
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

Executing a sql query using 4GL language

By Greytrix | November 22, 2013


0 Comment
There are many a time when we need to get the aggregate or maximum function but 4GL
Language do not offers a syntax for the same.
But we definitely have an option to use SQL queries in 4GL and this does the most of the
job for us.

Just go through the statements mentioned below:

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"

# Assign to a char array the value of SQL_CLOB


Setlob SQL_REQ With SQL_CLOB

# CHAR(RES(80(1)) will create an array of results


For (Char RES(80)(1)) From "5" Sql SQL_REQ As [REQ]
RES1 = num$([F:REQ]RES(0))
Infbox num$(RES1)
Next
End
Return

Find the Database Type to execute the SQL


Query from Sage X3
By Greytrix | June 4, 2016
0 Comment
To implement the business logic we need to use SQL Query to fetch the required data from
the Database. To execute the SQL Query from Sage X3 we need to know the database
type. We can fetch the database type as below:

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.

“3”: This will return when the database type is “Oracle”


“5”: This will return when the database type is “SQL”
And according to database type, the SQL query is executed and data is fetched from
database.

Hope this blog helps!

You might also like