DB2

DB2 is IBM's offering to the highend database market. The latest version of DB2 (Universal Database) is ideal for OLTP, Data Warehousing, Decision Support and everything in between. It's well priced, extremely scalable and runs on virtually every platform out there from handhelds to mainframes.

sql query--need help


Hi fellow developers,
I have to implement below mentioned design using SQL queries(DB2 Database).Pls help with your suggestions.
The base table 'BA' has an attribute (say X), which has two values - 'active' and 'inactive'. table BA is to be joined with table BA_ALT(which is identical to BA, but it stores 1 days history data). And the data is to be loaded in the target table 'tgt'. And the condtion to be implementated is - if the value of X is 'active', then the row must be loaded directlt in the tgt, but if the x='inactive', then some transformation logic is to be implementated and the row is to be loaded.
Now my query is , can this be implemented with 2 insert statements, in one using where x='active' in the join condition and in second insert , using where x='inactive'? will this work? Or is there a better way of implementin this if else situation?
PS-- the OS is unix. The queries will be executed in a unix scrpit.
Originally Posted by indigo3
will this work?
Yes.
Originally Posted by indigo3
is there a better way of implementin this if else situation?
You might try using the CASE expression.

Related Links

SQL1822N Unexpected error code "-30082
doubt high availability data replication
Help on logical partition setup (db2 9.7 ese)
Detect from catalog if Varchar-Column was defined for Bit/Mixed/SBCSData
problem with this function?
reorg DB2 Z/OS job
creating procedures
oracle vs db2
DB2 Dynamic query execution which returns row count
DB2 hadr on standby hangs after disconnect from primary
How to archive smartly in db2 ?
Strange SELECT query behaviour
Cataloging Mainframe table
configuration tool error
Transformation of date format
Date and Time Dimensions

Categories

DataBase Dev
MongoDB
Adabas
DB2
Informix
Microsoft SQL Server
MySQL
Oracle
Pervasive.SQL
PostgreSQL
Sybase
Other
ASP
Crystal Reports
Delphi, C etc
JAVA
Perl and the DBI
PHP
ANSI SQL
Unix Shell Scripts
Visual Basic
Brilliant Database
Corel Paradox
FileMaker
Microsoft Access
Microsoft Excel
Other PC Databases
New Members & Introduc...
Applications & Tools
Database Concepts & De...
Chit Chat
Marketplace
Job Opportunities
Suggestions & Feedback

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App