Saturday, September 29, 2012

redirect a page according to view parameter

in jsf page




  <f:metadata>
            
            <f:viewParam name="id" value="#{testBean.val}" />
        </f:metadata>




in managed bean

  public void setVal(String val) throws IOException {
        System.out.println("Value Set"+ new Date());
        if(val.startsWith("1"))
             FacesContext.getCurrentInstance().getExternalContext().dispatch("/foo.xhtml");
        else
            FacesContext.getCurrentInstance().getExternalContext().dispatch("/bar.xhtml");
           
        this.val = val;
    }

Wednesday, September 26, 2012

Checking NULL in PL/SQL


CREATE OR REPLACE FUNCTION date_null(
    iv_number IN DATE,dt IN DATE)
  RETURN integer
  IS
  d integer;
BEGIN

  IF iv_number is NULL THEN  d :=1;
  ELSE
    d :=2;
    
  END IF ;
   RETURN d;
   
END;


Tuesday, September 25, 2012

Functions in PL/SQL

 function definition



CREATE OR REPLACE FUNCTION larger_date(
    iv_number IN DATE,dt IN DATE)
  RETURN DATE IS
  d date;
BEGIN

  IF iv_number > dt THEN  d :=iv_number -7;
  ELSE
    d :=dt;
    
  END IF ;
   RETURN d;
   
END;


How to call in SQL

SELECT  larger_date

(sysdate-1,sysdate+1)

FROM DUAL;

Sunday, September 09, 2012

create database link with out editing tnsnames.ora



create database link a_dblink
  connect to system identified by password
 using
 '(DESCRIPTION=
   (ADDRESS=
     (PROTOCOL=TCP)
    (HOST=192.168.12.152)
    (PORT=1521))
   (CONNECT_DATA=
    (SID=my_sid)))';