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

  • SEARCH
  • Home
  • 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 7738037
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T08:09:29+00:00 2026-06-01T08:09:29+00:00

I have a program that must support both Oracle and SQL Server for it’s

  • 0

I have a program that must support both Oracle and SQL Server for it’s database.
At some point I must execute a query where I want to concatenate 2 columns in the select statement.

In SQL Server, this is done with the + operator

select column1 + ' - ' + column2 from mytable

And oracle this is done with concat

select concat(concat(column1, ' - '), column2) from mytable

I’m looking for a way to leverage them both, so my code has a single SQL query literal string for both databases and I can avoid ugly constructs where I need to check which DBMS I’m connected to.

My first instinct was to encapsulate the different queries into a stored procedure, so each DBMS can have their own implementation of the query, but I was unable to create the procedure in Oracle that returns the record set in the same way as SQL Server does.

Update: Creating a concat function in SQL Server doesn’t make the query compatible with Oracle because SQL Server requires the owner to be specified when calling the function as:

select dbo.concat(dbo.concat(column1), ' - '), column2) from mytable

It took me a while to figure it out after creating my own concat function in SQL Server.

On the other hand, looks like a function in Oracle with SYS_REFCURSOR can’t be called with a simple

exec myfunction

And return the table as in SQL Server.

In the end, the solution was to create a view with the same name on both RDBMs but with different implementations, then I can do a simple select on the view.

  • 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-06-01T08:09:31+00:00Added an answer on June 1, 2026 at 8:09 am

    If you want to go down the path of creating a stored procedure, whatever framework you’re using should be able to more or less transparently handle an Oracle stored procedure with an OUT parameter that is a SYS_REFCURSOR and call that as you would a SQL Server stored procedure that just does a SELECT statement.

    CREATE OR REPLACE PROCEDURE some_procedure( p_rc OUT sys_refcursor )
    AS
    BEGIN
      -- You could use the CONCAT function rather than Oracle's string concatenation
      -- operator || but I would prefer the double pipes.
      OPEN p_rc
       FOR SELECT column1 || ' - ' || column2
             FROM myTable;
    END;
    

    Alternatively, you could define your own CONCAT function in SQL Server.

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

Sidebar

Related Questions

Simple case I have a Python program that I intend to support on both
I have a program that connects to an Oracle database and performs operations on
I have a program that still must target Windows XP (_WIN32_WINNT 0x501), as most
I have program, that must interact with a console program before my program can
I have a program that spits out both standard error and standard out, and
I have a .Net program that I want to install on a terminal server.
I have a program that uses (and must continue to use) an old sorting
I have a Java program that I must do for homework, and here's the
I am developing a program that must calculate a color of each point on
I have program that has a variable that should never change. However, somehow, it

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.