Home > database >  Oracle JDBC operation for help
Oracle JDBC operation for help

Time:09-22


Or this table has no associated constraints, how can I let him reach the limit in or how do I catch the exception to the next statement
continue?

CodePudding user response:

1, do you want an error message posted, facilitate others to help you solve,
2, to build your table statements, statements, all post, to the text, don't screenshots,

CodePudding user response:

The create table T_GROUPFORBIDDENBOARD
(
Data_time VARCHAR2 (20),
Region_name VARCHAR2 (100),
Group_id VARCHAR2 (20),
Group_name VARCHAR2 (100),
Fine_money VARCHAR2 (20),
Few VARCHAR2 (100),
Region_id VARCHAR2 (20),
District_name VARCHAR2 (20),
Login_no VARCHAR2 (20),
Operate_time VARCHAR2 (40)
)
In tablespace USERTEMP

CREATE UNIQUE INDEX T_GROUPFORBIDDENBOARD_time_id ON T_GROUPFORBIDDENBOARD (NVL2 (data_time, group_id, NULL))
In tablespace USERTEMP

As for the error message is when I insert my pictures the first insert statement because so error is the only one that does not meet the constraint conditions, I mainly want to implement the insert the data in the table can not at the same time with the time and the groupid in the table this requirement

CodePudding user response:

 
SQL>
SQL> Create table test
2 (
3 data_time VARCHAR2 (20),
4 region_name VARCHAR2 (100),
5 group_id VARCHAR2 (20)
6);
The Table created
SQL> - CREATE UNIQUE INDEX T_GROUPFORBIDDENBOARD_time_id
SQL> - ON T_GROUPFORBIDDENBOARD (NVL2 (data_time, group_id, NULL));
SQL> Insert into test (data_time, group_id) values (' 201805 ', '12');
1 row inserted
SQL> Insert into test (data_time, group_id) values (' 201806 ', '12');
1 row inserted
SQL> - look at the results
SQL> Select NVL2 (data_time, group_id, NULL) new_value from test;
NEW_VALUE
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
12
12
SQL> Drop table test purge;
Table dropped

SQL>
  • Related