Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6158829
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T21:01:37+00:00 2026-05-23T21:01:37+00:00

Any better method to UPSERT into a table, provided : Data upsert at ~1

  • 0

Any better method to UPSERT into a table, provided :

  • Data upsert at ~1 row/second
  • Table Name is DYNAMIC, generated using ObjectID parameter passed to it

THE FOLLOWING PROCEDURE THROWS :
“ORA-00942: table or view does not exist”

CREATE OR REPLACE PROCEDURE
PROCEDURE "SPINSERTDATA"
(
  pObjectID IN RAW,
  pDateTime IN TIMESTAMP,
  pValue IN BINARY_DOUBLE,
)
AS
BEGIN
  Declare
    vQueryInsert VARCHAR2(1000);
    vQueryUpdate VARCHAR2(1000);
    vTableName VARCHAR2(30);
  Begin      
      vTableName := FGETTABLENAME(POBJECTID => pObjectID);
      vQueryUpdate := 'UPDATE '      || vTableName || ' SET "VALUE" = :1';
      vQueryInsert := 'INSERT INTO ' || vTableName || ' ("DTTIME", "VALUE") VALUES (:1, :2)';

      EXECUTE IMMEDIATE vQueryInsert USING pDateTime, pValue;
        EXCEPTION
          WHEN DUP_VAL_ON_INDEX THEN 
            EXECUTE IMMEDIATE vQueryUpdate USING pValue;
  End;
END "SPINSERTDATA";
  • Apparently MERGE does not work as the TableName Cannot be dynamic
    ???
  • I’m a newbie, my third month of coding, I scourged through
    STACKOVERFLOW & Googled for 3 days now, trying all sorts of funny &
    desperate solutions … Even a very relevant link if you found one
    would be honestly appreciated.
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T21:01:39+00:00Added an answer on May 23, 2026 at 9:01 pm

    MERGE works perfectly fine with Native dynamic SQL (EXECUTE IMMEDIATE):

    create table so_test(pk number not null primary key, value varchar2(20));
    
    insert into so_test(pk, value) values(1, 'one');
    
    declare
      l_SQL varchar2(4000);
      l_tablename varchar2(4000) default 'so_test';
    begin
      l_SQL := 'merge into ' || l_tablename || ' target' ||
        ' using (select 1 pk, ''eins'' value from dual union all
                 select 2 pk, ''zwei'' value from dual) source
          on (target.pk = source.pk)
          when matched then 
            update set target.value = source.value
          when not matched then
            insert values(source.pk, source.value)      
      ';
      dbms_output.put_line(l_sql);
      execute immediate l_SQL;
    end; 
    

    Could you please post the error message you get when using MERGE?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have lots and lots of data in various structures. Are there any better
I feel that using GetEnumerator() and casting IEnumerator.Current is expensive. Any better suggestions? I'm
Is it better to use $.get(http://www.example.com/mydirectory, function(data) { $(.someclass).html(data); }); or $('.tripPlannerBottom').load(http://www.example.com/mydirectory); any speed
I have a data struts like this: category: subcategory: color:red name:pen Is there any
Is there any better alternative for doing string formatting in VC6, with syntax checking
Do I use varchar(36) or are there any better ways to do it?
Does javascript coding work better with any particular server language?
Having the hours and minutes, is there any easier or better way to set
Are there any VC++ settings I should know about to generate better PDB files
Anyone have any experience evaluating BlazeDS and GraniteDS? I'm curious about which is better

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.