Quantcast
Channel: Teradata Forums - Database
Viewing all articles
Browse latest Browse all 14773

Use of CTE within stored procedures - response (3) by Harpreet Singh

$
0
0

It works with derived table ..
 
CREATE TABLE with_source ( a INT GENERATED always AS IDENTITY , b INT );
CREATE TABLE with_target ( a INT GENERATED always AS IDENTITY , b INT );
INSERT INTO with_source ( b ) VALUES ( 1 );
 
REPLACE PROCEDURE with_test_proc ()
BEGIN
INSERT INTO with_target ( b )
SELECT b
FROM (
SELECT 1 b
FROM with_source ) tmp
UNION
SELECT b + 1
FROM (
SELECT 1 b
FROM with_source ) tmp ; END;
DELETE FROM with_target;
CALL with_test_proc();
SELECT * FROM with_target;


Viewing all articles
Browse latest Browse all 14773

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>