Pages

Subscribe:

Tuesday, 1 August 2017

How to check date is valid or not using oracle

create or replace FUNCTION IS_VALIDDATE(v_date IN VARCHAR2) RETURN NUMBER IS
    v_date1 DATE;
BEGIN

    SELECT TO_DATE(substr(v_date,0,10),'mm/dd/yyyy') INTO v_date1 FROM DUAL;
        RETURN 1;
    Exception WHEN Others THEN
        RETURN 0;
END;

to check---

select IS_VALIDDATE('04/21/2015') as V_DATE from dual;

How to create cursor in procedure using oracle

create or replace PROCEDURE PROC_TESTPROCEDURENAME
(
REF_CURSOR         OUT      SYS_REFCURSOR,
OP_strException      OUT      VARCHAR2
)
AS
V_COUNT INTEGER:=0;
cursor c is select id from TBL_USERMASTER;
tmp INTEGER;
BEGIN
    open c;
    LOOP EXIT when c%NOTFOUND;
    FETCH c into tmp;
    V_COUNT:=0;
   select count(*) into V_COUNT from TBL_MAPPINGUSERDETAIL where fkUserid=tmp;
   if V_COUNT=0 then
   insert into TBL_MAPPINGUSERDETAIL(id,name,mobile,fkUserid,created_date)
   select SEQ_TBL_MAPPINGUSERDETAIL.NEXTVAL,NAME,MOBILE_NO,SEQID,sysdate from TBL_USERMASTER where id =tmp;
  end if;  
commit;
 
  END Loop;
close c;

  OPEN REF_CURSOR FOR
  select id,name,mobile,fkUserid from TBL_MAPPINGUSERDETAIL order by name;
  OP_strException:='';
 
  exception
        when others then
        OP_strException:= SUBSTR(SQLERRM, 1, 100);
       
        -- Log Table Maintain
END;

Loop in oracle

BEGIN
For i in (select id, name, mobile from testtable)
LOOP
Update mappingtesttable set name = i.name,mobile_no=i.mobile where fkid = i.id;
END LOOP;
END;

How to Create proxy class

C:\Program Files\Microsoft Visual Studio 10.0\VC> wsdl   /out:location to save proxy class(D:\proxyclass.cs) location to consume service or wsdl file(D:\test.wsdl)