SQL Date Issue...

Hi,
I am trying to enter values into the db. The data type for the column is "datetime".
I have the value in the format "2008-10-03 07:50:10.0" and if i do this, i am just left with the date. Time gets truncated.
java.util.Date uploadDate = photo.getUploadDate();
               java.sql.Date sqlUploadDate= null;
               if(uploadDate!=null){
                    sqlUploadDate = new java.sql.Date(uploadDate.getTime());
               stmt.setDate(6,sqlUploadDate);
When i try to print uploadDate i get following : 2008-10-03 07:50:10.0
When i try to print sqlUploadDate i get following : 2008-10-03
Please suggest how can i also pass time along with the date in "sqlUploadDate".
Please let me know if i am not clear enough.
Thanks
Deepti

Hey guys.. i got it working..
I did this if(uploadDate!=null){
                    t = new java.sql.Timestamp(uploadDate.getTime());
               stmt.setTimestamp(6,t);
and i am getting what i needed..
Thanks for you response though...
Thanks
Deepti

Similar Messages

  • After call commit sql , data can not flush to disk

    I use berkey db which support sql . It's version is db-5.1.19.
    1, Open a database.
    2. Create a table.
    3. exec "begin;" sql
    4. exec sql which is insert record into table
    5. exec "commit;" sql
    6. copy database file (SourceDB_912_1.db and SourceDB_912_1.db-journal) to Local Disk of D, then use a tool of dbsql to open the database.
    7. use select sql to check data, there is no record in table.
    1
    sqlite3 * m_pDB;
    int nRet = sqlite3_open_v2(strDBName.c_str(), & m_pDB,SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE,NULL);
    2
    string strSQL="CREATE TABLE [TBLClientAccount] ( [ClientId] CHAR (36), [AccountId] CHAR (36) );";
    char * errors;
    nRet = sqlite3_exec(m_pDB, strSQL.c_str(), NULL, NULL, &errors);
    3
    nRet = sqlite3_exec(m_pDB, "begin;", NULL, NULL, &errors);
    4
    nRet = sqlite3_exec(m_pDB, "INSERT INTO TBLClientAccount (ClientId,AccountId) VALUES('dd','ddd'); ", NULL, NULL, &errors);
    5
    nRet = sqlite3_exec(m_pDB, "commit;", NULL, NULL, &errors);
    Edited by: 887973 on Sep 27, 2011 11:15 PM

    Hi,
    Here is a simple test case program I used based on your description:
    #include <stdio.h>
    #include <stdlib.h>
    #include <string.h>
    #include "sqlite3.h"
    int error_handler(sqlite3*);
    int main()
         sqlite3 *m_pDB;
         const char *strDBName = "C:/SRs/OTN Core 2290838 - after call commit sql , data can not flush to disk/SourceDB_912_1.db";
         char * errors;
         sqlite3_open_v2(strDBName, &m_pDB, SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE, NULL);
         error_handler(m_pDB);
         sqlite3_exec(m_pDB, "CREATE TABLE [TBLClientAccount] ( [ClientId] CHAR (36), [AccountId] CHAR (36) );", NULL, NULL, &errors);
         error_handler(m_pDB);
         sqlite3_exec(m_pDB, "begin;", NULL, NULL, &errors);
         error_handler(m_pDB);
         sqlite3_exec(m_pDB, "INSERT INTO TBLClientAccount (ClientId,AccountId) VALUES('dd','ddd'); ", NULL, NULL, &errors);
         error_handler(m_pDB);
         sqlite3_exec(m_pDB, "commit;", NULL, NULL, &errors);
         error_handler(m_pDB);
         //sqlite3_close(m_pDB);
         //error_handler(m_pDB);
    int error_handler(sqlite3 *db)
         int err_code = sqlite3_errcode(db);
         switch(err_code) {
         case SQLITE_OK:
         case SQLITE_DONE:
         case SQLITE_ROW:
              break;
         default:
              fprintf(stderr, "ERROR: %s. ERRCODE: %d.\n", sqlite3_errmsg(db), err_code);
              exit(err_code);
         return err_code;
    }Than I copied the SourceDB_912_1.db database and the SourceDB_912_1.db-journal directory containing the environment files (region files, log files) to D:\, opened the database using the "dbsql" command line tool, and queried the table; the data is there:
    D:\bdbsql-dir>ls -al
    -rw-rw-rw-   1 acostach 0 32768 2011-10-12 12:51 SourceDB_912_1.db
    drw-rw-rw-   2 acostach 0     0 2011-10-12 12:51 SourceDB_912_1.db-journal
    D:\bdbsql-dir>C:\BerkeleyDB\db-5.1.19\build_windows\Win32\Debug\dbsql SourceDB_912_1.db
    Berkeley DB 11g Release 2, library version 11.2.5.1.19: (August 27, 2010)
    Enter ".help" for instructions
    Enter SQL statements terminated with a ";"
    dbsql> .tables
    TBLClientAccount
    dbsql> .schema TBLClientAccount
    CREATE TABLE [TBLClientAccount] ( [ClientId] CHAR (36), [AccountId] CHAR (36) );
    dbsql> select * from TBLClientAccount;
    dd|dddI do not see where the issue is. The data can be successfully retrieved, it is present in the database.
    Could you try putting in the sqlite3_close() call and see if you still get the error?
    Did you remove the __db.* files from the SourceDB_912_1.db-journal directory?
    Did you use PRAGMA synchronous, and if so, what is the value you set?
    If this is still an issue for you, please describe in more detail the exact steps needed to get this reproduced and provide a simple stand-alone test case program that reproduces it.
    Regards,
    Andrei

  • SQL Interface - Error in Loading the data from SQL data source

    Hello,
    We have been using SQl data source for loading the dimensions and the data for so many years. Even using Essbase 11.1.1.0, it's been quite a while (more than one year). For the past few days,we are getting the below error when trying to load the data.
    [Mon Jan 10 11:02:56 2011]Local/{App Name}/{DB Name}/{User Id}/Info(1021013)
    ODBC Layer Error: [S1000] ==> [[DataDirect][ODBC DB2 Wire Protocol driver][UDB DB2 for Windows, UNIX, and Linux]CURSOR IDENTIFIED IN FETCH OR CLOSE STATEMENT
    IS NOT OPEN (DIAG INFO: ).]
    [Mon Jan 10 11:02:56 2011]Local/{App Name}/{DB Name}/{User Id}/Info(1021014)
    ODBC Layer Error: Native Error code [4294966795]
    [Mon Jan 10 11:02:56 2011]Local/{App Name}/{DB Name}/{User Id}/Error(1021001)
    Failed to Establish Connection With SQL Database Server. See log for more information
    [Mon Jan 10 11:02:56 2011]Local/{App Name}/{DB Name}/{User Id}/Error(1003050)
    Data Load Transaction Aborted With Error [7]
    [Mon Jan 10 11:02:56 2011]Local/{App Name}///Info(1013214)
    Clear Active on User [Olapadm] Instance [1]
    Interestingly, after the job fails thru our batch scheduler environment, when I run the same script that's being used in the batch scheduler, the job completes successfully.
    Also, this is first time, I saw this kind of error message.
    Appreciate any help or any suggestions to find a resolution. Thanks,

    Hii Priya,
    The reasons may be the file is open, the format/flatfile structure is not correct, the mapping/transfer structure may not be correct, presence of invalid characters/data inconsistency in the file, etc.
    Check if the flatfile in .CSV format.
    You have to save it in .CSV format for the flatfile loading to work.
    Also check the connection issues between source system and BW or sometimes may be due to inactive update rules.
    Refer
    error 1
    Find out the actual reason and let us know.
    Hope this helps.
    Regards,
    Raghu.

  • Infopath form taking long time to load sql data

    In infopath form having with multple views. In one of the view SQL Data will be loaded on selection of dropdown to repeating table.  If it is lessthan 1000 items its working, if it is morethan 1500 items form will hanging for 15-20 mins. 
    Form is developed by C# code.  Can anyone suggest to relsolve this issue.  Thanks in Advance.

    Hello,
    I also had same problem while querying connection via rule so i gave chance to code and query executes within 2-5 seconds which was taking 10-15 mins earlier. Try this
    AdoQueryConnection myAdoQueryConnection = (AdoQueryConnection)(this.DataConnections["SQL Con"]);
    myAdoQueryConnection.Command = "select * from table1 where col1 = " + "'" + InstallationID + "'";
    myAdoQueryConnection.Timeout = 60;
    myAdoQueryConnection.Execute();
    Hope it could help
    Hemendra:Yesterday is just a memory,Tomorrow we may never see<br/> Please remember to mark the replies as answers if they help and unmark them if they provide no help

  • Dates issue while running ETL in DAC

    Hello all,
    I am trying to do a load from EBS12 into OBI Applications..everytime there is a task that uses a date, I am getting a date error...I changed the dates in dac..I tryied with runtime or static..I changed the configuration of my date to yyyy-mm-dd and nothing ever changes...
    Those are the messages from the log:
    DIRECTOR&gt; VAR_27028 Use override value DataWarehouse for session parameter:[$DBConnection_OLAP|http://forums.oracle.com/forums/].
    DIRECTOR&gt; VAR_27028 Use override value [ODBC_ORA|http://forums.oracle.com/forums/] for session parameter:[$DBConnection_OLTP|http://forums.oracle.com/forums/].
    DIRECTOR&gt; VAR_27028 Use override value [9] for mapping parameter:[http://mplt_sa_ora_codes.$$datasource_num_id/].
    DIRECTOR&gt; VAR_27028 Use override value --09/25/2008-- for mapping parameter:[http://mplt_bc_ora_codes_sales_picktype.$$last_extract_date/].
    WRITER_1_*_1&gt; WRT_8124 Target Table W_CODE_D :SQL UPDATE statement:
    UPDATE W_CODE_D SET SOURCE_CODE_1 = ?, SOURCE_CODE_2 = ?, SOURCE_CODE_3 = ?, SOURCE_NAME_1 = ?, SOURCE_NAME_2 = ?, MASTER_DATASOURCE_NUM_ID = ?, MASTER_CODE = ?, MASTER_VALUE = ?, W_INSERT_DT = ?, W_UPDATE_DT = ?, TENANT_ID = ? WHERE DATASOURCE_NUM_ID = ? AND SOURCE_CODE = ? AND CATEGORY = ? AND LANGUAGE_CODE = ?
    WRITER_1_*_1&gt; WRT_8124 Target Table W_CODE_D :SQL DELETE statement:
    DELETE FROM W_CODE_D WHERE DATASOURCE_NUM_ID = ? AND SOURCE_CODE = ? AND CATEGORY = ? AND LANGUAGE_CODE = ?
    WRITER_1_*_1&gt; WRT_8270 Target connection group #1 consists of target(s) [W_CODE_D|http://forums.oracle.com/forums/]
    WRITER_1_*_1&gt; WRT_8003 Writer initialization complete.
    READER_1_1_1&gt; BLKR_16007 Reader run started.
    READER_1_1_1&gt; RR_4029 SQ Instance [http://mplt_bc_ora_codes_sales_picktype.sq_wsh_new_deliveries/] User specified SQL Query [SELECT DISTINCT WSH_NEW_DELIVERIES.DELIVERY_TYPE
    FROM
    WSH_NEW_DELIVERIES
    WHERE
    WSH_NEW_DELIVERIES.LAST_UPDATE_DATE &gt; TO_DATE(*'2008-09-25 00:00:00', 'MM/DD/YYYY HH24:MI:SS'*)]
    READER_1_1_1&gt; RR_4049 SQL Query issued to database : (Thu Oct 02 15:12:32 2008)
    WRITER_1_*_1&gt; WRT_8005 Writer run started.
    WRITER_1_*_1&gt; WRT_8158
    *****START LOAD SESSION*****
    Load Start Time: Thu Oct 02 15:12:32 2008
    Target tables:
    W_CODE_D
    READER_1_1_1&gt; CMN_1761 Timestamp Event: [Thu Oct 02 15:16:11 2008]
    READER_1_1_1&gt; RR_4035 SQL Error [
    FnName: Fetch Optimize -- [DataDirect][ODBC Oracle Wire Protocol driver]Error in row.
    FnName: Fetch Optimize -- [DataDirect][ODBC Oracle Wire Protocol driver][Oracle]ORA-01843: not a valid month
    FnName: Fetch Optimize -- [DataDirect][ODBC Oracle Wire Protocol driver]Error in row.
    FnName: Fetch Optimize -- [DataDirect][ODBC Oracle Wire Protocol driver][Oracle]ORA-01002: fetch out of sequence
    FnName: Fetch Optimize -- [DataDirect][ODBC Oracle Wire Protocol driver]Error in row.
    I was never able and I don't know where is the setup for that MM/DD/YYYY that is showing there...that was the first configuration of my date...
    Also, I put null on the dates of the SIL_ tasks as stated in the documentation...but nothing changed....
    is there anyone who can help me?
    thank you very much in advance

    You should start a new thread rather than adding to one that's over 18 months old.
    Make sure to include details of your servers, OS, versions, exact error message, etc.

  • SQL Performance issue: Using user defined function with group by

    Hi Everyone,
    im new here and I really could need some help on a weird performance issue. I hope this is the right topic for SQL performance issues.
    Well ok, i create a function for converting a date from timezone GMT to a specified timzeone.
    CREATE OR REPLACE FUNCTION I3S_REP_1.fnc_user_rep_date_to_local (date_in IN date, tz_name_in IN VARCHAR2) RETURN date
    IS
    tz_name VARCHAR2(100);
    date_out date;
    BEGIN
    SELECT
    to_date(to_char(cast(from_tz(cast( date_in AS TIMESTAMP),'GMT')AT
    TIME ZONE (tz_name_in) AS DATE),'dd-mm-yyyy hh24:mi:ss'),'dd-mm-yyyy hh24:mi:ss')
    INTO date_out
    FROM dual;
    RETURN date_out;
    END fnc_user_rep_date_to_local;The following statement is just an example, the real statement is much more complex. So I select some date values from a table and aggregate a little.
    select
    stp_end_stamp,
    count(*) noi
    from step
    where
    stp_end_stamp
    BETWEEN
    to_date('23-05-2009 00:00:00','dd-mm-yyyy hh24:mi:ss')      
    AND
    to_date('23-07-2009 00:00:00','dd-mm-yyyy hh24:mi:ss')
    group by
    stp_end_stampThis statement selects ~70000 rows and needs ~ 70ms
    If i use the function it selects the same number of rows ;-) and takes ~ 4 sec ...
    select
    fnc_user_rep_date_to_local(stp_end_stamp,'Europe/Berlin'),
    count(*) noi
    from step
    where
    stp_end_stamp
    BETWEEN
    to_date('23-05-2009 00:00:00','dd-mm-yyyy hh24:mi:ss')      
    AND
    to_date('23-07-2009 00:00:00','dd-mm-yyyy hh24:mi:ss')
    group by
    fnc_user_rep_date_to_local(stp_end_stamp,'Europe/Berlin')I understand that the DB has to execute the function for each row.
    But if I execute the following statement, it takes only ~90ms ...
    select
    fnc_user_rep_date_to_gmt(stp_end_stamp,'Europe/Berlin','ny21654'),
    noi
    from
    select
    stp_end_stamp,
    count(*) noi
    from step
    where
    stp_end_stamp
    BETWEEN
    to_date('23-05-2009 00:00:00','dd-mm-yyyy hh24:mi:ss')      
    AND
    to_date('23-07-2009 00:00:00','dd-mm-yyyy hh24:mi:ss')
    group by
    stp_end_stamp
    )The execution plan for all three statements is EXACTLY the same!!!
    Usually i would say, that I use the third statement and the world is in order. BUT I'm working on a BI project with a tool called Business Objects and it generates SQL, so my hands are bound and I can't make this tool to generate the SQL as a subselect.
    My questions are:
    Why is the second statement sooo much slower than the third?
    and
    Howcan I force the optimizer to do whatever he is doing to make the third statement so fast?
    I would really appreciate some help on this really weird issue.
    Thanks in advance,
    Andi

    Hi,
    The execution plan for all three statements is EXACTLY the same!!!Not exactly. Plans are the same - true. They uses slightly different approach to call function. See:
    drop table t cascade constraints purge;
    create table t as select mod(rownum,10) id, cast('x' as char(500)) pad from dual connect by level <= 10000;
    exec dbms_stats.gather_table_stats(user, 't');
    create or replace function test_fnc(p_int number) return number is
    begin
        return trunc(p_int);
    end;
    explain plan for select id from t group by id;
    select * from table(dbms_xplan.display(null,null,'advanced'));
    explain plan for select test_fnc(id) from t group by test_fnc(id);
    select * from table(dbms_xplan.display(null,null,'advanced'));
    explain plan for select test_fnc(id) from (select id from t group by id);
    select * from table(dbms_xplan.display(null,null,'advanced'));Output:
    PLAN_TABLE_OUTPUT
    Plan hash value: 47235625
    | Id  | Operation          | Name | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT   |      |    10 |    30 |   162   (3)| 00:00:02 |
    |   1 |  HASH GROUP BY     |      |    10 |    30 |   162   (3)| 00:00:02 |
    |   2 |   TABLE ACCESS FULL| T    | 10000 | 30000 |   159   (1)| 00:00:02 |
    Query Block Name / Object Alias (identified by operation id):
       1 - SEL$1
       2 - SEL$1 / T@SEL$1
    Outline Data
      /*+
          BEGIN_OUTLINE_DATA
          FULL(@"SEL$1" "T"@"SEL$1")
          OUTLINE_LEAF(@"SEL$1")
          ALL_ROWS
          OPTIMIZER_FEATURES_ENABLE('10.2.0.4')
          IGNORE_OPTIM_EMBEDDED_HINTS
          END_OUTLINE_DATA
    Column Projection Information (identified by operation id):
       1 - (#keys=1) "ID"[NUMBER,22]
       2 - "ID"[NUMBER,22]
    34 rows selected.
    SQL>
    Explained.
    SQL>
    PLAN_TABLE_OUTPUT
    Plan hash value: 47235625
    | Id  | Operation          | Name | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT   |      |    10 |    30 |   162   (3)| 00:00:02 |
    |   1 |  HASH GROUP BY     |      |    10 |    30 |   162   (3)| 00:00:02 |
    |   2 |   TABLE ACCESS FULL| T    | 10000 | 30000 |   159   (1)| 00:00:02 |
    Query Block Name / Object Alias (identified by operation id):
       1 - SEL$1
       2 - SEL$1 / T@SEL$1
    Outline Data
      /*+
          BEGIN_OUTLINE_DATA
          FULL(@"SEL$1" "T"@"SEL$1")
          OUTLINE_LEAF(@"SEL$1")
          ALL_ROWS
          OPTIMIZER_FEATURES_ENABLE('10.2.0.4')
          IGNORE_OPTIM_EMBEDDED_HINTS
          END_OUTLINE_DATA
    Column Projection Information (identified by operation id):
       1 - (#keys=1) "TEST_FNC"("ID")[22]
       2 - "ID"[NUMBER,22]
    34 rows selected.
    SQL>
    Explained.
    SQL> select * from table(dbms_xplan.display(null,null,'advanced'));
    PLAN_TABLE_OUTPUT
    Plan hash value: 47235625
    | Id  | Operation          | Name | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT   |      |    10 |    30 |   162   (3)| 00:00:02 |
    |   1 |  HASH GROUP BY     |      |    10 |    30 |   162   (3)| 00:00:02 |
    |   2 |   TABLE ACCESS FULL| T    | 10000 | 30000 |   159   (1)| 00:00:02 |
    Query Block Name / Object Alias (identified by operation id):
       1 - SEL$F5BB74E1
       2 - SEL$F5BB74E1 / T@SEL$2
    Outline Data
      /*+
          BEGIN_OUTLINE_DATA
          FULL(@"SEL$F5BB74E1" "T"@"SEL$2")
          OUTLINE(@"SEL$2")
          OUTLINE(@"SEL$1")
          MERGE(@"SEL$2")
          OUTLINE_LEAF(@"SEL$F5BB74E1")
          ALL_ROWS
          OPTIMIZER_FEATURES_ENABLE('10.2.0.4')
          IGNORE_OPTIM_EMBEDDED_HINTS
          END_OUTLINE_DATA
    Column Projection Information (identified by operation id):
       1 - (#keys=1) "ID"[NUMBER,22]
       2 - "ID"[NUMBER,22]
    37 rows selected.

  • Add one day to java.sql.date

    I ask user to enter a date: yyyy-mm-dd, then I want to add one day to that date, I don't know how to do it?
    java.sql.Date time2 = java.sql.Date.valueOf( args[0] );
    Many Thanks.

    since a date object is really nothing more than a long you can always add one day's worth of milliseconds to it....
    long milliInADay = 1000 * 60 * 60 * 24;
    Date d = ......
    d.setTime(d.getTime() + milliInADay);although there may be some issues with this i'm unaware of, but seems pretty straightforward to me.

  • Convert java.sql.Date to oracle.jbo.domain.Date in oaf

    Hi,
    Need to dafault NeedBydate(i get in from query as below) to a messagelovinput and make it read only.
    i am facing some issue in converting from java.sql.Date to oracle.jbo.domain.Date.
    unable to figure out the problem.
    below is the sample code im trying to use.
    PreparedStatement ps=pageContext.createPreparedStatement("select sysdate from dual");
    ResultSet rs=ps.executeQuery();
    if (rs!=null && ps.next()
    java.sql.Date sqlDate= rs.getDate(1);
    oracle.jbo.domain.Date oracleDate = new oracle.jbo.domain.Date(sqlDate.getTime());
    vorow.setAttribute("Datevalue",oracleDate);
    this is my assumption : to set to UI i need date in format dd-Mon-yyyy.(am i correct? as to get that format i tried to use simple date format class but no use)
    when i tried to use simple date format :unpaseable date exception was raised.
    please guide.

    Hi,
    Why are you using this code???
    PreparedStatement ps=pageContext.createPreparedStatement("select sysdate from dual");
    ResultSet rs=ps.executeQuery();
    if (rs!=null && ps.next()
    java.sql.Date sqlDate= rs.getDate(1);
    oracle.jbo.domain.Date oracleDate = new oracle.jbo.domain.Date(sqlDate.getTime());
    you can get sysdate using this and then set it
    oracle.jbo.domain.Date currentDate = am.getOADBTransaction().getCurrentUserDate();
    java.text.SimpleDateFormat displayDateFormat = new java.text.SimpleDateFormat ("yyyy-MM-dd");
    String DateForm = displayDateFormat.format(currentDate.dateValue());
    oracle.jbo.domain.Date dateset = new oracle.jbo.domain.Date(DateForm);
    and then set the attribute
    vorow.setAttribute("Datevalue",dateset);
    Thanks,
    Gaurav

  • PL/SQL speed issues when using a variable

    I have a very strange issue that is causing problems.
    I am running Golden connecting to a 11g database.
    I created a procedure to insert records into a table based on a query. The source query includes variables that I have populated prior to the insert statement. The problem is that if I use the variable for one very specific where statement, the statement goes from running in less than 1 second, to running in 15 minutes. It gets even more strange though. Not only does a 2nd variable not cause any problems, the exact same variable in the same statement works fine.
    This procedure takes 15 minutes to run.
    declare
        v_start_period date;
        v_end_period date;
    begin
        select add_months(trunc(sysdate,'mm'), -1), trunc(sysdate,'mm')
        into v_start_period, v_end_period
        from dual;
        insert into RESULTS_TABLE
                (first_audit_date, last_audit_date,
                data_column1, data_column2, data_column3)
            select
                a.first_audit_date, a.last_audit_date,
                b.data_column1, b.data_column2, b.data_column3
            from
                SOURCE_TABLE_1 b,
                (select marker_id, min(action_time) as first_audit_date, max(action_time) as last_audit_date
                    from SOURCE_TABLE_2
                    where action_time >= v_start_period and action_time < v_end_period
                    group by marker_id) a
            where b.marker_id = a.marker_id
                and exists (select 1 from SOURCE_TABLE_2
                    where marker_id = b.marker_id
                    and action_time >= v_start_period and action_time < v_end_period
                    and action_type = 'XYZ');
        commit;
    end;This procedure runs in less than 1 second, yet returns the exact same results.
    declare
        v_start_period date;
        v_end_period date;
    begin
        select add_months(trunc(sysdate,'mm'), -1), trunc(sysdate,'mm')
        into v_start_period, v_end_period
        from dual;
        insert into RESULTS_TABLE
                (first_audit_date, last_audit_date,
                data_column1, data_column2, data_column3)
            select
                a.first_audit_date, a.last_audit_date,
                b.data_column1, b.data_column2, b.data_column3
            from
                SOURCE_TABLE_1 b,
                (select marker_id, min(action_time) as first_audit_date, max(action_time) as last_audit_date
                    from SOURCE_TABLE_2
                    where action_time >= v_start_period and action_time < trunc(sysdate,'mm')
                    group by marker_id) a
            where b.marker_id = a.marker_id
                and exists (select 1 from SOURCE_TABLE_2
                    where marker_id = b.marker_id
                    and action_time >= v_start_period and action_time < v_end_period
                    and action_type = 'XYZ');
        commit;
    end;The only difference between the two is where I replace the first v_end_period variable with trunc(sysdate,'mm').
    I've been googling for possible solutions and keep running into something called "parameter sniffing". It appears to be a SQL Server issue though, as I cannot find solutions for Oracle. I tried nesting the insert statement inside it's own procedure with new variables populated by the old variables, but nothing changed.
    Edited by: user_7000017 on Jan 8, 2013 9:45 AM
    Edited by: user_7000017 on Jan 8, 2013 9:52 AM Put the code in code tags.

    You are not describing procedures. You are listing anonymous PL/SQL blocks.
    As for the code - this approach to assigning PL/SQL variables are highly questionable. As the functions are native PL/SQL functions too, there is no need to parse and execute a SQL cursor, do context switching, in order to assign values to PL/SQL variables.
    This is wrong:
    select
        add_months(trunc(sysdate,'mm'), -1), trunc(sysdate,'mm')
        into v_start_period, v_end_period
    from dual;This is correct:
    v_start_period := add_months(trunc(sysdate,'mm'), -1);
    v_end_period := trunc(sysdate,'mm');Just as you would not use +"select 1 into plVariable from dual;+", instead of a standard variable assignment statement like +"plVariable := 1;"+.
    As for the performance/execution difference. Does not make sense. I suggest simplifying the code in order to isolate the problem. For example, take that in-line SQL (aliased as a in the main SQL) and create a testcase where it uses the function, versus a PL/SQL bind variable with the same data type and value as that returned by the function. Examine and compare the execution plans.
    Increase complexity (if no error) and repeat. Until the error is isolated.
    The 1st step in any troubleshooting, is IDENTIFYING the problem. Without knowing what the problem is, how can one fix it?

  • VPD date issue between 10.1 and 10.2 databases

    I have uncovered an issue today with VPD against date fields. The issue came up at a client site on a 10.2 database. When I got back to the hotel and tried this on my own database, which is 10.1, I got no issue and everything worked ok.
    Therefore, I am asking if anyone is able to try out the following for me on different Oracle databases and platforms and let me know whether it worked for you or not. I'd like to compile a list of database versions and platforms on which the issue occurs.
    Step 1: create this table as a user
    CREATE TABLE TST_DATE AS (
    SELECT 1 PERSON_UID,
    Trunc(SYSDATE) BIRTH_DATE,
    To_Char(Trunc(SYSDATE), 'DD-MON-YYYY') CHAR_DATE,
    123456 TAX_ID,
    'Smith, Michael B.' FULL_NAME FROM dual);
    Step 2: grant select rights on the table
    GRANT SELECT ON TST_DATE TO PUBLIC;
    Step 3: switch your login to SYS and run this script:
    CREATE OR REPLACE FUNCTION F_CHECK_ITEM_TST(p_object_schema in varchar2, p_object_name varchar2)
    RETURN VARCHAR2 IS
    V_PREDICATE VARCHAR2(2000) := '1 = 2';
    BEGIN
    RETURN(V_PREDICATE);
    END F_CHECK_ITEM_TST;
    Step 4: As SYS, run this to grant access rights over the function
    GRANT EXECUTE ON F_CHECK_ITEM_TST TO PUBLIC;
    Step 5: As SYS, run this to enable the policy
    BEGIN DBMS_RLS.ADD_POLICY(
    OBJECT_SCHEMA => 'DRAKE',
    OBJECT_NAME => 'TST_DATE',
    POLICY_NAME => 'SecByTST',
    FUNCTION_SCHEMA => 'SYS',
    POLICY_FUNCTION => 'F_CHECK_ITEM_TST',
    STATEMENT_TYPES => 'SELECT',
    POLICY_TYPE => DBMS_RLS.DYNAMIC,
    SEC_RELEVANT_COLS => 'BIRTH_DATE',
    SEC_RELEVANT_COLS_OPT => DBMS_RLS.ALL_ROWS);
    END;
    Note: in the above policy change the OBJECT_SCHEMA name to be the name of the user who owns the table you created in Step 1
    Step 6: Go into Discoverer Admin and import the table as a new folder.
    Be sure to uncheck the "Date hierarchies" box and set "Default aggregate on data points" to detail. Grant access to any user.
    Step 7: Using Desktop or Plus, log in as that user then try to query the folder with the date not included, there should be no problem.
    Step 8: Now try to query with the date included
    On my 10.2 database I get ORA-24334: no descriptor for this position. This happens when logged into Discoverer as the table owner, EUL owner or any other user. However, when logged into Discoverer as SYS which is exempt from all VPD policies, there is no error when the date is included.
    We tried this in Discoverer Desktop, Plus and Viewer with the same results in all three. We can successfully query the table from SQL*Plus, SQL Developer and TOAD.
    There also seems to be no issue at all with the 10.1 database so there seems to be an issue between Discoverer and the 10.2 database.
    What do you think?
    P.S. to cancel the policy use this script when logged in as SYS:
    EXEC DBMS_RLS.drop_policy(
    OBJECT_SCHEMA => 'DRAKE',
    OBJECT_NAME => 'TST_DATE',
    POLICY_NAME => 'SecByTST');
    This same information is available on my blog in a more readable format here:
    http://learndiscoverer.blogspot.com/2006/12/vpd-date-issue-between-101-and-102.html

    Hi Rod
    Well don't you just love Oracle. Obviously, whatever tests were done for certifying Discoverer against the 10.2 database did not include checking VPD policies. This merits a blog entry from me.
    Your workaround for V_PREDICATE VARCHAR2(2000) := 'BIRTH_DATE=TO_DATE(''01-JAN-0001'')'; works. However, I had to write a new function to do this because my real function was trapping about a dozen items at the same time, some dates, some numbers and some varchars - exactly the way that the Oracle example code shows it in the 10.2 database manual.
    So what I did was to create a new function that only handles dates and added a dedicated policy that works with only that function. Unfortuately, because I have many dates to manage, I was unabe to hard code the BIRTH_DATE so here is what I did:
    V_PREDICATE VARCHAR2(2000) := 'SYSDATE = TO_DATE(''01-JAN-0001'')';
    This works perfectly and Discoverer stopped complaining. It just has two policies on the same table for different data items. Isn't VPD cool? I'm hooked.
    I really appreciate your time and effort on this. Now, let's see what Oracle support make of the issue because I raised a service request last night. No reply yet I'm afraid.
    Best wishes
    Michael

  • Configuring SQL Data Sources in Essbase Server

    Hello,<BR><BR>I was trying to connect Oracle from Essbase Application Manager, after <BR>executing inst-sql.sh and properly setting the ARBORPATH variables and ODBC ini <BR>file into the correct path.Driver is also setup<BR>I created a Rule file and try to connect to Oracle , I am getting an error "SQL Data Source <BR>unavailable for the application"<BR><BR>Could anyone help me in resolving this issue?.

    Do you have the ODBC connection set up on your desktop, or on the server? It may be that you need it on both.

  • Oracle 11g - External Table/SQL Developer Issue?

    Oracle 11g - External Table/SQL Developer Issue?
    ==============================
    I hope this is the right forum for this issue, if not let me, where to go.
    We are using Oracle 11g (11.2.0.1.0) on (Platform : solaris[tm] oe (64-bit)), Sql Developer 3.0.04
    We are trying to use oracle external table to load text files in .csv format. Here is our data look like.
    ======================
    Date1,date2,Political party,Name, ROLE
    20-Jan-66,22-Nov-69,Democratic,"John ", MMM
    22-Nov-70,20-Jan-71,Democratic,"John Jr.",MMM
    20-Jan-68,9-Aug-70,Republican,"Rick Ford Sr.", MMM
    9-Aug-72,20-Jan-75,Republican,Henry,MMM
    ------ ALL NULL -- record
    20-Jan-80,20-Jan-89,Democratic,"Donald Smith",MMM
    ======================
    Our Expernal table structures is as follows
    CREATE TABLE P_LOAD
    DATE1 VARCHAR2(10),
    DATE2 VARCHAR2(10),
    POL_PRTY VARCHAR2(30),
    P_NAME VARCHAR2(30),
    P_ROLE VARCHAR2(5)
    ORGANIZATION EXTERNAL
    (TYPE ORACLE_LOADER
    DEFAULT DIRECTORY P_EXT_TAB_D
    ACCESS PARAMETERS (
    RECORDS DELIMITED by NEWLINE
    SKIP 1
    FIELDS TERMINATED BY "," OPTIONALLY ENCLOSED BY '"' LDRTRIM
    REJECT ROWS WITH ALL NULL FIELDS
    MISSING FIELD VALUES ARE NULL
    DATE1 CHAR (10) Terminated by "," ,
    DATE2 CHAR (10) Terminated by "," ,
    POL_PRTY CHAR (30) Terminated by "," ,
    P_NAME CHAR (30) Terminated by "," OPTIONALLY ENCLOSED BY '"' ,
    P_ROLE CHAR (5) Terminated by ","
    LOCATION ('Input.dat')
    REJECT LIMIT UNLIMITED;
         It created successfully using SQL Developer
    Here is the issue.
    It is not loading the records, where fields are enclosed in '"' (Rec # 2,3,4,7)
    It is loading all NULL value record (Rec # 6)     
    *** If we remove the '"' from input data, it loads all records including all NULL records
    Log file has
    KUP-04021: field formatting error for field P_NAME
    KUP-04036: second enclosing delimiter not found
    KUP-04101: record 2 rejected in file ....
    Our questions
    Why did "REJECT ROWS WITH ALL NULL FIELDS" not working?
    Why did Terminated by "," OPTIONALLY ENCLOSED BY '"' not working?
    Any idea?
    Thanks in helping.

    I don't think this is a SQLDeveloper issue. You will get better answers in the Database - General or perhaps SQL and PL/SQL forums.

  • Oracle 11g - Date Issue?

    Oracle 11g - Date Issue?
    =====================
    I hope this is the right forum for this issue, if not let me, where to go.
    We are using Oracle 11g (11.2.0.1.0) on (Platform : solaris[tm] oe (64-bit)), Sql Developer 3.0.04.
    Our NLS_DATE_FORMAT = 'DD-MON-RR'
    Using 'RR' in the format forces two-digit years less than or equal to 49 to be interpreted as years in the 21st century (2000–2049), and years 50 and over, as years in the 20th century (1950–1999). Setting the RR format as the default for all two-digit year entries allows you to become year-2000 compliant. For example:
    We have a date '01-JUN-31' in our source system. It treat this date as 01-JUN-2031' instead of '01-JUN-1931'. One century forward.
    Do we able to resolve using NLS_DATE_FORMAT change?
    How do we resolve this issue?
    Thanks in helping.

    qwe16235 wrote:
    Our source is Oracle data base, where S_date is defined as DATE. Why did you say STRING , when it defined as DATE data type?I doubt you source is an Oracle database. You may have it stored in an Oracle database, but it cam form somewhere else, and was very likely inserted into the table as a string, wherever it came from. Given a string that resembles a date, Oracle will try to convert it to a date using the nls_date_format parameter for the session (which can either be set in the session or inherited form the database). Perhaps this will help explain:
    SQL> create table t (conv_type varchar2(10), dt date);
    Table created.
    SQL> alter session set nls_date_format = 'dd-mon-rr';
    Session altered.
    SQL> insert into t values ('Implicit', '01-jun-31');
    1 row created.
    SQL> insert into t values ('Explicit', to_date('01-jun-1931', 'dd-mon-yyyy'));
    1 row created.
    SQL> commit;
    Commit complete.
    SQL> select conv_type, to_char(dt, 'dd-mon-yyyy') dt
      2  from t;
    CONV_TYPE  DT
    Implicit   01-jun-2031
    Explicit   01-jun-1931So, unless you are really inserting dates, not strings that look like dates, you are going to have problems.
    John

  • Concatenated SQL Data Source in BIP 11G

    Hi all,
    I have performed a repository upgrade of BI Publisher from 10G to 11G. Everything is working perfectly fine except the problem below:
    All the reports consists of 2 data sets. Both of them are sql queries. Data_set 1 is guaranteed to return the result set as it queries the sysdate and puts as the date the report ran. This is for auditing purpose. Data_Set2 contains the business logic for the report. At times this query does not return any data. In the case where both queries returned data, I am able to publish my report in all available output formats. e.g xml, pdf and html just to mention a few. However, in the case where Data_Set2 does not have any result set but Data_Set1 does, I am only able to display the data in XML not PDF or HTML. For pdf it come back with the message "Failed to load PDF Document" and in HTML comes with an error message "oracle.xdo.servelet.data.DataException: Layout not found".
    In BI Publisher 10G, you can could choose an option of "Concatenated SQL Data Source" and it will be able to generate the report in any format with just the result set of Data_Set1 i.e sysdate for the date when the report was ran.
    Any idea as to how I can achieve the same goal in BI Publisher 11.1.1.5
    Regards
    Joster

    Hi all,
    I managed to realise what was the problem.
    It seems like with BIP 11G, one does not to explicitly select "concatenated SQL Data Source" as was the case in 10G when using more than one data source. This option is implicitly applied.
    The issue on my side was that some of the templates I had upgraded from 10G were corrupted hence the data was returned through xml but not other template based output.
    Thanks
    Joster

  • My database not listed at SQL data source in Web Expression 4

    Can anyone help me out?
    Am not sure whether this is the correct place for my problem.
    I set up SQL Server 2005. Created a database named "employee" and a table under it "emp_info"
    I tried to connect it from Microsoft Web Expression 4 through SQL Data Source control. Well, the connection test is successful but the database i created is not shown in the drop down. However, it shows the system databases. 
    Again i create the table under one of the system databases, and tried to connect it. Those system tables which are there from before are only available to connect but not the table i newly created.
    I have checked the properties, permission of the table as well as the database. Nothing is wrong there.
    Will attach screenshot after the forum admin verify me.

    Hi Marconi,
    The forum supports VS setup and installation. Your issue is more about Web Expression 4. But I find the information below from the link:http://www.microsoft.com/expression/eng/#web
    The web is now about applications as well as traditional web sites, and this requires a new set of tools. Microsoft is committed to offering a unified approach to focus on web design and development features in Microsoft Visual Studio 2013 and beyond.
    As part of this consolidation, Microsoft Visual Studio 2013 provides the leading web development tool, which enables you to design, develop, and maintain websites and web applications. Visual Studio 2013 makes it easy to build CSS-based websites from the
    ground up with CSS layouts, HTML5 support and full featured capabilities for working with and debugging JavaScript. Learn more about
    Visual Studio Express 2013 for Web and
    WebMatrix 3.
    It seems you could install VS express 2013 for web to instead it. If you want to install VS express for web and you encounter any issue, you could post the installation issue to here.
    >>No, this is not the correct forum. This forum is for using .Net Framework inside SQL Server.
    The sentense is from the first reply. It seems you first post the issue to SQL server for help. As Erland said, it seems your issue is more about Web Expression 4. Have you solved your issue by using the first reply? If has, please mark the first reply as
    answer. If not, you could post your issue to the related forum for better support.
    http://social.msdn.microsoft.com/Forums/expression/en-US/home?forum=web
    I will move the thread to off-topic forum. Thanks for your understanding.
    Regards,
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

Maybe you are looking for