Skip to content

Instantly share code, notes, and snippets.

View angoca's full-sized avatar
🏠
Working from home

Andres Gomez Casanova angoca

🏠
Working from home
View GitHub Profile
@angoca
angoca / TweetTable.java
Created February 29, 2012 20:18
Access Twitter from DB2 via a select
import java.util.Iterator;
import twitter4j.Query;
import twitter4j.QueryResult;
import twitter4j.Tweet;
import twitter4j.Twitter;
import twitter4j.TwitterFactory;
import COM.ibm.db2.app.UDF;
/**
@angoca
angoca / chins
Created May 28, 2013 16:13
Instance changer for a db2 server When you have a DB2 server, with many instances, and you have to work in all of them from the same user, this is a useful script that allows you to switch effeiciently from one environment to the other. You just need to put the file in any directory of your server, configure the directories (Instance home and in…
#!/usr/bin/ksh
# Changes the environment to the given instance.
# You need to 'source' this command in order to change the environement.
# To ease the process, you can create an alias per instance in the .profile.
# alias i1=". ~/chins db2inst1"
#set -x
@angoca
angoca / db2cksec
Last active September 22, 2016 16:55
Checks the security in DB2 (authorities at instance and database level)
#!/bin/bash
# The MIT License (MIT)
#
# Copyright (c) 2014 Andres Gomez Casanova
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
@angoca
angoca / db2env
Created August 20, 2013 10:01
Change between multiple DB2 instances in the same server. It has two modes, interactive or with parameter. The script is written in bash for DB2 9.7 but it can be used in any previous or more recent version.
#!/bin/bash
# Changes the environment to the given DB2 instance.
#
# You need to 'source' this command in order to change the environement.
# To ease the process, you can create a function per instance in the .profile.
#
# function i01 { . ${CHINS} db2inst1 ; }
#
# To configure, you just need to change the DB2 path.
@angoca
angoca / Look_For_Object.sql
Last active December 28, 2015 03:19
How to look up for a object in DB2 and know what kind of object it is. It is called like this: db2 "call LOOK_FOR_OBJECT('NULLID','SQLC2H21')"
CREATE OR REPLACE PROCEDURE LOOK_FOR_OBJECT (
IN SCHEM VARCHAR(256),
IN NAME VARCHAR(256)
)
LANGUAGE SQL
SPECIFIC PRO_LOOK_FOR_OBJECT
DYNAMIC RESULT SETS 1
READS SQL DATA
DETERMINISTIC
NO EXTERNAL ACTION
@angoca
angoca / renderNsrLog
Last active June 26, 2016 14:40
Render NSR (Networker) log continuosly like tail -f
#!/bin/bash
# Reads the Networker logs periodically.
# By default 15 seconds.
#
# Original from: http://www.backupcentral.com/phpBB2/two-way-mirrors-of-external-mailing-lists-3/emc-networker-19/nsr-render-log-97064/
LOG_FILE=/nsr/logs/daemon.raw
#LOG_FILE=/nsr/apps/logs/nmda_db2.messages.raw
DATE=$(date +"%m/%d/%y %H:%M:%S")
@angoca
angoca / getAuths
Last active May 27, 2018 22:46
Get all authorization for a given user in DB2 LUW
#!/bin/sh
# Returns all privileges on a database granted to a user.
# The user is passes as first parameter.
#
# Author: Andres Gomez Casanova (AngocA)
# Version: 2016-08-02
# Made in COLOMBIA
DBUSER=$1
@angoca
angoca / deadlock
Last active November 23, 2016 14:23
Recreates a DB2 deadlock
#!/bin/bash
DATABASE=sample
TABLE1=t1
TABLE2=t2
db2 connect to ${DATABASE} > /dev/null
db2 "drop table ${TABLE1}" > /dev/null
db2 "drop table ${TABLE2}" > /dev/null
db2 "create table ${TABLE1} (col1 int, col2 varchar(15))"
@angoca
angoca / lookForObject
Created March 15, 2018 15:39
lookForDb2Object
#!/bin/bash
OBJECT=$2
if [[ -n ${OBJECT} ]] ; then
SCHEMA=$1
else
OBJECT=$1
fi
STMT=""
@angoca
angoca / installAllFixpacks
Created May 14, 2018 17:50
Installs all Db2 fixpack an creates a different instance for each one
#!/bin/bash
# Script to install a set of different Db2 fixpack in the same machine.
# The prerequisites to install Db2 should have been resolved:
# For V11.1:
# sudo dpkg --add-architecture i386
# sudo apt-get install binutils # strings
# sudo apt-get install libaio1 # libaio.so.1
# sudo apt-get install libpam-ldap:i386 -y -q # libpam
# supo apt-get install lib32stdc++6 -y