How to Convert Uint64 to Int64

Post questions here relative to DataStage Enterprise/PX Edition for such areas as Parallel job design, Parallel datasets, BuildOps, Wrappers, etc.

Moderators: chulett, rschirm, roy

Post Reply
mailravi.dw@gmail.com
Participant
Posts: 19
Joined: Sat Dec 19, 2009 8:50 am
Location: Chennai

How to Convert Uint64 to Int64

Post by mailravi.dw@gmail.com »

Actually i am using "Row Number column" property of Sequential file to generate Sequence Number. The "Row number Column" produces unsigned value like uint32 or uint64. I need to forcefully convert uint64 to int64 why because i could not locate Extended option at Sequential file column tab.

How to convert uint64 to int64 or How to enable Extended option at Sequential file Column tab. Both the solutions will solve the problem. Your inputs are greatly appreciated.

Thanks
Ravi
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

Assuming that the unsigned int will fit into a normal int then (a) you don't need to perform a conversion as the two values are identical at a bit level and/or (b) put in a transform, copy or other stage in your stream and remove the "unsigned" attribte from the output stream and you will get an implicit type conversion.
mailravi.dw@gmail.com
Participant
Posts: 19
Joined: Sat Dec 19, 2009 8:50 am
Location: Chennai

Post by mailravi.dw@gmail.com »

you are absolutely right. It is automatically converting uint64 to int64 and result is also fine.But i am getting a warning as below.

When checking operator: When binding input interface field "ROWNUMBER_COL" to field "ROWNUMBER_COL": Implicit conversion from source type "uint64" to result type "int64": Possible range limitation.

How to erodicate this warning without using message Handler.
mailravi.dw@gmail.com
Participant
Posts: 19
Joined: Sat Dec 19, 2009 8:50 am
Location: Chennai

Post by mailravi.dw@gmail.com »

I Managed to resolve the warning.

At target side also i defined it as uint64 as "Datatype is BIGINT and enabled Unsigned at Exteneded option of Columns Tab " rather than converting to int64(BIGINT).

Really is there any conversion functions available which is used to convert uint64 to int64 or vise versa.

Thanks
Ravi.K
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

None that won't give you the warning (this is a good example of where a job level message handler is very useful). You can convert an unsigned int32 to a signed int64 without a warning, but an unsigned int64 can potentially not fit into a signed int64 and thus the warning.
mailravi.dw@gmail.com
Participant
Posts: 19
Joined: Sat Dec 19, 2009 8:50 am
Location: Chennai

Post by mailravi.dw@gmail.com »

Hi Andrew,

The conversion is taking place implicitly.

How can we explicitly convert unsigned int32 to a signed int64? Is there any function available. If yes, kindly confirm the function.

Thanks
Ravi K
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

I did a quick look into the Parallel Job Developers Guide and found no explicit int32 to int64 function.
mailravi.dw@gmail.com
Participant
Posts: 19
Joined: Sat Dec 19, 2009 8:50 am
Location: Chennai

Post by mailravi.dw@gmail.com »

Hi ArndW,

Thanks for your inputs and time.

Thanks
Ravi K
Post Reply