URGENT! Working with SQLLE. Can't convert character string '-100' to negative for SQL output.


Please keep in mind I'm working on V5R1M0.

I'm working with a comma delimited file.

I need to be able to extract numbers and currency that may contain negatives. ('-100')
for example: A field may contain -1257.35 or -3456 between commas.

I need a routine to take any combination (-1257.35 or -3456) and change it to -125735 or -34560 in a field to do an SQL update to field defined in an SQL fetch.

The problem is I can create a negative numeric field, but when the field is moved to a character field
to perform the SQL update, I lose the negative information. Help!

This solution is needed urgently.

Please query me if necessary for more detail if necessary.

I believe daveslater created the original routine back in june using embedded SQL.

Thanks,

Pipster1  
Phillip KnoxSenior Systems AnalystAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

MurpheyApplication ConsultantCommented:
Hi Pipster1,

Have you tried to change the CSV file to a PF with the command CPYFRMIMPF (Copy From Import File)

Regards,
Murph

0
daveslaterCommented:
Hi
there are 2 solutions that I posted

http:Q_21095755.html
that used a sub procedure and

http:Q_21043876.html
that uses SQL

which is the one that you are useing?


Dave
0
Phillip KnoxSenior Systems AnalystAuthor Commented:
Dave,

I'm actually using both postings in the original program.

The problem is when this statement executes,

c                   eval      sql='UPDATE CSVORD SET ' +  fldname +
c                             ' = ' +  nbr  +          
c                             ' where key =' + %editc(key:'Z')    

I lose the negative information.

Pipster1
0
Cloud Class® Course: Microsoft Azure 2017

Azure has a changed a lot since it was originally introduce by adding new services and features. Do you know everything you need to about Azure? This course will teach you about the Azure App Service, monitoring and application insights, DevOps, and Team Services.

daveslaterCommented:
Hi
I think it is in the todec procedure
chage the last bit to this

C** test for -ve                                          
c                   eval      i=%scan('-':var)            
c                   if        i<>0                        
c                   eval      %subst(var:I:1)=' '          
c                   endif                                  
c                                                          
c                   MOVEL     CHAR10        NBR            
c                   MOVE      CHAR5         NBR            
c                                                          
c                   if         I<>0                        
c                   z-sub     nbr           nbr            
c                   endif                                  
C                                                          
C                   RETURN    NBR                          


dave
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Phillip KnoxSenior Systems AnalystAuthor Commented:
Dave,
Sorry, the 'nbr' field is character.

The problem I'm having is trying to use a numeric field in the sql string.
The compile throws up with RNF-7416 'The types of the right and left hand side do not match in
the EVAL operation'.
AND
RNF-7421 'Operands are not compatible with the type of operator.'

Thanks,

Pipster1
0
daveslaterCommented:
Hi try
if            %subst(Nbr:1:1)='-'
eval         nbr=%subsr(nbr: 2) + '-'
endif


before the SQL

Dave
0
Phillip KnoxSenior Systems AnalystAuthor Commented:
Will do.

Pipster1
0
MurpheyApplication ConsultantCommented:
I didn't use tham my self, but isn't the move zone suff the things Pipster1 is looking for:

“MHHZO (Move High to High Zone)”
“MHLZO (Move High to Low Zone)”
“MLHZO (Move Low to High Zone)”
“MLLZO (Move Low to Low Zone)”

If not, maybe it's nice to explain.
0
Phillip KnoxSenior Systems AnalystAuthor Commented:
I ended up contacting IBM because the ideas being provided here weren't working out. (no offense anyone)
I tried using the 'UPDATE DB SET FLD001 = :nbr2 where key =    1'
option and the IBM dudes are puzzled why it isn't working. It's
being sent to development for further study.

I'm splitting the points for all respondents. Thanks.
0
Phillip KnoxSenior Systems AnalystAuthor Commented:
How do I split points among respondents?
0
daveslaterCommented:
Hi
just above where you typethese comments there is a "Split Points" link

Dave
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
IBM System i

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.