Query NVL
Dear experts,I have a code like this.
DECLARE
a VARCHAR2 (1);
b VARCHAR2 (1);
c VARCHAR2 (1);
BEGIN
b: = NULL;
c : = a ' ;
a = NVL (b, c);
If a = a ' CAN
a: = 'E '.
END IF;
END;
My question is how can I write the article
a = NVL (b, c);
If a = a ' CAN
a: = 'E '.
END IF;
In a single expression.
Concerning
Rajat
use DECODING... not tested
select
DECODE(
NVL(b,c), 'D', 'E'
) into a
from dual;
Something like that?
SQL> DECLARE
2 a VARCHAR2 (1);
3 b VARCHAR2 (1);
4 c VARCHAR2 (1);
5 BEGIN
6 b := NULL;
7 c := 'D';
8 a := NVL (b, c);
9
10 /*IF a = 'D'
11 THEN
12 a := 'E';
13 END IF;*/
14 select DECODE(NVL(b,c), 'D', 'E') into a from dual;
15
16 DBMS_OUTPUT.put_line ('a= ' || a || ', b= ' || b || ', c= ' || c);
17 END;
18 /
a= E, b= , c= D
PL/SQL procedure successfully completed.
Tags: Database
Similar Questions
-
Hello
I have a request for a request to write that check null values in the CHANGE_CODE, makes it so 'none' if they are null, then the "none" takes the value and makes "open well". Should it be written in 2 separate calls to the database or can it be written as one? I wrote the following query, the "no" value is picked up, but its not to change the none for ' open wells. "I
StringBuilder sbSQL = new StringBuilder();
sbSQL.Append ("SELECT distinct RO. OBJECT_ID, RE. Stuff, RR.NAME, replace (nvl (A.CHANGE_CODE, '(none)'), '(none)', 'open_well') REV_CODE, "Autobalance"NOTE");
sbSQL.Append ("FROM PLX_SCRIPTED_LOAD_OBJECT_SET OBJ");
sbSQL.Append ("INNER JOIN PLX_CASE_ATTRIBUTE A ON OBJ. OBJECT_ID = A.OBJECT_ID");
sbSQL.Append ("INNER JOIN PLX_RECON_RESERVOIR RR ON A.UNIQUE_ID is RR. RESERVOIR_NAME");
sbSQL.Append ("INNER JOIN PLX_RECON_OBJECT RO ON RR. RESERVOIR_ID = RO. RESERVOIR_ID");
sbSQL.Append ("INNER JOIN PLX_RECON_RESERVOIR_ENTRY RE ON RO. RESERVOIR_DATA_OBJECT_ID = RE. RESERVOIR_DATA_OBJECT_ID");
sbSQL.Append ("INNER JOIN PLX_RECON_RESERVE_CATEGORY RRC ON RE. RESERVE_CATEGORY_ID = CRR. STUFF AND A.RESERVE_CATEGORY = CRR. CATEGORY_NAME');
If I run the following query in sql developer, I get the results I want:
SELECT replace (nvl (a.CHANGE_CODE, '(none)'), '(none),' open_well'), reservoir_entity, object_id, rr. Xxx_plx_case_attribute RESERVOIR_NAME A, PLX_RECON_RESERVOIR RR
where A.UNIQUE_ID = RR. RESERVOIR_NAME
any suggestions?
Thank youUPDATE XXX_PLX_CASE_ATTRIBUE SET CHANGE_CODE = "OPEN_WELL".
WHERE CHANGE_CODE IS NULL OR CHANGE_CODE = 'NONE '; -
Dynamic list - is current issue
I created a dynamic list. This works except for the IS_CURRENT parameter.
The page I access the dynamic list is on Page 11.List : dyn wizard page 11 Template: Wizard Progress List, Horizontal Train Query Source Type: Function Returning SQL Query Query case when :APP_PAGE_ID = '11' THEN RETURN 'SELECT null, progress_name label, '|| 'case WHEN NVL(:APPL_TAB_NAME,''PROJECT'')=CURRENT_TAB_NAME THEN ''Y'' else ''N'' end is_current_list_entry,'|| 'null,null,id ' || 'FROM csrsr_req_wizard_nav '|| 'WHERE form_number_id = 3 ORDER BY 6'; when :APP_PAGE_ID = '8' THEN RETURN 'SELECT null, current_tab_name label '|| 'FROM csrsr_req_wizard_nav '|| 'WHERE form_number_id = 1 ORDER BY 1'; when :APP_PAGE_ID = '10' THEN RETURN 'SELECT null, current_tab_name label '|| 'FROM csrsr_req_wizard_nav '|| 'WHERE form_number_id = 2 ORDER BY 1'; else RETURN 'SELECT null, current_tab_name label '|| 'FROM csrsr_req_wizard_nav '|| 'WHERE form_number_id = 4 ORDER BY 1'; END CASE;
Can someone please?
Robert
http://apexjscss.blogspot.comApplications of dynamic list you generate missing a column. Your questions have 6 columns:
SELECT null , progress_name label , case WHEN NVL(:APPL_TAB_NAME,'PROJECT') = CURRENT_TAB_NAME THEN 'YES' else 'NO' end is_current ,null ,null ,id FROM csrsr_req_wizard_nav WHERE form_number_id = 3 ORDER BY 6
The examples in the list wizard have 7:
SELECT null, ENAME label, null target, 'YES' is_current, '#APP_IMAGES#del.gif' image, 'width="20" height="20"' image_attrib, ENAME image_alt FROM emp ORDER BY ename
Although the target column is not used in a list of courses standard Wizard because it is not clickable, the column must always be included or the values of the column will be compensated. APEX sees your is_current as the target value column and your null image is_currentcolumn. It is advisable to include all columns and alias them:
select null level , progress_name label , null target , case nvl(:appl_tab_name, 'PROJECT') = current_tab_name then 'YES' else 'NO' end is_current , null image , null image_attrib , null image_alt from csrsr_req_wizard_nav where form_number_id = 3 order by 6
Also note that there are no application APPL_TAB_NAME element in this application, which will have an impact on the results of this query: nvl (: appl_tab_name, 'PROJECT') assess so always at the "PROJECT".
-
NVL selection list does not not on the place where clause in query
Ok. APEX 4.2...
Im having problems with my selection lists and NULL values... I see that it has come time and time again...
I have a tabular presentation, with a query based on a selection list. The selection list has the ability to '- Show All -'... The value of the selection list is a number, and the display is words... (for reference the LOV query is: select status, batch from pmt_stat_lookup by 1)
Initially I had problems with null and invalid numbers like ' display Null = 'Yes' and the problem of null % ', so have used the code in this blog to remove the NULL values... Display Null = & amp; #34; Yes & amp; #34; and the problem of null % | Inside Oracle APEX by Patrick Wolf
Then in the application of my report, I have a where clause clause that checks the value of the selection list... WHERE batch = nvl(:P11_STATUS_SELECT,STATUS_ID)
everything works almost fine, and I can choose a status, or I choose - see the All-, but the query will not include the lines where the State is null.
(I also see that maybe I should be, use the case statement instead of the NVL on where clause, but not sure of the syntax. In addition, NVL was used somewhat in the different reports in the application...)
For reference, the code of the old blog that I as a process page is:
BEGIN
FOR rItem IN
(SELECT NOM_ELEMENT
OF APEX_APPLICATION_PAGE_ITEMS
WHERE APPLICATION_ID = TO_NUMBER(:APP_ID)
AND PAGE_ID IN (TO_NUMBER(:APP_PAGE_ID), 0)
AND LOV_DISPLAY_NULL = 'Yes'
AND LOV_DEFINITION IS NOT NULL
-change here
AND LOV_NULL_VALUE = '% null | '%'
)
LOOP
IF V (rItem.ITEM_NAME) = "% null | '%'
THEN
Apex_Util.set_session_state (rItem.ITEM_NAME, NULL);
END IF;
END LOOP;
END;
Thank you very much
Richard
Richard,
Perhaps this example can help you solve your problem.
https://Apex.Oracle.com/pls/Apex/f?p=63838:2
Jeff
-
Using NVL in the query in the query resulting in error
I always use CF8 and Oracle 11 G back.
When I use NVL in the query in the query, I got error... I can't use NVL to check the value null? Help, please
Here are my codes:
< name cfquery = "GetC2" datasource = "#Trim (application." OracDSN) #">" SELECT CamID2, rel2_2, p_ln2, p_fn2, ins, l_year
OF prt_temp
WHERE Ins = 'CC '.
AND l_year = '1481'
AND NVL (Child_LN2,' ') <>' ' AND NVL (Child_FN2,' ') <>' ' < / cfquery >
< cfif GetC2.Recordcount NEQ 0 > < cfquery name = "CheckRel2C2", dbtype = "QUERY" > SELECT CamID2, rel2_2 OF GetC2 WHERE NVL (Rel2_2,' ') <>' ' AND NVL (p_ln2,' ') = ' ' AND NVL (p_fn2,' ') = ' ' AND Ins = 'CC '. AND l_year = '1481' < / cfquery > < / cfif > The error:
Run database query error.
Query of queries syntax error.
Met «NVL (Rel2_2.» Incorrect conditional expression, waiting for an a [as | null | between | in | comparison] condition,.
NVL is an Oracle function and it is not available in ColdFusion query of query. If you try to check the values null, use IS NULL or IS NOT NULL. Then
WHERE NVL (Rel2_2,' ') <> ' '
AND NVL (p_ln2,' ') = ' '
AND NVL (p_fn2,' ') = ' '
becomes
WHERE Rel2_2 IS NOT NULL
AND p_ln2 IS NULL
AND p_fn2 IS NULL
-Carl V.
-
Hello
I wrote a query below and run Toad which does no found exception data if the employee number ("12345") is a former employee. The nvl in the select statement is not '34567.
SELECT nvl(person_id,34567)
Of
Apps.per_all_people_f
WHERE
business_group_id = 100
AND trunc (sysdate) BETWEEN TRUNC (effective_start_date) AND TRUNC (effective_end_date)
AND current_employee_flag = 'Y '.
AND employee_number = '12345';
How can we reach without exceptional setting. I use the query above in a PL/SQL cursor?
Thanks in advance.You can not manage NVL like that.
Your query didn't get any folder. Change it as belowselect NVL((SELECT person_id FROM apps.per_all_people_f WHERE business_group_id =100 AND TRUNC(SYSDATE) BETWEEN TRUNC(effective_start_date) AND TRUNC(effective_end_date) AND current_employee_flag = 'Y' AND employee_number = '12345'), 34567) from dual;
Published by: PurveshK on June 21, 2012 17:19
-
Hi Master,
I am not able to resolve this query. Because it is a such a huge request. Take the time when I run this. Please help me to write this query in an optimized way. It's very kind of you.
SELECT payer_id_n, instance_id_n, lifecycle_type_n,
payer_status_n, replenishment_id_n, start_date_dt,
next_replenishment_date_dt, no_of_occurences_n,
payer_repl_status_n, last_charge_start_date_dt,
last_charge_end_date_dt, payer_repl_sequence_n,
pr_row_id_r, tariff_id_n, charge_type_n,
TO_NUMBER (gnl_extract_frm_cmd_str_fnc (plan_data, 4)) AS occurrence_type_n,
TO_NUMBER (gnl_extract_frm_cmd_str_fnc (plan_data, 5)) AS occurrence_count_n,
balance_option_n, repl_status_n,
discount_multiplier_flag_n,
TO_NUMBER (SUBSTR (gnl_extract_frm_cmd_str_fnc (slab_data, 1), 2)) AS start_period_n,
TO_NUMBER (gnl_extract_frm_cmd_str_fnc (slab_data, 2)) AS period_type_n,
TO_NUMBER (gnl_extract_frm_cmd_str_fnc (slab_data, 3)) AS interval_n,
gnl_extract_frm_cmd_str_fnc (slab_data, 4) AS start_day_v,
To_date (gnl_extract_frm_cmd_str_fnc (plan_data, 0), 'YYYYMMDDHH24MISS') AS plan_start_date_dt,
TO_NUMBER (gnl_extract_frm_cmd_str_fnc (plan_data, 1)) AS plan_id_n,
TO_NUMBER (gnl_extract_frm_cmd_str_fnc (plan_data, 2)) AS plan_type_n,
TO_NUMBER (gnl_extract_frm_cmd_str_fnc (plan_data, 3)) AS repl_plan_status_n,
debit_wallet_id_n, debit_units_n, debit_article_id_n,
credit_wallet_id_n, credit_units_n, credit_cf_policy_n,
credit_cf_limit_n, affect_validity_on_n,
validity_period_type_n, validity_period_n,
validity_extension_policy_n, credit_article_id_n,
TO_NUMBER (SUBSTR (bill_cycle, 9)),.
DECODE (ip_batch_count_n, 0, ROWNUM, MOD (ROWNUM, ip_batch_count_n)) AS process_batch_n
FROM (SELECT pa.payer_id_n, pa.instance_id_n,
PA.lifecycle_type_n, pa.payer_status_n,
PRT.replenishment_id_n, prt.start_date_dt,
PRT.next_replenishment_date_dt,
PRT.no_of_occurences_n,
PRT.status_n AS payer_repl_status_n,
PRT.last_charge_start_date_dt,
PRT.last_charge_end_date_dt,
PRT.payer_repl_sequence_n,
PRT. ROWID AS pr_row_id_r, rpl.tariff_id_n,
RPL.charge_type_n, rpl.balance_option_n,
RPL.status_n AS repl_status_n,
RPL.discount_multiplier_flag_n,
MAX (TO_CHAR (rp.start_date_dt,
'YYYYMMDDHH24MISS '.
)
|| '|'
|| To_char (100000 + rs.start_period_n)
|| '|'
|| RS.period_type_n
|| '|'
|| RS.interval_n
|| '|'
|| RS.start_day_v
) AS slab_data,
MAX (TO_CHAR (rp.start_date_dt,
'YYYYMMDDHH24MISS '.
)
|| '|'
|| RP.plan_id_n
|| '|'
|| RP.plan_type_n
|| '|'
|| RP.status_n
|| '|'
|| RP.occurrence_type_n
|| '|'
|| RP.occurrence_count_n
) AS plan_data,.
MAX (TO_CHAR (pbd.start_date_dt, 'YYYYMMDD')
|| PBD.bill_cycle_n
) AS bill_cycle
PA, payers,
payer_replenishment prt,
replenishment_master rpl,
replenishment_slabs rs,
replenishment_plan rp,
payer_bill_cycle_details pbd
WHERE pa.instance_id_n BETWEEN ip_min_instance_id_n
AND ip_max_instance_id_n
AND pa.payer_id_n = prt.payer_id_n
AND prt.status_n = crp_get_config_params.active_status
AND prt.occurrence_completion_flag_n = repl_occurrence_ongoing
AND prt.next_replenishment_date_dt < = TRUNC (ip_actual_sch_date_d)
AND prt.replenishment_id_n = rpl.replenishment_id_n
AND prt.event_request_no_n IS NULL
AND NVL (prt. SCHEDULE_FLG_YN_V, 'Y') = 'Y' - added CR CC-99
AND rp.replenishment_id_n = prt.replenishment_id_n
AND rp.start_date_dt < = prt.next_replenishment_date_dt
AND rp.status_n = crp_get_config_params.master_launched_status
AND rs.replenishment_id_n = prt.replenishment_id_n
AND rs.plan_id_n = rp.plan_id_n
AND rs.start_period_n < = prt.no_of_occurences_n + 1
AND pbd.payer_id_n = prt.payer_id_n
AND pbd.start_date_dt < = prt.next_replenishment_date_dt
AND pa.payer_status_n NOT IN (crp_get_config_params.waiting_payer_closure, crp_get_config_params.payer_closed)
AND NOT EXISTS)
SELECT 1
OF payer_replenishment_schedules prs
WHERE prs.payer_id_n = pa.payer_id_n
AND prs.replenishment_id_n = prt.replenishment_id_n
AND prs.status_n = crp_get_config_params.repl_retry)
AND THERE ARE)
SELECT 1
OF payer_tariffs pt
WHERE pt.payer_id_n = pa.payer_id_n
AND pt.tariff_id_n = rpl.tariff_id_n
AND pt.start_date_dt < = TO_DATE (TO_CHAR (prt.start_date_dt, 'YYYYMMDD') |) ("' 235959 ', ' YYYYMMDDHH24MISS ')
AND pt.event_request_no_n IS NULL
AND pt.status_n = crp_get_config_params.active_status)
Pa.payer_id_n GROUP,
PA.instance_id_n,
PA.lifecycle_type_n,
PA.payer_status_n,
PRT.replenishment_id_n,
PRT.start_date_dt,
PRT.next_replenishment_date_dt,
PRT.no_of_occurences_n,
PRT.status_n,
PRT.last_charge_start_date_dt,
PRT.last_charge_end_date_dt,
PRT.payer_repl_sequence_n,
PRT. ROWID,
RPL.tariff_id_n,
RPL.charge_type_n,
RPL.balance_option_n,
RPL.status_n,
RPL.discount_multiplier_flag_n),
RA replenishment_attribute
WHERE ((TO_NUMBER (gnl_extract_frm_cmd_str_fnc (plan_data, 4)) = 1))
AND TO_NUMBER (gnl_extract_frm_cmd_str_fnc (plan_data, 5)) > no_of_occurences_n)
OR (TO_NUMBER (gnl_extract_frm_cmd_str_fnc (plan_data, 4)) = 0)
)
)
AND TO_NUMBER (gnl_extract_frm_cmd_str_fnc (plan_data, 1)) = ra.plan_id_n
AND TO_NUMBER (SUBSTR (gnl_extract_frm_cmd_str_fnc (a.slab_data, 1), 2)) = ra.start_period_n;
Concerning
AR
Known Devil (regular expression - Yes, it's time CPU...) But it suits your problem) is better than an unknown Angel (your function)
You don't not tell/check if the query works at all the
See you soon,.
Manik.
-
Help with the query to create hourly statistics
Hello!
I have an array of jobs. Each task has a start_date and a column end_date. end_date can be null if the job is still running.
I need to create a query to display the number of jobs running for all hours during the last two weeks.
A job can run for more than an hour.
I tried to define what it means for a job during an interval:
Job.Start_date < = Interval.end AND Job.Finish_date > = Interval.start
Can help you with this query?
Thank you!
Mihai
Hi, Mihai,
User810719-Oracle wrote:
Hello!
I have an array of jobs. Each task has a start_date and a column end_date. end_date can be null if the job is still running.
I need to create a query to display the number of jobs running for all hours during the last two weeks.
A job can run for more than an hour.
I tried to define what it means for a job during an interval:
Job.Start_date <= interval.end="" and="" job.finish_date="">= Interval.start...
=>
You gave essentially the solution yourself. You just need to outside join your jobs table to a table (or, in the example below, a result set that acts like a table) containing 1 row for each interval. You can use NVL to equate finish_dates with an effective DATE NULL, so they will be counted:
WITH intervals AS
(
SELECT TRUNC (SYSDATE, 'HH') - ((LEVEL-1)/24) AS interval_start
, TRUNC (SYSDATE, 'HH') - ((LEVEL-2)/24) AS interval_end
OF the double
CONNECT BY LEVEL<= 14="" *="">=>
)
SELECT i.interval_start
EARL of (j.start_date) AS jobs_running
Intervals I have
LEFT OUTER JOIN jobs j WE j.start_date<=>=>
AND NVL (j.finish_date
i.interval_end
) > = i.interval_start
;
If you would care to post a small example of data (CREATE TABLE and INSERT statements) and the results desired from this data, I was able to test this.
Simplify the problem for display. Do what you are interested only for the past 6 hours, not the last 2 weeks. We will find a solution that can easily adapt to any number or intervals.
-
Hello. In my application, I have a classic report where, in a region, I built a toolbar with three Popup LOVs which interact with the report. Each LOV displays different items and returns the value according to the selected item.
For example:
Popup LOV 1 named P33_DEPARTMENTS has the following components: production, development, projecting, ecc.
Popup LOV 2 named P33_LOCATIONS was the following: Europe, America, Asia, Africa, ecc.
Popup LOV 3 named P33_DEVICES has the following: printer, keyboard, mouse, monitor, ecc.
If I query the table to return the lines according to the selected in these LOVs I have something like this:
SELECT * FROM < table > WHERE the dep =: P33_DEPARTMENTS AND loc =: P33_LOCATIONS AND dev =: P33_DEVICES
Now I want that if the user selects all values (LOVs one white point) (or all), then the query must return all values for that LOV.
For example, if for the named LOV P33_DEPARTMENTS 'white' value is selected, then the query must return to the table lines this cointain values "production ' OR 'developing' OR 'project', ecc for the columns named"dep".
This means that must be the operator AND between LOVs but the operator or inside the LOV even, if the item is selected.
How is it possible? Thank you
SELECT * FROM T WHERE dep = nvl( :P33_DEPARTMENTS, dep) and loc = nvl( :P33_LOCATIONS, loc) and dev = nvl( :P33_DEVICES, loc)
You just need to ensure that, when no value is selected, the LOV will return a NULL value.
MK
-
Hello
I want to run the table several queries. I have 4 tables. Table 1 is to have relatively in table 2, but table 3 & 4 is not related with table 1. wherever I want to extract the data from table 1, table 4. My current query works well but it miss the Chronogram of table 1, which records do not exist in table 2, where, from table 2 of table 4 its working fine.
SELECT z.productcode, fabqty z.productionadviceno, sum (z.fabricatedqty).
Fabqtynoms Round (Sum(z.fabricatedqty*.015) + Sum (z.fabricatedqty)),
w.workorderno, ons min (w.ons).
((SOMME (w.qtyinsheets) * min (ons))) PCS,
(SELECT SUM (NVL (mrnqty, 0)))
OF CANMRN
WHERE workorderno = w.workorderno) mrnqty;
(SELECT ROUND (SUM (NVL (ptnqty, 0))))
OF CANPTN
WHERE workorderno = w.workorderno
) ptnqty
OF CANWORKORDER w, productionadvice z
where w.productionadviceno = z.productionadviceno
and w.productcode = 501001
GROUP BY w.workorderno, z.productionadviceno, z.productcode
PRODUCTCODE PRODUCTIONADVICENO FABQTY FABQTYNOMS WORKORDERNO ONS SCP MRNQTY PTNQTY
----------- ------------------ --------- ---------- ----------- --------- --------- --------- ------
501001 20004182 250000 253750 20001805 15 253755 16917 253755
501001 20004229 200000 203000 20001817 15 202995 13533 202995
501001 20004251 130000 131950 20001829 15 131955 8797 131955
501001 20004256 200000 203000 20001839 15 202995 13533 202995
501001 20004277 500000 507500 20001844 15 507495 33833 507495
501001 20004411 500000 507500 20001918 15 507495 31619 474285
501001 20004904 230000 233450 20002150 15 233445
I want to get this record also is missing after you run the query, as I had mentioned w.productionadviceno = z.productionadviceno due to which its does not, how, in a delicate way, we can use this relationship.
501001 20004905 10000 10150
Sandy
use of EXTERNAL JOINS as follows
where w.productionadviceno = z.productionadviceno (+)
above is a left outer join. A LEFT OUTER JOIN is a JOIN operations that allow you to specify a join clause. He keeps the lines without correspondence of the first (left) table, join them with a NULL row in the form of the second table (right).
More details: LEFT OUTER JOIN operation
-
Single SQL query for the analysis of the date of customs declaration under the table of Stock codes
Dear all,
Please tell us a single SQL query for the below,
We have a Table of Stock as shown below,
STOCK_TABLE
ITEM_CODE
(item code)
BAT_NO
(lot no.)
TXN_CODE
(transaction code)
DOC_NO
(number)
BOE_DT
(date of the customs declaration)
I1
B1
I1
I2
I3
B70
I4
B80
I5
B90
T102
1234
JULY 2, 2015
I6
B100
We have to find the date of customs declaration (i.e. the date when the items have come under this particular table) for items that are not attached to any document (that is, who have TXN_CODE, DOC_NO and BOE_DT fields with a NULL value).
For each item in the table of actions, which is not attached to any document, the customs declaration date is calculated as follows.
- If (code section, lot number) combination is present under HISTORY_TABLE, the date of customs declaration will receive the UPDT_DT, the transaction code (TXN_CODE) is an IN or transactions (which can be analyzed from the TRANSACTIONS table).
- If (code section, lot number) combination is NOT currently at the HISTORY_TABLE (or) the transaction code respective to item - batch number combination code is an operation then customs declaration date will be the date of the document (DOC_DT) that we receive from one of the 3 tables IN_TABLE_HEAD that contains the element of that particular lot.
- If the case 1 and case 2 fails, our customs declaration date will be the last date of document (DOC_DT) that we receive from one of the 3 tables IN_TABLE_HEAD containing that particular item and the BAT_NO in expected results will be that corresponding to this document, as appropriate, to another NULL.
- If the case 1 or case 2 is successful, the value of the last field (in the output expected, shown further below) BATCH_YN will be 'Y', because it fits the lot. Otherwise it will be 'n'.
-
Run the query in accordance with condition
Oracle 10g version
Hi gurus
I have the following data
Examples of data
SELECT DeptNo FROM scott.emp
UNION ALL
SELECT EmpNo FROM scott.emp
;
Now what I want is I want to execute conditionally of those surveyed, something like below:
If list_item = 'I', then run below
SELECT DeptNo FROM scott.emp
otherwise run below
SELECT EmpNo FROM scott.emp
End if;
------
I want to keep the union all and run the query under the terms...
Set a long tank (max 4000)
L_WHERE_CLAUSE
Use it in your application as a substitution variable by prefixing with &
WHERE & L_WHERE_CLAUSE
Assign the value into a pl/sql block (trigger, formula column)
IF condition THEN
L_WHERE_CLAUSE: = '1 = 1';
ON THE OTHER
L_WHERE_CLAUSE: = '1 = 2';
END IF;
Now, among the options that have been suggested to you and the information you provided, I think the solution of Solomon should be easier. Just refer to the column list_item has a link within your query variable (assuming that this and the query where list_item belongs are related, for example, there is a join between them)
SELECT DeptNo FROM scott.emp, t
WHERE: list_item = 'l '.
UNION ALL
SELECT EmpNo FROM scott.emp, t
WHERE nvl(:list_item,'x')! = « l »
-
Hi all
I have create report sql in version 4.2, and now we have apex version 5.0 upgrade.
I encountered error when I change the State of sql
The error massage:
Query cannot be parsed in the generator. If you believe that your query is syntactically correct, check the generic "columns" box below the source of the region without analysis. ORA-00905: lack of keyword
My SQL
SELECT VW.*
, CASE WHEN (VW.file_code is null
OR VW.cancel_flg = 'Y'
OR (TOUR_DEP_DATE + GET_FILE_LOCKING_DAYS (VW. (SBU_CODE) < = trunc (sysdate))
) THEN
' < font color = "Red" > < b > other < /b > < / police > '
ON THE OTHER
"< a href =" f? p = & APP_ID.:51: & SESSION. : O PR: & DEBUG. : 51:P51_FILE_CODE, P51_COSTING_CODE, P51_TOUR_REG_NO, P51_VERSION_NO, P51_REQUEST, P51_AGENT_NAME, P51_ADULTS, P51_CHILDS, P51_MKT_CODE, P51_QUOT_CURR:'
|| FILE_CODE | «, » || COSTING_CODE | «, » || TOUR_REG_NO | «, » || VERSION_NO | «, » ||' OPR' | «, » || AGENT_CODE | «, » || VW. FROM_PAX | «, » || 0||','|| VW.mkt_code | ',' | VW. QUOT_CURR |': ' > < font color = blue > < b > other < /b > < / police > '. "
END as "other Actions".
, CASE WHEN ((VW.file_code is not null AND TOUR_DEP_DATE + GET_FILE_LOCKING_DAYS (VW. (SBU_CODE) < = TRUNC (SYSDATE))
OR cancel_flg = 'Y '.
OR (VW. REF_COSTING_CODE = VW. ADDL_FIELD2 AND VW. ADDL_FIELD1 LIKE '% COPIED FROM % OF APPROVAL'
AND BOOKING_NAME LIKE "%-Backup")
) THEN
' < font color = "Red" > < b > edit < /b > < / police > '
ON THE OTHER
"< a href =" f? p = & APP_ID.:149: & SESSION. : & DEBUG. : 149:P149_COSTING_CODE:'
|| COSTING_CODE |': ' > < font color = blue > < b > edit < /b > < / police > '. "
END AS 'Edit '.
, CASE WHEN (Nvl (cancel_flg, 'n') = 'Y')
)
THEN
' < font color = "Red" > < b > add < /b > < / police > '
ON THE OTHER
"< a href =" f? p = & APP_ID.:33: & SESSION. : & DEBUG. : 33:P33_COSTING_CODE, P33_FILE_CODE, P33_MKT_CODE, P33_QUOT_CURR, P33_NO_OF_ADULT, P33_NO_OF_CHILD:'
|| COSTING_CODE | «, » || file_code | «, » || VW.mkt_code | ',' | VW. QUOT_CURR | «, » || VW. FROM_PAX | «, » || 0 | ': "> < font color = blue > < b > add < /b > < / police > '
END as 'Services '.
OF TOUR_MAS_VW VW
How to solve it.
Thank you
Dear friends
Thanks for your helping hands.
I found the solution for this. We can solve this problem by using these solutions
- A region of HTML:
click me
- Using PL/SQL:
htf.anchor('f?p=100:5:'||V('APP_SESSION'),'click me');
- Using a SQL query: SELECT htf.anchor('f?p=100:5:'||:APP_SESSION,'clickme') FROM DUAL;
We can write the query in the form
SELECT ' f? p = 100: 1 :'|| : APP_SESSION |': ' | : APP_UNIQUE_PAGE_ID |
': P1_EMPNO :'|| employe_id,
first name,
job_id
Employees
Thank you & best regards
CORINE
- A region of HTML:
-
SQL query to create artificial lines (performance)
Database: Oracle 11g
the above is a table of operation for a given productid. for each master job there are jobs of the child and for each child employment there is an entry for insertion. When we remove the master station we only store one record for the id of the job to master an integer. However in some reports we show each child job id with a status being removed as the below. basically for each logical record that created the deleted entry will be the sequence number of the main entrance. in this example sequence # 4. tab1 is a very large table.
my query:
- with tab1 as
- (Select 1 sequence_num"p1" productid, 'jm1' job_master_id, 'jm11' job_id, "insert" State
- de double
- Union all
- Select 2 sequence_num 'p1' ProductID, 'jm1' job_master_id, "jm12" job_id, "Insert" status
- de
- Union all
- Select sequence_num 3, 'p1' ProductID, « jm1 » job_master_id, "jm13" job_id, "Insert" status
- de double
- Union all
- Select sequence_num 4, 'p1' ProductID, null job_master_id, 'jm1' job_id, "master_removed" status
- de double
- Union "! important;" >
- Select 1 sequence_num 'p2' ProductID, « jm2 » job_master_id, "jm21" job_id, "Insert" status
- de double
- )
- Select * de (
- Select a.*, 'physical' record de tab1 a
- Union all
- Select del.sequence_num,
- b.ProductID,
- b.job_master_id,
- "! important;" > b.job_id.
- 'logic' record
- de
- tab1 del, tab1 b
- où del.ProductID = b.productid
- et del.job_id = b.job_master_id
- et del.status = "master_removed"
- et b.status = "Insert" ) final
- order of final.productid, final.job_master_id, final.job_id
-
I have a table that looks roughly like this
NR PRD_NR CLT_NR DATE 123 65789 569123 124 57698 478966 10/01/2015 125 53789 389737 126 13547 021534 04/10/2015 And I'm interrogating him with a date condition. The value of the date would come from a page of the apex (date element) element that could be left to null, and then he return null values in the report.
How can I add a condition for the column nvl? I tried
select * from example_table where prd_nr = 13547 and --here date condition
= null does not work, so NVL is also useless I know. To query this table I want to do something like "when the date is null or date =: P23_DATE' but which returns two records are null and the date of entry."
Any help would be appreciated!
Thank you
J
Julijan wrote:
I have a table that looks roughly like this
NR PRD_NR CLT_NR DATE 123 65789 569123 124 57698 478966 10/01/2015 125 53789 389737 126 13547 021534 04/10/2015 And I'm interrogating him with a date condition. The value of the date would come from a page of the apex (date element) element that could be left to null, and then he return null values in the report.
How can I add a condition for the column nvl? I tried
- Select * from example_table where prd_nr = 13547 and - here date condition
= null does not work, so NVL is also useless I know. To query this table I want to do something like "when the date is null or date =: P23_DATE' but which returns two records are null and the date of entry."
Try
select * from example_table where prd_nr = 13547 and ( date = to_date(:p23_date, '
') or (date is null and :p23_date is null))
HISTORY_TABLE
ITEM_CODE | BAT_NO |
TXN_CODE
DOC_NO
UPDT_DT
I1
B1
T1
1234
JANUARY 3, 2015
I1
B20
T20
4567
MARCH 3, 2015
I1
B30
T30
7890
FEBRUARY 5, 2015
I2
B40
T20
1234
JANUARY 1, 2015
TRANSACTION
TXN_CODE | TXN_TYPE |
T1 | IN |
T20 |
OFF
T30
ALL THE
T50
IN
T80
IN
T90
IN
T60
ALL THE
T70
ALL THE
T40
ALL THE
IN_TABLE_HEAD_1
H1_SYS_ID (primary key) | TXN_CODE | DOC_NO |
DOC_DATE
H1ID1
T1
1234
JANUARY 1, 2015
H1ID2
T70
1234
FEBRUARY 1, 2015
IN_TABLE_ITEM_1
I1_SYS_ID |
H1_SYS_ID
(foreign key referencing H1_SYS_ID in IN_TABLE_HEAD_1)
ITEM_CODE
I1ID1
H1ID1
I1
I1ID2
H1ID1
I100
I1ID3
H1ID2
I3
IN_TABLE_BATCH_1
B1_SYS_ID | TXN_CODE DOC_NO (now in IN_TABLE_HEAD_1) | BAT_NO |
B1ID1
T1
1234
B1 / can be empty
B1ID2
T70
1234
B70
IN_TABLE_HEAD_2
H2_SYS_ID (primary key) | TXN_CODE |
DOC_NO
DOC_DATE
H2ID1
T30
4567
FEBRUARY 3, 2015
H2ID2
T60
1234
JANUARY 3, 2015
IN_TABLE_ITEM_2
I2_SYS_ID | H2_SYS_ID (foreign key referencing H2_SYS_ID in IN_TABLE_HEAD_2) | ITEM_CODE |
I2ID1 | H2ID1 |
I1
I2ID2
H2ID1
I200
I2ID3
H2ID2
I2
IN_TABLE_BATCH_2
B2_SYS_ID |
I2_SYS_ID
(foreign key referencing I2_SYS_ID in IN_TABLE_ITEM_2)
BAT_NO
B2ID1
I2ID1
B30 / null
B2ID2
I2ID2
B90
B2ID2
I2ID3
B60
IN_TABLE_HEAD_3
H3_SYS_ID (primary key) | TXN_CODE | DOC_NO | DOC_DATE |
H3ID1 |
T50
1234
JANUARY 2, 2015
H3ID2
T80
1234
JANUARY 3, 2015
H3ID3
T90
1234
JANUARY 4, 2015
H3ID4
T40
1234
AUGUST 5, 2015
IN_TABLE_ITEM_3
I3_SYS_ID |
H3_SYS_ID
(foreign key referencing H3_SYS_ID in IN_TABLE_HEAD_3)
ITEM_CODE
BAT_NO
I3ID1
H31D1
I2
B50
I3ID2
H3ID2
I4
B40
I3ID3
H3ID3
I4
I3ID4
H3ID4
I6
There is no IN_TABLE_BATCH_3
Please find below the expected results.
OUTPUT
ITEM_CODE | BAT_NO | TXN_CODE | DOC_NO |
BOE_DT
BATCH_YN
I1
B1
T1
1234
JANUARY 3, 2015
THERE
I1
B30
T30
7890
FEBRUARY 5, 2015
N
I2
B60
T60
1234
JANUARY 3, 2015
N
I3
B70
T70
1234
FEBRUARY 1, 2015
THERE
I4
T90
1234
JANUARY 4, 2015
N
I6
T40
1234
AUGUST 5, 2015
N
Controls database to create the tables above and insert the records.
CREATE TABLE stock_table()item_code VARCHAR2()80),bat_no VARCHAR2()80),txn_code VARCHAR2()80),
doc_no VARCHAR2 (80), boe_dt DATE );
INSERT EN stock_table
VALUES ('I1', 'B1', '', '', '');
INSERT EN stock_table
VALUES ('I1', '', '', '', '');
INSERT IN stock_table
VALUES ('I2', '', '', '', '');
INSERT EN stock_table
VALUES ('I3', 'B70', '', '', '');
INSERT EN stock_table
VALUES ('I4', 'B80', '', '', '');
INSERT EN stock_table
VALUES ('I5', 'B90', 'T102', '1234', '02-JUL-2015');
INSERT EN stock_table
VALUES ('I6', 'B100', '', '', '');
SELECT *
FROM stock_table
CREATE TABLE history_table()item_code VARCHAR2()80),bat_no VARCHAR2()80),txn_code VARCHAR2()80),
doc_no VARCHAR2 (80), updt_dt DATE );
INSERT IN history_table
VALUES ('I1', 'B1', 'T1', '1234', '03-JAN-2015');
INSERT IN history_table
VALUES ('I1', 'B20', 'T20', '4567', '03-MAR-2015');
INSERT IN history_table
VALUES ('I1', 'B30', 'T30', '7890', '05-FEB-2015');
INSERT IN history_table
VALUES ('I2', 'B40', 'T20', '1234', '01-JAN-2015');
SELECT *
FROM history_table
CREATE TABLE transaction1()txn_code VARCHAR()80),txn_type VARCHAR()80));
INSERT INTO transaction1
VALUES ('T1', 'IN');
INSERT INTO transaction1
VALUES ('T20', 'OUT');
INSERT INTO transaction1
VALUES ('T30', 'ALL');
INSERT INTO transaction1
VALUES ('T40', 'ALL');
INSERT INTO transaction1
VALUES ('T50', 'IN');
INSERT INTO transaction1
VALUES ('T60', 'ALL');
INSERT INTO transaction1
VALUES ('T70', 'ALL');
INSERT INTO transaction1
VALUES ('T80', 'IN');
INSERT INTO transaction1
VALUES ('T90', 'IN');
SELECT *
FROM transaction1
CREATE TABLE in_table_head_1()h1_sys_id VARCHAR2()80) PRIMARY KEY,txn_code VARCHAR2()80),
doc_no VARCHAR2 (80), doc_dt DATE );
CREATE TABLE in_table_head_2()h2_sys_id VARCHAR2()80) PRIMARY KEY,txn_code VARCHAR2()80),
doc_no VARCHAR2 (80), doc_dt DATE );
CREATE TABLE in_table_head_3()h3_sys_id VARCHAR2()80) PRIMARY KEY,txn_code VARCHAR2()80),
doc_no VARCHAR2 (80), doc_dt DATE );
INSERT IN in_table_head_1
VALUES ('H1ID1', 'T1', '1234', '01-JAN-2015');
INSERT IN in_table_head_1
VALUES ('H1ID2', 'T70', '1234', '01-FEB-2015');
INSERT IN in_table_head_2
VALUES ('H2ID1', 'T30', '4567', '03-FEB-2015');
INSERT IN in_table_head_2
VALUES ('H2ID2', 'T60', '1234', '03-JAN-2015');
INSERT IN in_table_head_3
VALUES ('H3ID1', 'T50', '1234', '02-JAN-2015');
INSERT IN in_table_head_3
VALUES ('H3ID2', 'T80', '1234', '03-JAN-2015');
INSERT IN in_table_head_3
VALUES ('H3ID3', 'T90', '1234', '05-JAN-2015');
INSERT IN in_table_head_3
VALUES ('H3ID4', 'T40', '1234', '05-AUG-2015');
CREATE TABLE in_table_item_1()i1_sys_id VARCHAR2()80) PRIMARY KEY,
h1_sys_id VARCHAR2 (80) REFERENCES in_table_head_1()h1_sys_id),item_code VARCHAR2()80));
CREATE TABLE in_table_item_2()i2_sys_id VARCHAR2()80) PRIMARY KEY,
h2_sys_id VARCHAR2 (80) REFERENCES in_table_head_2()h2_sys_id),item_code VARCHAR2()80));
CREATE TABLE in_table_item_3(i3_sys_id VARCHAR2(80) PRIMARY KEY,
h3_sys_id VARCHAR2 (80) REFERENCES in_table_head_3()h3_sys_id),item_code VARCHAR2()80),
bat_no VARCHAR2 (80));
INSERT IN in_table_item_1
VALUES ('I1ID1', 'H1ID1', 'I1');
INSERT IN in_table_item_1
VALUES ('I1ID2', 'H1ID1', 'I100');
INSERT IN in_table_item_1
VALUES ('I1ID3', 'H1ID2', 'I3');
INSERT IN in_table_item_2
VALUES ('I2ID1', 'H2ID1', 'I1');
INSERT IN in_table_item_2
VALUES ('I2ID2', 'H2ID1', 'I200');
INSERT IN in_table_item_2
VALUES ('I2ID3', 'H2ID2', 'I2');
INSERT IN in_table_item_3
VALUES ('I3ID1', 'H3ID1', 'I2','B50');
INSERT IN in_table_item_3
VALUES ('I3ID2', 'H3ID2', 'I4','B40');
INSERT IN in_table_item_3
VALUES ('I3ID3', 'H3ID3', 'I4','');
INSERT IN in_table_item_3
VALUES ('I3ID4', 'H3ID4', 'I6','');
SELECT *
FROM in_table_item_1
SELECT *
FROM in_table_item_2
SELECT *
FROM in_table_item_3
CREATE TABLE in_table_batch_1()b1_sys_id VARCHAR2()80) PRIMARY KEY,
txn_code VARCHAR2 (80), doc_no VARCHAR2 (80), bat_no VARCHAR2 (80));
CREATE TABLE in_table_batch_2()b2_sys_id VARCHAR2()80) PRIMARY KEY,
i2_sys_id VARCHAR2 (80) REFERENCES in_table_item_2()i2_sys_id),bat_no VARCHAR2()80));
INSERT IN in_table_batch_1
VALUES ('B1ID1', 'T1', '1234', 'B1');
INSERT IN in_table_batch_1
VALUES ('B1ID2', 'T70', '1234', 'B70');
INSERT IN in_table_batch_2
VALUES ('B2ID1', 'I2ID1', 'B30');
INSERT IN in_table_batch_2
VALUES ('B2ID2', 'I2ID2', 'B90');
INSERT IN in_table_batch_2
VALUES ('B2ID3', 'I2ID3', 'B60');
Please advise a solution for the same.
Thank you and best regards,
Séverine Suresh
very forced (question subfactoring used to allow easy testing/verification - could work with these test data only)
with
case_1 as
(select s.item_code,
s.bat_no,
h.txn_code,
h.doc_no,
h.updt_dt boe_dt,
cases where s.bat_no = h.bat_no then 'Y' else ' n end batch_yn.
cases where h.txn_code is not null
and h.doc_no is not null
and h.updt_dt is not null
then 'case 1' '.
end refers_to
from (select item_code, bat_no, txn_code, doc_no, boe_dt
of w_stock_table
where bat_no is null
or txn_code is null
or doc_no is null
or boe_dt is null
) s
left outer join
w_history_table h
On s.item_code = h.item_code
and s.bat_no = h.bat_no
and exists (select null
of w_transaction1
where txn_code = nvl (s.txn_code, h.txn_code)
and txn_type in ('IN', 'ALL')
)
),
case_2 as
(select s.item_code,
NVL (s.bat_no, h.bat_no) bat_no.
NVL (s.txn_code, h.txn_code) txn_code.
NVL (s.doc_no, h.doc_no) doc_no.
NVL (s.boe_dt, h.updt_dt) updt_dt.
cases where s.bat_no = h.bat_no then 'Y' else ' n end batch_yn.
cases where h.txn_code is not null
and h.doc_no is not null
and h.updt_dt is not null
then 'case 2'.
end refers_to
from (select item_code, bat_no, txn_code, doc_no, boe_dt
of case_1
where refers_to is null
) s
left outer join
w_history_table h
On s.item_code = h.item_code
and exists (select null
of w_transaction1
where txn_code = nvl (s.txn_code, h.txn_code)
and txn_type in ('IN', 'ALL')
)
and not exists (select null
of case_1
where item_code = h.item_code
and bat_no = h.bat_no
and txn_code = h.txn_code
and doc_no = h.doc_no
and updt_dt = h.updt_dt
)
),
case_31 as
(select s1.item_code,
NVL (S1.bat_no, W1.bat_no) bat_no.
NVL (S1.txn_code, W1.txn_code) txn_code.
NVL (S1.doc_no, W1.doc_no) doc_no.
NVL (S1.updt_dt, W1.doc_dt) updt_dt.
cases where s1.bat_no = w1.bat_no then 'Y' else ' n end batch_yn.
cases where w1.txn_code is not null
and w1.doc_no is not null
and w1.doc_dt is not null
then "case 31'.
end refers_to
from (select item_code, bat_no, txn_code, doc_no, updt_dt, batch_yn, refers_to
of case_2
where refers_to is null
) s1
left outer join
(select i1.item_code, h1.txn_code, h1.doc_no, h1.doc_dt, b1.bat_no
of w_in_table_item_1 i1
inner join
w_in_table_head_1 h1
On i1.h1_sys_id = h1.h1_sys_id
inner join
w_in_table_batch_1 b1
On h1.txn_code = b1.txn_code
and h1.doc_no = b1.doc_no
) w1
On s1.item_code = w1.item_code
),
case_32 as
(select s2.item_code,
NVL (S2.bat_no, W2.bat_no) bat_no.
NVL (S2.txn_code, W2.txn_code) txn_code.
NVL (S2.doc_no, W2.doc_no) doc_no.
NVL (S2.updt_dt, W2.doc_dt) updt_dt.
cases where s2.bat_no = w2.bat_no then 'Y' else ' n end batch_yn.
cases where w2.txn_code is not null
and w2.doc_no is not null
and w2.doc_dt is not null
then "case 32'.
end refers_to
from (select item_code, bat_no, txn_code, doc_no, updt_dt, batch_yn, refers_to
of case_2
where refers_to is null
) s2
left outer join
(select i2.item_code, h2.txn_code, h2.doc_no, h2.doc_dt, b2.bat_no
of w_in_table_item_2 i2
inner join
w_in_table_head_2 h2
On i2.h2_sys_id = h2.h2_sys_id
inner join
w_in_table_batch_2 b2
On i2.i2_sys_id = b2.i2_sys_id
) w2
On s2.item_code = w2.item_code
),
case_33 as
(select s3.item_code,
w3.bat_no,
NVL (S3.txn_code, w3.txn_code) txn_code.
NVL (S3.doc_no, w3.doc_no) doc_no.
NVL (S3.updt_dt, w3.doc_dt) updt_dt.
cases where s3.bat_no = w3.bat_no then 'Y' else ' n end batch_yn.
cases where w3.txn_code is not null
and w3.doc_no is not null
and w3.doc_dt is not null
then "case 33'.
end refers_to
from (select item_code, bat_no, txn_code, doc_no, updt_dt, batch_yn, refers_to
of case_2
where refers_to is null
) s3
left outer join
(select i3.item_code, h3.txn_code, h3.doc_no, h3.doc_dt, i3.bat_no
of w_in_table_item_3 i3
inner join
w_in_table_head_3 h3
On i3.h3_sys_id = h3.h3_sys_id
) w3
On s3.item_code = w3.item_code
)
Select item_code, bat_no, txn_code, doc_no, boe_dt, batch_yn
of case_1
where refers_to is not null
Union of all the
Select item_code, bat_no, txn_code, doc_no, updt_dt, batch_yn
of case_2
where refers_to is not null
Union of all the
Select item_code, bat_no, txn_code, doc_no, updt_dt, batch_yn
from (select item_code, bat_no, txn_code, doc_no, updt_dt, batch_yn,
ROW_NUMBER() over (partition by item_code of updt_dt desc order) rn
from (select item_code, bat_no, txn_code, doc_no, updt_dt, batch_yn
of case_31
where refers_to is not null
Union of all the
Select item_code, bat_no, txn_code, doc_no, updt_dt, batch_yn
of case_32
where refers_to is not null
Union of all the
Select item_code, bat_no, txn_code, doc_no, updt_dt, batch_yn
of case_33
where refers_to is not null
)
)
where rn = 1
ITEM_CODE | BAT_NO | TXN_CODE | DOC_NO | BOE_DT | BATCH_YN |
---|---|---|---|---|---|
I1 | B1 | T1 | 1234 | JANUARY 3, 2015 | THERE |
I1 | B30 | T30 | 7890 | FEBRUARY 5, 2015 | N |
I2 | B60 | T60 | 1234 | JANUARY 3, 2015 | N |
I3 | B70 | T70 | 1234 | FEBRUARY 1, 2015 | THERE |
I4 | - | T90 | 1234 | JANUARY 5, 2015 | N |
I6 | - | T40 | 1234 | AUGUST 5, 2015 | N |
Concerning
Etbin
Can rewrite us this query with just a single select statement with three full table on the same table scans? Something using connectby or connector line... Thanks in advance...
Something like:
with tab1 as)
Select 1 sequence_num, productid 'p1', 'jm1' job_master_id 'jm11', 'insert' Union status job_id double all the
Select 2 sequence_num, productid 'p1', 'jm1' job_master_id job_id 'jm12","insert"status of double union all
Select 3 sequence_num, productid 'p1', 'jm1' job_master_id job_id 'jm13', 'insert' status of double union all
Select 4 sequence_num "p1" productid, job_master_id, job_id 'jm1' null, 'master_removed' status of all the double union
Select 1 sequence_num "p2" productid, job_master_id 'jm2', 'jm21"job_id,"insert"status of double
)
Select sequence_num,
ProductID,
NVL (job_master_id, job_id) job_master_id.
nvl2 (job_master_id, job_id, job_id prior) job_id,
status,
level of the case
When 1 then 'physical '.
otherwise "logic."
end record
of tab1
connect by productid = ProductID prior
and job_id = prior job_master_id
and the State = "master_removed".
order by productid,
job_master_id,
job_id
/
SEQUENCE_NUM PR JOB_ JOB_ STATE REGISTRATION
------------ -- ---- ---- -------------- --------
4 p1 jm1 jm11 logical master_removed
1 p1 jm1 jm11 insert physical
2 p1 jm1 jm12 insert physical
4 p1 jm1 jm12 logical master_removed
4 p1 jm1 jm13 logical master_removed
3 p1 jm1 jm13 insert physical
4 p1 jm1 physical master_removed
1 p2 jm2 jm21 insert physical
8 selected lines.
SQL >
SY.
Maybe you are looking for
-
Re: A Satellite L50-A111X - problems with right click on the touchpad
Hello users,. I bought a new toshiba Satellite L50-A111X, I do not have that there is a problem or weither right click on his mouse touch pad is not available at all. Help, please.Thanks in advance
-
Hello I was curious to know how much space I had on my new iPhone 5 c. I got it 2 weeks ago and I don't have a lot of apps from your. According to what he says about the settings I used 10.7 GB and I have 1.6 GB left which is hard to believe. So, I d
-
audio book fast forward?
I just bought my zip clip a few days ago and have been listening to audio books on what I have with my previous 2 sansa (first we got older and was last update time fell in the sink and fries) listen well to my book it skiped I went back to the previ
-
Indicating my HP laptop, I get an endless amounts of beeps. Laptop has Vista. I already tried the following: (1) F2 = verification of commissioning that get no error but with beeps. (2) F9 = Menu of Boot Device - Select portable Drvie. Then, the c
-
error code 0 x 8007002 and 0x8004230f error code when you save
I get these error codes when trying to save... also system restore does not work