This question already has an answer here:
How to check if a columns value was explicitly specified in a PL/SQL BEFORE UPDATE trigger?
(1 answer)
Closed 8 years ago.
Is there an efficient method to identify which column has changed in a table in Oracle using a trigger? How to check if only one column (of interest) or all other columns also changed?
As the post Alex Pole pointed in your comments states, you could use the UPDATING function.
But you can also develop different triggers for updating specific columns with "BEFORE UPDATE OF" clause, witch is the optimal option if there is no code to share among the actions for the involved columns.
Related
I want to read from a table, change a couple column values for a few lines in a query, then update those lines on the same table.
I'm using SAP BODS, and that's what I tried:
I was about to insert images but just found out I can't insert images until 10 rep.
Anyway, I created a DataFlow where I have the same table as source and target.
A query to filter (using where) and change values (using mapping). And then a Table Comparison (where I expected those lines to be set to update, in this particular case), set table name on first entry, then PK in 'input primary key' and then the two columns I want to change in 'Compare columns'. No other changes from default that I can recall.
Got no warnings on 'validate all', and on execution I receive an ORA-00001 for the PK.
So ... I thought the Table Comparison would try to update, but seems like it's trying to insert instead. I want to know what I'm doing wrong and how could I get the job to do those updates. Thanks in advance.
Ps. I did search SO before asking and didn't find anything relevant.
Ok
So, turns out I just found what's going on a few minutes after posting the question.
Wasn't sure if I should answer my own question and took a look at this Etiquette for answering your own question
and decided to come back here and answer my own question.
For some reason I got stuck thinking that it was something to do with the Table Comparison trying to insert a line with a PK that's already there, instead of doing the update I wanted.
But after going back to the job to take another look at the issue, it occurred to me that maybe the problem could be a duplicate in the incoming data set. Made a few adjustment to filter those, and voilĂ .
Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 6 years ago.
Improve this question
I have a problem about my visual basic 6 program, I want to add an error message when a duplicate value is added by the user (I'm using SQL database). I tried a lot of codes but none of these works, I just deleted some of it. Here's the code. What code should I put to make it run? Please help, thanks in advance.
It is just a sample one, and I'm going to put the code to my original program if i am going to make it run.
You need to specify what do you consider as a duplicate line. A line with a IDNO that already exists or a line with IDNO and NAME that already exists?
Regardless the answer, you need to:
Define a unique key containing the fields that cannot have duplicate values. You must find out how to do that in your database management system. By doing that, you will have the guarantee that you will never have a duplicate line in your database.
Add a previous query to your code where you verify if there is a line in your table that already has the values you are trying to insert.
There are a number of ways to do this.
You could trap the error and check the error code/message, if it is "VIOLATION OF PRIMARY KEY CONSTRAINT" display the error message of your choice.
Personally I would check to see if it exists before the insert and if it does display the "The data you are trying to add already exists" message (or whatever it is you want to display).
On a side note you should look at Parameterized Queries. The query you have is open to SQL Injection. Take a look at this
This question already has answers here:
Synchronize independent spreadsheet rows, filled by IMPORTRANGE()
(2 answers)
Closed 7 years ago.
I am looking for some advice on how to approach this, I would like to sort a spreadsheet across 2 sheets using a google script. I know how to use sort () but it only works on a single sheet. First sheet has 2 columns, student name and student number, second sheet has columns student name and student number linked from the first sheet (ex. =Sheet1!A1) and additional columns to enter student marks. Problem is if I use sort on the first sheet then the mark columns will no longer align with the student names and numbers because they are referenced from the first sheet. I know combining into 1 sheet would solve this but I need them in different sheets as it's part of a bigger project.
I could use some advice on how to approach this using a google script.
You could also use VLOOKUP in your second sheet instead of direct references. Then you can rearrange the rows in Sheet1 all you want without affecting Sheet2. e.g. =VLOOKUP(A1, Sheet1!$A$1:$B,2,false)
Place that formula into all cells in column B of the second sheet.
I'm assuming that the student name is always in column A and the student number in column B.
This question already has answers here:
Oracle: function based index selective uniqueness
(2 answers)
Closed 8 years ago.
I have a table with a column IS_LOGGED which takes only two values 'Y' or 'N'
I want to have a Function based index on the column IS_LOGGED where value is 'Y'.
The purpose of index is to list all entries in an easy and fast to access manner.
Suppose you get a 1500 pages thick book to read with an index listing only specific chapters. What is the use of such an index?
I don't think you need a function based index here. Simply create an index and modify your queries to include IS_LOGGED = 'Y' clause.
This question already has answers here:
LINQ : Dynamic select
(12 answers)
Closed 8 years ago.
I'm working with dynamic queries using LINQ on Entity Framework.
To query some tables by user input filters, we are using PredicateBuilder to create conditional WHERE sections. That works really great, but the number of columns returned are fixed.
Now, if we need the user to select which columns he needs in their report, besides their filters, we are in trouble, as we don't know how to do dynamic myQuery.Select( x => new { ... }) as we do for Where clause.
How can we achieve something like this?
A bit of searching reveals that this is tricky. Anonymous types are created at compile time, so it is not easy to create one dynamically. This answer contains a solution using Reflection.emit.
If possible, I would recommend just returning something like a IDictionary<,> instead.