All Forums Database
Srihari1236 2 posts Joined 10/11
06 Mar 2012
Urgent please --> If then Else condition in BTEQ

Hi all,  

I am trying to implement an "IF THEN ELSE" condition in Bteq.  Can some one help me with making necessary changes to the code. 

 

 

IF

(SELECT MAX(effctv_from_dt) FROM pp_cs_stage.stg_cs_fact_cs_teammate_grp = SELECT MAX(effctv_from_dt) FROM pp_cs_tables.fact_cs_teammate_grp

AND

SELECT MAX(effective_from_dt) FROM pp_cs_stage.stg_cs_metric_grp_wght  =  SELECT MAX(effctv_from_dt) FROM pp_cs_tables.dim_cs_metric_grp_wght

AND

SELECT MAX(effective_from_dt) FROM pp_cs_stage.stg_cs_metric_sub_grp_wght = SELECT MAX(effctv_from_dt) FROM pp_cs_tables.dim_cs_metric_sub_grp_wght

AND

SELECT MAX(effective_from_dt) FROM pp_cs_stage.stg_cs_bnchmrk_que_grp = SELECT MAX(effctv_to_dt) FROM pp_cs_tables.fact_cs_bnchmrk_que_grp)

THEN

DELETE FROM pp_cs_tables.fact_cs_teammate_grp

WHERE CAST(cre_ts AS DATE)=(SELECT CAST(MAX(cre_ts) AS DATE)

        FROM pp_cs_tables.fact_cs_teammate_grp);

 

DELETE FROM pp_cs_tables.dim_cs_metric_grp_wght

WHERE CAST(cre_ts AS DATE)=(SELECT CAST(MAX(cre_ts) AS DATE)

        frompp_cs_tables.dim_cs_metric_grp_wght);

 

DELETE FROM pp_cs_tables.dim_cs_metric_sub_grp_wght

WHERE CAST(cre_ts AS DATE)=(SELECT CAST(MAX(cre_ts) AS DATE)

        FROM pp_cs_tables.dim_cs_metric_sub_grp_wght);

 

DELETE FROM pp_cs_tables.fact_cs_bnchmrk_que_grp

WHERE CAST(cre_ts AS DATE)=(SELECT CAST(MAX(cre_ts) AS DATE)

        FROM pp_cs_tables.fact_cs_bnchmrk_que_grp);

 

UPDATE pp_cs_tables.fact_cs_bnchmrk

SET rec_valid_to_dt=CURRENT_DATE -1

        WHERE rec_valid_to_dt=CAST('1969-12-31' AS DATE)

        AND   CAST(cre_ts AS DATE)=(SELECT CAST(MAX(cre_ts) AS DATE)

                FROM pp_cs_tables.fact_cs_bnchmrk);

 

ELSE

.QUIT;

END;

 

 

 

 

ulrich 816 posts Joined 09/09
06 Mar 2012

it's not working like this.

check

http://forums.teradata.com/forum/database/compare-strings-in-bteq-statement-not-in-sql#comment-19550

might give you a hint how you can achive what you want.

feel free to donate bitcoin:12kgAUHFUqvG2sQgaRBXFhCwyf9HXdkGud

You must sign in to leave a comment.