Expand my Community achievements bar.

Adobe Campaign User Groups are live now. Join our Adobe Campaign User Groups and connect with your local leaders!
SOLVED

Case conditional when updating data?

Avatar

Level 4

In order to match a Recipients column, I need to satisfay this conditions:

1.- If customer_cic is length 8, then add 4 spaces at the begging. 
2.- If customer cic is length 12, leave it as it is.


I tried: Case(When(Length(customer_cic)==12,customer_cic, Else('    '+customer_cic)) 

But is giving me error.

ogonzalesdiaz_0-1697494666272.png

 

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

Hello @ogonzalesdiaz 

 

The correct syntax is:

 

Case(When(Length(customer_cic)=12,customer_cic), Else('    '+customer_cic))

 


     Manoj
     Find me on LinkedIn

View solution in original post

3 Replies

Avatar

Correct answer by
Community Advisor

Hello @ogonzalesdiaz 

 

The correct syntax is:

 

Case(When(Length(customer_cic)=12,customer_cic), Else('    '+customer_cic))

 


     Manoj
     Find me on LinkedIn

Avatar

Level 4

hi @_Manoj_Kumar_ , I'm getting this error with  that code:

10/17/2023 9:38:07 AM PGS-220000 PostgreSQL error: ERROR: operator does not exist: integer == integer LINE 1: ...cional = case when char_length(W0.sCustomer_cic) == 12 then... ^ HINT: No operator matches the given name and argument types. You might need to add explicit type casts. .

Then I tried: 

Case(When(Length(toString(customer_cic))==12,customer_cic), Else(' '+customer_cic))

But gave me this error. 

10/17/2023 9:32:51 AM PGS-220000 PostgreSQL error: ERROR: operator does not exist: integer == integer LINE 1: ...cional = case when char_length(W0.sCustomer_cic) == 12 then... ^ HINT: No operator matches the given name and argument types. You might need to add explicit type casts. .

I request your kindly help.


 



Avatar

Level 4

Ok, this worked: 

Case(When(Length(customer_cic)=12,customer_cic), Else('    '+customer_cic))


Thank you, Manoj.