All Forums Database
Coghan 3 posts Joined 03/06
07 Mar 2006
How to Use Input Parameters

I am not new to SQL, but I don't know all the ins and outs of coding using Teradata's version of SQL. I have been able to read just enough to know that there is a way to set up input parameters using a macro, but I haven't been able to find a simple example of how it works.So if I have this code:SELECT Emp_NameFROM MyTableWHERE Emp_Number Between aram1Val and aram2Val;What is the proper way to set it up so that it will accept input instead of having to hardcode the values? All help greatly appreciated.

TD_Arch 35 posts Joined 07/05
08 Mar 2006

This is the way to create.CREATE MACRO MYDATABASE.MYMACRO(PARAM1VAL INTEGER,PARAM2VAL INTEGER)as(SELECT Emp_NameFROM MyTableWHEREEmp_Number Between :param1Val and :param2Val;);To execute, just give : execute MYDATABASE.MYMACRO(1,10);

Coghan 3 posts Joined 03/06
08 Mar 2006

Thanks. Hey it was weird how my colon and P turned into graphics. Obviously there is some setting in this forum that converted it from an emoticon to graphics... whatever, ha ha.Anyway, I have one follow up on this just to be sure that I know what you're talking about. When I create this macro, it's going to store it in the userdb (that's where I can put it). Will it stay there or do I need to recreate the macro every time?

TD_Arch 35 posts Joined 07/05
08 Mar 2006

It will stay there in the database where you create it, as long as you dont drop it.So, you do not need to recreate it. Hope that answers you.

Coghan 3 posts Joined 03/06
08 Mar 2006

Yes, thanks. I did it and it worked. Was able to pass the parms to it via VB in ACCESS and it worked like a charm, so it is totally automated now. I appreciate the help!

rntd 2 posts Joined 07/07
22 Oct 2007

Can you, or someone, please post the code for executing and passing parameter to teradata macro from vb and ms-access?Thank you in advance.

Khaleel 2 posts Joined 01/08
06 Jan 2008

Hi,Please post the code.It will be relayy helpful.Thanks in advance.Regards,Khaleel

You must sign in to leave a comment.