Like we execute .sql file against SQL, we can write multiple golden gate commands inside a .oby file and execute it against GGSCI prompt using OBEY command. Use OBEY to process a file that contains a list of Oracle GoldenGate commands. OBEY is useful for executing commands that are frequently used in sequence.

EXAMPLE:

In the below example, we will add supplemental login(add trandata) for multiple tables using obey the 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 the 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 in 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:

With ALLOWNESTED, obey file executed successfully. The maximum number of nested levels is 16.

About The Author

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.