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

Use of CTE within stored procedures - forum topic by andrewah

$
0
0

Hi all

 

I am using Teradata Express 13.10 & I am trying to write a stored procedure which uses multiple references to dataset defined using a 'common table expression.'

 

I have a test case below:

 

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 );

And this stored procedure ...

replace procedure with_test_proc ()
begin
 
       insert
         into
              with_target
            (
                b
            )
         with
              tmp
            (
                b
            )
           as
            (
                  select
                         1 b
                    from
                         with_source
            )
       select
              b
         from
              tmp
    union
       select
              b + 1
         from
              tmp
            ;
 
end;

... which compiles without error.
However, when I execute this procedure, I receive this error message:

Unhandled exception caught in rr_dfs_balance_recon:00000:   : Syntax error, expected something like a name or a Unicode delimited identifier or a 'SELECT' keyword or '(' or a 'NONTEMPORAL' keyword or 'AS' keyword between '(' and the 'WITH' keyword.: setting return code = -1

 

Does anybody have an idea how to resolve this?

 

Thanks,

 

Andrew.

Forums: 

Viewing all articles
Browse latest Browse all 14773

Trending Articles



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