Doubt in Constraint
Moderators: chulett, rschirm, roy
Doubt in Constraint
Hi,
I have an requirement like this. I have a columm in transformer called EconomicDevalution with DEC(7,4).The data is comming to transformer from xml and Iam loading to a DB2 table.I have to check if that Economic Devalution contains DEC(7,4) length. If it doesnot I have to load in a file. When I give in constraint I can give at as Link.EconomicDevalution but not as Link.EconomicDevalution DEC(7,4) can I give like this to achieve my target . Please correct me if Iam wrong.And also help me how to achieve this.
Thanks,
Somaraju
I have an requirement like this. I have a columm in transformer called EconomicDevalution with DEC(7,4).The data is comming to transformer from xml and Iam loading to a DB2 table.I have to check if that Economic Devalution contains DEC(7,4) length. If it doesnot I have to load in a file. When I give in constraint I can give at as Link.EconomicDevalution but not as Link.EconomicDevalution DEC(7,4) can I give like this to achieve my target . Please correct me if Iam wrong.And also help me how to achieve this.
Thanks,
Somaraju
somaraju
Hi Rasi,
I have seen isvalid function .It was given isvalid(%typestring%,%Valuestring%). please correct me if iam wrong isvalid(decimal,7,4).but before inserting in to a table I have to check ex : contract type is decimal (7,4) if it doesnot have decimal(7,4) I have to send to a reject link . How to check with isvalid function in transformer please help me
Thanks
Somaraju
I have seen isvalid function .It was given isvalid(%typestring%,%Valuestring%). please correct me if iam wrong isvalid(decimal,7,4).but before inserting in to a table I have to check ex : contract type is decimal (7,4) if it doesnot have decimal(7,4) I have to send to a reject link . How to check with isvalid function in transformer please help me
Thanks
Somaraju
somaraju
-
- Charter Member
- Posts: 166
- Joined: Wed Mar 16, 2005 6:52 am
- Location: Mumbai, India
What we did to perform this check was to read it as a varchar; use the num() function to see if it is a valid number and then convert it to the required decimal format.
If not valid, the varchar can be written to reject link.
Just one thing.. Watch out for RCP issues!
If not valid, the varchar can be written to reject link.
Just one thing.. Watch out for RCP issues!
Amey Vaidya<i>
I am rarely happier than when spending an entire day programming my computer to perform automatically a task that it would otherwise take me a good ten seconds to do by hand.</i>
<i>- Douglas Adams</i>
I am rarely happier than when spending an entire day programming my computer to perform automatically a task that it would otherwise take me a good ten seconds to do by hand.</i>
<i>- Douglas Adams</i>
Somu
The IsValid function will verify whether it is of valid datatype decimal or integer but it won't check to see whether you got decimal(7,4) or not. If you want to do that then convert the decimal in String and separate the scale and verify.
The IsValid function will verify whether it is of valid datatype decimal or integer but it won't check to see whether you got decimal(7,4) or not. If you want to do that then convert the decimal in String and separate the scale and verify.
Regards
Siva
Listening to the Learned
"The most precious wealth is the wealth acquired by the ear Indeed, of all wealth that wealth is the crown." - Thirukural By Thiruvalluvar
Siva
Listening to the Learned
"The most precious wealth is the wealth acquired by the ear Indeed, of all wealth that wealth is the crown." - Thirukural By Thiruvalluvar
-
- Charter Member
- Posts: 166
- Joined: Wed Mar 16, 2005 6:52 am
- Location: Mumbai, India
We have worked this with Sequential Files.
Actual Input Field: Field1[decimal(7,4) Nullable]
Read it in as : Field1[varchar(9) Nullable] (Check the XML File in a text editor to get the actual length of this field. Usually add 2(1 for a leading space and 1 for the decimal point)).
In a transformer Stage Variable:
SvCheckNumField1<-If Num(Trim(NullToEmpty(In.Field1))) then @TRUE else @FALSE
For the Output:
RCP Off for this Link
Constraint SvCheckNumField1
Derivations:
Field1[Decimal(7,4) Nullable]<-StringToDecimal(IN.Field1)
For the Reject:
RCP Off for this Link
Constraint not(SvCheckNumField1)
Derivations:
Field1[Varchar(9) Nullable]<-IN.Field1
Thats it.
Along with num, if you want to do additional validations about the number of decimals, etc, it can be done using additional validations either in the Stage Variable or in additional stage variables (depending on the level of detail of your error reporting requirements).
Actual Input Field: Field1[decimal(7,4) Nullable]
Read it in as : Field1[varchar(9) Nullable] (Check the XML File in a text editor to get the actual length of this field. Usually add 2(1 for a leading space and 1 for the decimal point)).
In a transformer Stage Variable:
SvCheckNumField1<-If Num(Trim(NullToEmpty(In.Field1))) then @TRUE else @FALSE
For the Output:
RCP Off for this Link
Constraint SvCheckNumField1
Derivations:
Field1[Decimal(7,4) Nullable]<-StringToDecimal(IN.Field1)
For the Reject:
RCP Off for this Link
Constraint not(SvCheckNumField1)
Derivations:
Field1[Varchar(9) Nullable]<-IN.Field1
Thats it.
Along with num, if you want to do additional validations about the number of decimals, etc, it can be done using additional validations either in the Stage Variable or in additional stage variables (depending on the level of detail of your error reporting requirements).
Amey Vaidya<i>
I am rarely happier than when spending an entire day programming my computer to perform automatically a task that it would otherwise take me a good ten seconds to do by hand.</i>
<i>- Douglas Adams</i>
I am rarely happier than when spending an entire day programming my computer to perform automatically a task that it would otherwise take me a good ten seconds to do by hand.</i>
<i>- Douglas Adams</i>
HI Somu,
May I know what is that you want to check?
Is that you want to check whether it is a decimal or whether it compatable to the given layout or whether it matches to 7,4 (filled with all character?)
If you want to check whether it is decimal you can use IsValid in the constataint as mentioned.
No need to bother about layout compatability, input stage will take of it.
If you want to check if it has all 7,4 with numbers, check whether the length of the value after converting to string and after striping the leading 0's is equal to 7.
May I know what is that you want to check?
Is that you want to check whether it is a decimal or whether it compatable to the given layout or whether it matches to 7,4 (filled with all character?)
If you want to check whether it is decimal you can use IsValid in the constataint as mentioned.
No need to bother about layout compatability, input stage will take of it.
If you want to check if it has all 7,4 with numbers, check whether the length of the value after converting to string and after striping the leading 0's is equal to 7.
Impossible doesn't mean 'it is not possible' actually means... 'NOBODY HAS DONE IT SO FAR'
Hi kumar,
Nice to see your post. Actually my requirement is if economic devaluation is not compatible with Dec(7,4) I must raise an error. I have a columm with name EC dec(7,4) in db2 . If I am getting from input more than dec(7,4) and when I tried to load to db2 I will get an error in log but I want to send that error to a file with the incomming data that is failed.Is there a way to load the record in a file that is not loaded in db2 to a reject link
Thanks,
Somaraju.
Nice to see your post. Actually my requirement is if economic devaluation is not compatible with Dec(7,4) I must raise an error. I have a columm with name EC dec(7,4) in db2 . If I am getting from input more than dec(7,4) and when I tried to load to db2 I will get an error in log but I want to send that error to a file with the incomming data that is failed.Is there a way to load the record in a file that is not loaded in db2 to a reject link
Thanks,
Somaraju.
somaraju
So its data type compatability.
Say if your file is tab delimited, and if the input is 8,4. The input stage you use to read the file will reject the record with an import warning thrown.
If you need to raise an error based on this, it would be easy to maintain a seperate job to import the input data into datastage (let the output of this job be dataset for performance concern). Check for rejection of records in the job with the warning related to this field and particularlay the compatability. you can use LinkInfo or dsjob -longdetail for that purpose. Based on this you can raise error or load into table.
Say if your file is tab delimited, and if the input is 8,4. The input stage you use to read the file will reject the record with an import warning thrown.
If you need to raise an error based on this, it would be easy to maintain a seperate job to import the input data into datastage (let the output of this job be dataset for performance concern). Check for rejection of records in the job with the warning related to this field and particularlay the compatability. you can use LinkInfo or dsjob -longdetail for that purpose. Based on this you can raise error or load into table.
Impossible doesn't mean 'it is not possible' actually means... 'NOBODY HAS DONE IT SO FAR'