Skip to Content
0
Former Member
Jul 24, 2014 at 12:50 PM

Is it possible to implement MobiLink's upload_insert as a SQL function

19 Views

Is it possible, to implement functionality of upload_insert as a function? From documentation, this is an example how to add an functionality to that event:

CALL ml_add_table_script(
 'ver1',
 'Customer',
 'upload_insert',
 'INSERT INTO Customer( 
  cust_id, 
  name, 
  rep_id, 
  active )
  VALUES ( 
  {ml r.cust_id}, 
  {ml r.name}, 
  {ml r.rep_id}, 
  1 )' );

But I'm wondering whether I've the chance to put also something like this into it

-- ....
declare @my_name varchar(50)
set @my_name = 'Teddy Test'
INSERT INTO Customer( 
  cust_id, name, rep_id, active )
  VALUES (  {ml r.cust_id}, @name,  {ml r.rep_id}, 1 )' )
-- ....

(this is just a random example)

I was thinking about a way defining this as a procedure and adding the call of the function with ml_add_table_script. But wondering, whether this is the best way on doing this.

Background: I've got about 500 tables for which I like to add some magic to recognize constrain violations during upload of new rows e.g. caused by inserting a new row on remote side and changing another line on consolidated database ending upon constraint violation when doing the merge)