Generic Insert and Update Queries to work on both Oracle and SQLServer

xMII12.0.2
I need to write queries which will be able to run on both Oracle and SQLServer database tables without any changes.  It needs to be able to handle dates without including Oracle specific date functions (TO_DATE, TO_CHAR, TO_TIMESTAMP, etc.).
I did read a post earlier by Jeremy Good regarding the use of ED and SD which invoke the DatePrefix and DateSuffix in the data server configuration.  That seems to work fine in cases of only trying to insert two distinct dates.  However, what do you do in the case of having three or more dates to insert.  An example query might be:
Insert into ProductionOrder
(ProdOrdNbr, Plant, Material, Quantity, UOM, DeliveryDate, ProdStartDate, ProdFinishDate, CreateDate, LastModifiedDate)
Values
('0100001001', '001', '000000000007887780', 20.0, 'PC', '21-FEB-08 22:01:19','11-FEB-08 00:01:34', '12-FEB-08 02:44:59', '01-FEB-08 12:00:00', '04-FEB-01 13:22:13')
So far I have been using the TO_DATE to convert the dates successfully, but SQLServer does not recognize that function (not surprising since it is an Oracle specific function).  So I would have to go through all the transactions/query templates and rebuild them separately to deal with the different database vendors. 
Any suggestions?
Thanks,
Mike

Hi Rick,
Are you talking about dynamically building each script based on a server setting and datatype?  If I understand you correctly, I guess it could be done that way, but it would be a royal pain to maintain.  I have done such things before and can see how it could be done. 
But is there no way to invoke the DatePrefix and DateSuffix besides the SD and ED parameters?  Or did I misunderstand your response?
I would be perfectly happy to build all the queries inside BLS transactions.  In the few cases, where they are not already contained in the BLS, we could throw a BLS wrapper around it and not pay much of a penalty in performance.
Thanks,
Mike

Similar Messages

  • SQL INSERT / SQL UPDATE don't work with form page, don't affect table

    The subject line says it all. No matter what I try, my updates on the form don't appear on the report page, which accesses the table. When I look at the table using SQL WORKSHOP, the changes aren't made there either. What am I missing? I have another report page and form page with a different table in the same application and updates in that table work fine. I coded them both the same. What should I be looking at?
    Steve "the n00b" in Raleigh NC

    Steve,
    How you have created the FORM page? Using FORM WIZARD? Or You have created blank page and after that you have manually created all the form items?
    If you have used WIZARD to create form page, then you can see a page process with Automatic Row Processing (DML) type. Here you need can set DML (Insert/Update/Delete) you wish to use on this form. APEX will take care of the rest.
    If there is no such process in your page, then you need to create one. You may have one process to do both (Insert and Update) and you can have two sepate processes. I prefer having two seperate page processes (after submit), one for Insert and one for Update.
    Now you can make the Insert process conditional so that it only execute when you click button - Create (Add or any similar button you have ) Also make the Update process conditional so that it only execute when you click button - Save (Update or any similar button you have )
    Just a quick note - From the above trigger, I can guess you are allowing users to enter Primary Key manually? In my opinion, Primary key should be always system generated using SEQUENCE. Users can only enter BUSINESS KEY (if any) and we should not use Business key as Primary Key.
    Good Luck :-)
    - Hari
    Edited by: Hari_639 on Oct 23, 2009 8:02 PM

  • Best Practice to Setup an application to work with both oracle and db2 db

    Hi,
    We have an application that currently supports both oracle and db2 databases . It is currently using JPA with eclipselink as backend mechanism and we want to move to ADFBc as our backend . So what is best practice to do this?
    I came across an old post in https://groups.google.com/forum/#!topic/adf-methodology/UlJZSTu14Io that states to create two different model projects to support oracle and db2 .
    Is this still the standard ? Is there a way that we could work around rather than creating multiple projects?
    How do i get the view controller to work with multiple model projects if this is the case?
    Thank you.

    Thanks for the response .
    The problem is i would have the same schema on both the databases (both in oracle and db2) .
    I don't see a scenario where i want both the application model projects at the same time . What i meant is , Application will either be deployed with Oracle DB or DB2 but not with both on a production environment .
    So is there a way where i just change the connection parameters alone rather having two different models ?
    If i have to use two model projects ,  would it be possible say i built the view controller for Oracle , and use it for DB2 if i make sure the BC objects names are similar between model projects and switch just the model jar based on the deployment environment ?
    -Sam

  • Which oracle client works with both Oracle 11.2.0.2 and BizTalk 2006 R2

    Hi there
    My Oracle11.2.0.2 is installed on linux server. My Biztalk2006R2 is installed on Windows Server 2003 R2 x64. I have already installed BizTalk Adapter for Oracle on the Biztalk server and now require to install Oracle Client to make Biztalk able to retrieve data from Oracle11.2.0.2 using the oracle client.
    From the following link,
    http://msdn.microsoft.com/en-us/library/aa559822%28v=BTS.20%29.aspx
    I came to know that the only oracle clients compatible with Biztalk adapter for oracle are as below:
    1) Oracle client 8i
    2) oracle client 9i
    3) oracle client 10i
    Now I need to install an oracle client on biztalk server in order to make biztalk talk to oracle and retrieve data from it.
    Question1: which of the above clients should i install on biztalk server that is compatible with both Oracle11.2.0.2 as well as Biztalk server 2006 R2?
    Question2: How to install and configure this client to make it work correctly?
    Please help.. thanks.
    Edited by: manibest on 19-Dec-2012 03:27
    Edited by: manibest on 19-Dec-2012 03:27

    The Biztalk Adapter interface with Oracle software has information, requirements per referenced document that does not make sense.
    E.g. "10i" does not exist and the requirement "Oracle ODBC driver 9.2.0.5.4" means that only 9.2 Client can be used. (Mixing parts from one Database Client product version with another version is not allowed/supported/certified.)
    Btw, does that machine happen to have Itanium hardware? (probably no, since you stated x64)
    For Oracle's OS requirements, 2003 was certified with/from 9.2.0.3 (and likely also terminal patch set version 9.2.0.8). Not sure about Server 2003 R2, 32 or 64-bit. I'm pretty sure 10.2 was certified on 2003 R2, but the note likely refers to 10.1 versions (before it was known it would be labeled 10g, g for grid replacing the i ).
    This FAQ may have some more information: http://www.oracle.com/technetwork/database/windows/faq-100614.html
    For Oracle client - server interoperability and certification, there's a support matrix on MOS. See doc id 207303.1.
    It seems 9.2 is supported on the wire to operate with 11.2 server, but Client with at least patch set 9.2.0.4 is required.
    So, I guess best bet is to find updated requirements.
    If you manage to get hold of 9.2.0.5, after verifying that 2003 R2 is ok, then it looks like the puzzle could be put together for a complete picture.
    For ease of install, take a look at the Instant Client. (However, there's no 9.2 IC, that type of client install came later)
    http://www.oracle.com/technetwork/database/features/instant-client/index-097480.html
    Edit;
    some corrections, specially about 9.2 version
    Edited by: orafad on Dec 19, 2012 10:58 PM

  • Does UMX Work with both Oracle Apps 11i and Oracle Portal

    Hi,
    I am looking for some information related to UMX, Please share...
    Has some one setup UMX in your 11i instance.. How comfortable it is after installation
    I am looking to setup UMX for an Apps11i instance...
    I am also sharing this Apps11i Database with Portal and Discoverer installation.
    It is my initial understanding that the UMX is tightly coupled with Apps11i, Can I also integrate or use UMX with Discoverer/Portal.
    Well, my basic purpose of exploring UMX is to get the Automatic Password Reset. If you are aware of anyother Password reset feature (which is not custom built using FND_USER Package & Procedure, coz..upgrade/maintenance issue), Please let me know.
    With kind regards,
    JRF.

    Refer Metalink Note 258281.1, 290525.1 for Configuring UMX with Oracle Apps
    also refer the following link
    http://www.oracle.com/technology/products/applications/security/index.html
    (white paper on UMX)

  • Before and After insert or update rowcount

    Hi
    I have several extract objects procs which are calling various build objects procs which in turn are inserting or updating the tables...now when i run these objects sometimes i get no errors and everything seems to be running perfectly but the tables do not get updated ? now what i am trying to achieve here is get some kind of summary where i can see the before and after rowcount..for that i have created a table of every extract object proc and another table with the coressponding tables being updated by tht proc...can anyone pls tell me how should i look into these procs and how do i get the rowcount for a particular table before and after the procedure was run ?
    Thanks a lot in advance

    Hi,
    On which version of RDBMS are you working , because if you're on 10g then just enable auditing or even FGA on the tables were you want to see the changes,
    Then query the DBA-AUDIT (not sure of the name anymore) view.
    If not then create a audit package yourself.
    something like
    create or replace package pck$audit as
    procedure prc$check_tablecount(p_tablename IN VARCHAR2, p_status IN VARCHAR2);
    end;
    create or replace package body pck$audit as
    procedure prc$check_tablecount(p_tablename IN VARCHAR2,p_status IN VARCHAR2) IS
    sqlstr VARCHAR2(100);
    v_count NUMBER;
    begin
    sqlstr := 'SELECT COUNT(*) FROM '||p_tablename;
    EXECUTE IMMEDIATE sqlstr into v_count; --could by 'using v_count' check syntax for this
    INSERT INTO audit_table(table_name,total_count,status,time_stamp)
    VALUES(p_tablename,v_count,p_status,SYSTIMESTAMP);
    COMMIT;
    end;
    end;
    you can elaborate on this creating additional procedure checking differences in total_count on same table at same time.
    Now call this procedure before starting your insert-delete- on your table make sure you put the parameters correct eg p_status => 'begin procedure'
    and call it again after your commit in your procedure.
    Hope this helps you out
    Erwin

  • Searching update insert and delete statements

    Hi.
    Suppose, there is change request containing 10 or more programs.
    One of the program has statements, working with database tables,
    like update, insert or delete.
    Is there any transaction where we can select request number and find
    programs working with tables directly.

    Hello
    1. Goto table E071 with TRKORR = change request and OBJECT = {reps, repo, rept}
    2. In field OBJ_NAME will be all reports names in this request
    3. In abap-programm upload this reports into internal table
    4. Search for 'update' 'insert' and 'delete'
    P.s. it is only for reports

  • One item used for insert and update

    I'm still trying to learn APEX and need to understand how to use an item for both update and insert. Is the LOV part used for the insert and the SOURCE for the update? I have a WHERE clause I need to use for the insert but not the update. I have to display items when updating that would not show up in the insert b/c only active things should be in the insert whereas the update can contain retired values. Also one such item needs to display its value but hold on to it's ID. Also, I am displaying items from more than one table so I'm not sure if I can say it's a Database Column. AS you can see, I'm really confused and the doc doesn't usually explain these details and is not helping me. Can someone explain how to set up such items? Thank you!

    I do actually have things working (I do have insert, update and delete processes) since I copied from another app, but there are some details that are not working well. For example, I have a linked field that pulls up a record (row fetch) and 2 of the fields do not pull up the values for that row (it's a select list and that's there but it doesn't highlight the correct value). For one of them, when inserting, the LOV (I think) should only show the active values but then, when the row is fetched, it needs to show a value from the table even if it's no longer active. I'm missing something and don't know what it is.

  • AFTER INSERT OR UPDATE TRIGGER the insert not working

    The update works but the insert is not working. I have two version that I have tried. I amd executing the inserts/update from Oracle Applications and the table row is either being inserted or updated correctly.
    DROP TRIGGER APPS.CCC_HZ_ORG_CONTACTS_ARU;
    CREATE OR REPLACE TRIGGER APPS.CCC_HZ_ORG_CONTACTS_ARU
    /* --Created By: SKELLEHER
    --Creation Date: 07/15/09
    --Last Updated By:
    --Last Update Date:  
    AFTER INSERT OR UPDATE OF department, job_title
    ON apps.hz_org_contacts
    FOR EACH ROW
    WHEN (
    NEW.department <> OLD.department OR
    NEW.job_title <> OLD.job_title
    DECLARE
    v_ChangeType VARCHAR2(10);
    BEGIN
    /* Use 'I' for Insert, 'U'' for Update, and'D' for delete(not part of app at this time). */
    IF INSERTING THEN
    v_ChangeType := 'INSERT';
    ELSIF UPDATING THEN
    v_ChangeType := 'UPDATE';
    ELSE
    v_ChangeType := 'DELETE';
    END IF;
    INSERT INTO cust.ccc_tca_po_tf_event_tbl
    VALUES (ccc_tca_po_tf_event_tbl_s.NEXTVAL
    , 'hz_org_contacts'
    , v_ChangeType
    , 'org_contact_id'
    , :NEW.org_contact_id
    , 'PENDING'
    , NULL
    , 0
    , 'N'
    , 'Y'
    , :NEW.LAST_UPDATED_BY
    , :NEW.LAST_UPDATE_DATE
    , -1
    , SYSDATE
    , 'DEPARTMENT_JOBTITLE_UPDATE'
    ,'LDAP'
    END;
    AND I TRIED ANOTHER VERSION:

    I have simplified it so it's just checking for insert but it's not picking up. Is the syntax IF INSERTING correct?
    CREATE OR REPLACE TRIGGER APPS.CCC_HZ_ORG_CONTACTS_ARU
    AFTER INSERT OR UPDATE
    ON ar.hz_org_contacts
    FOR EACH ROW
    DECLARE
    BEGIN
    IF INSERTING THEN
    INSERT INTO cust.ccc_tca_po_tf_event_tbl
    VALUES (ccc_tca_po_tf_event_tbl_s.NEXTVAL
    , 'hz_org_contacts'
    , 'UPDATE'
    , 'org_contact_id'
    , :NEW.org_contact_id
    , 'PENDING'
    , NULL
    , 0
    , 'N'
    , 'Y'
    , :NEW.LAST_UPDATED_BY
    , :NEW.LAST_UPDATE_DATE
    , -1
    , SYSDATE
    , 'DEPARTMENT_JOBTITLE_UPDATE'
    ,'LDAP'
    END IF;
    END;
    /

  • After burning CD tried to print jeweled case insert and playlist is typed over. Never had this problem until most recent update to newest version of Itunes

    After burning CD tried to print jeweled case insert and playlist is typed over. Never had this problem until most recent update to newest version of Itunes

    Most likely you have Office 2004 which are PPC-only applications and will not work in Lion. Upgrade to Office 2011. Other alternatives are:
    Apple's iWork suite (Pages, Numbers, and Keynote.)
    Open Office (Office 2007-like suite compatible with OS X.)
    NeoOffice (similar to Open Office.)
    LibreOffice (a new direction for the Open Office suite.)

  • I connected my external hard drive to my new imac to put all of the information from my macbook onto it. i have been working on the macbook now and want to reconnect the external hard drive so my imac is updated with the work. How is that done?

    I connected my external hard drive to my new imac to put all of the information from my macbook onto it. I have been working on the macbook now and want to reconnect the external hard drive so my imac is updated with the work. How is that done? or is it possible?

    As I said, I don't use Time Machine, so it'd be best to wait for an "expert" answer, but, with my very limited knowledge, I'd say: probably not - so, for now, I'd suggest you read up on Time Machine:
    http://web.me.com/pondini/Time_Machine/Home.html
    http://support.apple.com/kb/index?page=search&src=support_site.home.search&local e=en_US&q=time%20machine
    And, you might be attracting more knowledgeable answers if you were to post this question in the Time Machine Forum (part of the Snow Leopard forums).

  • HT201413 I have been trying to restore my iphone 4s for 5 hours, please help! The update wouldn't work and now when I connect the iphone it says I have to resore in order to start using itunes but I am getting an error msg. HELP!

    I am trying to update a 4s. The update did not work for some reason. Now I need to restore the iPhone. When I connect the usb to the computer and phone it says I need to restore. So, I click to restore. It starts extracting the software. But I am continually getting the same error message that it cannot complete for unknown error. I have been working on this for 5 and a half hours. I'm tired, mu husband needs his phone and apple support is a joke and of course I can't find any answers anywhere. Please help!

    Hi MB2751,
    As an iPhone user myself, I know it must be very much a problem to have the phone out of service because of an error such as you are seeing. Let's see if we can get you back up and running.
    I would suggest that you troubleshoot using the steps in this article - 
    If you can't update or restore your iPhone, iPad, or iPod touch
    Thanks for using Apple Support Communities.
    Best,
    Brett L 

  • On updating my iphone it shows no network inspite the sim inserted,now it also not working with itunes.i cant see menu page on display screen

    on updating my iphone it shows no network inspite the sim inserted,now it also not working with itunes.
    i cant see menu page on display screen

    http://support.apple.com/kb/HT1808

  • Safari is not working on the Mac. Internet is fine, mail, App Store etc all working and connecting to Internet fine. Done the latest software update, still not working. When selecting a web address from bookmarks or typing in search bar, partial blue bar.

    Safari is not working on the Mac. Internet is fine. mail, App Store etc all working and connecting to Internet fine. Done the latest software update, still not working. When selecting a web address from bookmarks or typing in search bar, partial blue bar only and coloured wheel appears.

    From the Safari menu bar, select
    Safari ▹ Preferences ▹ Extensions
    Turn all extensions OFF and test. If the problem is resolved, turn extensions back ON and then disable them one or a few at a time until you find the culprit.
    If you wish, you may be able to salvage the malfunctioning extension by uninstalling and reinstalling it. That will revert its settings to the defaults.
    If extensions aren't causing the problem, see below.
    Safari 5.0.1 or later: Slow or partial webpage loading, or webpage cannot be found

  • Can we use both INSERT and UPDATE at the same time in JDBC Receiver

    Hi All,
    I would like to know is it possible to use both INSERT and UPDATE at the same time in one interface because I have a requirement in which I have to perform both the task.
    user send the file which contains both new and old record and I need to save those in MS SQL database.
    If the record exist then use UPDATE otherwise use INSERT.
    I looked on sdn but didn't find any blog which perform both the things at the same time.
    Interface Requirement
    FILE -
    > PI -
    > JDBC(INSERT & UPDATE)
    I am thinking to use JDBC Lookup but not sure if it good to use for bulk record.
    Can somebody please suggest me something or send me the link of any blog or anything to solve this problem.
    Thanks,

    Hi ,
              If I have understood properly the scenario properly,you are not performing insert and update together. As you posted
    "If the record exist then use UPDATE otherwise use INSERT."
    Thus you are performing either an insert or an update which depends on outcome of a search if the records already exist in database or not. Obviously to search the tables you need " select * from ...  where ...." query. If your query returns some results you proceed with update since this means there are some old records already in database. If your query returns no rows  you proceed with "insert into tablename....." since there are no old records present in database.
      Now perhaps the best method to do the searching, taking a decision to insert or update, and finally insert or update operation is to be done by a stored procedure in MS SQL database.  A stored procedure is a subroutine available to applications accessing a relational database system. Here the application is PI server.   If you need further help on how to write and call stored procedure in MS SQL you can look into these links
    http://www.daniweb.com/web-development/databases/ms-sql/threads/146829
    http://www.sqlteam.com/article/stored-procedures-parameters-inserts-and-updates
    [ This part you can ignore, Since its not sure that you will face this situation
        Still you might face some problems while your scenario runs. Lets consider this scenario, after the stored procedure searches the database it found no rows. Thus you proceed with an insert operation. If your database table is being accessed by multiple applications (or users) other than yours then it is very well possible that after the search operation completed with a null result, an insert/update operation has been performed by some other application with the same primary key. Now when you are trying to insert another row with same primary key you get an error message like "duplicate entry not possible for same primary key value". Thus you need to be careful in this respect. MS SQL has a feature called "exclusive locks ". Look into these links for more details on the subject
    http://msdn.microsoft.com/en-us/library/aa213039(v=sql.80).aspx
    http://www.mssqlcity.com/Articles/Adm/SQL70Locks.htm
    http://www.faqs.org/docs/ppbook/r27479.htm
    http://msdn.microsoft.com/en-US/library/ms187373.aspx
    http://msdn.microsoft.com/en-US/library/ms173763.aspx
    http://msdn.microsoft.com/en-us/library/e7z8d5hf(v=vs.80).aspx
    http://mssqlserver.wordpress.com/2006/11/08/locks-in-sql/
    http://www.mollerus.net/tom/blog/2008/03/using_mssqls_nolock_for_faster_queries.html
        There must be other methods to avoid this problem. But the point is you need to be sure that all access to database for insert/update operations are isolated.
    regards
    Anupam

Maybe you are looking for

  • When Creating Credit memo pricing formula gets triggered even if pri typ D

    Hi gurus, We have a copy control set up from billing doc to credit memo doc with all the item catergories pricing type as D (Copy pricing elements unchanged ). We have a discount condition in pricing procedure which is set to statistical based on a c

  • Automatic creation of Purchase order not possible for 103 mvt type

    Hi, If i could configure "create p.o automatically", while doing G.R for mvt type 101, why cannot i do the same with 103 mvt type. I checked the checkbox "create p.o automatically" for movement type 103 and tried to do G.R for others using Mvt type 1

  • Problem posting photos to facebook from Organizer

    I have always exported photos from Organizer and then posted those .jpg files on Facebook however, this has suddenly stopped working.  I am still exporting the same way to a .jpg file but Facebook now tells me that it can't read the file.  I have con

  • How can I compare the lengths of two objects in a picture?

    I imagine there should be some sort of floating ruler hovering over each object and some cutting work to do to overlay one object on top of another while one object being transparent so that the length discrepancy is transparent.

  • Pushing Port Descriptions based on Client changes using PI2.0

    Is it possible to write a template or job in PI to catch a trap for a client change on a wired network and push an interface description to the related interface based on that change ? For example, 802.1x client authenticates to port fa0/13 on switch