teradata stored procedure
Teradata Teradata Discussion Forums Teradata.com Discussion Forum
Visit Teradata.com
Home       Guidelines    Member List
Welcome Guest ( Login | Register )
        


This online forum is for user-to-user discussions of Teradata products, and is not an official customer support channel for Teradata. If you require direct assistance, please contact Teradata support.


teradata stored procedure Expand / Collapse
Author
Message
Posted 10/7/2009 11:19:08 PM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: Forum Members
Last Login: 10/13/2009 10:49:55 PM
Posts: 2, Visits: 3
Hi All,
I am facing some wall in the stored procedure in Teradata. Please help me.
The definition of SP is as follows:
Create procedure 123(IN ABC varchar(1000))
(
begin
Define I integer;
Define query Varchar (1000);
Set I = 1;
Set query=ABC;
While (I < 36)
DBC.EXEC(:query);
set I= I+1;
END While;
)
sorry if the definition of Procedure is wrong
My doubt is if my input is 'Select A from DB1. Table where B= ;'
I want to pass 'I' in the procedure to this query for every loop....
How to do it in teradata ?

Thanks in Advance
Post #17061
Posted 10/8/2009 1:04:52 PM
Supreme Being

Supreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme Being

Group: Forum Members
Last Login: 10/8/2009 1:16:14 PM
Posts: 79, Visits: 105
Hi,

It is similar like you use the variable 'query' in DBC.EXEC().

You can make use of concatenation operator ( '||' ) while building a dynamic query which involves in using more than one local variable in a stored procedure.

Try like this:

DBC.SysExecSQL(:query|| :I ||';');

SysExecSQL invokes dynamic SQL, and important point to be noted while using dynamic SQL is, the user who is executing SP should be the immediate owner of SP.

Your input parameter should be like ''Select A from DB1.Table where B= ' (without semicolon symbol).

There are few other limitations in using dynamic SQL in SP, do refer Teradata Stored Procedure PDFs in www.info.teradata.com.

Hope this information helps you.


Regards,
Balamurugan
Post #17066
Posted 10/13/2009 10:55:18 PM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: Forum Members
Last Login: 10/13/2009 10:49:55 PM
Posts: 2, Visits: 3
thanks ,
but don't we have anything in teradata like & in C/C++..
It would be better if the variable in the passing string itself....
Post #17093
« Prev Topic | Next Topic »


Reading This Topic Expand / Collapse
Active Users: 0 ( 0 guests, 0 members, 0 anonymous members )
No members currently viewing this topic.


All times are GMT -5:00, Time now is 5:38pm

Powered By InstantForum.NET v4.1.4 © 2009
Execution: 0.047. 9 queries. Compression Disabled.