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…

Connect to more than one database to do work

import sqlj.runtime.*; import sqlj.runtime.ref.*; import java.sql.*; #sql context DB1Ctx; // Define conenction context #sql context DB2Ctx; public class SQLJTst3 { 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()); // Connect to multiple databases DB1Ctx dB1 = new…

Fetch multiple records from database

import sqlj.runtime.*; import sqlj.runtime.ref.*; import java.sql.*; // Iterators must be delared on top – sqlj will create classes for them #sql iterator TabIter (String, String); public class SQLJTst2 { 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());…

Select records from a database

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

Describe a database procedure and print its arguments

#define MAX_PLSQL_PARAMETERS 30 #include #include #define SQLCA_INIT EXEC SQL INCLUDE sqlca; typedef char strz[31]; EXEC SQL TYPE strz IS STRING(31) REFERENCE; /* Declare functions */ int ora_logon(); int ora_logoff(); int ora_error(); int plsql_desc(char *procname); /*——————————————————————–*/ int main() { ora_logon(); printf(“About to describe procedure DBMS_OUTPUT.PUT_LINE…\n”); plsql_desc(“DBMS_OUTPUT.PUT_LINE”); ora_logoff(); return 0; } /*——————————————————————– * Login to the Oracle…

Extract SQL Statements from export dump file

// { N=0; } /^CONNECT/ { N=0; } /^CREATE SYNONYM / { N=0; } /^CREATE SEQUENCE / { N=0; } /^CREATE DATABASE LINK / { N=0; } /^CREATE TABLE / { N=0; } /^CREATE INDEX / { N=0; } /^ALTER / { N=0; } /^ANALYZE / { N=0; } /^GRANT / { N=1; } /^AUDIT…

Indexfile beautifier (reformats indexfiles produced by ‘imp indexfile=’)

BEGIN { index_file=”create_index.sql”; print “REM Generated automatically” >index_file; print “SET TRIMSPOOL ON TIMING ON” >index_file; print “ALTER SESSION SET SORT_AREA_SIZE=102400000;” >index_file; print “SPOOL create_index.log” >index_file; print “” >index_file; table_file=”create_table.sql”; print “REM Generated automatically” >table_file; print “SET TRIMSPOOL ON TIMING ON” >table_file; print “SPOOL create_table.log” >table_file; print “” >table_file; trash_file=”create_trash.sql”; print “REM Generated automatically” >trash_file; current_file=trash_file;…