If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > DB2 > SQL compatible to DB2 and MSSQL

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 11-24-08, 04:01
nitingautam nitingautam is offline
Registered User
 
Join Date: Nov 2008
Location: Delhi, India
Posts: 15
SQL compatible to DB2 and MSSQL

Hi All,

We have a application that uses two database DB2 and MSSQL. I have a situation with our application regarding MSSQL. We have complete access of MSSQL database in prod server but in development server we only have read access. We cann't make any changes in DEVELOPMENT mode.

So we have decided to move all the tables to DB2 for DEV and TEST environment.

Now when user is in DEV mode data will be fetch by the DEV DB2 database and in PROD it will be fetched with MSSQL database.

So we have to make SQL Queries compatible with both the database..

Is there any equivalent available for *= and @@IDENTITY in DB2? what else challenges can be there?

Please help...
Reply With Quote
  #2 (permalink)  
Old 11-24-08, 04:38
stolze stolze is offline
Registered User
 
Join Date: Jan 2007
Location: Jena, Germany
Posts: 2,662
That's a bad idea because SQL statements may differ not only in the syntax but also the performance. You should fix the real problem and get a MS SQL Server installation with which you can do real work.

Regarding your specific question, you may want to explain to us what exactly "*=" and @@IDENTITY is doing. Both are not standard SQL, so it may be a good idea to avoid such constructs in the first place.
__________________
Knut Stolze
IBM DB2 Analytics Accelerator
IBM Germany Research & Development
Reply With Quote
  #3 (permalink)  
Old 11-24-08, 05:49
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,524
Quote:
Originally Posted by nitingautam
So we have to make SQL Queries compatible with both the database..
three words: not. gonna. happen.
__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
  #4 (permalink)  
Old 11-24-08, 10:41
aflorin27 aflorin27 is offline
Registered User
 
Join Date: Apr 2008
Location: Iasi, Romania
Posts: 317
In MSSQL, @@IDENTITY is a system function that returns the last-inserted identity value (an identity column is a numeric auto-incremented column).

In DB2 you create an identity column using GENERATED ALWAYS AS IDENTITY clause of the CREATE TABLE statement. I am not aware of a DB2 function that will return the last-inserted identity value in a table.
Reply With Quote
  #5 (permalink)  
Old 11-24-08, 11:13
ARWinner ARWinner is offline
Registered User
 
Join Date: Jan 2003
Posts: 3,575
Quote:
Originally Posted by aflorin27
In MSSQL, @@IDENTITY is a system function that returns the last-inserted identity value (an identity column is a numeric auto-incremented column).

In DB2 you create an identity column using GENERATED ALWAYS AS IDENTITY clause of the CREATE TABLE statement. I am not aware of a DB2 function that will return the last-inserted identity value in a table.
In DB2 it is Identity_Val_Local:

http://publib.boulder.ibm.com/infoce.../r0004231.html

Andy
Reply With Quote
  #6 (permalink)  
Old 11-24-08, 22:00
nitingautam nitingautam is offline
Registered User
 
Join Date: Nov 2008
Location: Delhi, India
Posts: 15
Thanks you guys for your valuable inputs in this issue...I was also sure about this that this can't be happen as both have different syntax but as I am not expert in SQL so I take help from you

Thanks you very much for your time
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On