Scripts

Execute operating systems commands from PL/SQL (external procedure call)

* Setup instructions: * * 1. Compile this program: cc -G extproc.c -o extproc.so (on Unix) * 2. Run $ORACLE_HOME/bin/extproc to ensure it is executable * 3. Define this TNSNAMES.ORA entry (Use the correct domain): * EXTPROC_CONNECTION_DATA.WORLD = (DESCRIPTION = * (ADDRESS=(PROTOCOL=IPC)(KEY=extproc)) * (CONNECT_DATA=(SID=extproc))) * 4. Define this LISTENER.ORA entry: * EXTERNAL_PROCEDURE_LISTENER = * (ADDRESS_LIST=(ADDRESS=(PROTOCOL=IPC)(KEY=extproc)))…

Tags:

Security fix for problem with arguments showing up in Unix ‘ps -ef’ output

#ifndef _OS_H #define _OS_H #ifdef SYS5 #undef SYS5 #endif #ifdef SVR4 #undef SVR4 #endif #ifdef __pyrsoft #define _DCOSX_ #define _OS_ “DCOSX” #define SYS5 #define SVR4 #else #ifdef pyr #define _OSX_ #define _OS_ “OSX” #else #ifdef _SEQUENT_ #define _PTX_ #define _OS_ “PTX” #define SYS5 #else #ifdef sequent #define _DYNIX_ #define _OS_ “DYNIX” #else #ifdef sun #if…

Wrapper for Oracle SQL*Plus to give you command editing and history

#include #include #include #include #include #include #include <sys/wait.h> #include <readline/readline.h> #include <readline/history.h> #define SQLPLUS “sqlplus” /******************************************************/ static volatile int g_done = 0; static volatile int g_exit_code = 0; static pid_t g_childpid = -1; char *commands[] = { /* SQL*Plus commands */ “ACCEPT”, “DEFINE”, “EDIT”, “EXIT”, “QUIT”, “GET”, “HOST”, “HELP”, “LIST”, “PROMPT”, “RUN”, “SAVE”, “SHOW”, “SPOOL”,…

Extracts archive log header information

#include #include #include #include #include #include #include #include #include #include /* 20010123/FLIX alexandre@neutrinos.org To compile the source: just do: gcc -Wall -O2 archivelog_magic.c -o archivelog_magic To use it: 1. archivelog_magic /path/to/my/archivelog 2. cat /path/to/my/archivelog | archivelog_magic What does it do: for earch file, it search for the magic cookie of oracle (AFAIK bits 12-15) then…

Fetch data from a REF CURSOR

import sqlj.runtime.*; import sqlj.runtime.ref.*; import java.sql.*; public class SQLJTst6 { #sql public static iterator EmpIter (int empno, String ename); public static void main(String[] args) { Connection c = null; String URL = “jdbc:oracle:thin:@localhost:1521:orcl”; String userid = “scott”; String passwd = “tiger”; try { DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver()); c = DriverManager.getConnection(URL, userid, passwd); System.out.println(“Successfully conencted to Oracle…”); //…

Execute DML against a database

import sqlj.runtime.*; import sqlj.runtime.ref.*; import java.sql.*; public class SQLJTst5 { public static void main(String[] args) { Connection c = null; String URL = “jdbc:oracle:thin:@oracle10:1521:acme”; String userid = “acme”; String passwd = “acme”; try { DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver()); c = DriverManager.getConnection(URL, userid, passwd); System.out.println(“Successfully conencted to Oracle…”); // You need to set a Context for SQLJ, otherwise…

Execute a database procedure with known IN OUT arguments

import sqlj.runtime.*; import sqlj.runtime.ref.*; import java.sql.*; public class SQLJTst4 { public static void main(String[] args) { Connection c = null; String URL = “jdbc:oracle:thin:@oracle10:1521:acme”; String userid = “acme”; String passwd = “acme”; try { DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver()); c = DriverManager.getConnection(URL, userid, passwd); System.out.println(“Successfully conencted to Oracle…”); // You need to set a Context for SQLJ, otherwise…