Donnerstag, 27. September 2018

ORA-01031: insufficient privileges from within a package

Symptom

You try to create tables from within a package, function or procedure. You run the package as the owner of the schema, the stored code is in that schema and the user has the create table privilege granted by a role.
Instead of the table being created, you get ORA-01031: insufficient privileges

Cause

Unknown quirk of Oracle?

Solutions

Make sure the security context of the stored code is authid current_user

Others

Creating views on tables that have been granted by role seems to cause the same problem.

Montag, 10. September 2018

Windows console and UTF-8 and Oracle SQLPLUS

Symptom

 You run scripts in UTF-8 codepage by sqplplus over the bat shell and special characters like umlauts get borked.

Cause

There can be two:
  1. Your bat shell is not running in UTF-8 codepage: Execute chcp to find out. If it returns 65001, you do not have to change anything.
  2. The Oracle ODBC codepage is UTF-8, you do not have to do anything.

Solution

You probably do not need to fiddle with the Windows Registry like described below. You might want to read How to utf-8 with sqlplus too.
  1. Change the codepage of your bat shell to UTF-8 by executing chcp 65001. However, this is a one shot solution only. A permanent solution could be to change registry entry HKEY_LOCAL_MACHINE\Software\Microsoft\Command Processor\Autorun to @chcp 65001>nul.
    Be aware that for some obscure reason the execution of the dir command in console makes it close invariably!
    Be aware that changing registry entry HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Nls\CodePage\OEMCP to 65001 is reported to leave your system in an UNBOOTABLE state!
  2. Change the registry key HKEY_LOCAL_MACHINE\SOFTWARE\Oracle\KEY_OraClient12Home\NLS_LANG to AMERICAN_AMERICA.UTF8.