Quantcast
Channel: SCN: Message List - SAP HANA and In-Memory Computing
Viewing all articles
Browse latest Browse all 8968

Re: In Hana SQL Script, can I insert records into an already existing table variable?

$
0
0

(Thanks for the reference Patrick)

 

Hi Dustin,

 

You are correct - can't do insert on table variables at all, and can't do insert to temp tables if you want to keep it read-only.

 

Can you provide more details on your core requirement? Should help in addressing alternatives.

 

For a workaround though, consider the following. In most programming langues (all?) you can assign a variable a value that results from some calculation against the same variable's prior value.

 

So, with some integer "c", this is, of course, valid: c = c + 1; // java and other C-like languages

 

(Of course, increment operator also works: c++;)

 

Think of this same approach to achieve what you need, but in database perspective.

 

Sample code:

 

a = SELECT 1 AS "MY_FIELD" FROM DUMMY;

 

-- append a record without INSERT

a = SELECT 2 AS "MY_FIELD" FROM DUMMY UNION ALL SELECT "MY_FIELD" FROM :a;

 

Hope that helps a bit.

 

Cheers

Jody


Viewing all articles
Browse latest Browse all 8968

Trending Articles