Thursday, September 13, 2007

How to list tables in another schema?

db2 > List tables for schema s1
db2> list tables for schema s2
db2> list tables for schema s3

or to list for all schemas

db2> list tables for all

or

db2 > Select TABSCHEMA, TABNAME, DEFINER from SYSCAT.TABLES where tabschema
IN ('S1','S2','S3')
tabschema is the schema name & Definer is the user name

EXTRA
to check store procedure
db2 > select PROCSCHEMA, PROCNAME from SYSCAT.PROCEDURES where procname = 'RPT_REGUSER_LOGIN_I' or procschema = 'IBSADMIN';

ref

Notes on creating a Java "jar" file for an application

If you have an appliation that you want to package so that it can be executed using a command like:

        java -jar myjarfile.jar arg1 arg2

you will need to create the ".jar" file properly. This means that the class containing the main method must be identified and that you have included any necessary support ".jar" files. You must also include a class path.

If you are using RAD, u may create "Application Client Project" with contain MyJarFileEar and MyJarFile project.

Tuesday, September 11, 2007

Cursor closes at COMMIT unless you use the WITH HOLD option on cursor.

Cursor closes at COMMIT unless you use the WITH HOLD option on cursor.

Example
OPEN UPDATE_CURSOR WITH HOLD;


-- Declare cursor
FOR vl AS
c1 CURSOR with hold FOR
SELECT customer_id as id,full_name from customer where full_name like 'test%'
DO
update customer set status ='A' where customer_id = id;
COMMIT; <======= Can commit inside Loop if you choose WITH HOLD

END FOR;
COMMIT;




ref ,
ibm

Monday, September 10, 2007

alter table in stored procedure

CREATE PROCEDURE ppg_gc (IN expiryTime INTEGER, IN batchSize INTEGER)
LANGUAGE SQL
MODIFIES SQL DATA
BEGIN


declare v_stmt varchar(20);
--now store ur query inside this variable,then prepare the statement.

v_stmt = 'alter table emp drop primary key';
prepare S1 from v_stmt;
EXECUTE IMMEDIATE S1;

END @


ref