Mass rename trigger parameters

27 views
Skip to first unread message

Dan Power

unread,
Mar 27, 2024, 1:18:50 PMMar 27
to schedulix
I have a number of triggers with the parameter APP. I want to update the batch being triggered to use APPS instead of APP. I was hoping there is a way to mass rename them. I suspect the syntax documentation it what I need to use but it seems I need to understand the underlaying structure to accurately use it. I am not sure what structure I need to use to target the trigger's parameters.

Ronald Jeninga

unread,
Mar 28, 2024, 8:35:51 AMMar 28
to schedulix
Hi Dan,

good to hear from you.
The way I understand your question is that you have a trigger like e.g.

create or alter trigger 'NEW_TRIGGER' on job definition SYSTEM.'MAIN_BATCHES'.'BUNCH_OF_BATCHES'.'EVERY_DAY'.'JOB1' 
with 
     active, 
     condition = '$P / $Q == ($R - 1) OR $P / $Q == $R', 
     nomaster, 
     nowarn, 
     limit state = none, 
     nosuspend, 
     state = ( 'PENDING', 'FAILURE' ), 
     submitcount = 100, 
     submit SYSTEM.'UTILITIES'.'NOTIFIER', 
     type = IMMEDIATE_MERGE, 
     parameters = ( 'APP' = '"Hi There"' ); 

and a Batch (in my case here a Job) that is triggered that looks like

create or alter job definition SYSTEM.'UTILITIES'.'NOTIFIER' 
with 
     dependency mode = all, 
     environment = 'SERVER@LOCALHOST', 
     errlog = '${JOBID}.log' NOTRUNC, 
     group = 'BATCH_OWNER', 
     kill program = none, 
     logfile = '${JOBID}.log' NOTRUNC, 
     mapping = NONE, 
     NOMASTER, 
     priority = 50, 
     parameters = none, 
     profile = 'STANDARD', 
     required = none, 
     rerun program = none, 
     resource = none, 
     run program = '/bin/bash -c "echo $APP; /bin/sleep 10"', 
     NOSUSPEND, 
     type = JOB, 
     workdir = none;


and you'd like to rename the parameter APP to APPS.
Is that correct?

If so, you'd need two updates:

alter trigger 'NEW_TRIGGER' on job definition SYSTEM.'MAIN_BATCHES'.'BUNCH_OF_BATCHES'.'EVERY_DAY'.'JOB1'
with 
    parameters = ( 'APPS' = '"Hi There"' );

and

alter job definition SYSTEM.'UTILITIES'.'NOTIFIER'
with
    run program = '/bin/bash -c "echo $APPS; /bin/sleep 10"';


One rename of the trigger parameter (in fact you remove the parameter APP and create a parameter APPS) and one rename while using the parameter.

It is very well possible that I entirely misunderstand your question.
If so, please correct me.
At least the above shows that if you want to change an object, you only have to specify the properties that you'd like to change.
And if all Triggers and triggered Jobs look similar, it should be possible to write a script to do the changes.

Best regards,

Ronald

Dan Power

unread,
Mar 28, 2024, 2:31:39 PMMar 28
to schedulix
Yes, you are very close to what I have. The triggered job is a message handler. It takes four parameters. Only one of the four I want to change the name. What you have shown me here presents many challenges. It looks like all parameters are updated completely at the same time. So, names and values of all parameters are getting "replaced" rather that the name of the one parameter getting replaced. The value and the other parameters, I don't expect to change. Just the one name. Also, in the UI for the triggered job, it gives a nice list of all the triggering jobs. That would be my target list to update the name of the parameter in question. There is a good 30 some jobs trigging my message handler. I need to find and update the targeted parameter name for all of them while preserving the value and the other parameters.

Ronald Jeninga

unread,
Mar 28, 2024, 5:21:12 PMMar 28
to Dan Power, schedulix
Hi Dan,

well, the good news is that it's doable.
And in fact it is a nice exercise in Python programming. I just hope you know a bit about python programming though.
The bad news (for you) is that I"ll take some days off during the easter days and I'll post a more helpfull answer on Tuesday.

Best regards,

Tonald

independIT Integrative Technologies GmbH

Dan Power

unread,
Mar 28, 2024, 6:18:46 PMMar 28
to schedulix
LOL, I am off until Tuesday too. :) Enjoy.

Ronald Jeninga

unread,
Apr 2, 2024, 6:03:15 AMApr 2
to schedulix
Hi Dan,

first of all, I'm not going to write that script for you. You'll have to do that yourself.
But I'll give you a number of hints that'll make it easy.

In our documentation of the command language (e.g. Command Reference 2.11) I've added a chapter with programming examples.
Don't be confused that I reference the latest release, it'll work in previous releases exactly the same way.
In fact, the GUI is written in Python and uses the command language to communicate with the server, and the GUI exists since ages.

The basic principle is that the user sends a command and the server replies with a structure called OutputContainer.
These OutputContainers always have a similar structure. It is either a record, a record with tables or a table.

If you want to know what an OutputContainer looks like, you can use telnet, for instance. (There are other possibilities too).
Like in (I've formatted the code to make it better readable):

schedulix@oncilla:~$ telnet localhost 2506
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
connect system identified by 'JohannJohann' with protocol = python;
{
    'DATA' : {
        'TITLE' : 'Connect',
        'DESC' : [ 'CONNECT_TIME' ],
        'RECORD' : {
            'CONNECT_TIME' : '02 Apr 2024 08:59:50 GMT'}
        },
    'FEEDBACK' : 'Connected'
}
show user;
{
    'DATA' : {
        'TITLE' : 'User',
        'DESC' : [ 'ID', 'NAME', 'IS_ENABLED', 'DEFAULT_GROUP', 'CONNECTION_TYPE', 'CREATOR', 'CREATE_TIME', 
                   'CHANGER', 'CHANGE_TIME', 'PRIVS', 'MANAGE_PRIVS', 'GROUPS', 'EQUIVALENT_USERS',
                   'PARAMETERS', 'COMMENTTYPE', 'COMMENT' ],
        'RECORD' : {
            'ID' : '0',
            'NAME' : 'SYSTEM',
            'IS_ENABLED' : 'true',
            'DEFAULT_GROUP' : 'ADMIN',
            'CONNECTION_TYPE' : 'PLAIN',
            'CREATOR' : 'SYSTEM',
            'CREATE_TIME' : '01 Jan 1970 00:00:00 GMT',
            'CHANGER' : 'SYSTEM',
            'CHANGE_TIME' : '07 Mar 2024 10:37:52 GMT',
            'PRIVS' : 'KDEVG',
            'MANAGE_PRIVS' : {
                'TITLE' : 'MANAGE_PRIVS',
                'DESC' : [ 'PRIVS' ],
                'TABLE' : [ ]
            },
            'GROUPS' : {
                'TITLE' : 'GROUPS',
                'DESC' : [ 'ID', 'NAME', 'PRIVS' ], 
                'TABLE' : [
                    {
                       'ID' : '81',
                       'NAME' : 'ADMIN',
                       'PRIVS' : 'KDEMO(OCRESDILUWPMKA)VGR'
                    }, {
                        'ID' : '80',
                        'NAME' : 'PUBLIC',
                        'PRIVS' : 'KDEMO(OCRESDILUWPMKA)VGR'
                    }
                ]
            },
            'EQUIVALENT_USERS' : {
               'TITLE' : 'EQUIVALENT_USERS',
               'DESC' : [ 'TYPE', 'EQUIVALENT_USER' ],
               'TABLE' : [ ]
            },
            'PARAMETERS' : {
                'DESC' : [ 'ID', 'NAME', 'VALUE' ],
                'TABLE' : [
                    {
                        'ID' : '113006',
                        'NAME' : 'PRIVATE_PROPERTIES',
                        'VALUE' : '{"NAME_UPPERCASING":"true","PRIVATE_TIME_ZONE":"Europe/Berlin","THEME":"LIGHT"}'
                    }
                ]    
            },
            'COMMENTTYPE' : None,
            'COMMENT' : {
                'DESC' : [ 'ID', 'SEQNO', 'TAG', 'DESCRIPTION' ],
                'TABLE' : [ ]
            }
        }
    },
    'FEEDBACK' : 'User shown'
}


In the above output you see the record output of the connect command as well as the combined record + table output of a show user.
In the description of the commands the output fields are documented. In case of writing commands that only return an OK or an Error, this is omitted.

Now back to your task.

The starting point is the job that is triggered by others.
If you issue a 

LIST TRIGGER OF jobname;

You'll get loads of information about all triggers that trigger this job.
E.g. :

[SYSTEM@localhost:2506] SDMS> list trigger of system.utilities.notifier;                            

List of Triggers

ID    NAME         OBJECT_TYPE    OBJECT_SUBTYPE OBJECT_NAME                                         ACTIVE ACTION STATES          SUBMIT_TYPE SUBMIT_NAME                ...
----- ------------ -------------- -------------- --------------------------------------------------- ------ ------ --------------- ----------- -------------------------  ...
44026 ASYNCTRIGGER JOB_DEFINITION JOB            SYSTEM.MAIN_BATCHES.BUNCH_OF_BATCHES.EVERY_DAY.JOB1 true   SUBMIT                 JOB         SYSTEM.UTILITIES.NOTIFIER  ...
10058 NEW_TRIGGER  JOB_DEFINITION JOB            SYSTEM.MAIN_BATCHES.BUNCH_OF_BATCHES.EVERY_DAY.JOB1 true   SUBMIT FAILURE,PENDING JOB         SYSTEM.UTILITIES.NOTIFIER  ...

2 Trigger(s) found

I've shortened the output, you can do this for yourself. But you can see what to expect.
The most interesting part here is the name of the Trigger (like ASYNCTRIGGER) and the name of the Job Definition (like ...EVERY_DAY.JOB1).
Your script can iterate over this table and do a 

SHOW TRIGGER triggername ON JOB DEFINITION jobname;

like e.g.

show trigger asynctrigger on job definition SYSTEM.MAIN_BATCHES.BUNCH_OF_BATCHES.EVERY_DAY.JOB1;

The output will contain a table of parameters of the trigger and with this list you can render an appropriate ALTER TRIGGER statement.

A small note remains.
You might have noticed that I use both upper- and lowercase identifiers and keywords.
Just like in SQL the command language is case insensitive, which is also true for identifiers.
But since there exist people that find that blanks are valid characters for identifiers (which is especially funny if you use a non fixed font), we've added the possibility to quote identifiers.
Quoting them adds a few additional characters that may be used in names and makes the identifiers case sensitive. It also allows you to use otherwise reserved words, like e.g. SYSTEM.
I myself am much too lazy for quoting and always use proper identifiers, which are much like identifiers in SQL (letters, digits, underscore. at- and hash-character).
This laziness rewards me with not having to pay attention to my shift key and no problems with copy and paste.

I think this should help you to get the job done, but tell me if you get stuck somewhere.
And after digesting the above you probably won't need breakfast  any more. ;-)

Best regards,

Ronald
Reply all
Reply to author
Forward
0 new messages