UNIX_TIMESTAMP and FROM_UNIXTIME from MySQL to ORACLE functions

Hi all

I'm migrating some functions and stored procedures in MySQL to ORACLE, and I the next instruction

Set valuedat = FROM_UNIXTIME (valor + UNIX_TIMESTAMP ('2000-1-01 00:00:00 '));

Since MySQL.

Look, I found that:

UNIX_TIMESTAMP ('2000-1-01 00:00:00 ')

can be equivalent to the following query:

SELECT (to_date (January 1, 2000 "," MON-DD-YYYY')-to_date('01-jan-1970','DD-MON-YYYY')) * (86400) as dt FROM dual;

but testing the numbers is not the same

Please can someone help me!

Specifically, I need to know how to build the equivalent in oracle for FROM_UNIXTIME and UNIX_TIMESTAMP functions

Thank you and best regards!

CRGM

Hello

These are functions that I built to solve the original requirement, thanks for all your comments.

************************************************************************************************************************************

CREATE OR REPLACE FUNCTION FROM_UNIXTIME

(

TIMESTAMP_ NUMBER

) AS OF DATE OF RETURN

NUMBER OF SECONDS_PER_DAY: = 86400;

MASK (50 CHAR) VARCHAR2: = 'DD-Mon-YYYY HH24:MI:SS ";

DATE OF REF_DATE;

BEGIN

REF_DATE: = TO_DATE ('01 - ENE - 1970 00:00:00 ', MASK);

RETURN REF_DATE + (TIMESTAMP_/SECONDS_PER_DAY);

END FROM_UNIXTIME;

**********************************************************************************************************************************

CREATE OR REPLACE FUNCTION UNIX_TIMESTAMP

(

DATE_ IN DATE

) RETURN AS NUMBER

NUMBER OF SECONDS_PER_DAY: = 86400;

NUMBER OF DIFF_BETWEEN_DATES;

MASK (50 CHAR) VARCHAR2: = 'DD-Mon-YYYY HH24:MI:SS ";

DATE OF REF_DATE;

BEGIN

REF_DATE: = TO_DATE ('01 - ENE - 1970 00:00:00 ', MASK);

DIFF_BETWEEN_DATES: = TO_DATE (TO_CHAR (SYS_EXTRACT_UTC (DATE_), MASK), MASK)

-REF_DATE;

RETURN DIFF_BETWEEN_DATES * SECONDS_PER_DAY;

END UNIX_TIMESTAMP;

******************************************************************************************************************************

Concerning

Tags: Database

Similar Questions

  • Migration from MySQL to Oracle SQL does not

    Hello everyone,

    I am new to Oracle SQL, but since our MySQL database is more and get more slowly, I would like to test the performance of Oracle SQL.

    So, I downloaded the current Oracle Linux distro and installed Oracle Database 11 g Express Edition.

    I connected with Oracle SQL Developer and started to migrate the MySQL database by following each step of this tutorial.

    I had to abandon all the privileges of the user migration (otherwise the creation and the deleteion of the migration repository did not) and I have disabled the migration of constraints to make migration work.

    Then I proceeded through all of the steps of the tutorial and ended with a "successful migration.

    The last step of the tutorial, it was to connect to the db migrated (using a combination of username/password generated name), it was not possible.

    What do I already checked?

    • Logged on as user system, I see that there is no new user created for the migrated db
    • Looking at the overview in the migration repository I see 3 phases, not knowing if the third displays an error or if it is not necessary at all (I got 58 tables in the db of the source)
      • Capture of 58/58
      • Convert 58/58
      • Compile 0/58

    From here, I don't know where to look for additional errors.

    I still can't use the migrated db and so I can't go forward with my tests.

    I missed something?

    I would appreciate your help.

    Astaldo

    Astaldo salvation,

    First, you must use SQL Developer 4.0.2 If you aren't already. It is available for free on OTN

    http://www.Oracle.com/technetwork/developer-tools/SQL-Developer/downloads/index-098778.html

    There are two ways to convert tables from MySQL to Oracle.

    1) copy to Oracle

    (2) migration to Oracle.

    Copy to Oracle is the simplest method. It does not imply the creation of a repository of migration.  But it only migrates data without constraints or default values or indexes and tables. The set of data to move should be reasonably low as it is moved on JDBC.

    It may suit your purpose to try to Oracle.

    http://dermotoneill.blogspot.co.UK/2010/11/copy-to-Oracle.html

    Migrate Oracle requires the implementation of a migration repository. But he migrate the default settings, constraints, and indexes and can also provide scripts offline data move that can manage the circulation of large data sets.

    Here is a small script to create a new MIGRATIONREPO user, and grant the correct privileges.

    CREATE USER MIGRATIONREPO IDENTIFIED BY oracle.

    ALTER USER MIGRATIONREPO QUOTA UNLIMITED ON USERS;

    GRANT CONNECT, RESOURCE, CREATE VIEW, CREATE MATERIALIZED VIEW to MIGRATIONREPO;

    Then using SQL Developer, create a connection to MIGRATIONREPO, right-click on the connection and choose "associate the Migration repository.

    I hope you have success best creation of migration with the privileges of theses repository.

    Migration Wizard step 8: target database

    Choose Offline Mode.

    This will present you with a build script that you can inspect before the race.

    The build script must be run using the SQL Developer worksheet and choose free user sufficiently privileged in Oracle generally SYSTEM.

    Note that if you would rather work with the repository you must currently you can browse your browser of Migration.

    Access converted database objects, right-click and select "generate the target".

    This will again open the Migration Wizard in step 8. Allowing you to choose Offline Mode so that you can review the build script.

    Hope this helps,

    Kind regards

    Dermot.

    SQL development team.

  • How to import the selected tables from MySQL to Oracle

    Hello world:

    How can I import tables from MySQL to Oracle? I have more than 180 tables in my DB (MySQL), but I copy only 12 of them to ORACLE... rigth now I do it manually, using SQL Developer (rigth clicking on the picture icon and copy to Oracle) but now I need to do this automatically every 4 hours...

    I read on the dblink option, but I don't know if this is the best for this case...

    I appreciate all help.

    Best regards
    Jack

    Hi Jack,

    I think that with a db-link you can define an automated task (PL/SQL + programmer).
    We use a db-link to Oracle's RDBMS to MySQL. So we have no experience.
    We have created the db-link like http://www.pythian.com/news/1554/how-to-access-mysql-from-oracle-with-odbc-and-sql/

    Heike cordially

  • Golden Gate 11 g replicate from MySQL to Oracle

    Golden Gate 11 g for MySQL can read mysql binlog. I have a question, can I use GG11g for MySQL to replicate from MySQL to Oracle?

    Thank and regard

    OK, here's the official word from Oracle on it.

    Oracle GoldenGate now supports MySQL 5.1.15 and later capture and oracle can be a target. Therefore, if you use MySQL 5.1.15 or later, you can indeed use Golden Gate to replicate from MySQL to Oracle when you use GoldenGate 11 g.

  • How to migrate from MySQL to Oracle stored procedure

    Hi all

    I've migrated mysql 5.1.42 - enterprise-gpl-advanced DB for oracle sqldeveloper 3.1.07 tool.

    DB objects migrate successfully except stored procedures.

    I checked .sql and files... Capture process not captured SQL stored procedures.

    Could you please suggest where I can check correct error or how to fix this.

    Thanks in advance.

    Hello

    SQL * Developer version you use is an old and you must use the latest version available from this link.

    Oracle SQL Developer

    However, even the v4 version does not support the migration of procedures stored as stated in this link - MySQL

    http://www.Oracle.com/technetwork/developer-tools/SQL-Developer/supportedmigplatforms-086703.html

    You will need to manually convert the MySQL in Oracle format, stored procedures since even the "Scratch Editor" under "tools - migration '-doesn't have an option for MySQL conversion.

    The documentation includes details of the difference between MySQL and Oracle stored procedures-

    Oracle SQL Developer information for the migration of MySQL®

    in chapter Triggers and procedures stored

    Kind regards

    Mike

  • Why is conversion of procedures & functions due to lack of MySQL to Oracle?

    Hi all

    I'm trying to migrate a database from MySQL to Oracle using the Migration Workbench data in SQL Developer 1.5.4.
    I ran both the quick Migration Wizard and the Manual Migration process as described in the documentation.

    I get through the process very well, even if not everything is successfully migrated. Namely, stored procedures and functions of the database of third parties are not correctly migrated.
    The following text is listed in the Migration log for each of the stored procedures and functions:

    * "Limitation of the translation"procedure_audit requires a translation of the manual"met on the column of the stored procedure fse.procedure_audit line 0-0."

    If I look at the 'converted' model the procedure has been created and is set to NULL. The procedure of 'captured the model' original is commented out in the body of the procedure in the "convert" template Does anyone have any ideas as to why it's a failure? And how do I fix it?


    In addition, there seems to be a problem with the conversion of the index, particularly those that are 'MAJOR' indexes in MySQL not appear in models 'captured' or 'converted '.


    In addition, the migration log provides the following:

    * "Index 'customer_customer_id' on the 'customer' table ' has been ignored, because it is a duplicate of a constraint" * "

    Looking at the index in the original third party database, it does appear that an index on that column on the respective table. The ides why this happens?


    Here, any help would be immensely appreciated.

    Thank you
    Amedeo.

    Mysql stored procedure to PL/SQL function is not available, or in the direction sqldeveloper statement:

    http://www.Oracle.com/technology/products/database/sql_developer/files/sqldeveloperstatementofdirection.htm

    -Turloch

  • Import MYSQL to Oracle Blob

    Our team is planning to migrate from mysql to oracle. They provided a file in text format which produce using the mysqldump utility, and I can find the sql statement in this file. But I do not see file contain some raw data associated with characters of blob. Can I import data from text/number, but how can I import data blob in oracle using the sql statement or tool. Any idea

    Use SQL * Developer.

    Here is a nice HOWTO move data from MySQL to ORACLE.

    Migration of MySQL

    MK

  • MySQL to Oracle using LKM SQL to Oracle, poor performance

    Hello

    I'm on the underside of technology.

    I'm try to use ODI to import data from MySQL to Oracle using the LKM SQL to Oracle, it works well for small amounts of documents but once volumes go higher it performs very badly.

    I'm replacing an integration of existing HS dblink to 44 seconds and ODI is 9 minutes.

    The MySQL and Oracle DB are on the same host with an autonomous ODI agent on the same host.

    MySQL 5.6.21

    Oracle 11.2.0.4

    Oracle Data Integrator 12.1.3

    I may try a different approach to dumping the MySQL table to a flat file and import from external table or sqlldr but y at - it a way to make the LKM SQL for Oracle perform better?

    Hello

    This problem has been resolved.

    I was setting the table sizes in batches on the data source server, after you set the values on the target data server is it now works as expected.

    Using a value of 5,000 for the two tables has reduced the operating time of 9 minutes to about 40 seconds.

  • Connect to MYSQL DB Oracle

    MY SQL-(5.1.61) version
    Oracle (11.2.0.2.0 - 64 bit)

    Must read a view in Oracle's MYSQL and flush the data in the table from Oracle scene.
    Please provide the steps in detail.

    Thank you.

    Best regards
    Franck Giri

    Hello
    You can use the database for ODBC (DG4ODBC) gateway to establish a connection to the MySQL database, and then use the copy, "create table as select... "or select / insert commands to move the data from MySQL in Oracle tables.
    You will need access to My Oracle Support, but the following notes have details on setting up Dg4ODBC on variosu - platforms

    How to set up DG4ODBC on x 86 32 bit Linux or HP - UX RISC (11.1 DG4ODBC only) to connect to databases Non-Oracle post installation (Doc ID 466228.1)
    How to set up DG4ODBC on 64 bit OS Unix (Linux, Solaris, AIX, HP - UX Itanium) to connect to Oracle databases Post Install (Doc ID 561033.1)
    How the installer DG4ODBC (gateway for ODBC Oracle database) on Windows 32 bits (Doc ID 466225.1)
    How to set up DG4ODBC (gateway for ODBC Oracle database) on 64-bit Windows operating systems to connect to Oracle databases Post Install (Doc ID 1266572.1)

    Then this note contains information on the data - transfer

    Copying data between Oracle database and non-Oracle foreign databases or data banks using gateways (Doc ID 171790.1)

    You can also use GoldenGate which allows the replication of data between Oracle and non-Oracle databases in real-time.

    Kind regards
    Mike

  • MySQL to Oracle query

    Hello World ^^

    I just downloaded Oracle XE and migrated my database from MySQL to Oracle successfully.
    And I'm doing/reviewing my application now especially the query syntax.
    I am facing a problem, I have a request in the form below in MySQL and it works fine but when I tried it at the Oracle XE database, it cannot run :( So I'm asking for help here, I have already searched on the internet but had no luck.

    SELECT A.INVOICEDATE,
    *@Step1:=cast (adddate (A.INVOICEDATE, A.TERMOFPAYMENT) as date) AS STEP1, *.
    *@Step2:=if (@step1 > CURDATE (), A.TOTALAMOUNT, 0) AS STEP2, *.
    *@step3:=if (@step2 <>0,0,IF(DATEDIFF(CURDATE(),@step1) < = 30, A.TOTALAMOUNT, 0)) AS step 3,
    T_invoice FROM has
    WHERE A.STATUS = 'Open'

    I can conclude the problem is based on the variable declaration in Oracle, but I still can't understand.
    What I do in MySQL, it's that I want to fill the variable with the expression/logic so I can use 'than' variable more later in the other part of the query output syntax.
    I used variables to be filled by value due to I can't use / select ALIAS later in the other party.

    So please help to convert to Oracle query syntax. Thank you.

    Oracle and MySql are two different animals. You need to learn SQL and Oracle's PL/SQL.

    Your SQL

    SELECT A.INVOICEDATE,
    @step1:=cast(ADDDATE(A.INVOICEDATE,A.TERMOFPAYMENT) as date) AS STEP1,
    @step2:=IF(@step1>CURDATE(),A.TOTALAMOUNT,0) AS STEP2,
    @step3:=IF(@step20,0,IF(DATEDIFF(CURDATE(),@step1)<=30,A.TOTALAMOUNT,0)) AS STEP3,
    FROM t_invoice A
    WHERE A.STATUS='Open' 
    

    Can be writern as

    select invoicedate,
           step1,
           step2,
           case when step2 = 0
                then case when sysdate-step1 <=30 then A.TOTALAMOUNT else 0 end
           end AS step3
      from (
             select A.invoicedate,
                    A.invoicedate+A.termofpayment step1,
                    case when (A.invoicedate+A.termofpayment) > sysdate then A.totalamount else 0 end as step2,
               from t_invoice A
              where A.status = 'Open'
           )
    
  • I have published my muse built Business Catalyst site and all from the 'Site in the web browser view' function in the program of the Muse does not work. Screen comes up with a message that it cannot locate the page and suggests I check the ip address.

    I recently published my muse built the Business Catalyst site for preview and all from the 'Site in the web browser view' function in the program of the Muse does not work. Screen comes up with a message that it cannot locate the page and suggests I check the ip address.

    Hello Jimw93000314,

    Are you preview site in the edge browser? When you preview the page in the browser Muse create a local server to give you the preview in the browser. With the edge browser, there was a reported issue to access the local server.

    Please click the link below that shows the steps to enable the browser to edge.

    http://StackOverflow.com/questions/30334289/cant-open-localhost-in-Microsoft-edge-project-spartiate-dans-Windows-10-APER cu

    I'm sure this will help.

    Kind regards

    Vivek

  • How to insert image from mysql into the table using php and create the checkbox in the table?

    How can I insert image from mysql into the table using php and create the checkbox for each data as a vote? Here is my code...

    WELCOME

    connect_error) {die ("connection failed:".)} $conn-> connect_error); } $sql = "SELECT no, Calon, ID, of course, the Image OF THE candidates." $result = $conn-> Query; If ($resultat-> num_rows > 0) {echo ' '; export data of each line while ($row = $result-> fetch_assoc()) {"echo"}}
    NO Candidate INFO Vote
    " . $row ["no"]. "-" . $row ["Calon"]. "
    -" . $row ['ID']. "
    -" . $row ['class']. "
    "; } ECHO ' ' ;} else {echo '0 results' ;} $conn-> close();?} >

    hope someone can help me because I am a newbie in this program... need to finish this project... Thank you.

    If you have saved the file name in the database, it's pretty simple.

    echo '' . $row['description'] . '';
    

    Is the same for the box:

    echo '';
    

    If you have saved the image file in the database, it is much more complicated. I recommend you store only the file name in the database.

  • AJAX/Spry gets MySQL data and images from directory records

    Hello

    I'm under Open-Realty (Real Estate Listings Software - http://www.open-realty.org ) with MySQL.

    Open-Realty stores its data in the MySQL database while saving his images in Directory folders.

    I am trying to convert the web site to display real estate listings using Ajax/Spry framework without reloading an entire page every time.

    I have no problem getting to the screen/get data from MySQL using Ajax/Spry, but I still don't have to figure out how to get the images of directory records to match with MySQL database.

    All this may be donw in the environment or the Dreamweaver Extensions?

    Or at least point me in the right direction pls?

    Can someone please give me some advice pls?

    Thanks in advance.

    Tommy

    You can read my article "Exchanging data using the Spry Ajax and PHP framework" in the Adobe Developer Center - he actually treats, vaguely said, displaying images from a directory that s associated with some 'item ID': http://www.adobe.com/devnet/dreamweaver/articles/spry_php_images.html

  • Conversion of a query GROUP_CONCAT of MySQL to Oracle

    Hi all
    We migrated our MySQL to Oracle database and we are facing the GROUP_CONCAT in MySQL built-in function.
    I went through the WM CONCAT, COLLECT AND other built-in aggregates Oracle packages. Our problem is the following:
    Table A (emp_number, emp_firstname, emp_lastname, Emp_status) and table B (emp_reporting_mode, emp_sub_mode, emp_sup_mode); Emp_sup_mode here is the employee
    These tables are not related, and we have these data
    Table A
    emp_number emp_firstname emp_lastname Emp_status
    5 BEN STA000 Raoul
    Nadine 6 YAYA NULL
    1 Hermann LONDJI STA001
    STAT00 ONANA honors 14

    Table B
    emp_reporting_mode emp_sup_mode emp_sub_mode
    1-6-1
    1-14-5
    The emp_sup_mode represents the emp_number and emp_sub_mode the emp_number subordinate supervisor. MySQl was able to use the GROUP_CONCAT to concatenate this.
    as such and should exit the emp_firstname and the emp_lastname of the contractor where the supervisor code is equivalent to the number of the employee. Here, we can see Nadine YAYA (emp_number 6) is the prime contractor to Hermann LONDJI (emp_number 1) and Honoré ONANA (emp_number 14) is the architect of Raoul ESSOME (emp_number 5).
    Thanks for any input. Other methods and rather global functions of similar id and cos.
    with a as (
               select 5 emp_number,'Raoul' emp_firstname,'ESSOME' emp_lastname,'STA000' emp_status from dual union all
               select 6,'Nadine','YAYA',NULL from dual union all
               select 1,'Hermann','LONDJI','STA001' from dual union all
               select 14,'Honore','ONANA','STAT00' from dual
              ),
         b as (
               select 1 emp_reporting_mode,6 emp_sup_mode,1 emp_sub_mode from dual union all
               select 1,14,5 from dual
              )
    select  a1.emp_number,
            a1.emp_firstname,
            a1.emp_lastname,
            a2.emp_firstname || ' ' || a2.emp_lastname supervisor
      from  b,
            a a1,
            a a2
      where a1.emp_number = b.emp_sub_mode(+)
        and a2.emp_number(+) = b.emp_sup_mode
    /
    
    EMP_NUMBER EMP_FIR EMP_LA SUPERVISOR
    ---------- ------- ------ --------------
             1 Hermann LONDJI Nadine YAYA
             5 Raoul   ESSOME Honore ONANA
            14 Honore  ONANA
             6 Nadine  YAYA
    
    SQL> 
    

    SY.

  • How a copy cell text, supporting details and attachments from a Version to another Member?

    How a copy cell text, supporting details and attachments from a Version to another Member?

    There was a Hyperion Planning 11.1.1.3 copied cell text utility, supporting details and attachments from one (job) Version to another Version (for example Final).  At the time where we ran, data erased!

    The old version (11.1.1.3's) Administration, management, copy data doesn't copy the text in the cell, supporting details and attachments from one Version to another Version. Latest version 11.1.2.4 copy these textual data?

    Thank you.


    Yes, in 11.1.2.4 data copy copy 'annotations to account', 'support detail' and 'text in the cell. Read below for what copy can do and can't do.

    http://docs.Oracle.com/CD/E57185_01/EPM.1112/planning_admin.PDF

    Copy of data

    You can copy plans of one dimensional intersection to another, including relational data and supporting details. For example, you can copy Final of Budget, FY10, FY11, forecast, first draft.

    Notes:

    l parameters to copy selected data are kept for the current session only.

    members of dimension l copied must be present in the selected plan types.

    the data must be copied in the cells that can accept data. For example, you can not copy data in read-only or dynamic of cells.

    l , you can copy annotations of account, to support in detail and text in cells. You can't copy annotations unit planning.

    l you cannot use this feature with attributes, selecting the attributes to copy.

    data l Essbase is copied regardless of selections for the copy of data Options.

    l because it is an administrative function, planning means that you have full access to the data you are copying. You cannot copy in the planning units that are approved.

    l this feature does not calculate data. To perform calculations, including the increase in the forecast of 5%, apply the business rule after you have copied the data.

    l to copy the data to succeed, you must select at least one Member for dimensions scenario, account, entity, period, and Version.

Maybe you are looking for

  • Stop clearing no user/system cache Firefox.

    I use FF 8.0 with Windows. The total cache under options-> advanced-> network fluctuates, goes up and down without my having unblocked. The result is slower loading of the page, because, it seems, some sites or data have been removed from the cache.

  • Update BIOS 1.90 M45-S331 Sam - computer laptop now, recognized as the A40

    Hello!Has anyone with M45 S331 updated their BIOS with the latest version? Well, I have, and my cell phone utilities software Toshiba now recognizes as the A40. :(I have used certainly good available BIOS here:http://cdgenp01.CSD.Toshiba.com/content/

  • How to resume the download of audiobook?

    Download the audio book has been interrupted. Now it comes not as a current download or as a purchased product. I tried to buy it again, and the system says that you already bought. Does anyone have any suggestions on how to resume the download?

  • NI-CAN Bus Monitor still works, but no examples of LabVIEW

    I have a USB-8473 on a PC running Windows XP I'm trying to monitor transmissions CAN go to an external device. No matter what settings I select in the Measurent Explorer & Automation, the bus monitor never miss a message and is completely error-free.

  • Pavillion E120SD: HP Pavillion E120SD CPU upgrade

    Someone at - it a list with processors that will fit in this laptop for replacement of the processor AMD-E1-2500?