Modifying Column Type in Table
Method 1 :

  1. Add a Copy of the Column appending to some identifier to say its a copy i.e _CP
  2. Update the New Column to the Column whose datatype is to be changed
  3. Drop the Old Column
  4. Rename the New Column to Old Column Name
ALTER TABLE TB1 ADD COL_CP VARCHAR2(10);

UPDATE TB1 SET COL_CP = COL1;

ALTER TABLE TB1 DROP COLUMN COL1;

ALTER TABLE TB1 RENAME COLUMN COL_CP to COL1;

In case you are upgrading from Varchar2(250) to Varchar2(4000) the above is not required

Method 2 :

  1. Create a New table(TB2) with the same Columns and Type
  2. Insert the Values into TB2
  3. Truncate or Drop Table TB1
  4. Run the Changes such as New DDL Script
  5. Insert into new Table TB1 from TB2
  6. Drop Table TB2
CREATE TABLE TB1(COL1 NUMBER);

INSERT INTO TB1 VALUES(10);

CREATE TABLE TB2 AS
SELECT * FROM TB1;

DROP TABLE TB1;

.
.
New table Creation Script with New Column Types
.
.
.

INSERT INTO TB1
SELECT * FROM TB2;

DROP TABLE TB2;

While developing Java designers made a Mistake by allowing the static methods to get invoked by instance of a class.

someVariable.SomeMethod() I expect it to use the value of someVariable. If SomeMethod() is a static method, that expectation is invalid.

Language spec allows it like VB does and C# doesn’t.

class Base
{
    static void foo()
    {
        System.out.println("Base.foo()");
    }
}

class Derived extends Base
{
    static void foo()
    {
        System.out.println("Derived.foo()");
    }
}

public class Test
{
    public static void main(String[] args)
    {
        Base b = new Derived();
        b.foo(); // Prints "Base.foo()"
        b = null;
        b.foo(); // Still prints "Base.foo()"
    }
}

There may be times where the excel date is displayed as number like one below. In such case the date can be converted to string as follows

Two things

  1. The J column is aligned to Left which tells there is some custom format done over the cells
  2. On selecting the cell and when you check the drop down at top it shows Custom

The Column K represents the actual value of Cells in J by making it to text format. Now to convert the Column J to Text use this simple excel formula

 =TEXT(A1,"DD/MM/YYYY hh:mm:ss")

இதனை இதனால் இவன்முடிக்கும் என்றாய்ந்
ததனை அவன்கண் விடல்.

“யாரால் இந்த வேலையை முடிக்க முடியும்?”, “அதை செய்வதற்கு அவனுக்கு வேண்டியவை இருக்கின்றதா?” என்பதை யோசித்து ஒரு அரசன் ஒரு வேலையை செய்ய ஆளை தேர்ந்தெடுக்க வேண்டும். அவனை தேர்ந்தெடுத்த பின் அந்த வேலையை அவனிடமே முழுமையை விட வேண்டும்

வெள்ளத்தனைய மலர் நீட்டம்; மாந்தர் தம் உள்ளத்தனையது உயர்வு — திருவள்ளுவர்

Whenever you submit a form to download a file the response sent back is a file. In this case the setter called after the method which does the download has no effect.

 if(form.getDownloadForm != null && form.getDownloadForm.equals("Y"))
 {
   downloadForm(form, request);

   //The Below Setter has No Effect
   form.setDownloadForm("Y");
 }
 class RegisterForm()
 {
   public String downloadForm;

    public void setDownloadForm(String p_download) 
    {
	  this.downloadForm= p_download;
    }
    
    public String getDownloadForm() 
    {
	  return downloadForm;
    }
 } 

The Setter had no effect since the request sent to the downloadForm(form, request); will end up with response of file download and not response which has new values to form set by setter(in our case downloadForm(form, request)) and Page reload.

There are 2 simple fix for this.

Fix 1
One simple fix is to set form hidden property in java script to N after the form get submitted. Note though the form is submitted it is not reloaded with new response since the response sent back is a file.

The Page will be reloaded only when response is sent back to the same URL of browser. Not to the browser as file.

 function downloadWFSetup(pWaterfallId) 
 {	
    $('#downloadForm').val('Y');
    document.WaterfallTriggerForm.submit();

    //This part of code runs even after the form submission since the 
    //response sent is file which does not require page reload
    $('#downloadForm').val('N');			
 }

In our case the page is not going to get reloaded so the java script continues its execution even after form submission setting property of downloadForm to N.

Fix 2
The Other way is to send request in Link with downloadForm=Y. In this case there is no need to to reset the form values as we get the values by request.getParameter() Method.

சிந்தனை 1

‘செல்லாத காசுக்குள்ளும் செப்பு இருக்கு’னு சொல்வாங்க. என் வாழ்க்கையில் நான் கத்துக்கிட்ட ஒரே விஷயம் இதுதாங்க. அடுத்த மனுஷனை மதிக்கணும். அவரையும் நம்மோட ஒருத்தரா நேசிக்கணும். இங்க பெரியவங்க, சின்னவங்கனு யாரும் இல்லை. எல்லாப் பெரியவங்களுக்கும் ஒரு ‘நேத்து’ இருக்கும். அதுபோல சின்னவங்களுக்கும் ஒரு ‘நாளை’ இருக்கும். எனக்கு டீ தர்றான் ஒரு பையன். அது அவர் வேலை. அவர் எங்க வீட்டுக்கு வந்தா நான்தான் அவருக்கு டீ எடுத்துட்டு வந்து தருவேன். தரணும்.

என்னைப் பொறுத்தவரைக்கும் மனுஷங்க மகான்களாவறது பெரிய விஷயம் இல்லை; மனுஷங்களாவே இருக்க முடிஞ்சா… அதுதாங்க சந்தோஷம்!”

-தேவா

சிந்தனை 2

வாழ்வதற்கான செலவு மிகவும் குறைவு…
அடுத்தவன் போல் வாழ்வதற்குத் தான் செலவு அதிகம்…!!

Table Function return a result set that mimics what we would normally expect from a traditional SQL SELECT statement

Table functions are a new feature in Oracle9i that allow you to define a set of PL/SQL statements that will, when queried, behave just as a regular query to table would. The added benefit to having a table function is that you can perform transformations to the data in question before it is returned in the result set.

CREATE OBJECT
Create our own object type called PERSON_DETAILS.Then we create a table of PERSON_DETAILS called PERSON_DETAILS_TABLE.

CREATE TYPE PERSON_DETAILS AS OBJECT
       (USER_NAME     VARCHAR2(50),
        ADDRESS       VARCHAR2(50),
        LOCATION      VARCHAR2(50));
/
CREATE TYPE PERSON_DETAILS_TABLE AS TABLE OF PERSON_DETAILS;
/

PIPELINED Clause

Within the CREATE FUNCTION clause, there is a new option called PIPELINED. This option tells Oracle to return the results of the function as they are processed, and not wait for a complete execution or completion of the result set. This pipelining of the result set to one row at a time has the immediate advantage of not requiring excessive memory or disk staging resources.
PIPE ROW(out_rec)

The PIPE ROW statement is the interface or mechanism to send a piped row through the PIPELINED option through to the caller of the function.

Working with a simple pipelined function requires 2 things

  • collection type
  • pipelined function
 CREATE OR REPLACE TYPE number_ntt AS TABLE OF NUMBER;
CREATE FUNCTION row_generator(rows_in IN P_INTEGER) RETURN number_ntt
  PIPELINED IS
BEGIN
  FOR i IN 1 .. rows_in LOOP
    PIPE ROW(i);
  END LOOP;
  RETURN;
END;
/

The CSV_TABLE is a collection which has rows of comma separated value.

CREATE OR REPLACE TYPE "CSV_TABLE" as table of varchar2(32767)
CSV_TABLE
FUNCTION CSV_TO_TABLE(p_delimted_string VARCHAR2,
                         p_delimter        VARCHAR2 := ',')
  RETURN CSV_TABLE
  PIPELINED IS
  indexCount PLS_INTEGER;
  csvString  VARCHAR2(32767) := p_delimted_string;
BEGIN
  LOOP
    indexCount := instr(csvString, p_delimter);
  
    IF indexCount > 0 THEN
      PIPE ROW(substr(csvString, 1, indexCount - 1));
      csvString := substr(csvString, indexCount + length(p_delimter));
    ELSE
      PIPE ROW(csvString);
      EXIT;
    END IF;
  
  END LOOP;
  RETURN;
END CSV_TO_TABLE;

Input

A,B,C,D

Output

A
B
C
D

The above output is a collection.

 SELECT PACKAGE_NAME.CSV_TO_TABLE('A,B,C,D') FROM DUAL;

When the Column value is NULL it would be replaced by ‘~’ in output

  SELECT NVL(FAX_NO, '~') FROM DUAL;
  SELECT NVL(NULL, '~') FROM DUAL;

The Below query can be used in scenarios where 3 drop downs are used and Location is mandatory and loaded first based on which Area and Pincode should be populated and selection can be made based on that later.

  SELECT Name, Age, PhoneNo
    FROM Person 
   WHERE Location =  p_location and 
         Area =  NVL(p_area, Area) and 
         PinCode =  NVL(p_pin_code, PinCode);

Having more than one input in where clause
i.e

 SELECT * 
  FROM Person 
 WHERE Location IN('North Chennai', 'South Chennai');

When the same query is used in search screen it may have Three possible Values

  • NULL
  • Single Value
  • Multiple Value

The above query works for Single and Multiple value but does not work for NULL.The Above query works for NULL and Single Value but not for Multiple Value.

The below is a simple query which works when PERSON_ID is NULL, Single Value, Multiple Value(CSV).

 SELECT PERSON_ID
  FROM PERSONS P
 WHERE ((CASE
         WHEN 'P101' IS NULL THEN
          NULL
         ELSE
          'P101'
       END) IS NULL OR P.WATERFALL_ID IN ('P101'));

For Multiple Value we need to do slight modification.We need to convert the CSV values into table and give it as input.

 SELECT DISTINCT PERSON_ID
   FROM tblPerson 
  WHERE nvl(PERSON_ID, '~') IN (SELECT column_value
                                  FROM TABLE(PACKAGE_NAME.CSV_TO_TABLE(P_CSV_PERSON_ID))
                                UNION ALL
                                SELECT '~'
                                  FROM dual);

The select query in the where clause will take the value of P_CSV_PERSON_ID (Single or Multiple value) else it will take ~ in case it is NULL

The Other workaround to this is as below

SELECT PERSON_ID
    FROM tblPerson 
   WHERE (((CASE
           WHEN P_CSV_PERSON_ID IS NULL THEN
            NULL
           ELSE
            P_CSV_PERSON_ID
         END)) IS NULL
      OR PERSON_ID IN
         (SELECT *
            FROM TABLE(PACKAGE_NAME.CSV_TO_TABLE(P_CSV_PERSON_ID))));

where

 P_CSV_PERSON_ID= 'P101,P102'

For more details on CSV_TO_TABLE refer Link