The boss assigns a task to perform CRUD operations on the Identification table and identification table. There is no difficulty in coding, but there are two places I want to record.
First, give the table structure.
REPOT_BS ):
Name Type Nullable Default Comments
----------------------------------------------
Id number (12) id of the identification type
NAME VARCHAR2 (128) y id type NAME
PARENT_ID NUMBER (12) Y identification type parent id
MARK VARCHAR2 (2000) Y remarks
REPOT_CATEGORY ):
Name Type Nullable Default Comments
--------------------------------------------------------
Id number (12) id
NAME VARCHAR2 (128) Y NAME
MARK VARCHAR2 (2000) Y remarks
CATEGORY_ID NUMBER (12) Y type id
State char (1) Y 1 enabled 0 disabled cannot be deleted
Well, the first point is that when inserting data, take the maximum value + 1 of the table id as the id. SQL:
Insert into REPOT_BS (ID, NAME, MARK, CATEGORY_ID, STATE) VALUES (select nvl (MAX (ID), 0) + 1 FROM REPOT_BS), # name #, # mark #, # categoryId #, # state #)
The red part indicates the maximum value + 1 of the table as the id, max indicates the maximum value function, and NVL (A, B) indicates that the value of A is null, then B is returned, otherwise, return. Both max and nvl are oracle system functions.
Note: oracle is case-insensitive. -_-
Second, determine whether a startup ID exists under a certain identification type. SQL:
Select count (*) from (select 1 from ZY_SYS_REPOT_BS B where B. state = '1' and B. category_id = # categoryId #)
If the returned value is greater than 0, a startup identifier is available for this identifier type. If the returned value is less than 0, no startup identifier is available. This SQL statement must be pre-determined when the ID type is deleted.
Haha, I have declared it is easy to remember. It may be of little help to you. I hope it will be slower...
From Scott's column