Tuesday, December 13, 2011

has been updated by another user (3,1)

Whenever we have error with description: 'has been updated by another user (3,1)' in Application Designer, Purge Cache Directories in Configuration Manager will help. This is expected when we edit PeopleCode on Component level.

Some times it is not same as deleting files in directory: PS/CACHE. As such, first option is suggested over Second one.


Wednesday, November 30, 2011

Friday, November 11, 2011

Export import utility in Oracle


Exporting Setup Tables


STEP 1 :  Create a Directory Object in Sourced Oracle Database


CREATE DIRECTORY BKUP AS 'export directory path';

eg.,

a.  Login to the Source database using sysadm (if sysadm has directory creation rights) or system or sysdba and create the directory

CREATE DIRECTORY BKUP AS '/opt/oracle/expbkp';

b. Grant access to the directory to the sysadm user if you created the directory using non sysadm user


GRANT ALL ON DIRECTORY BKUP TO SYSADM;

EXIT


STEP 2 :  Prepare parameter file for exporting setup tables.  Change the values of the parameters userid, tables


a.  Edit the values of the parameters

USERID=SYSADM/SYSADM@DBNAME   --> change the logon credential
EXCLUDE=STATISTICS
COMPRESSION=ALL
DIRECTORY=BKUP  --> directory name created in the Step 1
TABLES=SETUP_TABLE_NAME1,   --> setup table names..
SETUP_TABLE_NAME2,
SETUP_TABLE_NAME3,
SETUP_TABLE_NAMEn

EG.,

USERID=SYSADM/SYSADM@HR91DMO  
EXCLUDE=STATISTICS
COMPRESSION=ALL
DIRECTORY=BKUP  
TABLES=PS_COUNTRY_TBL,
PS_REG_REGION_TBL,
PS_STATE_TBL



b. Login to the Server where the Source db is hosted and navigate to the backupfolder

c. create the parameter file setuptables.par

Open up any text editor and paste the above lines after changing the parameter values and save it as setuptables.par



STEP 3 :  Trigger the Oracle Export Utility

a.  Navigate to the the backup folder where you saved the parameter file and kick off the below script in the command line

expdp parfile=setuptables.par DUMPFILE=SETUPTABLES.dmp  LOGFILE=SETUPTABLES.log


STEP 4 : Monitor the execution of Step 3 for successful completion.  The output should be similar to the one given below..



Dump file set for SYSADM.SYS_EXPORT_TABLE_01 is:
  /opt/oracle/oradata/expbkup/SETUPTABLES.dmp
Job "SYSADM"."SYS_EXPORT_TABLE_01" successfully completed at 09:35:54



Exporting Transactional Tables


STEP 1 :  Create a Directory Object in the Source Database

If you first exported the setup tables, you can ignore this step as the directory was created when you
exported setup tables

STEP 2 : Create the parameter file for exporting transactional tables


USERID=SYSADM/SYSADM@DBNAME   --> change the logon credential
EXCLUDE=STATISTICS
COMPRESSION=ALL
DIRECTORY=BKUP  --> directory name created in the Step 1
TABLES=TRANS_TABLE_NAME1,   --> setup table names..
TRANS_TABLE_NAME2,
TRANS_TABLE_NAME3,
TRANS_TABLE_NAMEn
QUERY=TRANS_TABLE_NAME1:"WHERE ",
      TRANS_TABLE_NAME2:"WHERE ",
      TRANS_TABLE_NAME3:"WHERE "
      TRANS_TABLE_NAMEn:"WHERE "


eg.,

1. COMMON FILTER

USERID=SYSADM/SYSADM@HR91DMO  
EXCLUDE=STATISTICS
COMPRESSION=ALL
DIRECTORY=BKUP  
TABLES=PS_PERSON,
PS_NAMES
PS_ADDRESSES
QUERY="WHERE EMPLID LIKE 'KCN%'"   --> WHEN ALL TABLES ARE HAVING COMMON FILTER


2. DIFFERENCE IN FILTER

USERID=SYSADM/SYSADM@HR91DMO  
EXCLUDE=STATISTICS
COMPRESSION=ALL
DIRECTORY=BKUP  
TABLES=PS_PERSON,
PS_NAMES
PS_ADDRESSES


QUERY=PS_PERSON:"WHERE EMPLID LIKE 'KCN%'",   --> WHEN ALL TABLES ARE HAVING COMMON FILTER
PS_NAMES:"WHERE NAME_TYPE='PRI'",
PS_ADDRESSES:"WHERE CITY='SGP'"


b. Login to the Server where the Source db is hosted and navigate to the backupfolder

c. create the parameter file transtables.par

Open up any text editor and paste the above lines after changing the parameter values and save it as transtables.par


STEP 3 :  Trigger the Oracle Export Utility

a.  Navigate to the the backup folder where you saved the parameter file and kick off the below script in the command line


 expdp parfile=transtables.par DUMPFILE=TRANS_TABLES1.dmp  LOGFILE=TRANS_TABLES1.log


STEP 4 : Monitor the execution of Step 3 for successful completion.  The output should be similar to the one given below..


******************************************************************************
Dump file set for SYSADM.SYS_EXPORT_TABLE_01 is:
  /opt/oracle/oradata/expbkup/TRANS_TABLES.dmp
Job "SYSADM"."SYS_EXPORT_TABLE_01" successfully completed at 09:46:47




Importing the data in to source

Step 1 :  create a directory object in the Target Database

Step 2 :  Copy the .dmp files generated for setup and transactional tables in to the folder for which the directory object is created

Step 3 :  Kick off the impdp to import the data with appropriate import flags


Eg.,

impdp sysadm/SYSADM@hr91dmo directory=bkup full=y IGNORE=Y dumpfile=TRANS_TABLES.dmp logfile=trans_tables_import.log 

impdp sysadm/SYSADM@hr91dmo directory=bkup full=y IGNORE=Y dumpfile=SETUP_TABLES.dmp logfile=setup_tables_import.log 


Note :  IGNORE=Y should be mentioned if the setup and transactional tables are already present in the target database

Thursday, November 3, 2011

Locked Objects Delete


DELETE
   FROM PSCHGCTLLOCK

WHERE  OBJECTVALUE1 ='
obj_name' AND OPRID = 'Oprid'

Singapore NRIC Number Generator

http://samliew.com/icgen/

Tuesday, October 25, 2011

Simple SQL to load data from one table to other table with the same structure


Simple SQL to load data from one table to other table. It has below features
  1. It has exception section to avoid aborting the SQL for errors.
  2. It will tract the start and end time of loading.
  3. First one: First Section is record by record processing section. It will dynamically take the record names from a table. Source record is the same structure as destination but in different instance which is connected to Destination DB with a DBLink.
  4. Second Section: Second Section is row by row processing.
Please note that the text enclosed in Square Brace should be replaced with appropriate Record name/Field Name.


DECLARE

  ERRORCODE NUMBER(10);
  ERRORMESG VARCHAR2(1000);
  TIMESTMP TIMESTAMP;
  RECNAME12 VARCHAR2(20);
  STMT_STR VARCHAR2(500);
  RECNM2 VARCHAR2(500);
  RECNM1 VARCHAR2(500);
  SINGLESPACE VARCHAR2(500);
  SINGLESPACE1 VARCHAR2(500);
  ROW_COUNT1 NUMBER(10);
  ROW_COUNT2 NUMBER(10);

BEGIN
SELECT CURRENT_TIMESTAMP INTO TIMESTMP FROM DUAL;
DBMS_OUTPUT.PUT_LINE('Sample DC start '||TIMESTMP);

FOR J IN(SELECT RECNAME RECNAME1 FROM [RECORD WITH TABLE NAMES] WHERE FLAG_FIELD = 'REC')

LOOP
   BEGIN
    STMT_STR := 'INSERT INTO [Log TAble1](RECNAME,BEGINDTTM,ENDDTTM,ROW_COUNT,TOTAL_ROW_COUNT,ERRCOLORBG,DESCR200) VALUES(:TEST1,:TEST2,:TEST3,:TEST4,:TEST5,:TEST6,:TEST7)';
    EXECUTE IMMEDIATE 'SELECT COUNT(*) FROM PS_'||J.RECNAME1||'@[DB Link NAme]' INTO ROW_COUNT1 ;
    EXECUTE IMMEDIATE STMT_STR USING J.RECNAME1,CURRENT_TIMESTAMP,SYSDATE,ROW_COUNT1,0,' ',' ';
   
    EXECUTE IMMEDIATE 'INSERT INTO PS_'||J.RECNAME1||' SELECT * FROM PS_'||J.RECNAME1||'@[DB Link NAme]';
   
    STMT_STR := 'INSERT INTO [Log TAble1](RECNAME,BEGINDTTM,ENDDTTM,ROW_COUNT,TOTAL_ROW_COUNT,ERRCOLORBG,DESCR200) VALUES(:TEST1,:TEST2,:TEST3,:TEST4,:TEST5,:TEST6,:TEST7)';
    EXECUTE IMMEDIATE 'SELECT COUNT(*) FROM PS_'||J.RECNAME1 INTO ROW_COUNT2 ;
    EXECUTE IMMEDIATE STMT_STR USING J.RECNAME1,CURRENT_TIMESTAMP,SYSDATE,ROW_COUNT1,ROW_COUNT2,' ',' ';
   
    EXCEPTION
    WHEN OTHERS THEN
      errorcode := SQLCODE;
      ERRORMESG := SQLERRM;
      ERRORMESG := ERRORMESG || '->(' || J.RECNAME1  || ')' ;
      EXECUTE IMMEDIATE 'INSERT INTO SYSADM.[Log TAble1](RECNAME,BEGINDTTM,ENDDTTM,ROW_COUNT,TOTAL_ROW_COUNT,ERRCOLORBG,DESCR200) VALUES(:TEST1,:TEST2,:TEST3,:TEST4,:TEST5,:TEST6,:TEST7)' USING J.RECNAME1,CURRENT_TIMESTAMP,SYSDATE,ROW_COUNT1,0,' ',ERRORMESG;
      COMMIT;
      DBMS_OUTPUT.PUT_LINE(TO_CHAR(ERRORCODE) || '-' || ERRORMESG);
   
  END;
END LOOP;
COMMIT;
DBMS_OUTPUT.PUT_LINE('Sample DC End '||TIMESTMP);

---------- Second Section - Start ---------
-- Table1
    SELECT CURRENT_TIMESTAMP INTO TIMESTMP FROM DUAL;
    dbms_output.put_line('Table1 start '||timestmp);
--    SELECT 'Table1' INTO RECNAME1 FROM DUAL;
--Insert total count in log table before running script
    INSERT INTO [Log TAble1](RECNAME,BEGINDTTM,ENDDTTM,ROW_COUNT,TOTAL_ROW_COUNT,ERRCOLORBG,DESCR200) VALUES('[Table1]',CURRENT_TIMESTAMP,NULL,(SELECT COUNT(*) FROM [Table1]@[DB Link Name]),0,' ',' ');

--Insert 8.3 table data into 9.1 table
      FOR J IN (SELECT [Field1] Field1,
      [FIELD2] FIELD2,
      [FIELD3] FIELD3,
      [FIELD4] FIELD4,
      [FIELD5] FIELD5,
      [Field6] Field6 FROM [Table1]@[DB Link Name])
   
LOOP
                BEGIN
                                INSERT INTO [TABLE1]
                                ([Field1],
      [Field2],
      [FIELD3],
      [Field4],
      [Field5],
      [FIELD6])
    VALUES
    (J.field1,
    J.field2,
    J.FIELD3,
    J.field4,
    J.FIELD5,
    J.FIELD6);
   
                EXCEPTION
                                                WHEN OTHERS THEN
                                                                errorcode := SQLCODE;
                                                                ERRORMESG := SQLERRM;
                                                                errormesg := errormesg || '->(' || J.field1 || ',' || J.field2 || ',' || J.field3 || ')' ;
       
                                                INSERT INTO [DETAILED LOG TABLE2](RECNAME,BEGINDTTM,ENDDTTM,FIELDNAME0,FIELDNAME1,FIELDNAME2,DESCR200) VALUES ('[Table1]',CURRENT_TIMESTAMP,NULL,'[field1]','[field2]','[field3]',ERRORMESG);
   
                                                COMMIT;
                               
    dbms_output.put_line(TO_CHAR(errorcode) || '-' || errormesg);
                END;
END LOOP;

DBMS_OUTPUT.PUT_LINE('table1 completed '||TIMESTMP);
INSERT INTO [Log TAble1](RECNAME,BEGINDTTM,ENDDTTM,ROW_COUNT,TOTAL_ROW_COUNT,ERRCOLORBG,DESCR200) VALUES('[Table1]',CURRENT_TIMESTAMP,NULL,(SELECT COUNT(*) FROM [Table1]@[db link name]),(SELECT COUNT(*) FROM [Table1]),' ',' ');
COMMIT;


END;

Tuesday, October 18, 2011

Issue in loading PeopleTools

If we have any issue with loading PeopleTools, it can be because of Visual Studio is not installed in your machine. Try running file as specified below.

File name: psvccrt_retail.msi Path: PeopleTools8.51\PT8.51\setup\psvccrt