About this topic: I have tables created by PowerDesigner and they are almost normalized. In many cases,my tables have simple columns, but when I need to pass all collumns of, for example, a supplier, what I do is
create or replace function getAllSuppliersObjects RETURN FORNECTABLE AS
suppliersList FORNECTABLE := FORNECTABLE();
BEGIN
FOR res IN (SELECT supplier, products FROM fornecprods) LOOP
/*dbms_output.put_line('-----------------------');
dbms_output.put_line('Existent suppliers: '
|| res.supplier.NOME_FORNECEDOR);*/
suppliersList.extend;
suppliersList(suppliersList.last):= res.supplier;
END LOOP;
return suppliersList;
END;
I also have a table with supplier_id, supplier_object and a table of products (type prod_obj) to retrieve list of objects in a easy way. But is this faster?
Should I change all my tables from something like this:
create table SUPPLIER
(
SUPPLIER_ID NUMBER(6) not null,
SUPPLIER_NAME VARCHAR2(100) unique not null,
ADDRESS VARCHAR2(300),
warehouse VARCHAR2(300),
EMAIL VARCHAR2(30),
TLF NUMBER(30) ,
TLM NUMBER(30),
FAX NUMBER(30),
constraint PK_SUPPLIER primary key (SUPPLIER_ID)
);
to something like that:
create or replace type SUPPLIER_OBJ as object (
SUPPLIER_ID NUMBER(6) ,
SUPPLIER_NAME VARCHAR2(100),
ADDRESS VARCHAR2(300),
warehouse VARCHAR2(300),
EMAIL VARCHAR2(30),
TLF NUMBER(30) ,
TLM NUMBER(30),
FAX NUMBER(30),
);
/
create table SUPPLIER of SUPPLIER_OBJ (constraint PK_SUPPLIER primary key (SUPPLIER_ID),SUPPLIER_NAME unique not null);
/
My CDM is very simple, with typical relationships between suppliers, employees, clients, products and services, with strong entities being services, products, employees, suppliers and clients and some of the others being weak entities to order porducts from a supplier, etc.
If this change from "normal" to "object or nested tables" doesn't pay off, how I can retrieve an object or list of them each time I do a select and want to send the resultSet to java?
Do I have to iterate over each result of the select query and create, let's say, a supplier object with all column values and add it to a table os those objects?