Things to NOTE while creating a Stored Procedure.
- Stored Procedure is a database ‘Object’ and DDL is used to create it.
- The set of statements that forms the primary task of a Stored Procedure contains within, what is called a Stored Procedure body.
- Stored Procedure body can be either a single state a compound statement.
- Single statement procedure can contain only one looping mechanism or SQL statement, excluding Cursors.
- Where as compound statements can have multiple statements but it has to be within the BEGIN and END block.
- It is not a good practice to use DDL statements within a Stored Procedure.
- It is stored in USER DATABASE space.
- Can have parameters like IN, OUT and INOUT.
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);
Popularity: 50% [?]
Our Random Articles
- New Year Wishes 2010
- New Year Wishes
- How to use EXTRACT function with date and time columns
- How to Post on a Separate/New Page in WordPress
- Usage of Macro in Teradata
More Links




7 Comments
How to handle the exception in Terada stored procedure?
How do you handle Error> 5862:C/C++ compiler is not installed during the creation of stored procedures in Teradata.
REG:_5862:C/C++ compiler is not installed ???
Visual C++ 6.0/some later(advanced) versions should be installed on the same machine that is running the terdata since we use that compiler to compile the stored procedure.
My Dear Giri…What u said is wrong…..first u try then….
hi abhi..,
i have tried and working fine…tat’s needs a c/c++ compiler…to work..if have any issues..let u mail me..i vl clarify ..
I tried the example from Teradata Sql Assistant and it errored when calling the procedure saying the “Positional assignment list has too few values”. : (
Hi Jessi,
Did you get any error number, what is it. With the limited information on what are you doing, I can say that looks like you are inserting/loading data using this procedure. In this case check the target table with all the column names in your insert statement. This has to be the same.
Hope this helps.
Popular Articles