Skip to Content

How to Abstract Dual-Replicated Shop Floor SQL Database Connection

One of our plants has replicated virtual servers that contain a shop floor database that must be queried for production posting to SAP. The databases are replicated, with perhaps a 20s delay, and each has a separate IP address, but identical databases.

I am trying to think of an elegant way to switch SQL queries between the databases in the event that the primary server goes off-line.

A simple way is to write two identical queries, one for each database, and then do a server check and choose either the primary or secondary server query. Of course this is messy, and you have to maintain two copies of each query, easy to make mistakes when making changes.

Ideally I would like to be able to programmatically change the SQL connection for the queries. Since both databases are identical copies of each other (with slight delay), if I could figure out how to change the connection it would simplify my transactions.

Does anyone know how to change a SQL connection within a transaction?

Seems like in the .irpt script assistant there is a .getServer and .setServer under the iCommand.getQueryObject() -> SQL. I won't be creating a web page for my transactions, but this seems like a possible to lead to follow. Looking in the workbench, it is not obvious to me.

Anyway to abstract the SQL connection? I haven't used virtual server connections, thinking that these are only for linking to other MII NetWeaver databases.

I could always create two Linked SQL server connections from our MII database and change the query text using a [Param.x], but I would like to avoid that solution.

I am developing on MII15, so the new SAPUI5 tools are available, but again, they center around web development and I will be running transactions via MII scheduler.

Any suggestions?

Thanks,

Dan K

Add a comment
10|10000 characters needed characters exceeded

Related questions

1 Answer

  • Best Answer
    Posted on Jul 22, 2016 at 03:03 AM

    With more digging I now see that in the workbench, withing the Link editor, the SQL query has a "Server" attribute, which I was simply able to change the text strings between the connection names and the proper database was queried. Works as I had hoped. Funny, as soon as I finished posting this question I had a second look and found the solution.

    Add a comment
    10|10000 characters needed characters exceeded

    • MII is parameter driven in many ways, so I'm glad to hear you sorted it out. Another consideration, depending upon the way your database is structured would be to fully qualify the table or schema within the query itself, using [Param.x] (32 available). The benefit with this would be a single connection pool for the data server. In your case it sounds like you found the right approach since the DB's are separate, and here the naming convention of your data servers is key.

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.