Like we execute .sql file against SQL, we can write multiple goldengate commands inside a .oby file and execute it against GGSCI prompt using OBEY command.
EXAMPLE:
In the below example, we will add supplemental login(add trandata) for multiple tables using obey command.
1. Create a text file and put goldengate commands.
vi addtran.oby dblogin USERID ggate, PASSWORD ggate123 add trandata dbaclass.TEST3 add trandata dbaclass.TEST4
2. execute obey command from GGSCI
SYNTAX – obey < text_file_name.oby>
ggsci> obey addtran.oby
./ggsci GGSCI > obey addtran.oby GGSCI > dblogin USERID ggate, PASSWORD ggate123 Successfully logged into database. GGSCI > add trandata dbaclass.TEST3 2017-07-17 11:24:29 WARNING OGG-06439 No unique key is defined for table TEST3. Logging of supplemental redo data enabled for table DBACLASS.TEST3. TRANDATA for scheduling columns has been added on table 'DBACLASS.TEST3'. TRANDATA for instantiation CSN has been added on table 'DBACLASS.TEST3'. GGSCI 4> add trandata dbaclass.TEST4 2017-07-17 11:24:33 WARNING OGG-06439 No unique key is defined for table TEST4. Logging of supplemental redo data enabled for table DBACLASS.TEST4. TRANDATA for scheduling columns has been added on table 'DBACLASS.TEST4'. TRANDATA for instantiation CSN has been added on table 'DBACLASS.TEST4'.
We can see, it executed all the commands mentioned inside the text file.
NESTED OBEY:
Can we put one obey file inside another obey file.?? Well this nested obey is controlled by the keyword ALLOWNESTED.
NOALLOWNESTED:
This is the default setting. Any attempt to run nested obey file will throw below error.
ERROR: Nested OBEY scripts not allowed. Use ALLOWNESTED to allow nested scripts.
ALLOWNESTED:
This parameter Enables the use of nested OBEY files. i.e we can use one obey file inside another obey file.
Let’s create two obey files:
--- obey file 1 cat infotran1.oby dblogin USERID ggate, PASSWORD ggate123 info trandata dbaclass.TEST3 --- obey file 2 cat infotran2.oby dblogin USERID ggate, PASSWORD ggate123 info trandata dbaclass.TEST4
Let’s try with the default one(NOALLOWNESTED)
Here I have created two obey files and put them inside another obey file
cat infotran.oby obey infotran1.oby obey infotran2.oby
Execute the obey file
GGSCI > obey infotran1.oby ERROR: Nested OBEY scripts not allowed. Use ALLOWNESTED to allow nested scripts.
As expected it is throwing error,
Now let’s use ALLOWNESTED parameter:
cat infotran.oby ALLOWNESTED obey infotran1.oby obey infotran2.oby
Execute the obey file:
GGSCI > obey infotran.oby GGSCI > ALLOWNESTED Nested OBEY scripts allowed. GGSCI > obey infotran1.oby **** Halting script [infotran.oby], starting script [infotran1.oby]... GGSCI > dblogin USERID ggate, PASSWORD ggate123 Successfully logged into database. GGSCI > info trandata dbaclass.TEST3 Logging of supplemental redo log data is enabled for table DBACLASS.TEST3. Columns supplementally logged for table DBACLASS.TEST3: CREATED, DATA_OBJECT_ID, EDITION_NAME, GENERATED, LAST_DDL_TIME, NAMESPACE, OBJECT_ID, OBJECT_NAME, OBJECT_TYPE, OWNER, SECONDARY, STATUS, SU BOBJECT_NAME, TEMPORARY, TIMESTAMP. Prepared CSN for table DBACLASS.TEST3: 11733401025760 GGSCI 6> GGSCI 6> **** Terminating script [infotran1.oby], resuming script [infotran.oby]... GGSCI 6> obey infotran2.oby **** Halting script [infotran.oby], starting script [infotran2.oby]... GGSCI > dblogin USERID ggate, PASSWORD ggate123 Successfully logged into database. GGSCI > info trandata dbaclass.TEST4 Logging of supplemental redo log data is enabled for table DBACLASS.TEST4. Columns supplementally logged for table DBACLASS.TEST4: CREATED, DATA_OBJECT_ID, EDITION_NAME, GENERATED, LAST_DDL_TIME, NAMESPACE, OBJECT_ID, OBJECT_NAME, OBJECT_TYPE, OWNER, SECONDARY, STATUS, SU BOBJECT_NAME, TEMPORARY, TIMESTAMP. Prepared CSN for table DBACLASS.TEST4: 11733401025806 GGSCI > GGSCI > **** Terminating script [infotran2.oby], resuming script [infotran.oby]...
With ALLOWNESTED, obey file executed successfully. The maximum number of nested levels is 16.