473,788 Members | 2,811 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Only 1 of 3 columns per row can ever be populated!

Thanks to denormalised developers, I have a table where only one
column of three can ever be populated per row. I feel
a) BEFORE INSERT/UPDATE triggers would have an unacceptable
performance impact (this table will be accessed heavily).
b) creating three views would be clumsy.
c) restricting inserts/updates using the application is far too much
to ask.

Does anyone have any bright ideas?

Thanks
Bruce
Nov 12 '05 #1
4 1471
It would be easier to give advice if saw the DDL and some sample rows
for the table. Could you define all three columns with default values
and somehow define a constraint to enforce the rules you want?

Bruce Pullen wrote:
Thanks to denormalised developers, I have a table where only one
column of three can ever be populated per row. I feel
a) BEFORE INSERT/UPDATE triggers would have an unacceptable
performance impact (this table will be accessed heavily).
b) creating three views would be clumsy.
c) restricting inserts/updates using the application is far too much
to ask.

Does anyone have any bright ideas?

Thanks
Bruce


Nov 12 '05 #2
Bruce,

Is this dynamic SQL? As long as you exploit dynamic statement cache and or
use static SQL I don't see how a well written before trigger with a SIGNAL
statement can have a significant negative performance impact. The runtime
impact should be the evaluation time for the condition.
Keep in mind that DB2 for LUW uses inline SQL PL for triggers. Can't get any
faster than that.

Cheers
Serge
Nov 12 '05 #3
Bruce Pullen <br**********@h otmail.com> wrote:
Thanks to denormalised developers, I have a table where only one
column of three can ever be populated per row. I feel
a) BEFORE INSERT/UPDATE triggers would have an unacceptable
performance impact (this table will be accessed heavily).
b) creating three views would be clumsy.
c) restricting inserts/updates using the application is far too much
to ask.


What's the behavior that you want to have if 2 (or 3) of these columns are
to be populated? If you want to return an error, then a simple check
constraint on the table could be sufficient:

CHECK ( col1 IS NOT NULL AND col2 IS NULL AND col3 IS NULL OR
col1 IS NULL AND col2 IS NOT NULL AND col3 IS NULL OR
col1 IS NULL AND col2 IS NULL AND col3 IS NOT NULL )

If you want to handle the situation in the database system, then you would
need some more logic and triggers could be the way to go.

--
Knut Stolze
Information Integration
IBM Germany / University of Jena
Nov 12 '05 #4
After proposing a check constraint and a trigger, we're going for the
check constraint (I thought it wouldn't be possible to enforce this
logic using check constraints so thank you).

Thank you.
Bruce
Nov 12 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
2793
by: Paul | last post by:
Hi I have a table that currently has 466 columns and about 700,000 records. Adding a new DEFAULT column to this table takes a long time. It it a lot faster to recreate the table with the new columns and then copy all of the data across. As far as I am aware when you add a DEFAULT column the following happens:
1
1698
by: Peter | last post by:
Hello, Thanks for reviewing my question. My SQL table has a few string columns and a image column. After inserting a new row into the dataset with the columns populated, I tried calling the Update method on the DataAdapter and I get the following error: "The query processor could not producce a query plan from the optimizer because a query cannot update a text, or image column and a clustering key at the same time.". What is the...
0
1052
by: Jordo | last post by:
Help! I have a datagrid that is being populated after a button click to fill based on parameters set by the user at run-time. I am creating the columns programmatically from a datatable and setting the sort expression there. I have AllowSort set to True but when the grid shows up, the column headers don't have the hyperlink to allow postback and sort. Any ideas? Code snippet posted below: ------------------- Private Sub...
1
1235
by: coleenholley | last post by:
I'm getting frustrated with trying to format a datagrid that is entirely populated dynamically using a class module written in VB .Net (No C# used!) We connect to a DB2 database using an RPC that is written in COBOL. The connection to the datagrid works in the code-behind in the class module, when I check the 'Create columns automatically at run time' box. If I don't select that, I don't get any data, even if I go in and add all my columns in...
1
1101
by: Mac via DotNetMonster.com | last post by:
Hi all, I have a datagrid on a form which is not populated until the user enters selection criteria and clicks a button. Rather than have a blank datagrid when the form is displayed, I would like to have the columns headings that are to be displayed actually there. Is this possible? I know how to create a DataGridStyle programatically and add columns, so I added this chunk of code to the "page_load" event and nothing happened. Am I on...
4
2181
by: Greg | last post by:
I have a VB.NET Windows application with bound DataGrid control with it’s DataSource property set to a DataSet object. The DataSet object is created from an XML Schema. I would like to define some new columns in the DataGrid that are not yet in the DataSet object that are populated based on a given critera and values in the existing DataSet object. I added the new columns to the XML Schema and created a DataGridTableStyle that contains...
0
2321
by: schoultzy | last post by:
Hello Everyone, I have been trying to figure this one out for two days now. I have created a DataGridView which is populated by an ObjectDataSource. My problem occurs when I attempt to use the Edit feature of the DataGridView. I have set several of the BoundField elements of the DataGridView to ReadOnly="True". When I attempt to use the Edit feature to UPDATE the rows in the DataGridView I get a System.NullReferenceException for...
2
2103
by: Richard Maher | last post by:
Hi, Recently on the web I came across documentation discussing Data Source Objects (DSO) in relation to browser and html functionality (in particular the ability to declare a Java applet as a data source that can be used with any or the HTML tags that take the src="" attribute). I find it interesting and potentially *very* useful and would like to know more, so if anyone can answer any of the following questions that would be great: - ...
6
7723
by: napatel04 | last post by:
Hi everyone, I would like to know if there is a quick query someone can help me write for the following scenario. I think I can do this with VBA but since this is suppose to be a temp. solution, I really do not want to spend too much time on it. I have two tables, 1 an old one which has work done in it with all the necessary columns correctly populated with the data and the second one I need which has the same columns but need to be...
0
9656
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9498
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10370
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10177
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10113
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
7519
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6750
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5402
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5538
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.