Archives of the TeradataForum
Message Posted: Fri, 12 Aug 2011 @ 13:23:19 GMT
Subj: | | Re: How to assign the value od dynamic sql ? |
|
From: | | David Clough |
I suspect you're actually looking for something like this :-
-- Build up the Dynamic SQL statement, if a filter has been passed in
--
SET sLSQLSTATEMENT_TX = 'INSERT INTO MY_W.AUDIT_CON_LIST Select '
||''''||SPTERM_ID||''''
|| sLAuditSQL;
IF SPIMP_ID IS NOT NULL THEN
SET sLSQLSTATEMENT_TX = sLAuditSQL || ' AND CON.CUS_ID_IMP = ' ||''''||SPIMP_ID||'''';
END IF;
IF SPCAC_ID IS NOT NULL THEN
SET sLSQLSTATEMENT_TX = sLSQLSTATEMENT_TX || ' AND CON.CAC_ID = ' ||''''||SPCAC_ID||'''';
END IF;
IF SPCON_ID_LEGACY IS NOT NULL THEN
SET sLSQLSTATEMENT_TX = sLSQLSTATEMENT_TX || ' AND CON.CON_ID_LEGACY = ' ||''''||SPCON_ID_LEGACY||'''';
END IF;
It just gets a bit fiddly with the quotes.
What some people do is to write the sLSQLSTATEMENT_TX to a Log Table, so you can then see what the Proc was about to run .... actually, I do
that sometimes myself (if I'm in the right mood).
Regards
David Clough
Senior Database Designer
Database Design Group
|