CAST Varchar

Database
Lee
Enthusiast

CAST Varchar

This is a cross posting from a question in the Connectivity forum as I am not sure where the resolution fits - apologies if inappropriate:

We are having in issue in that a WebFocus report cannot read a view and we have narrowed it down to the columns below..

My question is there is anything in the CAST statement that can declare the result as ANSI, I did see one reference on here to an ANSI explicit CAST but am struggling to find.

All advice gratefully received! Thank you

,cast(case

when  SD1.EDWSS46_DLR_C

  is not null

  then  SD1.EDWSS44_DLR_DSTRCT_N

  else null

  end as Varchar(80)) as EDWSS44_DLR_DSTRCT_N

,Cast(case

when   SD1.EDWSS46_DLR_C

  is not null

  then SD1.EDWSS45_DLR_ZONE_D

  else null

  end as char(2)) as EDWSS45_DLR_ZONE_C

,cast(case

when  SD1.EDWSS46_DLR_C

  is not null

  then SD1.EDWSS45_DLR_ZONE_N

  else null

  end as varchar(80))  as EDWSS45_DLR_ZONE_N

4 REPLIES
Teradata Employee

Re: CAST Varchar

CAST is an ANSI construct.

What error are you getting from the tool? Have you talked to WebFocus about the error?

Lee
Enthusiast

Re: CAST Varchar

Ahha - thank you

Yes, the problem I have is that the WF team are pointing at the code on the view and I think it's in the connection set up (from reviewing other posts)

We are getting error 3996 Truncation of right string..

This answer will help me push the question, thank you :-)

Teradata Employee

Re: CAST Varchar

In Teradata mode, string right truncation is ignored. But in ANSI mode, you get 3996 error if a non-blank character is truncated.

Eliminate the error either by increasing the length for the CAST or using SUBSTRING inside the CAST (if you intend to truncate the long values). Then the SQL will work in both ANSI and Teradata mode.

Lee
Enthusiast

Re: CAST Varchar

Thank you!

The interesting thing I learn was what works in Teradata directly gets in a twist with WF SQL Passthru - good to learn!