Issue in invoking procedure

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • hussain123
    New Member
    • Jan 2007
    • 28

    Issue in invoking procedure

    Hi All,
    I am invoking a procedure which takes 2 IN parameters and both are dates which are passed as string.In the procedure I am using those 2 IN parameters to query the db and fetch record between those two dates.
    In java I m doin something like:-

    Code:
    String s_dt= "14/03/2006 09:30:30";
    String e_dt= "15/04/2008 09:30:30";
    String query = "begin ? := pkg.temp_proc(?, ?); end;";
    CallableStatement proc = con.prepareCall(query);
    proc.setString(1, s_dt);
    proc.setString(2, e_dt);
    In the procedure I m doing this :-

    Code:
    CREATE OR REPLACE PACKAGE BODY pkg
    AS
    Procedure temp_proc
    (pv_startdate_in IN VARCHAR2,
    pv_enddate_in IN VARCHAR2)
    as
    Begin
    
    select * from table_temp where col_one between to_date(pv_startdate_in,'DD/MM/YYYY HH24:MI:SS') AND to_date(pv_enddate_in,'DD/MM/YYYY HH24:MI:SS')
    
    end;
    end pkg;
    When I run my java code I get the following error message:-
    ORA-01830: date format picture ends before converting entire input string

    I have gone mad trying to figure out why it is throwing this error.

    Any help would be highly appreciated.

    Thanks in advance,
    Hussain
  • amitpatel66
    Recognized Expert Top Contributor
    • Mar 2007
    • 2358

    #2
    Originally posted by hussain123
    Hi All,
    I am invoking a procedure which takes 2 IN parameters and both are dates which are passed as string.In the procedure I am using those 2 IN parameters to query the db and fetch record between those two dates.
    In java I m doin something like:-

    Code:
    String s_dt= "14/03/2006 09:30:30";
    String e_dt= "15/04/2008 09:30:30";
    String query = "begin ? := pkg.temp_proc(?, ?); end;";
    CallableStatement proc = con.prepareCall(query);
    proc.setString(1, s_dt);
    proc.setString(2, e_dt);
    In the procedure I m doing this :-

    Code:
    CREATE OR REPLACE PACKAGE BODY pkg
    AS
    Procedure temp_proc
    (pv_startdate_in IN VARCHAR2,
    pv_enddate_in IN VARCHAR2)
    as
    Begin
     
    select * from table_temp where col_one between to_date(pv_startdate_in,'DD/MM/YYYY HH24:MI:SS') AND to_date(pv_enddate_in,'DD/MM/YYYY HH24:MI:SS')
     
    end;
    end pkg;
    When I run my java code I get the following error message:-
    ORA-01830: date format picture ends before converting entire input string

    I have gone mad trying to figure out why it is throwing this error.

    Any help would be highly appreciated.

    Thanks in advance,
    Hussain
    Run this statement before running your code:

    [code=oracle]

    ALTER SESSION SET nls_Date_format = 'DD/MM/YYYY HH24:MI:SS'
    /
    [/code]

    Comment

    • QVeen72
      Recognized Expert Top Contributor
      • Oct 2006
      • 1445

      #3
      Hi,

      I guess, Your Proc returns some data and it is the first parameter..
      second and third would be your Date parameters..

      [code=java]
      String query = "begin ? := pkg.temp_proc(? , ?); end;";
      CallableStateme nt proc = con.prepareCall (query);
      proc.setString( 2, s_dt);
      proc.setString( 3, e_dt);
      [/code]

      Regards
      Veena
      Last edited by amitpatel66; Mar 18 '08, 09:18 AM. Reason: code tags

      Comment

      • smruti
        New Member
        • Mar 2008
        • 6

        #4
        Originally posted by hussain123
        Hi All,
        I am invoking a procedure which takes 2 IN parameters and both are dates which are passed as string.In the procedure I am using those 2 IN parameters to query the db and fetch record between those two dates.
        In java I m doin something like:-

        Code:
        String s_dt= "14/03/2006 09:30:30";
        String e_dt= "15/04/2008 09:30:30";
        String query = "begin ? := pkg.temp_proc(?, ?); end;";
        CallableStatement proc = con.prepareCall(query);
        proc.setString(1, s_dt);
        proc.setString(2, e_dt);
        In the procedure I m doing this :-

        Code:
        CREATE OR REPLACE PACKAGE BODY pkg
        AS
        Procedure temp_proc
        (pv_startdate_in IN VARCHAR2,
        pv_enddate_in IN VARCHAR2)
        as
        Begin
        
        select * from table_temp where col_one between to_date(pv_startdate_in,'DD/MM/YYYY HH24:MI:SS') AND to_date(pv_enddate_in,'DD/MM/YYYY HH24:MI:SS')
        
        end;
        end pkg;
        When I run my java code I get the following error message:-
        ORA-01830: date format picture ends before converting entire input string

        I have gone mad trying to figure out why it is throwing this error.

        Any help would be highly appreciated.

        Thanks in advance,
        Hussain
        try to put cast or convert functions
        i think it will help u..

        Comment

        Working...