Está en la página 1de 2

Sample schema file:

TABLE zSalesRegion {

//Table statement this is the table


// name used by

pdm_extract
id
INTEGER UNIQUE KEY;
// every table needs a primary key
last_mod_dt
LOCAL_TIME;
// TIme is stored in an integer / unix time
last_mod_by
UUID REF ca_contact; // foreign key to the ca_contact table
description STRING 1000;
// data type and size
successDirector
UUID REF ca_contact;
sym STRING 100;
}
p1 zSalesRegion -> CURR_PROV zSalesRegion;

// maps the ddict.sch table name

// to the SQL table name


Sample mod file:
OBJECT zSalesRegion { // object name
ATTRIBUTES zSalesRegion { // mapping to ddict.sch table name
description description STRING 1000;// left column is majic attribute
//

middle column is the ddict.sch table name


successDirector SREL cnt;
// "SREL" is a foreign key
sym STRING 100;
last_mod_dt DATE { ON_CI SET NOW; };
last_mod_by SREL cnt { ON_CI SET USER; // trigger to set the logged in user
as the value
ON_NEW DEFAULT USER; };
};
FACTORY zSalesRegion {
STANDARD_LISTS {
MLIST OFF; // not cached by the domsrvr
RLIST OFF; // not cached by the domsrvr
};
REL_ATTR id; // how will other tables foreign key to this table?
};

};
Sample mod file with trigger:
MODIFY cnt userid {ON_PRE_VAL validate_userid() 40 //before saving it will call
the spel method validate_userid()
FILTER (delete_flag != 1); //It will only call the spel
method if ther record is active
};
Sample spel file:
cnt.userid::validate_userid( ... ) // valid for the contact object and looks at
userid field
{
int del_flag;
del_flag = 0;
string new_val;
string old_val;
string ignore_case;
old_val = (string) argv[2];
new_val = (string) argv[3];

string userid_escaped ;
userid_escaped = gsub(new_val, "'", "''");
ignore_case = getenv("NX_IGNORE_SECURITY_CASE"); //ANYTHING with "NX_" i
s looking at a NX.env variable
if ( !is_null(ignore_case) && downcase(ignore_case) == "yes" ) {
if ( !is_null(old_val) && old_val!="" )
old_val = downcase(old_val);
if ( !is_null(new_val) && new_val!="" )
new_val = downcase(new_val);
}
logf(TRACE, "old_val='%s' new_val='%s' userid_escaped='%s'", old_val, ne
w_val, userid_escaped); //logf means it will write to the log
// files. in this case if TRACE is enabled
if(!is_null(new_val) && new_val!="") {
if ( old_val != new_val) {
send_wait(0,top_object(),"call_attr","cnt",
"sync_fetch","RLIST_DYNAMIC", format("userid LIK
E '%s'",userid_escaped), -1,0); // get a list of other contact objects with
// the same userid

userid: %s", msg[0]);

if (msg_error()) {
logf(ERROR, "Error getting during sync_fetch of
//ERROR wil always log to the stdlog
}
int domset_size;
domset_size = msg[1];
logf(TRACE,"found %d UserID's that matches '%s'", domset

_size, new_val);
if (domset_size != 0){
logf(TRACE, "'%s' UserID already exists", new_va
l);
set_error(1);
set_return_data(find_msg(5, 910));
}
}
}
}

También podría gustarte