cancel
Showing results for 
Search instead for 
Did you mean: 

Redirecting Mobilink server event

former_member329524
Active Participant
0 Kudos

Hello, all

I would like to use the same exact script in upload_insert and upload_update events.

The script is of form "insert into table on existing update", so it is the same for both events.

Question: can I, somehow redirect upload_update event to upload_insert event, so I would not have to replicate the SQL code?

Thank you

Arcady

Accepted Solutions (1)

Accepted Solutions (1)

chris_keating
Advisor
Advisor
0 Kudos

Each event is distinct and one event cannot trigger another's code.

You could write a script if this was common usage for your events. You could also get fancy and query the system tables to determine the tables and columns 

For example, (untested)  this builds both the insert and update upload scripts with the same SQL statement:

-- create table scripts

declare scriptVersion(128);

declare table char(128);

declare upsertStatement  long varchar;

set table = 't1';

set scriptVersion = 'v';

set upsertStatement = string ( 'insert into table ', table, ' on existing update {rest of statement}' );

call ml_add_table_script( scriptVersion, table, 'upload_insert', upsertStatement );

call ml_add_table_script( scriptVersion, table, 'upload_update', upsertStatement );

{ other scripts for table }

set table = 't2';

set upsertStatement = string ( 'insert into table ', table, ' on existing update {rest of statement}' );

call ml_add_table_script(scriptVersion, table, 'upload_insert', upsertStatement );

call ml_add_table_script( scriptVersion, table, 'upload_update', upsertStatement );

{ other scripts for table }

former_member329524
Active Participant
0 Kudos

Hello, Ghris

What I meant was that for almost all tables, which have active upload_insert script, the upload_update script is identical.

So, I was just wondering if mobilink has a similar command to "trigger event" as sql anywhere has. If there were such a command, I could just put it into the upload_update script of each table, so the code would not have to be replicated.

Answers (1)

Answers (1)

former_member188493
Contributor
0 Kudos

In theory, you might be able to write SQL code to SELECT upload_update scripts from the ml_script table and INSERT them into the corresponding upload_insert rows in ml_script...

...or even code triggers on ml_script to keep the upload_update / upload_insert rows in sync (bad pun intended).

In reality, this may be a very very very very very bad idea... but I'm old and thus lacking in imagination