Teradata provides a UDF called GetQueryBand and an external stored procedure called GetQueryBandSP that retrieve the query band using the FNC_GetQueryBand library function. GetQueryBand and GetQueryBandSP are created in the SYSLIB database when you run the DIPDEM script using the DIP utility.
See Teradata Vantage™ - Database Utilities, B035-1102 and Teradata Vantage™ - Application Programming Reference, B035-1090.