K2 BLACKPEARL PRODUCT DOCUMENTATION: USER GUIDE
Oracle Tables

Oracle Service - Tables

All the CRUD (CREATE, READ, UPDATE, DELETE) methods including LIST will only be created as Service Object methods if there is a primary key on the table. If there is no primary key on the table only a List method will be created.

There is no concept of an Identity Key in Oracle. You can only designate a column as a Primary Key. To provide an “auto-increment” value to a Primary Key (or any field you wish) you need to create or use a Sequence. Sequences are scoped database wide. You can ask a Sequence for the next available value which you can use to insert into the Primary key field. To automate it, you create a trigger on INSERT to get the next value from Sequence before inserting.

It is possible for more than 1 table to use the same Sequence. It is therefore good practice to name the sequence something that identifies it with the table name.

For example:
Think of a Sequence as a Next Customer ticket number dispenser. You could have two departments using the same dispenser or they could each have their own.

In K2 a situation could arise where a table might have a Primary key which is NOT NULLABLE.
This means that a field will be required for ServiceObjects and SmartObjects derived from that table.
The problem is that the table might be using a Sequence to populate the Primary key and K2 has no way of deriving that information by interrogating the Database schema.
The workaround would be to send a NULL value as the primary key field value on Create. This gets us past the Required validation and will leave it to the Database to insert the correct value obtained from the Sequence. To send a NULL you can click the null button on the SmartObject tester tool next to the text box. Using the API you can set it to null or set the value itself to “scnull”.

Important: Output parameters are unsupported.


Fig. 1. Oracle Service Object Tables methods displayed in the K2 Object Browser

Samples of Table scripts

With CRUD methods: In this sample code CREATE, READ, UPDATE, DELETE and LIST methods will be created as there is a primary key on the table.

Copy Code   

CREATE TABLE STUDENT(

   STUDENT_ID NUMBER PRIMARY KEY,

   SALUTATION VARCHAR(5) NULL,

   FIRST_NAME VARCHAR(25) NULL,

   LAST_NAME VARCHAR(25) NULL,

   STREET_ADDRESS VARCHAR (50) NULL,

   ZIP VARCHAR(5) NULL,

   PHONE VARCHAR(15) NULL,

   EMPLOYER VARCHAR(50) NULL

)

 

 

 


K2 blackpearl Help 4.6.11 (4.12060.1731.0)