Home > database >  Serial number is automatically generated
Serial number is automatically generated

Time:09-26

There are many tables in the database, I think in the first column of each table to automatically generate an integer types of data, each one line 1, all the first data table in the table to a dedicated take to find the most to add a assigned to the first column of the table, function how to do excuse me, please everybody your advice, I am a beginner,

CodePudding user response:

The select Max (col) from TB

CodePudding user response:

 
The update seed_table set seed=seed + 1;

If the sqlca. Sqlcode=0 then
Select seed into: l_seed from seed_table;
Commit;

The else
The rollback.
Debugbreak ()
MessageBox (" error!" Update, "seed error - 1! ~ n ~ n please try again!" + the sqlca. SQLErrText StopSign!)
Return
End the if

CodePudding user response:

I have two columns in the data table ID (INTEGER) and NR (CHAR) with the following statement is wrong
Long ll_row
The integer ls_bh

Ll_row=dw_1. InsertRow (0)
Dw_1. ScrollToRow (ll_row)
If dw_1. RowCount & gt; 1 then
Ls_bh=dw_1. GetItemNumber (4, 'id')
The else
Ls_bh='
end if

CodePudding user response:

Grammar mistake

CodePudding user response:

Dw_1. GetItemNumber ( 4 ,
'id')
Confirm whether line 4

CodePudding user response:

I am using the oracle database
Stored procedures in a process automatically submit options, connected with outside affairs not
Do it himself a table missequ (mismodel, mistable, key1, key2 and key3, key4, misvalue)
The create or replace procedure pd_mis_sequ (as_model in varchar2, as_table in varchar2, as_key1 in varchar2, as_key2 in varchar2, as_key3 varchar2, as_key4 in varchar2, as_key5 in varchar2, al_return_value out varchar2) is
PRAGMA AUTONOMOUS_TRANSACTION ;
/*
Function: increasing custom sequence, 1
As_key5 0:1: local database remote database
New coder: wang
Create: 2010.11.8
*/
Al_current_value missequ. Misvalue % type;
The begin
If as_key5='0' then, local data
The begin
The select misvalue into al_current_value from missequ
Where mismodel=as_model and mistable=as_table and key1=as_key1 and key2=as_key2 and key3=as_key3 and key4=as_key4
For update.
The exception
The when NO_DATA_FOUND then
The begin
Insert into missequ (mismodel mistable, key1, key2 and key3, key4, misvalue)
Values (as_model as_table, as_key1 as_key2, as_key3, as_key4, 0).
Al_current_value:=0;
end;
end;
The update missequ
The set misvalue=https://bbs.csdn.net/topics/misvalue + 1
Where mismodel=as_model and mistable=as_table and key1=as_key1 and key2=as_key2 and key3=as_key3 and key4=as_key4;
Al_return_value:=al_current_value + 1;
commit;
The else
Al_return_value:=1;
End the if;
End pd_mis_sequ;
Didn't write remote data in the process of writing, ha ha, I now project has not been used, if you want to write again later

CodePudding user response:

To create a new table missequ (mismodel mistable, key1, key2 and key3, key4, misvalue)
This process is automatically submit (independent), not related to the application
The create or replace procedure pd_mis_sequ (as_model in varchar2, as_table in varchar2, as_key1 in varchar2, as_key2 in varchar2, as_key3 varchar2, as_key4 in varchar2, as_key5 in varchar2, al_return_value out varchar2) is
PRAGMA AUTONOMOUS_TRANSACTION ;
/*
Function: increasing custom sequence, 1
As_key5 0:1: local database remote database
New coder: wang
Create: 2010.11.8
*/
Al_current_value missequ. Misvalue % type;
The begin
If as_key5='0' then, local data
The begin
The select misvalue into al_current_value from missequ
Where mismodel=as_model and mistable=as_table and key1=as_key1 and key2=as_key2 and key3=as_key3 and key4=as_key4
For update.
The exception
The when NO_DATA_FOUND then
The begin
Insert into missequ (mismodel mistable, key1, key2 and key3, key4, misvalue)
Values (as_model as_table, as_key1 as_key2, as_key3, as_key4, 0).
Al_current_value:=0;
end;
end;
The update missequ
The set misvalue=https://bbs.csdn.net/topics/misvalue + 1
Where mismodel=as_model and mistable=as_table and key1=as_key1 and key2=as_key2 and key3=as_key3 and key4=as_key4;
Al_return_value:=al_current_value + 1;
commit;
The else
Al_return_value:=1;
End the if;
End pd_mis_sequ;

CodePudding user response:

What do you use the database, for example of asa database field has autoincrement attribute, is very convenient for
If the oracle database, just as well with sequence, combined with the trigger used together is also very convenient,
A maximum sampling plus one way, and many people use is problematic, concurrency
  • Related