Upgrade RMAN Catalog To 19.8

Configuring a new database in rman catalog to backup I got the following error

You only have to be connected to the Rman catalog, if it is connected to a target database we would get the following error

The upgrade is very simple and as simple as running the command twice, the second time to confirm.

It should be noted that the rest of the databases that are registered in the same catalog and are lower versions of the database are not affected by the change.

HTH – Antonio NAVARRO

A Very Silly Mistake

Yesterday I was installing a patch on a Windows Server, when I receive the following error;

The truth is that the error is very silly and simple. This is a Windows Server 19. Basically I opened the cmd as a normal user when you have to open it as Administrator. In this case we can open a PowerShell as administrator and from there call cmd, as seen in the image below

HTH – Antonio NAVARRO

How To Check Syntax In Shell Script

The other day I was asked if there is any way to check if the syntax of a script (Unix or Linux) is correct, without having to execute the script. This can be interesting when you have a script that deletes files, generates single-use values or modifies structures of any kind.

The following script, valid to some extent for KSH and BASH shells, is correct from a syntactic point of view.

for files in *.log; do
echo "ficheros ${files%}"
done
exit 0

In KSH and BASH we have the -n option to check the syntax of the scripts. If we execute it in the following way;

ksh -n script_poc
bash -n script_poc

We will not receive any type of message, this means that the script passes the validation correctly.

Now to test that it detects a possible problem with the syntax we are going to remove the token “done”


for files in *.log; do
echo "ficheros ${files%}"

exit 0

The output messages are as follows


$ ksh -n script_poc_ok
script_poc_ok[5]: syntax error at line 4 : `for' unmatched
$
$ bash -n script_poc_ok
script_poc_ok: line 11: syntax error: unexpected end of file
$

HTH – Antonio NAVARRO

How To See Execution Plan For a Specific Child

Today a development person asked me how he can see an execution plan of an sqlid that has five childs. There are several ways to see the execution plan, from third-party tools that take it out at the press of a button, as if it were magic, and behind they are doing the explain plan, to packages like DBMS_XPLAN. The latter is my recommendation since it is possibly the most powerful that Oracle currently has.

To see a specific child, it is worth making the call in the following way, we pass the child we want to see as the second parameter, in this case child 4;

SELECT * FROM TABLE (DBMS_XPLAN.display_cursor (‘4vnfx3810bfnk’, 4));

HTH – Antonio NAVARRO

Generating hashes For Oracle Procedures

In my previous post I proposed a simple method to identify possible modifications in files at the Operating System level. The idea is simple, it is to generate a checksum or hash of the file by passing it some algorithm that generates this type of hash, the most common are usually DES, 3DES, MD5, SHA, although the former are older and easier to attack. The proposed algorithm is based on MD5 and SHA, and implemented in Python.

In this case we are going to see an example to have a control, and to be able to determine if any procedure, package or function has been modified. We are doing this example in Oracle, but it can be extrapolated to other managers.

Basically what we are going to do is choose a procedure, join all the lines in a variable and apply an algorithm to it, in this case it will be SHA1, to generate a hash. We must store this hash (in a table, in a record in another database, in an excel, etc.) so that at a later time we can compare it and determine if that code has been touched.

DECLARE
TEXTO CLOB;
BEGIN
FOR i IN (SELECT TEXT FROM USER_SOURCE WHERE NAME='MY_PROCEDURE')
LOOP
TEXTO :=  TEXTO || i.text;
END LOOP;
DBMS_OUTPUT.PUT_LINE ('HASH SHA1 FOR THE STORED PROCEDURE : ' || DBMS_CRYPTO.HASH (TEXTO, DBMS_CRYPTO.HASH_SH1));
END;
/

The output is show below;

SQL> DECLARE
2    TEXTO CLOB;
3 BEGIN
4   FOR i IN (SELECT TEXT FROM USER_SOURCE WHERE NAME='MY_PROCEDURE')
5   LOOP
6         TEXTO :=  TEXTO || i.text;
7   END LOOP;
8   DBMS_OUTPUT.PUT_LINE ('HASH FOR THE STORED PROCEDURE : ' || DBMS_CRYPTO.HASH (TEXTO, DBMS_CRYPTO.HASH_SH1));
9  END;
10/

HASH FOR THE STORED PROCEDURE : 047E68B89B3F3321AD9772BE7C4EEAA59A03BF30

PL/SQL procedure successfully completed.

HTH – Antonio NAVARRO