Question about using stored procedures to do inserts and updates

Database
Enthusiast

Question about using stored procedures to do inserts and updates

Hi Everybody!!!

I am trying to put togeather a stored procedure that will update exsisting records or insert a new record when appropriate.

Any suggestions on how to do this would be greatly appreciated.

Thanks

1 REPLY
Enthusiast

Re: Question about using stored procedures to do inserts and updates

You can refer to the Stored procedure documentaion for detail reference. Here is the link

www.info.teradata.com/edownload.cfm?itemid=113480020

The stored procedure support both the INSERT and UPDATE SQL statements just like you are doing in any other scripts. Here is a very basic example showing how things work in stored procedure...

REPLACE    PROCEDURE DP_CCP.IC_AGLD_CCP(OUT Ret_Cd INTEGER)

L1: BEGIN    

    DECLARE AGG_ALL_MAX_ROW_DT DATE;

    INSERT    INTO TBL_Error

    (        Time_Stamp     )

    SELECT CURRENT_TIMESTAMP;   

    SET Ret_cd = 1;

    IF   Ret_Cd = 0 THEN

    UPDATE TBL_ERROR

    SET TIME_STAMP = CURRENT_TIMESTAMP;

END    ;