I'm trying to build a master-detail form using two DataGridView's based on Oracle 11g Database in VB.net (Enterprise 2015). It is a setup form to define categories (category_id, title, status) and sub categories (sub_cat_id, category_id, title, status). I've followed this example to build the form. However, to retrieve the primary column value I've used following query in the category table adapter to fetch next sequence value.
I'm facing following problems:
a) Form generates error if I leave the primary key column "category_id" blank
b) If I provide any dummy value say "-1" in the "category_id" column while filling the record and press save button, -1 is stored in the database and value of sequence is just shown on the form.
The tables structure is as follows:
VB.NET:
SELECT ePos.PROD_CATG_SEQ.NEXTVAL FROM DUAL
I'm facing following problems:
a) Form generates error if I leave the primary key column "category_id" blank
b) If I provide any dummy value say "-1" in the "category_id" column while filling the record and press save button, -1 is stored in the database and value of sequence is just shown on the form.
The tables structure is as follows:
VB.NET:
CREATE TABLE ePos.prod_category
(
category_id NUMBER(5) PRIMARY KEY,
title VARCHAR2(100) NOT NULL,
status VARCHAR2(1) default 'Y' NOT NULL
);
CREATE SEQUENCE ePos.PROD_CATG_SEQ
INCREMENT BY 1
START WITH 1
MAXVALUE 99999
MINVALUE 1
NOCYCLE
NOCACHE
NOORDER;
CREATE TABLE ePos.prod_sub_category
(
sub_cat_id NUMBER(5) PRIMARY KEY,
category_id NUMBER(5) NOT NULL REFERENCES ePos.prod_category(category_id),
title VARCHAR2(100) NOT NULL,
status VARCHAR2(1) default 'Y' NOT NULL
);
CREATE SEQUENCE ePos.PROD_SUBCATG_SEQ
INCREMENT BY 1
START WITH 1
MAXVALUE 99999
MINVALUE 1
NOCYCLE
NOCACHE
NOORDER;