sql - Dynamically concatenating multiple columns in a sequence -
sql - Dynamically concatenating multiple columns in a sequence -
i have requirement in have concatenate fields based on sequence given in table along respect lengths. eg..
input:
table a: (below fields , respective values, not fields have values)
kschl - zic0 (key) kotabnr - 521 (key) matnr kunnr--> 1234567890 lifnr vkorg--> a234 prctr kunre--> 4355325363 lifre--> 88390234
table b: (it contains same fields in table , have sequence number in concatenation should happen. length field(len) have corresponding field lengths(pipe delimited) should considered in concatenation)
kschl - zic0 (key) kotabnr - 521 (key) matnr kunnr--> 1 lifnr vkorg--> 3 prctr kunre--> 2 lifre--> 4 len 10|10|4|10
expected result:
kschl - zic0 (key) kotabnr - 521 (key) matnr kunnr 1234567890 lifnr vkorg a234 prctr kunre 4355325363 lifre 0088390234 concat_string 12345678904355325363a2340088390234
note: if field length given in table b doesn't match actual size of fields then, field should filled 2 left spaces while concatenation.. eg. in above illustration lifnr
value = 88390234(len=8)
then, after concatenation value should below
12345678904355325363a234 88390234
i can have number of fields concatenation..above illustration 4... should dynamic plenty handle number of fields..
can 1 help me on how can accomplish in sql?
sql
Comments
Post a Comment