Midrange News for the IBM i Community


Posted by: Tim Brinker
Variable Expression
has no ratings.
Published: 10 May 2012
Revised: 23 Jan 2013 - 2805 days ago
Last viewed on: 26 Sep 2020 (4635 views) 

Using IBM i? Need to create Excel, CSV, HTML, JSON, PDF, SPOOL reports? Learn more about the fastest and least expensive tool for the job: SQL iQuery.

Variable Expression Published by: Tim Brinker on 10 May 2012 view comments(5)

Return to midrangenews.com home page.
Sort Ascend | Descend

COMMENTS

(Sign in to Post a Comment)
Posted by: DaleB
Premium member *
Reading, PA
Comment on: Variable Expression
Posted: 8 years 4 months 20 days 16 hours 9 minutes ago

So the %DEC is secondary. What you really want is a subprocedure that evaluates a string containing an infix expression, and returns a numeric result:

Equation = '5+2*2';
Result = %DEC(evalExpression(Equation): 10: 3);

Anyone have an example of this? There's probably a way to do it with embedded SQL, along the lines of SELECT 5+2*2 FROM SYSIBM.SYSDUMMY, but you'd have to do it dynamically, since you don't know the string ahead of time.

Posted by: bobcozzi
Site Admin ****
Chicagoland
Comment on: Variable Expression
Posted: 8 years 4 months 20 days 16 hours 9 minutes ago

Yes and no.

You'd need to use embedded SQL and use (probably) the SET followed by execute immediate... have to think about that.

Posted by: tbrinkereaglewindowcom
Premium member *
Comment on: Variable Expression
Posted: 8 years 4 months 20 days 15 hours 25 minutes ago

Thanks for the quick response.

 

I believe SQL will work for what I am trying to do.

Posted by: TFisher
Premium member *
Comment on: Variable Expression
Posted: 8 years 4 months 20 days 8 hours 31 minutes ago

Isn't there a C function that will allow this? 

Posted by: bobcozzi
Site Admin ****
Chicagoland
Comment on: Variable Expression
Posted: 8 years 4 months 20 days 4 hours 20 minutes ago

No. There is however a Java!--script-- instruction that will do this.