Solution:
Use the following script
if ( sql('DS_Datastore_Name','SELECT EXTRACT_STATUS FROM EXTRACT_RUN WHERE EXTRACT_NAME ='Extract 1') != 'Completed' )
begin
raise_exception_ext( 'Job terminated due to error in previous run. Correct the previous load and re-run again',1);
end
In the above code, we write a script where in we use an if condition and inside the if condition with the help of a SQL function, we write code to check if the previous run was completed or not. If not completed, it goes inside the if condition where we have written the below code,
raise_exception_ext( 'Job terminated due to error in previous run. Correct the previous load and re-run again',1);
This code will make sure that a exception is raised and there by failing the job.