Minus Query in Stored Procedure


Minus Query in Stored Procedure


 I am trying to write a stored procedure which will perform the following.

1. Dynamically create a Column List to be used in a SELECT statement

2. Minus Query 

I have included the template of it below. I need to know will the stored procedure mentioned below be able to create the Column List on its own? Additionally, I need to check the result of minus query. If there is no record returned for my minus query, it should come out of the stored procedure with OUT value as 1. If there are rows returned in my minus query, I need to put the result set into something like a log (UNIX) which I can use it for reference. Basically, I need to know the equivalent of SQL%Found (Oracle) to be used in Teradata. 


Replace Procedure <ProcedureName>

(IN Tableid INTEGER, OUT Result Integer)


Declare colNameList Varchar(4000) Default NULL;

For colList AS

   Sel colName from <table> where Table_ID = Tableid;


  colNameList = colNameList||','||colList.colName

End For;

(Sel colNameList From <Instance of table1>


Sel colNameList From <Instance of Table2>)



Thanks for your help!!!