Separate records, based on the condition of a table
Hello PL/SQL gurus and experts.I use Oracle Database 11 g Enterprise Edition Release 11.2.0.1.0 - 64-bit Production version
I have table-
Note - Table do not have a primary key on Order_ID.
DROP TABLE T;
create table T(Order_ID,Active_Flg) as select
'201002', 'Y' from dual union all select
'201002', '' from DUAL union all select
'201003', '' from dual union all select
'201004', 'Y' from DUAL union all select
'201004', '' from dual union all select
'201005', '' from DUAL ;
I want to go get these Order_ID who have Active Flg as NULL and do not have the entry for Active_Flg = YIf use the following, then it returns the distinct Order_ID but not the expected-
SELECT DISTINCT ORDER_ID FROM T WHERE ACTIVE_FLG IS NULL;
Result-ORDER_ID
------
201004
201002
201003
201005
Kindly help...
This?
select order_id
from (
select order_id
, active_flg
, count(decode(active_flg, 'Y',1)) over(partition by order_id) cnt1
, count(decode(active_flg, null,1)) over(partition by order_id) cnt2
from t
)
where cnt1 = 0 and cnt2 > 0;
Tags: Database
Similar Questions
-
Restrict the records based on the condition
Select * from EMP where deptno = 10;
O/P:
7782 CLARK MANAGER 7839 JUNE 9, 81 2450 10 7839 KING PRESIDENT NOVEMBER 17, 81 5000 10 7934 MILLER CLERK 7782 JANUARY 23, 82 1300 10 But I need 1 sheet with as described in condition.
If JOB = 'MANAGER' pick this record
If is not available, then choose JOB = 'PRESIDENT' record
If is not available, then choose JOB = ' ' record
A way
Select * from)
Select
EmpNo
ename
work
Manager
hire_date
salary
deptno
, rank() over (stopped in case of job when = "MANAGER", 1).
When job = 'PRESIDENT' then 2
When job = 'CLERK' then 3
4 something else
end
) rnk
from EMP
where deptno = 10
)
where rnk = 1
If there is more than a Manager for example, the result would be more than one line.
If you don't want that one line in these cases use row_number instead of rank.
In this case, you want to refine the order by clause probably.
-
Can I get the total number of records that meet the conditions of a query using the Table API?
Hello
A < row > TableIterator is returned when I ask operations using the index of tables. If I want to get the total number of records, I count one by one using the returned TableIterator < row >.
Can I get the total number of records directly meets the conditions of the query?
I can get the total number of records directly the request of the meeting of the conditions of CLI using the command Global table - name tableName - count - index index-name-field fieldName - start startValue-end endValue.
Can I get the same results using the Table API?
I used MongoDB and NoSQL Oracle for about a year. According to the experience of the use of these dbs, I think mongoDB querying interface is powerful. In the contras, the query interface is relatively simple, which results is a lot of work that is usually a long time in the client side.
Hello
Counting records in a database is a tricky thing. Any system that gives you an accurate count of the records will have a hotspot of concurrency on updates, namely the place where the counting is maintained. Such a count is a problem of performance in addition to competitive access problem. The problem is even more difficult in a system widely distributed such a NoSQL database.
The CLI has overall command that counts, but does so by brutal force - iterate keys that correspond to the parameters of the operation. This is how you must do this within the API. There is not a lot of code, but you have to write. You certainly want to use TableIterator
TableAPI.tableKeysIterator (), because a key iteration is significantly faster than the iteration of lines. Just one iteration and count. If you use TableAPI.multiGet () and a key with a touch of brightness full then, in fact, count the results as they are returned in a single piece (a list).
Kind regards
George
-
Merge the queries based on the conditional
Apex 4.2
I have a pretty complex question. I have a page that will have a selection list on the data entry form. The selection list contains a list of both 1) Active only or 2) active and inactive areas. We show the active areas when we create a new record (P101_ID IS NULL), we appear active and inactive sectors when you edit a record (P101_ID IS NOT NULL). I have therefore two separate queries to account for each case. Simple so far.
Problem I am seeing that create two lists of selection on the page and put a separate condition on each one (hiding one of selection lists depending on the case the ID IS NULL or the ID IS NOT NULL) does not work. So I was wondering if there was a way to combine queries for that to work based on a conditional statement. I did experiment with the instructions box and unions, etc., but my questions are a bit complicated. They are as follows:
LIST OF ASSETS SECTORS (P101_ID is NULL)
Select unique ISEC.inspection_sector_name, ISEC.inspection_sector_id From INSPECTION_SECTORS ISEC left join HWE_INSPECTION_SCHEDULING SCH on ISEC.inspection_sector_id = SCH.inspection_sector_id Where (ISEC.hurricane_protection_flag = :P157_IS_HURR and ISEC.river_protection_flag = :P157_IS_RIV) AND ISEC.superseded_date is null AND ISEC.commenced_date is not null AND ISEC.inspection_sector_id not in ( Select ISEC.inspection_sectors_id From INSPECTION_SECTORS ISEC left join HWE_INSPECTION_SCHEDULING SCH on ISEC.inspection_sector_id = SCH.inspection_sector_id Where SCH.high_water_event_id = :P157_high_water_event_id AND SCH.inspection_date = :P157_inspection_date) OR ISEC.inspection_sector_id = :P157_inspection_sector_id AND ISEC.superseded_date is null Order by inspection_sector_name
LIST ACTIVE AND INACTIVE SECTORS (P101_IS is NOT NULL)
Select inspection_sector_name, inspection_sector_id From ( Select ISEC.inspection_sector_name, ISEC.inspection_sector_id, '0' as this From dual, INSPECTION_SECTORS ISEC left join HWE_INSPECTION_SCHEDULING SCH on ISEC.inspection_sector_id = SCH.inspection_sector_id Where (ISEC.hurricane_protection_flag = :p157_IS_HURR and ISEC.river_protection_flag = :P157_IS_RIV) AND ISEC.superseded_date is null AND ISEC.commenced_date is not null AND ISEC.inspection_sector_id not in ( Select ISEC.inspection_sector_id From inspection_sectors ISEC left join HWE_INSPECTION_SCHEDULING SCH on ISEC.inspection_sector_id = SCH.inspection_sector_id Where SCH.high_water_event_id = :P157_high_water_event_id AND SCH.inspection_date = :P157_inspection_date) OR ISEC.inspection_sector_id = :P157_inspection_sector_id AND ISEC.superseded_date is null UNION Select unique ISEC.inspection_sector_name|| ' [CLOSED]', ISEC.inspection_sector_id, '1' as this From dual, INSPECTION_SECTORS ISEC left join HWE_INSPECTION_SCHEDULING SCH on ISEC.inspection_sector_id = SCH.inspection_sector_id Where ISEC.superseded_date is not null and ISEC.commenced_date is not null AND ISEC.river_protection_flag =:P157_IS_RIV and ISEC.hurricane_protection_flag = :P157_IS_HURR AND ISEC.inspection_sector_id not in ( Select ISEC.inspection_sector_id From INSPECTION SECTORS ISEC left join HWE_INSPECTION_SCHEDULING SCH on ISEC.inspection_sector_id = SCH.inspection_sector_id Where SCH.high_water_event_id = :P157_high_water_event_id AND SCH.inspection_date = :P157_inspection_date) OR ISEC.inspection_sector_id = :P157_inspection_sector_id NAD ISEC.superseded_date is not null Order by this, inspection_sector_name asc
If the requests are quite complex. I tested the times and they work in APex, separately from the course. Forgive me if I have mispeled anything. But any help on this would be greatly appreciated. Thanks in advance.
Thank you for taking to your friend Frank. You are a bird-guy (my attempt at sarcasm). Nobody has questioned whether its knowledge base; more so in the way he responded to my original post did not «do» Like the people who come on this forum looking for help to those who have greater knowledge, it would be nice to be greeted a little more friendly, lol. Just my thoughts. But, feel free to correct my spelling test, grammar and syntax in my sentences so (the effort once again to emphasize that I misspelled 'AND', and that the request would not be performed--> of course... smh... you are funny)
Apparently I failed to explain the issue in its entirety. I should start by saying... "I have two separate petitions that I tested and already working and am looking to put on a list of selection (at the top) with a conditional execution statement one or the other, through the conditional statement, but again, I was looking for more so for syntax and structure." I'm sorry, I forgot to mention that.
Anyway, enough of this. I found a solution to my problem:
Within the Apex 4.2, you can have a list of selection as a page element. I want to display different results depending on whether Yes or no P101_ID is set to Null or NOT NULL
P101_ID is a primary key for a table.
P101_ID is not the exact name I use in my application / request however.
In addition, you don't need to include double; It's not make or break the query. Something that I forgot to omit them.
In addition, something along the lines of
Select inspection_sector_name, inspection_sector_id From ( .....all the stuff in query 1.......) Where P101_ID is null UNION Select inspection_sector_name, inspection_sector_id From ( ....all the stuff in query 2.....) Where P101_ID is not null
will work on a selection list in the APex. So problem solved. Thank you for all your wonderful insight, of words and thoughts. Thank you.
-
Enable and disable the item based on the Condition
Hi Experts,
I work in the form of 10g, I conditionally.
I have the block master detail.
Master block contains sub elements.
CUSTOMER
Address (read only) - no database element
PRODUCT GROUP (read only) - no database article
Note: The CUSTOMER is LOV, when I select the customers, I'm failing address and product group.
Block detail contains sub elements.
DATE OF START OF BLOCK
DATE OF END OF BLOCK
REASON
Note: when I opened form all fields of retail blocks are enabled
Requirement:
1. when I created new record, at the time where I select the customer name, Bill and product group will be by default, in the block of detail - I want to activate and deactivate the block start date based on the value of the product group.
2 if I erase block master, I need to activate the block_start_date like back when the new form is opened
3. when I search the data also, block start date must be enabled and disabled based on the value of the product group.
Could someone help me the best approach to achieve so that she will have no side effects.
Thank you
801619 wrote:
Hello
Thank you for your response... I have tried code trigger after change of category of products below.
If: blockname.product_group = "Aviation" then
set_item_property ('block.block_start_date', enabled, property_false);
On the other
set_item_property ('block.block_start_date', enabled, property_true);
end if;
1. it is disable the Group field when I put the cursor inside if the product category is "Aviation", but I want it to be automatic at a time where it will default to the value of product category.
2. If the master clear record, is not allowing return product group
3 suppose that if enter new record category of products "Aviation", once I put the cursor inside, it's debilitating, let's say if I erase the main recording without saving the changes, it not again allows the Group of products, it is now status (disable) previous.
4. in query mode, it is not disabling or enabling from a group of products.
Help, please.
Thank you
Ok.
1. put your code on this trigger after changing point that fills the default value in the product category.
2. remove the trigger after change of product group.
3 put the same code to trigger once - new - Record - Instance of the main block.
Hope this helps
Hamid
-
Displaying an icon for each record, based on a condition
Hi people,
I'm developing an application that uses forms 6i with oracle 10g. I have the "Grant" and "Deny" options in my application. I have also two icons is TICK icon and next is WRONG icon.according to the corresponding status icons ("granted" or "Refused") should be displayed for me.for this i have used multi-record block composed of 10 documents. Here is my sample code.
Using this code, I am able to get the visibility of icons, but it affects the entire column. For example, if the first status of cases is "granted" then TICK icon should appear to runtime.similarly if second status of cases is "denied" then ERROR icon should be displayed for me.but for me that the TICK icon is displayed for all 10 records if the State of the first record is "granted". How do the visibled corresponding icons according to status ("Granted" or "Refused"). Kindly give me a solution.IF :STATUS.C_STATUS = 'GRANTED' THEN Set_Item_instance_Property('status.tick',VISIBLE,PROPERTY_TRUE); Set_Item_instance_Property('status.tick',DISPLAYED,PROPERTY_TRUE); Set_Item_Property('status.wrong',VISIBLE,PROPERTY_FALSE); set_item_property('status.wrong',DISPLAYED,PROPERTY_FALSE); .............
Published by: vidusnat on May 2, 2012 12:26Hello
Well, I don't think you can do it by making visible or invisible button/item. I can share an idea to create two image files a given and one for refuse. Multi record block you create an element of the image (non-database) and read the image on this element in the post (at the block level) based on the State values that you so condition...
TRIGGER = POST-QUERY (BLOCK-LEVEL) IF :STATUS.C_STATUS = 'GRANTED' THEN READ_IMAGE_FILE('image_path\access_given.JPG','JPG','BLOCK_NAME.IMAGE_ITEM_NAME'); ELSE READ_IMAGE_FILE('image_path\access_denied.JPG','JPG','BLOCK_NAME.IMAGE_ITEM_NAME'); END IF;
-Clément
-
Need to set the attribute of the current record based on the value of the next record
With the help of forms 6, I have a form that displays the list of folders. There may be multiple records with the same ID, but with different expiration dates. I need set attributes for hilite only the record with the latest expiration date. The current list points of interest reviews of future expiration dates - but we found that, sometimes, the subscription is renewed before the expiration date has been reached, causing two records with the same ID with expiry dates in the future.
I can (and do) sort the records by date of expiry and the identification for the record with the latest expiration date is always the last to this ID, so what I want to do is to check the next record to see whether or not it has a different ID. If the current record is the last expiration date, & must be hilited. Because I might want to hilite the current record, I can't simply navigate to another record, according to the description I found, what makes the next_record builtin. Anyone know how I can check for a value in the next record without making the current record?
Thank you.What I would do:
-Create a DB view based on your table and including the function call DRIVE as a separate column.
-Base that block you on this point of view
-If the block is modifiable, set the DML target for the block to your database table. -
Retention of records based on the end of the calendar year
Content using WebCenter 11 g and Records Management, I'm looking for a way to create a rule of provision based on the end of a calendar year. For example, the rule might wait two years after the end of the calendar year in which the content item has been published. Does anyone know how to do this? I'm looking for something that is easy to maintain, but right now my best option is to create a metadata field to end of calendar year and then do a little iDoc script to set point which is archived for each content. I would really like to avoid this if possible. Any ideas?
I think what you're trying to do is to "synchronize on the period start date. It is part of the definition of the trigger.
http://docs.oracle.com/cd/E21764_01/doc.1111/e10640/e01_interface.htm#RMDSG620.
Assuming that the trigger is based on the release date:
-An item is activated in June 30, 2016.
-After the date of recording, wait two years. This makes the eligible trigger on June 30, 2018.
- But you want to wait until the end of 2018 to make available.
-Check the above mentioned framework would force alienation to fire on January 1, 2019, instead of June 30, 2018.
-
Delete records based on the foreign keys of oracle 11 g
I have a requirement to remove the records from the tables in the order according to
the existing foreign keys.
I for example, the following tables and the pk, fk constraints:
create table one
(aa number (1),)
descr varchar2 (20));
ALTER table one
Add constraint a_pk key (aa) primary;
create table b
(aa number (1),)
descr varchar2 (20));
ALTER table b
Add constraint b_pk key (aa) primary;
create table c
(aa number (1),)
descr varchar2 (20));
ALTER table c
Add constraint c_pk key (aa) primary;
create table a2
(aa number (2),)
id_aa number (1).
descr varchar2 (20));
ALTER table a2
Add constraint a2_pk key (aa) primary;
ALTER table a2
Add constraint a2_fk foreign key (id_aa)
references a (aa);
create table b2
(aa number (2),)
id_aa number (1).
descr varchar2 (20));
ALTER table b2
Add constraint b2_pk key (aa) primary;
ALTER table b2
Add constraint b2_fk foreign key (id_aa)
references b (aa);
create table z
(aa number (3),)
id_aa number (1).
id_bb number (1).
descr varchar (20));
ALTER table z
Add constraint z_pk key (aa) primary;
ALTER table z
Add constraint z_fk1 foreign key (id_aa)
references a (aa);
ALTER table z
Add constraint z_fk2 foreign key (id_bb)
references b (aa);
So, I want to choose the names of the tables in such an order so as
deleting records will succeed...
I built the following sql query (using the recursive subquery factoring):
[p]
with q (r_constraint_name, table_name, constraint_name, lvl) as
(select table_name, constraint_name, r_constraint_name 1 lvl
from user_constraints one
where a.constraint_type = 'P '.
Union of all the
Select b.table_name b.constraint_name, b.r_constraint_name, q.lvl + 1 lvl
from user_constraints b
Join q
on (q.constraint_name = b.r_constraint_name)
where b.constraint_type = 'R '.
)
Select f.table_name, f.constraint_name, f.r_constraint_name, f.lvl
q f
[/ p]
I want the results as the following list:
Table-name
----------------
B2
A2
Z
A
B
C
The table - B2, A2, Z - (in any order) must first referred in the list
because they are based on the other three tables - A, B, C. Thus, in order to remove the
A, B, C table records the B2, A2, table Z records must be beleted first.
The query I posted above has the problem that it displays tables A2, B2 twice
(1 because they have a pk and 2 because they have fk referring A, B relatively tables).
Is there a solution for this problem?
Note: I use db11g v2
I wrote not all relationships of tables user_constraints (only argument constraint_name = r_constraint_name)
Thank you
SIM
I have a requirement to remove the records from the tables in the order according to
the existing foreign keys.
. . .
The table - B2, A2, Z - (in any order) must first referred in the list
because they are based on the other three tables - A, B, C. Thus, in order to remove the
A, B, C table records the B2, A2, table Z records must be beleted first.
Is there a solution for this problem?
Yes - the 'solution' is to use ON DELETE CASCADE, as appropriate or write a procedure that removes tables in the proper order.
The solution is NOT to try to use dynamic sql statements to do so.
You already know the good parent/child relationships. Simply create a procedure that uses the correct order.
Analyses are necessary in any case to determine the proper order AND press the appropriate values to use to remove the appropriate lines
Your DDL for tables and constraints must be in a version control system
Update the procedure when / if new constraints or tables are added to the application
IMHO, you must use dynamic SQL NOT to try to adjust automatically if a new constraint appears. New constraints should not appear by accident - they appear ONLY as part of a well planned release.
-
Poller DB to select records based on the timestamp
Hi all
I want select records from the coloumn timestamp where the timestamp is older than an hour. Is it possible to do this through poller db? I tried but unable to pass the dynamic value (currently - 1 hr)
Thanks in advance!
Eventually create a view based on the timestamp and singled out the dbpoller view.
-
unique several record based on the date record selection
Hi experts,
I have a table that contains multiple records for unique identification number now, I select the single record that contains the most recent date.
Here is the structure
Name of Type Null
------ ---- ------------
NUMBER OF ID_P
NAME_P VARCHAR2 (12)
DATE_P TIMESTAMP (6)
Reviews
---------------------
1 loosi 22 August 13 01.27.48.000000000 PM
1 hahahaha August 26, 13 01.28.10.000000000 PM
KK 2 22 August 13 01.28.26.000000000 PM
Emmeline 2 26 August 13 01.28.42.000000000 PM
now I have to select below 2 lines how to write select qurie for this?
1 loosi 26 August 13 01.27.48.000000000 PM
Emmeline 2 26 August 13 01.28.42.000000000 PM
Hello
You can use the ROW_NUMBER analytic function.
I don't have a copy of your table, so I'll use scott.emp to illustrate. In scott.emp, there may be several lines for a single job. To display only 1 row per job, hiredate line with the most recent:
WITH got_r_num AS
(
SELECT empno, hiredate-, deptno, job or whatever columns you want
ROW_NUMBER () taken OVER (PARTITION OF work
ORDER BY hiredate DESC
) AS r_num
FROM scott.emp
-WHERE--if you need a filter put it here
)
SELECT *- or the list of all columns except r_num
OF got_r_num
WHERE r_num = 1
;
What results do you want in the case of links? Depending on your needs, you can add expressions of tiebreaker to the analytical ORDER BY clause or the use of RANK instead of ROW_NUMBER.
I hope that answers your question.
If not, post a small example of data (CREATE TABLE and only relevant columns, INSERT statements) for all of the tables involved and the results desired from these data.
Point where the above query is to produce erroneous results, and explain, using specific examples, how you get the right results from data provided in these places.
If you change the query at all, post your modified version.
Always say what version of Oracle you are using (for example, 11.2.0.2.0).See the FAQ forum: https://forums.oracle.com/message/9362002
-
Filter records based on the selection in adf 11.6
Hello
I have page, on the top section af:table displayed and tabs (af:showdetaiItem), in the section displayed below each tab having slumped workflow as a region (each workflow with the table)
After selecting any line on table top, then should filter the corresponding records on table region taskflow I am able to get the selected value to the region through input parameters task flow.
I have question concern, how to run the workflow after the selection of each row in the table? (see communication of the region)
Please suggest good approach, as appropriate
Thank you
you are correct. by passage of parameter is an approach. Another approach is contextual event...
-
update of column with the number of sequence based on the condition
HelloVersion of DB: database Oracle 11 g Enterprise Edition Release 11.2.0.1.0 - 64 bit Production
Here's the script to reporduce:
CREATE TABLE T2
(
PARAMLOCATION NVARCHAR2 (16).
PARAMTYPE VARCHAR2 (3 BYTE),
PARAMNUM VARCHAR2 (3 BYTE)
)Insert into T2
(PARAMLOCATION)
Values
('49');
Insert into T2
(PARAMLOCATION)
Values
(« 12 ») ;
Insert into T2
(PARAMLOCATION)
Values
(« 50 ») ;
Insert into T2
(PARAMLOCATION, PARAMTYPE)
Values
('loc51', 'B');
Insert into T2
(PARAMLOCATION, PARAMTYPE)
Values
('loc52', 'B');
Insert into T2
(PARAMLOCATION, PARAMTYPE)
Values
('loc53', 'B');
Insert into T2
(PARAMLOCATION)
Values
("loc54");
Insert into T2
(PARAMLOCATION)
Values
("loc55");
Insert into T2
(PARAMLOCATION, PARAMTYPE)
Values
('aoc01', 'I');
Insert into T2
(PARAMLOCATION, PARAMTYPE)
Values
('aoc02', 'I');
Insert into T2
(PARAMLOCATION)
Values
("loc58");
Insert into T2
(PARAMLOCATION, PARAMTYPE)
Values
("doc03", "DL");
Insert into T2
(PARAMLOCATION, PARAMTYPE)
Values
("doc02", "DL");
Insert into T2
(PARAMLOCATION, PARAMTYPE)
Values
("doc01", "DL");I should update the column in table (paramnum) function sequential paramtype as this: also you can not order in paramlocation, its like that paramlocation comes first start sequence ordering from there based on paramtype.
PARAMLOCATION PARAMTYPE PARAMNUM 49 12 50 loc51 B 1 loc52 B 2 loc53 B 3 loc54 loc55 aoc01 AI 1 aoc02 AI 2 loc58 doc03 DL 1 doc02 DL 2 doc01 DL 3 Please advice.
Hello
I'll assume you have a column called load_order, which corresponds to the order of the lines:
CREATE TABLE T2
(
NUMBER OF LOAD_ORDER
PARAMLOCATION NVARCHAR2 (16).
PARAMTYPE VARCHAR2 (3 BYTE),
PARAMNUM VARCHAR2 (3 BYTE)
) ;Insert into T2
(LOAD_ORDER, PARAMLOCATION)
Values
(1, '49');
Insert into T2
(LOAD_ORDER, PARAMLOCATION)
Values
(2, '12');
Insert into T2
(LOAD_ORDER, PARAMLOCATION)
Values
(3, '50');
Insert into T2
(LOAD_ORDER, PARAMLOCATION, PARAMTYPE)
Values
(5, 'loc51', 'B');
Insert into T2
(LOAD_ORDER, PARAMLOCATION, PARAMTYPE)
Values
(8, 'loc52', 'B');
Insert into T2
(LOAD_ORDER, PARAMLOCATION, PARAMTYPE)
Values
(13, 'loc53', 'B');
Insert into T2
(LOAD_ORDER, PARAMLOCATION)
Values
(13.2, "loc54");
Insert into T2
(LOAD_ORDER, PARAMLOCATION)
Values
(13.5, 'loc55');
Insert into T2
(LOAD_ORDER, PARAMLOCATION, PARAMTYPE)
Values
(50, 'aoc01', 'I');
Insert into T2
(LOAD_ORDER, PARAMLOCATION, PARAMTYPE)
Values
(80, 'aoc02', 'I');
Insert into T2
(LOAD_ORDER, PARAMLOCATION)
Values
(81, 'loc58');
Insert into T2
(LOAD_ORDER, PARAMLOCATION, PARAMTYPE)
Values
(82, "doc03", "DL");
Insert into T2
(LOAD_ORDER, PARAMLOCATION, PARAMTYPE)
Values
(83, "doc02", "DL");
Insert into T2
(LOAD_ORDER, PARAMLOCATION, PARAMTYPE)
Values
(99, "doc01", "DL");Any data type, this column is or what are the values it contains, as long as you can derive from the order of the rows of values in the column. (Of course, the values can be consecutive integers, only they do not have to be). If you do not have this type of column, you don't have any order to your lines, and what you request is impossible.
Since you have a load_order column, here's a way to get the results you requested:
MERGE INTO dst t2
WITH THE HELP OF)
WITH got_grp AS
(
SELECT load_order
paramlocation
paramtype
ROW_NUMBER () OVER (ORDER BY load_order)
-ROW_NUMBER () OVER (PARTITION BY CASE
WHEN paramtype IS NULL
THEN 0
END
ORDER BY load_order
) AS the grp
THE t2
)
SELECT load_order
paramlocation
ROW_NUMBER () OVER (PARTITION BY grp
ORDER BY load_order
), Paramnum
OF got_grp
WHERE the paramtype IS NOT NULL
) CBC
WE (dst.paramlocation = src.paramlocation)
WHEN MATCHED THEN UPDATE
SET dst.paramnum = src.paramnum
;
Results:
LOAD_ORDER PARAMLOCATION BY
---------- ---------------- --- ---
1 49
2 12
3 50
loc51 5 B 1
loc52 8 B 2
13 loc53 B 3
13.2 loc54
loc55 13.5
50 aoc01 AI 1
80 aoc02 AI 2
loc58 81
1 DL of 82 doc03
2 DL doc02 83
3 DL of 99 doc01
-
Deleting record based on the ID of the main table
Hello
I am trying to remove the news that are published before 2012, but the tables in detail consists the notebook of the child based on the news_id has been. Request certainly simple deletion will not workSQL> desc news Name Null? Type ----------------------------------------- -------- ---------------------------- NEWS_ID NOT NULL NUMBER(14) NEWS_DATE TIMESTAMP(0) SL_ID NUMBER(2) HEADING VARCHAR2(3120) DESCRIPTION VARCHAR2(3900) SQL> desc news_location Name Null? Type ----------------------------------------- -------- ---------------------------- NEWS_ID NUMBER(14) COUNTRY VARCHAR2(32) REGION NUMBER(2) SQL> desc news_product Name Null? Type ----------------------------------------- -------- ---------------------------- NEWS_ID NUMBER(14) PRODUCT_CATEGORY_ID NOT NULL NUMBER(14) PRODUCT VARCHAR2(27) SQL> desc news_service Name Null? Type ----------------------------------------- -------- ---------------------------- NEWS_ID NUMBER(14) SERVICE_ID NOT NULL NUMBER(14) SRVIS VARCHAR2(16) SQL> desc news_info Name Null? Type ----------------------------------------- -------- ---------------------------- NEWS_ID NUMBER(14) SOURCE VARCHAR2(203) ORIGIONAL_NEWS VARCHAR2(3900) HEADING VARCHAR2(3110) SQL> select count(*) from news where TO_CHAR(news_date,'YYYY') < 2012; COUNT(*) ---------- 8759
Please advise and thank you in advanceOnce again, I tell you, do not need ON DELETE CASCADE in the Delete query.
Just use the Delete query like: -.
delete from news where TO_CHAR(news_date,'YYYY') < 2008;
And the child tables are deleted as a result.
-
The default value based on the field from another table to a custom object
I'm trying to set the default value to a field in the custom object to the value of a field of account. I tried the syntax 50 ways different and just don't get the case. The label for the account field displays the form of s/n, the integration of the tag is ltDBA_ACCT and it appears in the fx reports area as Account.Text_22.
The field of custom object that I am triying update is also called s/n, which was originally the required field 'NAME '. The name of the table, account, should it be included? Do I need a function to the field?
I've updated the external ID using the line with syntex < ID > ID (at least higher ID) so I know that it is possible to define a default value, but s / < n >, < ltDBA_ACCT >, 'account '. "" S/n "and so on are simply not working.
If anyone knows how to get into what I would be really grateful for the help.OK, so if you default a field to the value of another object, you must use the JoinFieldValue function. I think you understand that, based on your original post, but I want to be sure you do.
Then this won't work by default if the folder is created from the object that you want to join the because a default works in record creation and the ID must be available so that it works correctly. It will not work if you choose the record of the related object after that registration of the custom object is created. You can set the default after, but that does not meet your requirements.
The syntax of the default are the following: JoinFieldValue (ref_record_type, foreign_key, field_name).
In your case, ref_record_type is '
', foreign_key is [ ] and field_name is ' '. The best way is to determine what is the name of the field to create a new workflow for the account and use the Workflow Rule Condition expression builder to choose your field ("DBA") in the list. The value returned by the expression builder must be placed in the field_name variable in the function JoinFieldValue (minus the parentheses and quotes). Give it a shot and let me know how you do.
Thom
Maybe you are looking for
-
2 magic keyboard fn key does not work (PC windows 7), so I can't use Up, fn, fn + DEL, fn + down... and so on...
-
MacBook Pro question mark flashing, no wifi, only own internet connection
I have a flashing question mark on start up with my MacBook Pro. Through the process of restarting, but it asks me to choose a wifi network. I did not, as my computer has its own internet connection, so can not continue to the next step. Help please?
-
Hi guys -. Where are the drivers for the 15-f010wm? They seem not to be displayed. Just got this laptop home of Wal-Mart, loaded a new copy of Windows 8.1 on it and concluded that the page 'pilot' is devoid of pilots, a link with recovery media order
-
How to write data in an existing database table in sql using table in lab mode
I am trying to write the data to an existing table in sql databse.but I don't know how to get it done me .plz help
-
Pavilion 500 - 205t (Memphis-S) DT PC U - product F9A61AV #ABA
I have problems setting up two monitors. The monitors are HP W2072a - Intel HD 4600 graphics card - Win 7 Home Premium 64 is the operating system. I bought aftermarket cables, DVI - D and spilter. The monitor detects no signal DVI. I can connect VGA