prosportal
prosportal

Reputation: 109

AS400 WRKQRY Concatenate Decimal

Within WRKQRY > Define Result Fields is throwing an error when trying to concatenate two fields where one field contains a decimal.

How do I get a value with a decimal to concatenate?

DSICF = .400

DSIUM = MG

Field       Expression                         Column Heading       
DOSE        DSICF||DSIUM                       DOSE

Value not allowed with concatenation operator.

After doing research, IBM states if any field in the expression is a double-byte character set (DBCS)-graphic, all fields or constants in the expression must be DBCS-graphic.

Still researching.

Upvotes: 0

Views: 3007

Answers (2)

prosportal
prosportal

Reputation: 109

Numeric fields with decimals have to be converted to a string first. However, you lose the decimal in this conversion. In order to add the decimal back, you must parse the string and manually concatenate the decimal.

Example

DCIFC = 0.400
DCIUM = MG

Field           Expression
CNVRTUNIT        digits(DCIFC)  //Converts .400 to 0000000400 

NEWUNIT         substr(CNVRTUNIT,7,1)||'.'||substr(CNVRTUNIT,8,2)||'/'||DCIUM

-----
NEWUNIT now equals 0.400/MG

Upvotes: 1

Charles
Charles

Reputation: 23823

DIGITS() appears to be the only operator Query for i supports for numeric to character conversion. I suspect that it won't give you what you want...

CHAR() and VARCHAR() work for dates, times, & timestamps...

You'd be best served by moving off the unsupported and way outdated Query for i product to an SQL based solution.

IBM wants you to use WebQuery...

But Query Manager (STRQM) is a 5250 tool that can even read & execute your Query/400 queries. In prompted mode, it is similar to Query/400, but with all the functionality of SQL.

Upvotes: 1

Related Questions