Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Rounding function in 4GL 2

Status
Not open for further replies.

qtie

Programmer
May 16, 2003
11
US
Hello,

Does anyone know if there's a Rounding function in 4GL?
Any help is appreciated.

Thanks,
Quinn
 
Hi,

4GL does not have a in-built function to support rounding of values. However, you may rely on SQL ROUND keyword to accomplish this.

Syntax:
ROUND(expression, rounding factor)

Examples:
SELECT order_num, ROUND(total_price) FROM items WHERE ROUND(total_price)=300.00;
SELECT ROUND(425.46), ROUND(total_price) FROM items;

How factor works:
ROUND (90536.8746, -2) = 90500.00
ROUND (90536.8746, 0) = 90537.00
ROUND (90536.8746, 2) = 90536.87

9 0 5 3 6 . 8 7 4 6
| | |
-2 ---------------- | |
0 -------------------- |
2 ------------------------

Cursor preparation Ex:
PREPARE round_id FROM "SELECT NVL(ROUND(?, ?),0) FROM systables WHERE tabid=1"
DECLARE round_cur CURSOR FOR round_id
FREE round_id

Execute Ex:
LET var1=125.62
LET var2=2

OPEN round_cur USING var1, var2
EXECUTE round_id INTO mval

Regards,
Shriyan
"No amount of careful planning will ever replace dumb luck."
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top