Timestamp column loading error

hi ,
I am 1 table as below.               
CREATE TABLE DBMG_SAL_HEAD (
CM_DATE DATE,
CM_TIME VARCHAR2(8),
data in table is..
CM_DATE     CM_TIME
10/20/2010 13:09:06
now I need to insert above data in below table with 1 second less time ex-10/20/2010 13:09:05
CREATE TABLE PC (
COL1 TIMESTAMP(9)
how I can do it??
I tried below query but when I entered in table its not showing correct format..I m using oracle 11g.
select TO_DATE( TO_CHAR(TO_DATE( CM_DATE||' '||CM_TIME,'dd-mm-yyyy hh24:mi:ss'),'dd-mm-yyyy hh24:mi:')||
          TO_CHAR(TO_CHAR(TO_DATE( CM_TIME,'hh24:mi:ss'),'ss')-1) ,'dd-mm-yyyy hh24:mi:ss') cr_date
FROM DBMG_SAL_HEAD ;
o/p is correct as i need..
10/20/0010 1:09:05 PM
now i m inserting ..
insert into pc
select TO_DATE( TO_CHAR(TO_DATE( CM_DATE||' '||CM_TIME,'dd-mm-yyyy hh24:mi:ss'),'dd-mm-yyyy hh24:mi:')||
          TO_CHAR(TO_CHAR(TO_DATE( CM_TIME,'hh24:mi:ss'),'ss')-1) ,'dd-mm-yyyy hh24:mi:ss') cr_date
FROM DBMG_SAL_HEAD ;
commit;
select * from pc;
o/p is
20-OCT-10 0 why data is coimng like this ??i need it in 10/20/0010 1:09:05 PM format...
plz fix it..........!
rgds,
pc

PC wrote:
hi ,
I am 1 table as below.               
CREATE TABLE DBMG_SAL_HEAD (
CM_DATE DATE,
CM_TIME VARCHAR2(8),
Bad design from the get-go. DATE data holds both date and time. No justification for having a separate column for time only.
data in table is..
CM_DATE     CM_TIME
10/20/2010 13:09:06
now I need to insert above data in below table with 1 second less time ex-10/20/2010 13:09:05
CREATE TABLE PC (
COL1 TIMESTAMP(9)
how I can do it??
I tried below query but when I entered in table its not showing correct format..I m using oracle 11g.
select TO_DATE( TO_CHAR(TO_DATE( CM_DATE||' '||CM_TIME,'dd-mm-yyyy hh24:mi:ss'),'dd-mm-yyyy hh24:mi:')||
          TO_CHAR(TO_CHAR(TO_DATE( CM_TIME,'hh24:mi:ss'),'ss')-1) ,'dd-mm-yyyy hh24:mi:ss') cr_date
FROM DBMG_SAL_HEAD ;
o/p is correct as i need..
10/20/0010 1:09:05 PM
now i m inserting ..
insert into pc
select TO_DATE( TO_CHAR(TO_DATE( CM_DATE||' '||CM_TIME,'dd-mm-yyyy hh24:mi:ss'),'dd-mm-yyyy hh24:mi:')||
          TO_CHAR(TO_CHAR(TO_DATE( CM_TIME,'hh24:mi:ss'),'ss')-1) ,'dd-mm-yyyy hh24:mi:ss') cr_date
FROM DBMG_SAL_HEAD ;
commit;
select * from pc;
o/p is
20-OCT-10 0 why data is coimng like this ??i need it in 10/20/0010 1:09:05 PM format...
plz fix it..........!You fix it.
You need to understand that DATE and TIMESTAMP are stored in oracle's internal format. They are presented in a query with the formatting specified by the controlling setting of your NLS parameters. That's what to_char and to_date are all about.
============================================================================
If the column is defined as a DATE, then the data is NOT+ stored in the format you stated. Oracle always stores dates in its own internal format.
What you are referring to is the character string representation of the data. That presentation is controlled by the controlling setting of NLS_DATE_FORMAT. The reason I say the "controlling" setting is because NLS_DATE_FORMAT can be set in any of several different locations, each with its own scope of influence. That being the case you should never depending on a setting outside of your own control. That means you will always do one of the following:
1) ALTER SESSION SET NLS_DATE_FORMAT='whatever format mask you want';
or
2) Proper use of TO_CHAR and TO_DATE at the individual sql statement
I prefer the second, so there is never any ambiguity or question when looking at an individual SQL statement.
Just to drive home the point:
SQL> create table mytable (mydate date);
Table created.
SQL> insert into mytable values (to_date('09-15-2010','mm-dd-yyyy'));
1 row created.
SQL> insert into mytable values (to_date('20091225','yyyymmdd'));
1 row created.
SQL> insert into mytable values (to_date('1970-06-25 15:45:37','yyyy-mm-dd hh24:mi:ss'));
1 row created.
SQL> commit;
Commit complete.
SQL> select * from mytable;
MYDATE
15-SEP-10
25-DEC-09
25-JUN-70
3 rows selected.
SQL> select to_char(mydate,'yyyymmdd') from mytable;
TO_CHAR(
20100915
20091225
19700625
3 rows selected.
SQL> select to_char(mydate,'mmMON-dd-yy hh:mi') from mytable;
TO_CHAR(MYDATE,'MMM
09  SEP-15-10 12:00
12  DEC-25-09 12:00
06  JUN-25-70 03:45
3 rows selected.
SQL> select to_char(mydate,'MON-dd-yyyy hh24:mi') from mytable;
TO_CHAR(MYDATE,'M
SEP-15-2010 00:00
DEC-25-2009 00:00
JUN-25-1970 15:45
3 rows selected.
SQL> Through any of the above, was the format of the stored data ever changed?
>
rgds,
pc

Similar Messages

  • Data loading: formatting data for timestamp column

    Hi All,
    I have a table with a timestamp column named as created_date. I want to upload data to that table using data loading page. but there is one problem while uploading data, I have a csv file in which the created_date column data in two different format as follows ,
    09/03/2013 03:33am
    09/02/2013 03:24pm
    the above data throws an error ORA-01821: date format not recognized.
    In Data / Table Mapping page, I tried with MM/DD/YYYY HH12:MI:SS AM. What format should i use for am and pm??
    Please help me to solve....
    Thanks in advance
    Lakshmi

    I solved by using the format MM/DD/YYYY HH:MIAM.
    Thanks
    Lakshmi

  • ODBC errors while retrieving timestamp column

    Hi,
    I created 2 views selecting timestamp column of table ULTBPM_CCHK.CC_APPINFO:
    CREATE OR REPLACE FORCE VIEW "ULTBPM_CCHK"."ERKANDENE_V" ("CCAI_RECORDDATETIME") AS select TO_DATE(TO_CHAR(CCAI_RECORDDATETIME,'DD/MM/YYYY hh24:mi:ss'),'DD/MM/YYY
    Y hh24:mi:ss') CCAI_RECORDDATETIME from ULTBPM_CCHK.CC_APPINFO;
    CREATE OR REPLACE VIEW "ULTBPM_CCHK"."ERKANDENE_V2"
    "CCAI_RECORDDATETIME") AS select CCAI_RECORDDATETIME from ULTBPM_CCHK.CC_APPINFO;
    While i can query "ULTBPM_CCHK"."ERKANDENE_V" without any problem, following errror occurs for "ULTBPM_CCHK"."ERKANDENE_V2":
    SELECT AL1.CCAI_RECORDDATETIME FROM ULTBPM_CCHK.ERKANDENE_V2 AL1
    ODBC Error: SQL API: [SQLBindCol], SQL RETURN: [-1], SQL STATE: [HY003], SQL NATIVE ERROR: [0], SQL MESSAGE: [[Microsoft][ODBC Driver Manager] Program type out of range]
    I want to select timestamp colum, Any sugestions?
    Hyperion Reporting Studio 9.3.1
    Oracle 9i clent
    Oracle 10g (10.2.0.4) database
    Regards,
    Erkan Saka

    Hi,
    This time it gives "ORA-03106: fatal two-task communication protocol error". I searched metalink and fould that this may be caused by incompatible SqlNet libraries or NLS settings between cklient and server. I checked NLS settings but did not solved the problem. In dbgprint file i saw that hyperion identified timestamp column (B) as ColType 0. Is it normal for timestamp column? Because when i look at the column properties in Reporting Studio, i see nothing in Item Type.
    SELECT DISTINCT COLUMN_NAME, '*', COLUMN_ID, DATA_TYPE, DATA_LENGTH,
         DATA_SCALE, DATA_PRECISION, NULLABLE, '*' FROM SYS.ALL_TAB_COLUMNS
         WHERE TABLE_NAME = 'ERKAN_DENE' AND OWNER = 'DISBANK' ORDER BY
         COLUMN_ID
    Server Column Information
    ColName ColNum ColType Length Places Digits Nulls
    ======= ====== ======== ====== ====== ====== =====
    A 1 NUMBER 22 0 10 0
    B 2 TIMESTAMP(6) 11 6 10 1
    End Select
    DaMgr DMTable Column Information
    ColName ColNum ColType Length Places
    ======= ====== ====== ====== ======
    A 0 4 22 0
    B 1 0 11 6
    Begin Executing Document OnPreProcess Script.
    End Executing Document OnPreProcess Script.
    Begin Select
    (0 0 )
    Sending SQL to the Server:
    SELECT AL1.B FROM DISBANK.ERKAN_DENE AL1
    Oracle error -1 3106: ORA-03106: fatal two-task communication protocol error
    Exception thrown in v1_bi_code\bl\da\dasnet_l.cpp, line 959: Oracle Error -1: ORA-03106: fatal two-task communication protocol error
    DaSession::CancelOk()
    Regards,
    Erkan

  • Internal error with timestamp columns

    Hi
    i have a table in which there's a TIMESTAMP column whenever i try to create a form on this table i cannot choose the columns in form builder data block wizard.
    Or even when i try to modify a form which was created before the columns were added.
    it generates this error.
    FRM - 10095: Assertion Failed in iewbdbc_oracle_to_id, at C:myade\608\src\ie\iewbdb.c:703
    i dont even have that directory on my machine!!!!
    i tried this with forms9i & forms6i, same thing with both.
    is it impossible to develope forms on a table having a timestamp column??? or is there another way?
    Any help is REALLY apreciated.
    Thanks in Advance
    Regards
    Tony G.

    No the with timestamp types are not supported. Forms does supplort multiple timezones, but uses normal datatime fields mapping to dates in the DB. The Forms server then takes care of mapping the Client Time to the Database time and visa versa.
    See: http://www.oracle.com/technology/products/forms/pdf/9inewfeatures.pdf
    Section 10

  • Converting Oracle TIMESTAMP(4) column to SQL datetime column conversion error in ssis

    I could not able to convert Oracle TIMESTAMP(4) column to SQL datetime column conversion error in ssis.
    I'm connecting OLEDD Oracle Source to OLEDB SQL Destination in SSIS package. I'm trying to insert data from oracle datetime column into sql datetime column. I'm getting some errors.
    Please provide helpful info.

    You can transform the data types directly at the source by writing a proper SQL statement, or you can convert them using the data conversion component.
    Please refer the below link
    http://stackoverflow.com/questions/6256168/how-to-convert-a-timestamp-in-string-format-to-datetime-data-type-within-a-packa

  • Data load error regarding timestamp

    Hi All,
    I am getting data load error related to time.
    I am using  2lis_02_SCN for CNFTM(time stamp) filed 
    with value "08:00:" need to convert to 08:00:00...for some records and rest of the records are coming with normal 6 digit time.
    please send your suggestion as early as possible.
    Thanks
    Rupa

    Hi Rupa,
    Try out following sample code inthe transfer rule for the same info object and it should work
    lv_len  = strlen( str ).
    if lv_len = 4.
    concatenate str '00' into str.
    endif
    Regards
    Kapadia

  • Error in running a query in XSJS - column store error: [2950] user is not authorized :  at ptime/session/dist/RemoteQueryExecution.cc:1354]

    Hi All,
    I get the below error when i load my xsjs file in browser,
    Error while executing query: [dberror(PreparedStatement.executeQuery): 2048 - column store error: column store error: [2950] user is not authorized : at ptime/session/dist/RemoteQueryExecution.cc:1354]
    I am able to execute the same query in  HANA SQL editor
    Please note that ,No Analytical privileges are applied to the view.
    Could you please help solving this issue.
    Regards,
    Logesh Kumar.

    Hay,
    are you using the same Database user for both SQL Editor and XSJS ?
    try the following.
    Before executing the query , display it and copy the same from browser and execute in SQL editor.
    Put the statement in  a try catch block and analyse the exception .
    Sreehari

  • SQL Loader Error using regexp_replace

    Hi Guys,
    i am trying to using sql loader to load data and one column in control file is
    x1 POSITION(718:725) DATE "YYYYMMDD" NULLIF FI_CLM_RCPT_DT = BLANKS,
    XYZ POSITION(736:745) CHAR "regexp_replace(substr(:XYZ,1,9),\'[^1|Y|N|U|W]\',\' \')||regexp_replace(substr(:XYZ,10,1),\'[^Z]\', \' \'))")
    But at last part i am getting error
    SQL*Loader-951: Error calling once/load initialization
    ORA-02373: Error parsing insert statement for table TDESAI_DBA.HAJI_CLM_A.
    ORA-00933: SQL command not properly ended
    I know the error is with XYZ Column but where. Or am i doing something wrong?
    Can you guys help me

    Please see the discussion on the Semantic Technologies OTN form at SQL*Loader error 350 using SDO_RDF_TRIPLE_S constructor

  • SQL*LOADER ERROR 비교 (ORA-2359, ORA-1401)

    제품 : ORACLE SERVER
    작성날짜 : 2002-04-09
    SQL*LOADER ERROR 비교 (ORA-2359, ORA-1401)
    ==========================================
    PURPOSE
    SQL*LOADER 를 사용하는 경우 ORA-2359 ERROR가 나는 경우와
    ORA-1401 ERROR가 나는 경우를 비교한다.
    Examples
    table 의 desc가 다음과 같다고 가정하자.
    SQL> create table test5(a varchar2(1000));
    이 경우 delimiter 가 comma 인지 position 으로 구분되는지에 따라 error
    message가 달리 나타난다.
    1) ORA-2359 : field in datafile exceeded maximum specified length
    load data
    infile test.dat
    replace
    into table test5
    fields terminated by ','
    (a char) 로 실행 시 발생.
    ---> a char(1000) 으로 하면 error 해결이 가능하다.
    2) ORA-1401: inserted value too large for column
    load data
    infile test.dat
    replace
    into table test5
    fields terminated by ','
    (a position(1:2000) char)
    ---> 이 경우 a position (1:1000) char 로 하면 해결 가능하다 .
    * 참고로 + , - 기호와 comma 를 load 하기 위해서는 decimal external을
    사용한다. (a position decimal external (10))
    Reference Documents
    ---------------------

    You hit Bug 3531336
    Run the script catcio.sql from $ORACLE_HOME/rdbms/admin directory.
    Run this in sys schema.
    And then load the data with sqlloader.

  • SSDT tries to alter timestamp column in TFS build

    We're trying to perform an upgrade test against a copy (backup/restore) of our customer database as target. There are some tables with  timestamp column in the database. The way we do this is by having a database project with a publish profile targeting
    that copy of customer database and then with TFS build server is used to build the database but only to generate a publish script (/p:UpdateDatabase=False) set in the build definition - msbuild argument.
    Example of table definition:
    CREATE TABLE dbo.CodeTable1
    (ID INT IDENTITY(1,1) NOT NULL PRIMARY KEY
    ,Code CHAR(6)
    ,[Timestamp] TIMESTAMP NULL);
    We would like to have the "Code" column to have CHAR(7), so in the project we modify the table definition:
    CREATE TABLE dbo.CodeTable1
    (ID INT IDENTITY(1,1) NOT NULL PRIMARY KEY
    ,Code CHAR(7)
    ,[Timestamp] TIMESTAMP NULL);
    Expecting SSDT build will generate alter script:
    ALTER TABLE dbo.CodeTable1 ALTER COLUMN Code CHAR(7);
    To our surprise the generated script was:
    ALTER TABLE dbo.CodeTable1 ALTER COLUMN Code CHAR(7);
    ALTER TABLE dbo.CodeTable1 ALTER COLUMN [Timestamp] TIMESTAMP NULL;
    Which will cause error when the script is executed: "Cannot alter column 'TIMESTAMP' to be data type timestamp."
    Why is SSDT generating the change script for that timestamp column??
    We then try a local build in VS, the issue is not happening, SSDT correctly generates alter script only for the "Code" column to CHAR(7);
    Both local machine and TFS Build server are having VS 2013 Update 4- SSDT 12.0.50318.0 installed.
    As we tried to troubleshoot further, we found out that it seems it only happens on a restored database from a backup copy of our customer database. It doesn't happen for databases created by SSDT build from scratch or that we manually created. We've tried make
    sure all database properties are the same as the database that correctly built. But still if the target database is the one we restored from a customer's copy, SSDT always tries to alter timestamp column (on server build).
    Anyone have same experience?
    I have posted a bug in ms connect: https://connect.microsoft.com/SQLServer/feedback/details/1266051
    Thanks!

    Thanks Paul!
    However, it doesn't happen when I build the database project locally or if the target database was created by SSDT (or manually for that matter). The issue happens when I change the target database to the one we restored from a backup copy of our customer's
    database and run the build through our TFS build server.
    So I thought there must be something different with the restored database (which causes SSDT to alter timestamp column) as opposed to the one SSDT/manually created (which doesn't alter the timestamp column). Maybe there is difference on database property/settings?
    Whatever it is, I just couldn't find it.
    The only thing we will do now as workaround is to get db schema creation script from that of customer's database and run that script to re-create the database from scratch and use that as target database instead, as luck would have it, the issue would be
    gone.
    Still, why the heck SSDT tries to alter timestamp column in that specific case and not in other case as described above??
    Elvin

  • Insert only time on timestamp column

    How can I insert time only in a timestamp column? i tried inserting time only and it's giving me an error.

    Hi,
    All TIMESTAMPs (and DATEs) have year, month, day, hours, minutes and seconds. It's impossible not to have all parts.
    You could use the same year, month and day (January 1, 2001, for example) in every column, but that's probably not the best thing for your needs, whatever they are.
    TIMESTAMPs represent points in time.
    What are you trying to represent? A duration of time? In that case, an INTERVAL data type would be more appropriate, or maybe a NUMBER, or even a VARCHAR2.
    How do you plan to use this column? How will you be manipulating the values (for example, adding 1 hour to a time, or averaging them)?

  • Doubt in Timestamp column

    Hi,
    In below Query i am trying to retrive the data
    ,which is greater then the 18-DEC-10,
    But its retriving all the datas,why? please help.how to handle this time stamp column?
    desc vcps_misc_ch
    Name Null Type
    ENT_NM NOT NULL VARCHAR2(30)
    ATRBT_NM NOT NULL VARCHAR2(30)
    TXN_TYPE NOT NULL CHAR(1)
    TXN_DT NOT NULL TIMESTAMP(6)
    PREV_VALUE VARCHAR2(4000)
    CURR_VALUE VARCHAR2(4000)
    LAST_UPDT_GMIN VARCHAR2(9)
    LAST_UPDT_NM VARCHAR2(4000)
    REF_ID NOT NULL VARCHAR2(2000)
    SELECT txn_dt,to_char(txn_dt,'dd-mon-yy hh24:mi:ss')
    FROM vcps_misc_ch
    WHERE to_char(txn_dt,'dd-mon-yy hh24:mi:ss') > TO_CHAR(TO_date('18-DEC-10','DD-MON-YY'),'dd-mon-yyyy hh24:mi:ss')
    and rownum<10
    TXN_DT TO_CHAR(TXN_DT,'DD-MON-YYHH24:MI:SS')
    26-FEB-10 01.14.43.055154000 PM 26-feb-10 13:14:43
    25-MAR-10 05.23.35.601172000 PM 25-mar-10 17:23:35
    26-MAY-10 08.12.40.106995000 AM 26-may-10 08:12:40
    27-MAY-10 10.38.32.033523000 AM 27-may-10 10:38:32
    28-MAY-10 11.40.23.313450000 AM 28-may-10 11:40:23
    28-MAY-10 01.09.52.332828000 PM 28-may-10 13:09:52
    18-JUN-10 02.44.37.614339000 PM 18-jun-10 14:44:37
    18-JUN-10 02.46.47.141109000 PM 18-jun-10 14:46:47
    24-JUN-10 10.45.43.814528000 AM 24-jun-10 10:45:43
    9 rows selected

    Hi,
    Always compare TIMESTAMP columns to other TIMESTAMPs.
    To compare a TIMESTAMP column to a value that is being supplied as a string, convert the string to a TIMESTAMP, not the other way around. It's more efficient, and less prone to error.
    For example:
    SELECT      txn_dt
    ,     to_char (txn_dt,'dd-mon-yy hh24:mi:ss')
    FROM      vcps_misc_ch
    WHERE      txn_dt     >= TO_TIMESTAMP ( '18-DEC-2010 14:45:00'
                        , 'DD-MON-YYYY HH24:MI:SS'
    ;or
    SELECT      txn_dt
    ,     to_char (txn_dt,'dd-mon-yy hh24:mi:ss')
    FROM      vcps_misc_ch
    WHERE      txn_dt     >= TO_TIMESTAMP ( p_date
                        , 'DD-MON-YYYY HH24:MI:SS'
    Do not nest conversion functions (such as "TO_CHAR ( TO_TIMESTAMP ...)").  There's almost always a simpler, more efficient way.
    TO_CHAR is appropriate for displaying a date (as in the SELECT clause above).  If you're tempted to use TO_CHAR for any other purpose (in a WHERE clause, for example), ask yourself why.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • JD3 - Load error.

    I successfully constructed and ran project in a workspace and
    then saved it. Upon reopening it, I get an Information popup
    describing a Load error on the only project in the workspace:
    Load error.
    Project: C:\Program Files\Oracle\JDeveloper 3.0
    \myprojects\scc_soa.jpr
    Exception: oracle.jbo.dt.objects.JboException
    Load error.
    Project: C:Progam Files\Oracle\JDeveloper 3.0
    \myprojects\scc_soa.jpr
    Object: lightInfo
    Exception: java.lang.ClassCastException
    The curious thing is that after dismissing the popup, the
    applet/application runs. However, I cannot use the visual
    designer on the class that defines my query nor deploy the app.
    How can I trace down the problem?
    null

    Laura -
    Thanks for the replies! The application I'm working on is an
    Infobus project that was working against an 7.3.4 database. Last
    monday night the database was upgraded to 8.0.4. Yesterday, the
    problems persisted with the load errors, so I'm planning on
    rebuilding the project/workspace and migrating the old
    application on top of newly created business components.
    - Scott
    JDeveloper Team (guest) wrote:
    : Hi Scott,
    : The AppModule can be created in one of two ways. When you go
    : through the Business Component wizard, on the page where you
    : select your tables and views, there are two checkboxes below:
    one
    : for 'Create View Objects and Links' and a second for 'Create
    App
    : Module'. If you selected those in the BC Wizard, your app
    module
    : would be created by default based on all the entities you
    : selected.
    : The other way to do it is to select the package where all
    your
    : entities and views are located, and select Create AppModule
    from
    : the right-mouse menu (or go to the File\New gallery). If you
    go
    : this way, you hand-pick which views to include in the App
    Module
    : versus having them all put there by default.
    : Tables without primary keys should not be a problem unless the
    : database is a 7.3.x. In 8.x, we use the rowid column as a
    : substitute for a primary key, but there were structural
    changes
    : to the rowid element between 7 and 8, so we can't do that for
    7.
    : What type of project are you trying to migrate from 2.0? Is
    it a
    : DBServlet or Infobus project?
    : Laura
    : Scott (guest) wrote:
    : : Laura -
    : : I did create the project with Business Components.
    : : In Business Components Project Wizard: Step 3 of 3, I
    selected
    : : many tables and views from my schema. I do have an appModule
    : but
    : : do not recall how it was created (and I am unable to edit it
    : : same exceptions as before).
    : : I think the problem may be with a couple of the dozen or so
    : : tables and views in the schema that are referenced by the
    : : project (too much to type!). One of the tables does not have
    a
    : : primary key. This table is used in a view that is
    constructed
    : : with an outer join and an optimizer hint. I have started in
    : : another workspace to re-build my application, verifying each
    : new
    : : component added to the project. Neither the table nor the
    view
    : : could be added through the
    : : File/New/BusinessComponents/EntityObject method. I could
    send
    : : the project/workspace with the table/view descriptions if
    the
    : : entities mentioned above are supported by the Business
    : Component
    : : model.
    : : What I would really like to do is migrate the application I
    : : developed in JD2 to JD3 without having to re-construct it or
    : : redesign the database.
    : : JDeveloper Team (guest) wrote:
    : : : Scott,
    : : : Can you provide some details to help track down the
    possible
    : : : source of this problem?
    : : : 1. I am assuming you have created a 'Project containing
    : : Business
    : : : Components' and then run through the Business Component
    : Wizard
    : : to
    : : : create entity objects, and possibly also view objects and
    an
    : : : appModule. If this is not the case, could you let me know
    : : what
    : : : steps you performed when you 'constructed and ran project'.
    : : : 2. Can you provide some information about the database
    schema
    : : you
    : : : created your entity objects on (table descriptions, etc.).
    : : : If there is way too much information to type, let me know
    and
    : : : we'll figure out a way for you to send us your project so
    we
    : : can
    : : : see what is causing the problem.
    : : : Thanks,
    : : : Laura
    : : : Scott (guest) wrote:
    : : : : I successfully constructed and ran project in a
    workspace
    : : and
    : : : : then saved it. Upon reopening it, I get an Information
    : popup
    : : : : describing a Load error on the only project in the
    : workspace:
    : : : : Load error.
    : : : : Project: C:\Program Files\Oracle\JDeveloper 3.0
    : : : : \myprojects\scc_soa.jpr
    : : : : Exception: oracle.jbo.dt.objects.JboException
    : : : : Load error.
    : : : : Project: C:Progam Files\Oracle\JDeveloper 3.0
    : : : : \myprojects\scc_soa.jpr
    : : : : Object: lightInfo
    : : : : Exception: java.lang.ClassCastException
    : : : : The curious thing is that after dismissing the popup,
    the
    : : : : applet/application runs. However, I cannot use the
    visual
    : : : : designer on the class that defines my query nor deploy
    the
    : : app.
    : : : : How can I trace down the problem?
    null

  • Problem fetching multiple values in a TIMESTAMP column

    Hi all,
    I'm having a problem trying to fetch multiple values in a TIMESTAMP column. I can successfully fetch the TIMESTAMP column if I do the following:
    OCIDateTime tstmpltz = (OCIDateTime )NULL;
    rc = OCIDescriptorAlloc(p_env,(dvoid **)&tstmpltz, OCI_DTYPE_TIMESTAMP,
    0, (dvoid **)0);
    rc = OCIDefineByPos(p_sql, &p_dfn, p_err, 1, &tstmpltz, sizeof(tstmpltz),
    SQLT_TIMESTAMP, 0, 0, 0, OCI_DEFAULT);
    This works fine. I can then do what I want with the OCIDateTime variable tstmpltz, like convert it to a text string, etc.
    But what I am trying to do is fetch many rows of data that could include a TIMESTAMP column. For character columns this is no problem. I simply allocate a buffer of the correct width and length and then do my OCIDefineByPos to point to the start and the character data gets filled in. Same for numeric columns as well.
    I can do this with a TIMESTAMP column if I do the OCIDefineByPos with a column type of SQLT_CHR. But the problem I'm running into when I do things this way is if I fetch a Timestamp value that is before 1950 I believe it is, I get back the wrong century. So for instance 1900 comes back as 2000. I think this is because the default date format when fetching is a 2 digit year. So I've tried to the do following:
    long fetchrows = 50;
    unsigned char *descpp1;
    descpp1 = (unsigned char *)calloc(fetchrows, sizeof (OCIDateTime *));
    int i;
    for (i = 0; i != fetchrows; i++)
    /* Allocate descriptors */
    rc = OCIDescriptorAlloc((void *)p_env,(void **)&descpp1[i * sizeof (OCIDateTime *)], OCI_DTYPE_TIMESTAMP,
    0,(void **)0);
    // Bind the column
    rc = OCIDefineByPos(p_sql, &p_dfn, p_err, 1, descpp1, sizeof(descpp1),
    SQLT_TIMESTAMP, 0, 0, 0, OCI_DEFAULT);
    rc = OCIStmtExecute(p_svc, p_sql, p_err, (ub4) 50, (ub4) 0,
    (CONST OCISnapshot *) NULL, (OCISnapshot *) NULL,
    OCI_DEFAULT);
    And I get an "ORA-01403: no data found" error. I'm missing something here but I can't figure out what it is. Is this proper way to fetch multiple Timestamp columns ?
    Thanks,
    Nick

    Hi Nick,
    I think the "trick" here is that when you call OCIDescriptorAlloc normally you would pass a pointer to an OCIDateTime pointer (i.e. OCIDateTime**). However, you're being sneaky here and using unsigned char * with malloc/calloc for the reasons you have already mentioned. So, that changes things a bit because in this scenario the "destination address" where OCI is going to put the address for the OCIDateTime descriptor is in the memory you have dynamically allocated rather than in the target pointer of an OCIDateTime** declaration. So far so good, but the problem, as you've discovered, comes about when you need to get the OCIDateTime* to pass into the OCIDateTimeToText function. In your call you have this:
    (OCIDateTime *)descpp1[0 * sizeof (OCIDateTime *)]However, that isn't the address of the descriptor it's a pointer to the address so, depending on your actual calls, etc. you'll either get a memory violation or an invalid OCI handle error. What you can do is get the address from that memory location and stuff it into a proper OCIDateTime* and then it can be used in the OCIDateTimeToText function.
    I'm probably doing a terrible job explaining it, but I have cobbled together a sample which does what you want (at least as far as I can tell). Of course, being OCI, there's a fair bit of code, but here's the main parts.
    I created a table called "ts_test" that has the following structure and sample data:
    SQL> desc ts_test
    Name             Null?    Type
    TS_ID                     NUMBER
    TS_VALUE                  TIMESTAMP(3)
    SQL> select * from ts_test order by ts_id;
         TS_ID TS_VALUE
             1 01-JAN-09 08.00.00.123 AM
             2 01-JAN-09 12.34.56.789 PM
             3 01-JAN-09 04.46.00.046 PM
             4 01-JAN-09 10.00.00.314 PM
    4 rows selected.I use the same query as above in the OCI sample code to get the values back out of the table.
      ** will hold pointers to TimeStamp Descriptor memory
      unsigned char *pTSD = (unsigned char *) NULL;
      ** temp pointer used with descriptors
      OCIDateTime *pTemp = NULL;
      ** allocate memory for the ts_id column
      if ((pID_val = (ub4 *) malloc(sizeof(ub4) * arrsize)) == NULL)
        printf("Failed to allocate memory for pID_val!\n");
        return;
      ** allocate memory for the ts descriptors
      if ((pTSD = (unsigned char *) malloc(sizeof(unsigned char *) * arrsize)) == NULL)
        printf("Failed to allocate memory for pTSD!\n");
        return;
      ** allocate date time descriptors
      for (i = 0; i < arrsize; i++)
        rc = OCIDescriptorAlloc(pDBCtx->envhp,
                                (void **) &pTSD[i * sizeof(OCIDateTime *)],
                                (ub4) OCI_DTYPE_TIMESTAMP,
                                (size_t) 0,
                                (void **) 0);
      ** define the first column in the results
      rc = OCIDefineByPos(stmtp,
                          &defnp,
                          pDBCtx->errhp,
                          (ub4) 1,
                          (void *) pID_val,
                          (sword) sizeof(ub4),
                          (ub2) SQLT_INT,
                          (void *) pID_ind,
                          (ub2 *) 0,
                          (ub2 *) 0,
                          (ub4) OCI_DEFAULT);
      ** define the second column in the results
      rc = OCIDefineByPos(stmtp,
                          &defnp,
                          pDBCtx->errhp,
                          (ub4) 2,
                          (void *) &pTSD[0],
                          (sword) sizeof(OCIDateTime *),
                          (ub2) SQLT_TIMESTAMP,
                          (void *) pTS_ind,
                          (ub2 *) 0,
                          (ub2 *) 0,
                          (ub4) OCI_DEFAULT);
      ** execute the statement
      rc = OCIStmtExecute(pDBCtx->svchp,
                          stmtp,
                          pDBCtx->errhp,
                          (ub4) arrsize,
                          (ub4) 0,
                          (CONST OCISnapshot *) NULL,
                          (OCISnapshot *) NULL,
                          (ub4) OCI_DEFAULT);
      ** get the text value of the timestamp
      ** null-terminate it, and display the value.
      ** the address of the allocated descriptor
      ** is copied from the dynamically allocated
      ** memory to the temp variable and that
      ** is passed to OCIDateTimeToText
      for (i = 0; i < arrsize; i++)
        memcpy((void *) &pTemp, &pTSD[i * sizeof(OCIDateTime *)], sizeof(OCIDateTime *));
        rc = OCIDateTimeToText((void *) pDBCtx->usrhp,
                               pDBCtx->errhp,
                               pTemp,
                               (oratext *) 0,
                               (ub1) 0,
                               (ub1) 3,
                               (oratext *) 0,
                               (size_t) 0,
                               &buflen,
                               buf);
        buf[buflen] = '\0';
        printf("Timestamp value[%d]: %s\n", *pID_val++, buf);
    ...Obviously there's lots left out, but hopefully that can be of some help. I've not really thoroughly reviewed the code so there may be a few things to fix. Anyway, using the above table and data the full sample outputs this on my system:
    Timestamp value[1]: 01-JAN-09 08.00.00.123 AM
    Timestamp value[2]: 01-JAN-09 12.34.56.789 PM
    Timestamp value[3]: 01-JAN-09 04.46.00.046 PM
    Timestamp value[4]: 01-JAN-09 10.00.00.314 PM
    ENTER to continue...Thanks,
    Mark

  • Importing timestamp columns appears to use to_date instead of to_timestamp

    I'm trying to import data (using the latest version 1.5.4 with Patch 2 applied) to an Oracle 10g database that contains timestamp columns. The input data has times with fractional (millisecond) values The data was exported using SQL Developer from a Sybase database and the timestamp format in the Excel (xls) file is YYYY-MM-DD HH24:MI:SS.FF3. When I specify this format for the TIMESTAMP columns on the import screens, the importer generates an insert statement like this:
    INSERT INTO A (TMS) VALUES (to_date('2008-12-049 12:12:39.967', 'YYYY-MM-DD HH24:MI:SS.FF3'));
    This command fails to execute with this error:
    Error report:
    SQL Error: ORA-01821: date format not recognized
    01821. 00000 - "date format not recognized"
    *Cause:   
    *Action:
    I found that if to_timestamp is used instead of to_date, there is no issue inserting the row with the correct time precision. The question I have is why isn't SQL Developer using to_timestamp for importing a TIMESTAMP column, and should it?
    Any advise woudl be appreciated.
    Thanks

    In 1.5.4 I see a bug where the "Format" field doesn't show up in the page in the import wizard, preventing the user from entering a mask when the column type is TIMESTAMP. This has been fixed in the code line under development and should be available when 2.1 gets released.
    To give you a bit more detail on the confusing DATE/TIMESTAMP behaviour...
    SQL Developer misrepresenting date as timestamp and vice versa stems from the behaviour of the Oracle JDBC driver. Following are the details I obtained from the JDBC team when I raised a bug("WRONG VALUE RETURNED FOR GETCOLUMNTYPE FOR DATE COLUMN ") on them:-
    oracle.jdbc.mapDateToTimestamp is by default set
    to true to indicate reporting DATE column as TIMESTAMP type. To turn off, pass
    -Doracle.jdbc.mapDateToTimestamp=false" at the command line.
    To effect this option in SQL Developer, you can add an AddVMOption -Doracle.jdbc.mapDateToTimestamp=false
    A bit more history on the option:
    8i and older Oracle databases did not support SQL TIMESTAMP, however Oracle
    DATE contains a time component, which is an extension to the SQL standard. In
    order to correctly handle the time component of Oracle DATE the 8i and
    earlier drivers mapped Oracle DATE to java.sql.Timestamp. This preserved the
    time component.
    Oracle database 9.0.1 included support for SQL TIMESTAMP. In the process of
    implementing support for SQL TIMESTAMP we changed the 9i JDBC driver to map
    Oracle DATE to java.sql.Date. This was an incorrect decision since it
    truncates the time component of Oracle DATE. There was also a backwards
    compatibility problem trying to write java.sql.Timestamps to 8i databases.
    These are separate problems but we "fixed" both under the control of a single
    flag, V8Compatible. This flag was introduced in a 9.2 patch set.
    By default the flag is false. When it is set to false the driver maps Oracle
    DATE to java.sql.Date, losing the time component and it writes
    java.sql.Timestamps to the database as SQL TIMESTAMPS. When the flag is set
    to true the driver maps Oracle DATE to java.sql.Timestamp and writes
    java.sql.Timestamps to the database as Oracle DATEs.
    In 11.1 the V8Compatible flag was deprecated because it controlled Database
    8i compatibility which is no longer supported. The additional behavior it
    controlled, how SQL DATEs are handled, is controlled by a new flag,
    mapDateToTimestamp. In 11.1 setting V8Compatible will just set
    mapDateToTimestamp. This new flag only controls how SQL DATEs are
    represented, nothing more. This flag will be supported for the foreseeable
    future.
    Finally, the default value for V8Compatible is false in 9i and 10g. This
    means that by default the drivers incorrectly map SQL DATEs to java.sql.Date.
    In 11.1 the default value of mapDateToTimestamp is true which means that by
    default the drivers will correctly map SQL DATEs to java.sql.Timestamp
    retaining the time information. Any customer that is currently setting
    V8Compatible = true in order to get the DATE to Timestamp mapping will get
    that behavior by default in 11.1. Any customer that wants the incorrect but
    10g compatible DATE to java.sql.Date mapping can get that by setting
    mapDateToTimestamp = false in 11.1.
    About the only way to see the difference between mapDateToTimestamp settings
    is to call getObject on a DATE column. If mapDateToTimestamp is true, the
    default setting, the result will be a java.sql.Timestamp. If
    mapDateToTimestamp is false, then getObject on a DATE column will return a
    java.sql.Date.
    HTH
    Edited by: vasan_kps on Jun 12, 2009 2:01 PM

Maybe you are looking for

  • Content Conversion Issue - sender File adapter..!!

    Hi All , Input file: GRP|HD|7001|7001A00443|012| GRP-LN|DTL|1|ZTAS|3|002|209782010|0001|EN GRP-LN|TXT|Customer: KR Test, Case 3 GRP-LN|TXT|Power            : -2.25 GRP-LN|DTL|2|ZTAS|4|002|209782035|0001|EN GRP-LN|TXT|Customer: CL Test, Case 4 GRP-LN|

  • How I can print on the both sides of the paper on printer P2055d

    Can printer P2055d print on both side of the paper? How I turn on duplex? I do not have a manual.

  • New computer core I7 950

    Hi! I am just going to config. a new computer for editing HD and AVCHD videos. I bought a new videocamera, a Canon Legria HF 200 recently, and it`s not possible to edit HD and AVCHD on my old computers. I am planning to run Win.7 64 bit and Prem.El.8

  • 'number of open cursors exceeded' exception - 10.3.1

    Hi All, We have may DynamicSQL statements fired from our processes due to which we are getting 'number of open cursors exceeded' exception. We don't want to increase the limit of the maximum open cursors. Is there any way to close the cursors explici

  • DVD gets compressed

    When I burn my 16:9 DVDs to disc, then play them back on a DVD player and 16:9 tv, the picture is compressed with black bands top and bottom. Can anybody help please?