User Tools

Site Tools


insert_into_table_with_generated_always

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

insert_into_table_with_generated_always [2018/12/12 08:28] (current)
mihael created
Line 1: Line 1:
 +====== Insert Into Table With Generated Always ======
  
 +From time to time you need to insert a row of data into a table which has an identity column or a column with the definition containing ''​GENERATED ALWAYS''​.
 +
 +Specifying a value for the field won't work as the system wants to generated the value leaving your with an SQL error behind.
 +
 +But there are ways to add a row:
 +
 +  * Specifying the fields on the SQL statement excluding the identity column
 +  * using ''​OVERRIDING USER VALUE''​
 +  * using ''​DEFAULT''​ as the value for the identity column
 +
 +See [[https://​www.ibm.com/​support/​knowledgecenter/​en/​ssw_ibm_i_73/​sqlp/​rbafyinsertidentity.htm | IBM Knowledge Center]].
 +
 +{{tag>​devel ibm sql}}
insert_into_table_with_generated_always.txt ยท Last modified: 2018/12/12 08:28 by mihael