Click here to Skip to main content
14,601,061 members
Rate this:
Please Sign up or sign in to vote.
See more:
Hi,
I created 6 different SQL queries in Teradata SQL Assistant. In order to complete my project, I need to run 6 of them to get the final report that I want.
Could any body please show me how to put those 6 queries together into simple SQL statements to execute them at one time instead of run one by one.

Thank you,
Posted
Updated 5-Nov-13 3:23am
v4
Comments
CHill60 3-Nov-13 9:56am
   
Without seeing the queries themselves we can't help. Are you trying to get all of the results into a single table/dataset that is returned from "something"? Have you tried contacting http://www.aquafold.com/support.html[^]
Christine_13 4-Nov-13 17:34pm
   
Hi,
My queries are long to post here.
In general, I created query1 to clean all existing tables, query2 to create a new list of customer, query3&4 to upload this list as Ushare table in Teradata, query5&6 to get the final reports.
In order to get the final reports, I need to run these 6 queries one by one because they are related to one another. I consider them as step1, 2,... and so on to get the final reports.
I'd like to know if there are any ways that I can execute them all at one time by using one single query.

Thank you,
syed shanu 5-Nov-13 1:14am
   
Hi,
Try to use Stored procedure where you can run all your 6 query one by one
Christine_13 5-Nov-13 12:13pm
   
Hi Syed,
Could you please lead me to build a stored procedure?
Consider Query1, Query2, Query3, Query4, Query5, and Query6 in order for this procedure.
I appreciate your help.
Rate this:
Please Sign up or sign in to vote.

Solution 1

There is no such thing as "one time" in nature. You can talk about parallelism, but, as you explained yourself that your queries depends on each other (that should mean that one statement depends on the result of another one), they should be executed sequentially.

That's it.

—SA
   
Rate this:
Please Sign up or sign in to vote.

Solution 2

Hi
Check this link hope this will help you to create SP in Teradata

http://readvitamin.com/2007/08/20/how-to-create-a-stored-procedure-in-teradata/[^]

Example:
CREATE PROCEDURE MyFirstProc (IN emp_number INTEGER,
                                             IN dept_number INTEGER,
                                             OUT dept_name CHAR(10),
                                             INOUT errstr VARCHAR(30))
BEGIN
        INSERT INTO Employee (EmpNo, DeptNo )
        VALUES (emp_number, dept_number);
        SELECT DeptName INTO dept_name FROM Department
        WHERE DeptNo = dept_number;
END;
To execute/call the above Stored Procedure:
CALL MyFirstProc (495, 211);
   

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100