﻿<?xml version='1.0' encoding='UTF-8'?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/"><channel><title>Teradata Forums / Teradata  / Teradata Database  / Stored Procedure / Latest Posts</title><generator>InstantForum.NET v4.1.4</generator><description>Teradata Forums</description><link>http://www.teradata.com/teradataforum/</link><webMaster>info@teradata.com</webMaster><lastBuildDate>Wed, 03 Dec 2008 15:35:49 GMT</lastBuildDate><ttl>20</ttl><item><title>RE: Stored Procedure</title><link>http://www.teradata.com/teradataforum/Topic11729-9-1.aspx</link><description>Hello,Following is the most simple example of a Stored-Procedure:CREATE PROCEDURE spName(IN P1 INTEGER, OUT P2 INTEGER)BEGIN  SELECT P1 + 10 INTO P2;END;Perhaps the task you wish to achieve can be better done using dynamic-sql or offcourse BTEQ script will be great. Following is the example of dynamic-sql in Stored-Procedure (you will have to add ID column against each username in temporary table):CREATE PROCEDURE spName(IN P1 INTEGER, OUT P2 INTEGER)BEGIN  DECLARE DSQL VARCHAR(100);  DELCARE UserCount INTEGER;  SELECT COUNT(*) INTO UserCount FROM VolatileTable1;  L1: LOOP    SELECT 'CREATE USER ' || UserNameColumn INTO DSQL FROM VolatileTable1 WHERE ID = UserCount;        CALL DBC.SysExecSQL(DSQL);      SELECT UserCount - 1 INTO UserCount;      IF(UserCount &amp;lt; 1)      LEAVE L1;    END IF;  END LOOP L1;END;HTH.Regards,Adeel</description><pubDate>Wed, 04 Jun 2008 10:07:31 GMT</pubDate><dc:creator>Adeel.Chaudhry</dc:creator></item><item><title>Stored Procedure</title><link>http://www.teradata.com/teradataforum/Topic11729-9-1.aspx</link><description>Hi, I need to write a stored procedure for creating a user on the basis of the values in a temp table. The temp table will have only username column and based on the values in the table. My SP shud do the following- Create role for user- Create default database for user- Create user- Moving perm space to user from d_spacereserve- Granting privs for user- Granting role to the user Can anyone help me please as I have never worked on SP. If you can provide me a general structure with a simple example i wud be great.Thanks</description><pubDate>Wed, 04 Jun 2008 07:37:53 GMT</pubDate><dc:creator>terakops</dc:creator></item></channel></rss>