How to Use Input Parameters

Database
Fan

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_Name
FROM
MyTable
WHERE
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.
6 REPLIES
Enthusiast

Re: How to Use Input Parameters

This is the way to create.
CREATE MACRO MYDATABASE.MYMACRO(PARAM1VAL INTEGER,PARAM2VAL INTEGER)
as
(
SELECT
Emp_Name
FROM
MyTable
WHERE
Emp_Number Between :param1Val and :param2Val
;
)
;

To execute, just give : execute MYDATABASE.MYMACRO(1,10);
Fan

Re: How to Use Input Parameters

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?
Enthusiast

Re: How to Use Input Parameters

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.

Fan

Re: How to Use Input Parameters

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!
Fan

Re: How to Use Input Parameters

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.

Re: How to Use Input Parameters

Hi,

Please post the code.

It will be relayy helpful.

Thanks in advance.

Regards,
Khaleel