Conditional Join - Specific Column Select
hi
I just receive a request from Finance Team to retrieve customer address from Account, Agent and Customer table. here is the requirement
1. when the customer is direct call in, use customer number from account table to get the address form customer table
2. when the customer is walk in, use agent number from account table to get the customer number from agent table then get the address from customer table.
how can I write the query to get those information?
>> I just receive a request from Finance Team to retrieve customer address from Account [sic], Agent [sic] and Customer [sic] table. here is the requirement <<
Please follow basic Netiquette and post the DDL we need to answer this. Follow industry and ANSI/ISO standards in your data. You should follow ISO-11179 rules for naming data elements. You failed! A table is a set, so its name has to be plural or collective.
You are telling us that you have one account, one agency and one customer. Back in the 1950's, before RDBMS, we had file systems that process records, one at a time. The early system design methods used singular file names because that was the “unit of work”
back then.
You should follow ISO-8601 rules for displaying temporal data. We need to know the data types, keys and constraints on the table. Avoid dialect in favor of ANSI/ISO Standard SQL.
How do you write SQL without DDL?? You expect us to do this for you, but please tell us how! Or quite being rude to the forum members.
>> 1. when the customer is direct call in, use customer number from account [sic] table to get the address from customer [sic] table
2. when the customer is walk in, use agent number from account [sic] table to get the customer number from agent [sic] table then get the address from customer [sic] table.
<<
Why are addresses in two places and treated as attributes? Do you know what normalization is? Should you have a table of them then reference the addresses in other tables. Does your industry use a SAN (Standard Address Number) system?
--CELKO-- Books in Celko Series for Morgan-Kaufmann Publishing: Analytics and OLAP in SQL / Data and Databases: Concepts in Practice Data / Measurements and Standards in SQL SQL for Smarties / SQL Programming Style / SQL Puzzles and Answers / Thinking
in Sets / Trees and Hierarchies in SQL
Similar Messages
-
How to select a specific column in a bean method?
Hey everyone,
I'm trying to select a specific column in my adf table so i can hightlight the ones i can after, with a method bean that does a match from another table. I'm using JDeveloper 12.1.2.0.0.
Here's my table at the moment (its a static list that Timo and Alejandro helped me create, thanks to them again!):
<af:table value="#{bindings.Anos1.collectionModel}" var="row"
rows="#{bindings.Anos1.rangeSize}"
emptyText="#{bindings.Anos1.viewable ? 'No data to display.' : 'Access Denied.'}"
rowBandingInterval="0" fetchSize="#{bindings.Anos1.rangeSize}"
filterModel="#{bindings.Anos1Query.queryDescriptor}"
queryListener="#{bindings.Anos1Query.processQuery}"
filterVisible="false" varStatus="vs" id="t5"
styleClass="AFStretchWidth" columnSelection="multiple"
inlineStyle="max-width:100%;" columnStretching="multiple"
columnSelectionListener="#{ControlBean.onAnoColumnSelect}"
disableColumnReordering="true"
binding="#{ControlBean.dimAnos}">
<af:column sortProperty="#{bindings.Anos1.hints.A2011.name}"
filterable="true" sortable="false"
headerText="2011"
id="c54" width="16%">
<af:outputText value="#{row.A2011}"
shortDesc="#{bindings.Anos1.hints.A2011.tooltip}"
id="ot54">
<af:convertNumber groupingUsed="false"
pattern="#{bindings.Anos1.hints.A2011.format}"/>
</af:outputText>
</af:column>
<af:column sortProperty="#{bindings.Anos1.hints.A2012.name}"
filterable="true" sortable="false"
headerText="2012"
id="c55" width="16%">
<af:outputText value="#{row.A2012}"
shortDesc="#{bindings.Anos1.hints.A2012.tooltip}"
id="ot55">
<af:convertNumber groupingUsed="false"
pattern="#{bindings.Anos1.hints.A2012.format}"/>
</af:outputText>
</af:column>
<af:column sortProperty="#{bindings.Anos1.hints.A2013.name}"
filterable="true" sortable="false"
headerText="2013"
id="c56" width="16%">
<af:outputText value="#{row.A2013}"
shortDesc="#{bindings.Anos1.hints.A2013.tooltip}"
id="ot56">
<af:convertNumber groupingUsed="false"
pattern="#{bindings.Anos1.hints.A2013.format}"/>
</af:outputText>
</af:column>
</af:table>
I've deleted some of the columns because they are all equal and by doing so, you have less problems in reading it.
In my method i have a matchEm but i'm trying to select a column by using this line:
dimAnos.setColumnSelection("A2012");
dimAnos is the binding for my table Anos (Years in Portuguese). I even tried another values fro the columnSelection but i couldn't make it selected. Am i doing anything wrong?
Please help me or give me an idea of how can i do this.
Regards,
Frederico.Hi Frederico,
The method setColumnSelection is meant to set whether your table supports column selection or not. It doesn't select the column. In order to select the column, you need to set the column attribute Selected to true. So I don't know if its an option for you but you can create a binding to all the columns you have in you bean, and then call the method A2012.setSelected(true), and then add a partial target to the table to re render it and show the selected column.
Hope this helps -
Grant select privilege to specific columns on a table to user in Oracle 9i
Can anyone tell me how to grant select privilege to a user for specific columns in a table?
I have tried the following statement
GRANT SELECT (EMP_ID) ON EMP TO USER1
But it's not working and I am getting this error "Missing ON Keyword".
Please anyone tell me how to grant select privilege for specific columns.
Edited by: 899045 on Nov 24, 2011 7:03 AM899045 wrote:
Can anyone tell me how to grant select privilege to a user for specific columns in a table?
I have tried the following statement
GRANT SELECT (EMP_ID) ON EMP TO USER1
But it's not working and I am getting this error "Missing ON Keyword".
Please anyone tell me how to grant select privilege for specific columns.
Edited by: 899045 on Nov 24, 2011 7:03 AMFrom the 9.2 SQL Reference manual, found at tahiti.oracle.com (http://docs.oracle.com/cd/B10501_01/server.920/a96540/statements_912a.htm#2062456)
*"You can specify columns only when granting the INSERT, REFERENCES, or UPDATE privilege. "* -
I want to select specific columns from a table dynamically which are basically the columns returned by quering the user_tab_columns data dictionary which in turn has to satisfy certain condition for me.
So, what I want to do is something like:
SELECT b.(dynamic column list from a)
FROM b,
(SELECT column_name FROM user_tab_columns WHERE table_name='STH' AND ........) a
any help will be greatly appreciated.sql>create or replace procedure p_dynamic_sql
2 is
3 v_sql varchar2(4000);
4 begin
5 v_sql := 'select ';
6 for r in (select column_name
7 from user_tab_cols
8 where table_name = 'EMP'
9 and column_name like 'E%') loop
10 v_sql := v_sql || r.column_name || ',';
11 end loop;
12 v_sql := rtrim(v_sql, ',') || ' from emp';
13 dbms_output.put_line( v_sql );
14 -- do something with SQL (open cursor, etc.)
15 end;
16 /
Procedure created.
sql>exec p_dynamic_sql
select EMPNO,ENAME from emp
PL/SQL procedure successfully completed. -
Invalid exists/not exists condition: ORA-00928: missing SELECT keyword
I am getting errors when I edit the source region and add the sql I want to run in the report. If I run the following query in sqlplus with the schema owner substituted for OWNER it works fine.
SELECT TK_IN_TIME
from "#OWNER#"."TIME_KEEPING_T"
I also run the following code in sqlplus and it works perfect, but from the source region I get a divide by 0 error.
select dt,to_char(trunc(mod((elaps)*24,24)),'fm00')||':'||
to_char(trunc(mod((elaps)*24*60,60)),'fm00')||':'||
to_char(trunc(mod((elaps)*24*60*60,60)),'fm00') ELAPSED
from
select trunc (tk_in_time) dt, sum(tk_out_time-tk_in_time) elaps
from time_keeping_t
group by trunc(tk_in_time)
order by dt
What is so different between the source region and sqlplus. I need to have this query run in my report and unfortunately, it doesn't seem possible. I'm about to give up on APEX and try something different.I couldn't paste a screenshot, so I cut and paste. If there is somewhere I could put the screenshot let me know. There is IDENTIFICATION, USER INTERFACE, and SOURCE. I'm putting the sql into the SOURCE region. I've gotten so many errors, that I have it just limited to a simple select of two fields, and I apply changes and then RUN, and get the 00928 error.
Region Definition Report Attributes Print Attributes
Region: 2 of 2 Name: Report on TIME_KEEPING_T
Show All Identification User Interface Source Conditions Cache Header and Footer Authorization Customization Configuration Comments
Identification
Page: 3 Report on TIME_KEEPING_T
Title exclude title from translation
Type SQL Query SQL Query (PL/SQL function body returning SQL query)
Static ID
Region Attributes
User Interface
Template No Template Borderless Region Bracketed Region Breadcrumb Region Button Region with Title Button Region without Title Chart Region Form Region Hide and Show Region List Region with Icon (Chart) Navigation Region Navigation Region, Alternative 1 Region without Buttons and Title Region without Title Report Filter - Single Row Report List Reports Region Reports Region 100% Width Reports Region, Alternative 1 Sidebar Region Sidebar Region, Alternative 1 Wizard Region Wizard Region with Icon Sequence
Display Point After Header Page Template Body (1. items below region content) Page Template Body (2. items below region content) Page Template Body (3. items above region content) Before Footer Page Template Region Position 1 Page Template Region Position 2 Page Template Region Position 3 Page Template Region Position 4 Page Template Region Position 5 Page Template Region Position 6 Page Template Region Position 7 Page Template Region Position 8 Column 1 2 3 4 5 6 7 8 9
[Body][Pos.1][Pos.2][Pos.3][Pos.4]
Region HTML table cell attributes
Source
Region Source
SELECT TK_IN_TIME,
TK_OUT_TIME
from "DAPDEV"."TIME_KEEPING_T"
Use Query-Specific Column Names and Validate Query
Use Generic Column Names (parse query at runtime only)
Maximum number of generic report columns: -
Using VPD/FGA to null specific columns for all but some users
I've been reading up on VPD and - though there a numerous examples - I'm having a tough time putting them together.
I have a table that - when most users select against - they should be getting NULL back in a specific column.
That column should only display for a select group of users as a value of other than null.
Can anyone help me out with an example of implementing this?
Any/all help is appreciated.An extract from http://www.oracle-base.com/articles/10g/DatabaseSecurityEnhancements10g.php
CONN sys/password@db10g AS SYSDBA
GRANT EXECUTE ON dbms_rls TO scott;
CONN scott/tiger@db10g
-- Create the policy function to restrict access to SAL and COMM columns
-- if the employee is not part of the department 20.
CREATE OR REPLACE FUNCTION pf_job (oowner IN VARCHAR2, ojname IN VARCHAR2)
RETURN VARCHAR2 AS
con VARCHAR2 (200);
BEGIN
con := 'deptno = 20';
RETURN (con);
END pf_job;
-- Using the same policy function as before.
BEGIN
DBMS_RLS.ADD_POLICY (object_schema => 'scott',
object_name => 'emp',
policy_name => 'sp_job',
function_schema => 'scott',
policy_function => 'pf_job',
sec_relevant_cols => 'sal,comm',
sec_relevant_cols_opt => DBMS_RLS.ALL_ROWS);
END;
-- All rows are returned but the SAL and COMM values are only
-- shown for employees in department 20.
SELECT empno, ename, job, sal, comm FROM emp;
EMPNO ENAME JOB SAL COMM
7369 SMITH CLERK 10000
7499 ALLEN SALESMAN
7521 WARD SALESMAN
7566 JONES MANAGER 2975
7654 MARTIN SALESMAN
7698 BLAKE MANAGER
7782 CLARK MANAGER
7788 SCOTT ANALYST 3000
7839 KING PRESIDENT
7844 TURNER SALESMAN
7876 ADAMS CLERK 1100
EMPNO ENAME JOB SAL COMM
7900 JAMES CLERK
7902 FORD ANALYST 3000
7934 MILLER CLERK
14 rows selected.
-- Remove the policy function from the table.
BEGIN
DBMS_RLS.DROP_POLICY (object_schema => 'scott',
object_name => 'emp',
policy_name => 'sp_job');
END;
/The function returns "deptno=20" so any row matching this condition will display the sal and comm value , rest will display null.
IN your case I guess you check for the user in the function who is executing the query (select user from dual), once you get the user see if this is a user who is suppose to see the columns values if yes return "1=1" otherwise return "0=1". -
Question about a conditional join
Is it possible to do a conditional join based on a field in a table?
say I have the query below and the table fields ate the bottom. I am trying to get the exact syntax for doing a conditional join. Can any one help?
Thanks
select e.fname,e.lname,a.areaname
FROM employee e
JOIN area a ON (If e.newareaid is not null and date being searched for >= e.movedate then a.areaid = e.newareaid ELSE a.areaid = e.areaid
======================================================
For example
Employee table
empid
areaid
fname
lname
newareaid
movedate
Area table
areaid
areanameHi,
In this particular case, the complicated join condition can be simplified considerably.
There are 2 situations that have different join conditions, but in each situation a.areaid has to match something (let's call it join_id) from the employee table, and that can be determined just by looking at the row in the employee table. If we decide what join_id is before starting the join, then the join condition will be quite simple:
WITH got_join_id
SELECT fname, lname, areaid, newareaid
, CASE
WHEN newareaid IS NOT NULL
AND date_being_searched_for >= movedate
THEN newareaid
ELSE areaid
END AS join_id
FROM employee
SELECT e.fname, e.lname, a.areaname
FROM got_join_id e
JOIN area a ON a.areaid = e.join_id
;You could also skip the sub-query, and put the CASE expression in the join condition:
SELECT e.fname, e.lname, a.areaname
FROM got_join_id e
JOIN area a ON a.areaid = CASE
WHEN newareaid IS NOT NULL
AND date_being_searched_for >= movedate
THEN newareaid
ELSE areaid
END
;This is basically what Hoek did, except Hoek complicated it by putting the comparison to a.areaid inside the CASE expression.
Edited by: Frank Kulash on Apr 15, 2013 3:22 PM -
How to generate a report for all Analyses which conatins a specific column
Hello Experts
I am trying to generate a report of all Analyses which contains a specific column. We are currently using OBIEE 11.1.1.7.0.
I have tried to use the command line options using ./runcat.sh, but did not find any arguments that can filter the analyses by a specific column used.
Any help is much appreciated.
Regards
RakeshHi Rakesh,
SampleApp has your answer: everything is available for free, just copy/paste and run on your own instance.
http://slc02ojw.oracle.com:7780/analytics/saw.dll?Dashboard&PortalPath=%2Fshared%2F10.%20Lifecycle%20and%20Admin%2F_port…
(as long as this instance will be up...)
In the dashboard named "10.31 Webcat Analysis" you have a columns to analysis report where you select the presentation column and you get all the reports using it.
This dashboard require a script to be run on your catalog, it will parse it and extract all the column info (and many other interesting things) and load it in a database. The scripts are simple and well documented, so you can easily adapt them to your own environment.
If you want the script there is no miracle solution: download SampleApp and extract it (it's not small, but with all the great content it has we can't complain about that ...). -
Analysis report with totals on specific columns
I have an analysis report that I need to create totals on specific columns. If I turn on "Grand Totals" from the "Edit View: Table" section, all of the numeric columns will display grand totals. This is a nice automatic feature, but I only need totals of specific columns. Not all numeric columns need totals nor do Grand Totals of some columns make any sense.
For example, to display opportunity details, we will have on the report:
Opportunity Name, Item number, Item Description, Quantity, Price, Extended Price
Since the opportunity may have multiple items on it, having a grand total of quantity and unit price makes no sense. All we need is Grand Total of the opportunity extended price.
Is there a way to selectively turn on/off column totals or is it an all or nothing option?
Thanks in advance.
Edited by: nsidev on Sep 1, 2009 10:10 AMActually, i just solved the problem.
Here is what I did:
1. I added a column to the "Design Criteria" section (step 1). To keep the units consistant, I made sure that the data element was suitable for the value (I used a currency element). Ensure you note the position of the new column, mine was in position 11.
2. Under the newly added elements "Column Properties", I set it to HIDDEN and changed the name to "Grand Total"
3. Under the "Edit Formula", I changed the formula to be: SUM(<numeric column>)
4. In "Create Layout" (Step 2), I added a narrative view to the bottom of the page.
5. In the "Edit Narrative View", I set the appropriate formatting and added the following: Total Extended Price: @11
6. Ensure that "Rows to display" is set to 1.
Save and run
All done, works like a charm. -
How to create a condition based on a select that retrieve dynamically a LOV
Hi all, I need to create a condition based on a select that retrieve dynamically a LOV.
So, the condition have to be:
inventory_item_id NOT IN (SELECT inventory_item_id FROM apps.mtl_system_items_kfv WHERE concatenated_segments = 'GENERAL_FAULTS_IPTV')
I need to create a LOV based on this select without making any join with the folder which contains the field inventory_item_id, because otherwise I have the contradiction:
and o124757.INVENTORY_ITEM_ID = o118741.INVENTORY_ITEM_ID -- join between the main custom folder (o118741) and the LOV custom folder (o124757)
and o118741.INVENTORY_ITEM_ID NOT IN (o124757.INVENTORY_ITEM_ID) -- condition
These two condition together don't show any data, obviously....This means also, that I can't use a calculated field, because if I want to see this field, I have to create a join, another time, with the main custom folder.
I tried to create a LOV on the Administrator, but when I create the condition I have to check manually the values....and if in the future this LOV will increase I need every time to re-check all the values.....instead I need that the inventory_item_id have to be NOT IN dinamically in the list of values retrieved by the select.
Anybody has inplemented something similar ??
Thanks in advance
AlexHi alex,
SELECT incidents.INVENTORY_ITEM_ID,
pcodes.PROBLEM_NAME
FROM apps.cs_incidents_all_b incidents,apps.jtf_rs_problem_codes_v pcodes
WHERE incidents.category_id IN (SELECT category_id
FROM mtl_categories_kfv
WHERE concatenated_segments = 'IPTV')
AND incidents.PROBLEM_CODE = pcodes.PROBLEM_CODE
where incidents.INVENTORY_ITEM_ID NOT IN SELECT inventory_item_id
FROM apps.mtl_system_items_kfv
WHERE concatenated_segments = 'GENERAL_FAULTS_IPTV'
You want to add this condition to the first query it holds good for this scenerio.All the items which are NOT IN will be retrieved.Here you are selecting other than "General_faults_iptv"
But again your trying to select in the second query where you want "General_faults_iptv"
SELECT inventory_item_id
FROM apps.mtl_system_items_kfv
WHERE concatenated_segments = 'GENERAL_FAULTS_IPTV'
If you carefully go through what your doing,you will understand.In the above explantion ,there will be no records generated.First query your saying NOT IN and again your saying for the same IN,how will records retrieve its meaningless.
I dont know what you want to get from second query.I would suggest you to do is dont use the second query and just use the first query and you will get.Here is the query and this will give you result.
SELECT incidents.INVENTORY_ITEM_ID,
pcodes.PROBLEM_NAME
FROM apps.cs_incidents_all_b incidents,apps.jtf_rs_problem_codes_v pcodes
WHERE incidents.category_id IN (SELECT category_id
FROM mtl_categories_kfv
WHERE concatenated_segments = 'IPTV')
AND incidents.PROBLEM_CODE = pcodes.PROBLEM_CODE
AND incidents.INVENTORY_ITEM_ID NOT IN SELECT inventory_item_id
FROM apps.mtl_system_items_kfv
WHERE concatenated_segments = 'GENERAL_FAULTS_IPTV'
Regards,
Kranthi. -
Column definition for a specific column in a view
Is there a way to query the metadata to get the definition of a single column in a view? I can see the complete DDL for a view from USER_VIEWS.TEXT, and I can see the column listing in USER_TAB_COLUMNS to give the datatype etc. However, what I'm looking for is the DDL that defined a specific column.
So, given:
create table PERSON (
SSN VARCHAR2(12),
FIRST_NAME VARCHAR2(25),
LAST_NAME VARCHAR2(25),
STREET VARCHAR2(40),
CITY VARCHAR2(30),
STATE VARCHAR2(30),
ZIP VARCHAR2(15),
COUNTRY VARCHAR2(35))
create view PERSON_VW as
select SSN,
FIRST_NAME,
LAST_NAME,
FIRST_NAME || ' ' || LAST_NAME FULL_NAME
from PERSON
I expect the query might look something like:
select DDL from metadata where table_name = 'PERSON_VW' and column_name = 'FULL_NAME'
and the result would be: "PERSON.FIRST_NAME || ' ' || PERSON.LAST_NAME"
or select DDL from metadata where table_name = 'PERSON_VW' and column_name = 'FIRST_NAME'
and the result would be: "PERSON.FIRST_NAME"
Thanks!>
Hi again Barry,
When I queried user_tab_columns (or dba_tab_columns or all_tab_columns), I have the following list of columns:
TABLE_NAME
COLUMN_NAME
DATA_TYPE
DATA_LENGTH
DATA_PRECISION
DATA_SCALE
NULLABLE
COLUMN_ID
DEFAULT_LENGTH
DATA_DEFAULT
I don't see anything resembling the DDL for the view column. Somewhere underneath some
cover I haven't peeked under, Oracle must be keeping track of what it is supposed to be giving
for, in my example, FULL_NAME.Unless I'm very much mistaken, these columns' data (per table) looks pretty much like DDL to me.
Maybe what you need is just SQL Developer (great tool, if you don't have it, get it!).
And it's free (as in beer - not as in speech! :( )
Beside the connections tab is a "Reports" tab with various, as you might expect ;), reports.
One of them is on the Tables - with (some) DDL. This will work as a once-off if that's what
you need?
Otherwise there's the SQL tab if you open a table under connections - it's very complete - sample
at bottom of post.
HTH,
Paul...
(Ultimately, I'm diagnosing problems in existing databases that have views already created so
I don't have the option of considering virtual columns.)Quelle surprise ;(
Paul...
-Barry
CREATE TABLE "HR"."COUNTRIES"
"COUNTRY_ID" CHAR(2 BYTE) CONSTRAINT "COUNTRY_ID_NN" NOT NULL ENABLE,
"COUNTRY_NAME" VARCHAR2(40 BYTE),
"REGION_ID" NUMBER,
CONSTRAINT "COUNTRY_C_ID_PK" PRIMARY KEY ("COUNTRY_ID") ENABLE,
CONSTRAINT "COUNTR_REG_FK" FOREIGN KEY ("REGION_ID") REFERENCES "HR"."REGIONS" ("REGION_ID") ENABLE
ORGANIZATION INDEX NOCOMPRESS PCTFREE 10 INITRANS 2 MAXTRANS 255 LOGGING STORAGE
INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645 PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT
TABLESPACE "USERS" PCTTHRESHOLD 50;
COMMENT ON COLUMN "HR"."COUNTRIES"."COUNTRY_ID"
IS
'Primary key of countries table.';
COMMENT ON COLUMN "HR"."COUNTRIES"."COUNTRY_NAME"
IS
'Country name';
COMMENT ON COLUMN "HR"."COUNTRIES"."REGION_ID"
IS
'Region ID for the country. Foreign key to region_id column in the departments table.';
COMMENT ON TABLE "HR"."COUNTRIES"
IS
'country table. Contains 25 rows. References with locations table.'; -
Get OLD&NEW value of an UPDATED column selected dynamically in a Trigger
Hi All,
I am writting a trigger which take column name dynamically. And on the basis of that column it should give me old value as well as updated value of a column corresponding to a modified row.
OOO_SCHEDULE is my table name;
Note: This is only for test so I am writting only for update not for insert and delete.
create or replace trigger "OOO_SCHEDULE_AUDIT"
BEFORE
insert or update or delete on "OOO_SCHEDULE"
for each row
begin
DECLARE
v_username varchar2(30);
AUDIT_EMP_ID varchar2(30);
AUDIT_EMP_ID_NEW varchar2(30);
v_Column_name VARCHAR(30);
v_stmt1 VARCHAR(40);
v_stmt2 VARCHAR(40);
CURSOR C1 is
select COLUMN_NAME from user_tab_columns where table_name='OOO_SCHEDULE';
BEGIN
OPEN c1;
LOOP
FETCH c1 into v_Column_name;
EXIT WHEN c1%NOTFOUND;
v_stmt1:=('OLD.'||v_Column_name);
v_stmt2:=('NEW.'||v_Column_name);
AUDIT_EMP_ID:=v_stmt1;
AUDIT_EMP_ID_NEW:=v_stmt2;
INSERT INTO TEMPTEST VALUES(v_stmt1);
INSERT INTO TEMPTEST VALUES(AUDIT_EMP_ID);
END LOOP;
CLOSE c1;
END;
end;
Suppose OOO_EMP_NAME is the column name where user made the change.
If i do like this..
AUDIT_EMP_ID:=OLD.OOO_EMP_NAME;
AUDIT_EMP_ID_NEW:=NEW.OOO_EMP_NAME;
Then it is working fine because I have given column name statically. But I want the column name to be selected dynamically and I am able to do it through cursor. Also I am able to fetch all column names in v_Column_name variable one by one dyanamically for the cursor.
But by executing these statements
AUDIT_EMP_ID:=v_stmt1;
AUDIT_EMP_ID_NEW:=v_stmt2;
I am getting OLD.OOO_EMP_NAME and NEW.OOO_EMP_NAME rather then old and new values of the updated column.
Please help me identifying the problem, where I am doing the mistake? What is the correct way to execute these statements? So that I can get old and new values of the column (updated column).
I have tried it by passing in a procedure also but don't know how to execute this dynamic statement to get the old and new values.
Thanks,
Ishrat.In the given link, column name has been selected statically. But i want that column name should be selected daynamically throgh loop and then check the
condition for any update corresponding to that column value. I don't want to write as many if condition as the no. of column name. I just want one if condition for all column namesDon't be lazy. Write all column names into your trigger. Or use a way to create the trigger "dynamically".
What is the problem that you have with static column names? "I don't want to write many..." is not a problem, but an opinion. -
Hi world,
I've encountered rather weird behavior with Numbers 2.0.3 (iWork '09, update 3 or whatever they've called it). When using the AVERAGEIFS() function, when I select a range of dates to use as a conditional, the range also selects the header cell. All the rest of my ranges (of text and numbers) do not include the header cell. Is this by some kind of design (that I'm not getting) or have I discovered a bug?
Here is a file that demonstrates this:
http://files.me.com/link.dupont/6wx2xe.numbers.zipHello
Most of the time, it's useful to write formulas matching the application's required syntax which is:
AVERAGEIFS(avg-values, *test-values, condition*, test-values…, condition… )
In your formula you wrote:
avg-values: Data::B +is a range (the column A in table Data)+
I don't know how you may hope to get an average of city names !
test-values: A2 +is a single cell+
condition: MONTHNAME(MONTH(Data::A)) +this is not a condition and the fonctions can't apply to a range+
test-values: B1 +is a cell (must be a range)+
condition: Data::C +is a range (the column C in table Data but it's not a condition)+
Here:
in Data column D the formula is:
=MONTHNAME(MONTH(A))
in Table 2 :: B2 the formula is:
=AVERAGEIFS(Data::C,Data::D,"="&B$1,Data::B,"="&$A)
Yvan KOENIG (VALLAURIS, France) mardi 6 octobre 2009 09:59:51 -
How to use update trigger in sql server 2008 with specific column
Hello friends currently my trigger updates on table update, and I need to change this to only fire when specific column changes.
/****** Object: Table [dbo].[User_Detail] ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[User_Detail](
[sno] [int] IDENTITY(1,1) NOT NULL,
[userid] [nvarchar](50) NULL,
[name] [nvarchar](max) NULL,
[jointype] [nvarchar](50) NULL,
[joinside] [nvarchar](50) NULL,
[lleg] [nvarchar](50) NULL,
[rleg] [nvarchar](50) NULL,
[ljoining] [int] NULL,
[rjoining] [int] NULL,
[pair] [int] NULL
) ON [PRIMARY]
GO
/****** Object: Table [dbo].[User_Detail] table data ******/
SET IDENTITY_INSERT [dbo].[User_Detail] ON
INSERT [dbo].[User_Detail] values (1, N'LDS', N'LDS Rajput', N'free', N'Left', N'jyoti123', N'SUNIL', 6, 4, 4)
INSERT [dbo].[User_Detail] VALUES (2, N'jyoti123', N'jyoti rajput', N'free', N'Left', N'mhesh123', N'priya123', 3, 2, 2)
SET IDENTITY_INSERT [dbo].[User_Detail] OFF
/****** Object: Table [dbo].[User_Detail] trigger ******/
CREATE TRIGGER triggAfterUpdate ON User_Detail
FOR UPDATE
AS
declare @userid nvarchar(50);
declare @pair varchar(100);
select @userid=i.userid from inserted i;
select @pair=i.pair from inserted i;
SET NOCOUNT ON
if update(pair)
begin
insert into Complete_Pairs(userid,pair)
values(@userid,1);
end
GO
/****** Object: Table [dbo].[Complete_Pairs] Script Date: 05/22/2014 21:20:35 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[Complete_Pairs](
[Sno] [int] IDENTITY(1,1) NOT NULL,
[userid] [nvarchar](50) NULL,
[pair] [int] NULL
) ON [PRIMARY]
GO
my query is TRIGGER triggAfterUpdate is fired only when pair column in User_Details table is update only and when we update other column like ljoin or rjoin then my trigger is not fired
please any one can suggest us how it can done or provide solution
Jitendra Kumar Sr. Software Developer at Ruvixo Technologies 7895253402>select @userid=i.userid
frominserted i;
select
@pair=i.pair
frominserted i;
The code above assumes a single row UPDATE.
You have to setup the trigger for set processing like when 100 rows are updated in a single statement.
UPDATE trigger example: http://www.sqlusa.com/bestpractices2005/timestamptrigger/
Kalman Toth Database & OLAP Architect
SQL Server 2014 Design & Programming
New Book / Kindle: Exam 70-461 Bootcamp: Querying Microsoft SQL Server 2012 -
Can we make apply join a column on which VPD policy applied in Oracle 10g
Hi,
i am planning to apply a column level security using VPD concept into Oracle 10g
but i have a one doubt.
Suppose i am going to apply a VPD policy based on user priviliges on a column DEPTNO in EMP table so whenever a particular user logs in,he will not see the deptno.But he can fetch the data from other table DEPT based on join condition EMP.DEPTNO=DEPT.DEPTNO . Is it possible can we make a join a column on which VPD polciy is applied ?
pls any idea or thought would be appreciable..
Thanks in advance
AnwarHi Anwar!
I have not tried yet, but I believe that you can do this.
However imagine the following:
A user U1 has the right to see some values in the deptno column, but not all. This is fine, and I believe that this is what you want to achieve.
A user U2 will see no records from the deptno column. This will impact your query, as your emp.deptno = dept.deptno part of the where clause will deliever no records.
So you have to be careful if this condition could apply and what the impact will be on your software.
cu
Andreas
Maybe you are looking for
-
How to use a work manager dedicated for an URI
Hello, I have a servlet able to manage different use cases, based on differents URI (the servlet is mapped on /*, and depending of the URI and the configuration, I do different work) I would like to set a workmanager on each of my use cases. Is it po
-
Import and Export sections of material present in the Timeline
Hi, I know it is possible with Premiere EL 11 to import and export titles. I have an existing movie and am working on a new one. I wish to utilize part of what I created on the previous movie. Is it possible to copy part of the old movie and paste it
-
Just show 1 in 2 in at same time. I need help???
foreach (var node in senseblock1_1) var extraexample = node.Descendants("div").FirstOrDefault(x => x.GetAttributeValue("class", "") == "extraexamps"); if (extraexample != null) Dictionaries.MoreExample = extraexample.InnerText.Trim(); var phrase_bloc
-
Laptop won't start quickly but power wifi and caps lock light keeps blinking
Hi, it has happened before too but rarely but nowadays it happens on daily purposes. When I switch on my laptop after leaving it for 8-9 hrs, it won't start up but instead power, wifi and caps lock light keep blinking. I tried removing battery and pr
-
Hello, I have exported my 63 slide presentation to Quicktime. There is no audio in the original presentation, so I don't have to deal with that issue. I have exported the presentation to play back manually - i.e. a new transition when I click on the