cancel
Showing results for 
Search instead for 
Did you mean: 

How to generate some ID while inserting data into a table in SAP HANA SQL SCRIPT

former_member623318
Discoverer
0 Kudos

Hi All,

I have to create a procedure in SAP HANA where I want to generate new column named ID when i am inserting data into xyz table.

In xyz table, I have 3 columns(name,designation,location).

now when i am inserting new column "ID" should add along with name,designation,location.

Regards,

Deepthi

Accepted Solutions (0)

Answers (3)

Answers (3)

former_member213277
Active Participant
0 Kudos

Hi,

I assume you are looking for an option to automatically populate unique IDs in an existing column,

please refer this blog IDENTITY column in SAP HANA

Thanks

former_member302041
Contributor
0 Kudos

I would try to use hash_sha256 function like:

select
hash_sha256( to_varbinary(concat("NAME","DESTINATION","LOCATION") ) ) AS "UNIQUE_GUID"
from ....
SergioG_TX
Active Contributor
0 Kudos

why not create the column beforehand and make it an auto increment identity via sqlscript with an alter statement. then in your stored procedure when you insert your identity would automatically increased

former_member623318
Discoverer
0 Kudos

Thanks Sergio Guerrero

In xyz table, I have 3 columns(name,designation,location).

Here the case is like now i just mentioned ID..But i actually needed that we need to add dynamically columns to the table for each user.

We don't know how many columns just needed to add to the table but it has to create dynamically by taking users input..

For suppose user1 want 3 columns to that table(along with name,designation,location) & user2 want 5 columns to that same table(name,designation,location)..

The procedure should be able to create those 3/5 columns on basis of users input.

Regards,

Laxmi

SergioG_TX
Active Contributor
0 Kudos

i there a limit of how many columns do you need to have? (i hope so) otherwise the n-user can have unlimited columns resulting in a horrible structure.... if you do have a limited number of columns structure, then why not setting it the same for all.. and only allow the users to insert/update into the number of columns allowed. this may require an additional table to control what column(s) a user may be able to interact with. just a thought