Hi @Narsi,
You seems to be asking for a full training manual!
One of the best ways to discover the code you want to use is via debugging. You can find out exactly what code runs when you create or delete a record or make a change and then use that code as a template to work with. Take a look at this thread with brief instructions on debugging.
Ged.
One thing that debugging won’t show you is how to build values for the attr_
string. I used to concatenate CHR(31)
and CHR(30)
until I learned about the CLIENT_SYS
package.
/*
IFS logical units have base views and base packages.
Let's assume we have the logical unit HelloWorld.
It'll have a base view HELLO_WORLD and a base package HELLO_WORLD_API. (Each
change in character case, which represents a new word, is represented by an
underscore, since Oracle object names aren't ordinarily case sensitive.)
*/
DECLARE
info_ VARCHAR2(32767);
-- I like to use %TYPE constructions whenever possible.
-- They make the code more self-documenting by revealing the purpose of variables.
objid_ hello_world.objid%TYPE
objversion_ hello_world.objversion%TYPE;
attr_ VARCHAR2(32767);
BEGIN
-- This sets attr_ to NULL, but the exact implementation may change
client_sys.clear_attr(attr_);
-- This fills in the default values for a new record
hello_world_api.new__(info_, objid_, objversion_, attr_, 'PREPARE');
-- This adds a value for some column that wasn't defined in PREPARE
client_sys.add_to_attr('SOME_FIELD_NAME', 'some value', attr_);
-- This overrides a value that might have been populated by PREPARE
client_sys.set_item_value('SOME_FIELD_NAME', 'some value', attr_);
-- This creates a new record
hello_world_api.new__(info_, objid_, objversion_, attr_, 'DO');
END;
/
I know I should use .add_to_attr but I’m an old dog and still use chr() method. Maybe I’ll update my templates one day!
I know I should use .add_to_attr but I’m an old dog and still use chr() method. Maybe I’ll update my templates one day!
Probably the most compelling reason to use ADD_TO_ATTR
is that it has an overload to automatically format DATE
values. You won’t have to think much about your data types.
I know I should use .add_to_attr but I’m an old dog and still use chr() method. Maybe I’ll update my templates one day!
Probably the most compelling reason to use ADD_TO_ATTR
is that it has an overload to automatically format DATE
values. You won’t have to think much about your data types.
OK. I’m sold!