function body pl/sql return SQL query - if with in the select statement
Hi allI have a condition where, when the summary field is checked, only we see the this column for users in the report. IF statement is possible in this case? I gave the code below... is possible to write something like below, or y at - it another way to do it?
\
v_sql: = ' select TBLCASES. INVESTIGATOR as an INVESTIGATOR,';
v_sql: = v_sql | "TBLCASES. CASENUMBER as CASENUMBER,';
v_sql: = v_sql | "TBLCASES. OPENDATE as OPENDATE,';
v_sql: = v_sql | "TBLCASES. ESTCOMPLETE as DATE_CIBLE,';
v_sql: = v_sql | "TBLCASES. STATUS of STATUS ';
v_sql: = v_sql | "TBLCASES. Case CODE case CODE as,';
v_sql: = V_sql | "TBLCASES. FAIR_HOTLINE as FAIRHotline,';
v_sql: = v_sql | "TBLCASES. NYSIG as NYSIGCase,';
v_sql: = v_sql | "TBLCASES. The REGION';
IF: P44_INCLUDE_SUMMARY_FIELD is not null THEN
v_sql: = v_sql | "TBLCASES. SUMMARY,';
END IF;
v_sql: = v_sql | "TBLCASES. PROGAREA as PROGArea ';
v_sql: = v_sql | ' from TBLCASES where 1 = 1';
.. \
Hi Lucie,.
You are adding and removing a column in a report, so it may be useful to have the extra on the end of the query.
You get an error? If so, paste it in...
BUT - that I would put a condition on the column where ': P44_INCLUDE_SUMMARY_FIELD is not null '
It under 'Attributes of the column' report select the change column icon, and there a breadcrumb "Condition."
Select "In Expression 1 point value is not Null" and put the P44_INCLUDE_SUMMARY_FIELD in the Expression 1 text box.
And I have to make it more readable like that when I do the dynamic SQL code:
IF: P44_INCLUDE_SUMMARY_FIELD is not null THEN
v_INCLUDE_SUMMARY_FIELD: = ' TBLCASES. SUMMARY summary ';
END IF;
v_sql: = ' select TBLCASES. RESEARCHER, researcher,
TBLCASES. CASENUMBER as CASENUMBER
TBLCASES. OPENDATE as OPENDATE,
TBLCASES. ESTCOMPLETE as DATE_CIBLE,
TBLCASES. STATUS of STATUS,
TBLCASES. Case CODE case CODE as,
TBLCASES. FAIR_HOTLINE as FAIRHotline,
TBLCASES. NYSIG as NYSIGCase,
TBLCASES. REGION as the region,
TBLCASES. PROGAREA as PROGArea,' |
v_INCLUDE_SUMMARY_FIELD |
' from TBLCASES where 1 = 1; ';
It will be useful,
BRITISH COLUMBIA
Tags: Database
Similar Questions
-
function() nested in the select statement
Oracle 11g. Try to nest a function within the select statement. Goal: get the average customer rating for each of the qualified user.
Select user_name, f_get_avg_cust_rating() "Notation.
of u, OTHER_TABLES o TAB_USER
where u.id = o.id and another condition matched;
How Oracle would deal with the sql. Is it
(1) first of all display records based on the where clause, then call the f_get_avg_cust_rating() for each of the selected records OR
(2) for the analysis in tables, the f_get_avg_cust_rating() will be called for each record met?
Thank you
Scott
Words of Frank, I created two functions with dbms_output and used a function in where clause in select another function. See the bottom of the unit tests. Everyone says, where first clause then select...
-Where function clause
SQL > CREATE or REPLACE FUNCTION ret_empno
2 RETURN NUMBER
3 AS
4 BEGIN
5 DBMS_OUTPUT. Put_line (' where Clause Function');
6 RETURN 7839;
7 END;
8.
The function is created.
-Select the function
SQL > CREATE or REPLACE FUNCTION ret_1
2 RETURN NUMBER
3 AS
4 BEGIN
5 DBMS_OUTPUT. Put_line ('Select function');
6 RETURN 1;
7 END;
8.
The function is created.
SQL > SELECT empno, ename,ret_1
2 FROM emp
3. WHERE empno = ret_empno;
EMPNO, ENAME RET_1
---------- ---------- ----------
7839 KING 1
Where the function Clause
Select the function
-
Update using a function in the select statement
Hello
Is it possible to do the follwing.
I tabele and a custom function, the custome service will update the column (amount) of the table based on the value of going through the function of the select statement.
SELECT id, stock, where an id = get_update (id);
Now
Get_update function will return the same id I'm passing and update the column amount to a value in the
table a.
When I run the satament selection I have the updated data in the column amount in my first executtion, but if execute the same statement, again, I see the changes reflected. is it possible to get data updates to the first performance himself.
the function is of type PRAGMA AUTONOMOUS_TRANSACTION
ConcerningIndeed a strange requirement and probably not the way to go in a production environment. But anyway is a way to achieve your goal
SQL> create table a as select 12 id, 500 amount from dual union all select 13 id, 600 amount from dual / Table created. SQL> create or replace type a_typ as object (id number, amount number) / Type created. SQL> create or replace function get_id (pid number) return a_typ is pragma autonomous_transaction; l_a_typ a_typ := a_typ (null, null); begin update a set amount = 800 where id = pid returning id, amount into l_a_typ.id, l_a_typ.amount; commit; return l_a_typ; end get_id; / Function created. SQL> select id, d.a_typ.amount amount from a, (select get_id (13) a_typ from dual) d where id = d.a_typ.id / ID AMOUNT ---------- ---------- 13 800 1 row selected.
-
How to pass parameter in the function using the select statement?
Hello
I had a problem. I can't pass as parameter to the function by using the select statement. But it can pass as a parameter using the "code". How can I solve this problem?
For example,.
Select * from table (SplitFunction ('HS750020, HS750021')) < < < this work.
but
Select * from table (SplitFunction (select LOT_NO in the TRACER_SEARCH_SCHEDULE where JOB_ID = '36')) < < < do not work.
Thank you for trying to help him. Thank you.Select * from table (SplitFunction (select LOT_NO in the TRACER_SEARCH_SCHEDULE where JOB_ID = '36'))< do="" not="">
Try like this
select * from table(select splitfunction(lot_no) from tracer_search_schedule where job_id='36')
Just make sure that your subquery returns only 1 row.
-
passing multiple values from the query in the select statement of the procedure
I am collecting IDS to select education agreement from the date of rental values and then I would pass the result of the query in the statement select to get the result.
data type for the contract id is of type varchar and date of rental there is more than one id to contract for most of the time. Help, please. Thank you
CREATE OR REPLACE PROCEDURE abstract_menu (p_letting IN VARCHAR2, p_results OUT SYS_REFCURSOR) IS v_contractId VARCHAR2 (40); SELECT lcontid INTO v_contractId FROM letprop WHERE datestat IS NOT NULL AND letting = p_letting AND letstat <> 'R'; BEGIN OPEN p_results FOR SELECT DISTINCT SUBSTR (l.letting, 3, 2) || '-' || SUBSTR (l.letting, 5, 2) || '-' || SUBSTR (l.letting, 1, 2) lettingdate, l.lcontid contractid, SUBSTR (q.cprojnum, 1, 10) projectnumber, DECODE (TRIM (MIN (j.route)), NULL, 'N/A', TRIM (MIN (j.route))) routenumber, L.DATESTAT statusdate, L.LETSTAT lettingstatus, (q.cdescr) jobdescription, INITCAP (q.clocat1 || q.clocat2) LOCATION FROM vendor v, vendaddr r, letprop l, planhold p, proposal q, project j, propproj k, bidlet bd WHERE v.vendor = r.vendor AND k.contid = q.contid AND k.pcn = j.pcn AND l.lcontid = k.contid AND p.vendor = v.vendor AND l.letting = p.letting AND l.lcontid IN v_contactid "**************This is where I would like to pass the contract id from the above select statement***********'" AND l.CALL = p.CALL AND r.addrnum = p.billto AND bd.letting = l.letting GROUP BY q.cdescr, q.clocat1, q.clocat2, bd.letting, l.letting, l.lcontid, q.cprojnum, L.LETSTAT, L.DATESTAT ORDER BY lettingdate; end;
user9196150 wrote:
AND l.lcontid IN v_contactid ' * this is where I would like to pass the id of the select statement above contract * ""»CREATE OR REPLACE PROCEDURE abstract_menu (p_letting IN VARCHAR2, p_results OUT SYS_REFCURSOR) IS BEGIN OPEN p_results FOR SELECT DISTINCT SUBSTR (l.letting, 3, 2) || '-' || SUBSTR (l.letting, 5, 2) || '-' || SUBSTR (l.letting, 1, 2) lettingdate, l.lcontid contractid, SUBSTR (q.cprojnum, 1, 10) projectnumber, DECODE (TRIM (MIN (j.route)), NULL, 'N/A', TRIM (MIN (j.route))) routenumber, L.DATESTAT statusdate, L.LETSTAT lettingstatus, (q.cdescr) jobdescription, INITCAP (q.clocat1 || q.clocat2) LOCATION FROM vendor v, vendaddr r, letprop l, planhold p, proposal q, project j, propproj k, bidlet bd WHERE v.vendor = r.vendor AND k.contid = q.contid AND k.pcn = j.pcn AND l.lcontid = k.contid AND p.vendor = v.vendor AND l.letting = p.letting AND l.lcontid IN ( SELECT ll.lcontid FROM letprop ll WHERE ll.datestat IS NOT NULL AND ll.letting = p_letting AND ll.letstat 'R' ) AND l.CALL = p.CALL AND r.addrnum = p.billto AND bd.letting = l.letting GROUP BY q.cdescr, q.clocat1, q.clocat2, bd.letting, l.letting, l.lcontid, q.cprojnum, L.LETSTAT, L.DATESTAT ORDER BY lettingdate; end; /
SY.
-
Production PL/SQL query: can not find the error
I have a PL/SQL which produces a query for me, which is used to fill out a report. I use this to supply a filter/search form. Since I want to only filter using xxx movies WHERE = yyy when yyy actually has something else NULL, I use a PL/SQL script in the query I need to produce. However, it does not work as expected and I can't understand why. Here is my code:
However, the report still contains all lines, as if P15_REGION has not been defined - and so I guess that the script never enters the IF part. Everyone around who can enlighten me, why it is?DECLARE query VARCHAR(1000); BEGIN query := 'SELECT * FROM F_OBJEKTE WHERE 1=1 '; IF :P15_REGION != null THEN query := query || 'AND REGION = :P15_REGION '; END IF; RETURN query; END;
Just another little thing: is there a way I can print debugging messages I see when I press the "Debug" button on the lower bar of APEX? It would help a lot of debugging such PL/SQL functions.Try changing
IF: P15_REGION! = null THEN
TO
IF: P15_REGION is not null THEN
-
SQL query for roll up the amounts from more down to the highest level
with data (select child 'C', 'P' as a parent, 11 amount of double
the Union all select 'C1', 'C',-2 double
Union all select 'C2', 'C', 3 double
the Union all select 'C3', 'C',-8 double
Union all select 'C4', 'C', 10 double
Union all select 'C11', 'C1', 7 double
the Union of all select them 'C12', 'C1', double 12
Union all select "C21", "C2", 5 double
Union all select "C22", "C2", 9 double
Union all select 'C31', 'C3', 6 double
the Union all select 'C32', 'C3',-4 double
the Union all select 'C41', 'C4',-3 double
the Union of all select them "C42', 'C4' 13 doubles
the Union of all select them "C111", "C11", 16 doubles
Union all select 'C121","C12", 8 double
) Select * from given by 2
Hi Experts,
I have the following table with the child-parent relationship which I would like to roll up from a lower to a higher level. The problem here is that I'm moving the level I should replace the amount for a parent with the overall value of his children and grand total aggregate amount should be c
For example; In the example given the c111 data roll up to c11 as 16 (Please note: the amount for c11 is 7 should not be added to 16 rather replaced by 16) that more should roll up to c1.
That means c1 = c11c12; c11 = c111 = 16 Yes, c1 = 16instread 12 16712.
Since it is an intermediate table, I don't have any control over how many levels it can contain.
So dynamically, I need a rollup query and group the amount of a lower to a higher level from the bottom.
Is this possible? I look forward to any help. Thanks in advance.
SQL > data
() 2
3. Select 'C' child, 'P' as a parent, 11 amount of double
4 union all select 'C1', 'C',-2 double
5 Union all select them 'C2', 'C', 3 double
6 Union all select them 'C3', 'C',-8 double
7 union all select 'C4', 'C', 10 double
8 union all select 'C11', 'C1', the double 7
9 Union all select 'C12', 'C1', 12 dual from
all the 10 union select "C21", "C2", 5 double
all the 11 union select "C22", "C2", 9 double
12 union all select 'C31', 'C3', 6 double
all the 13 union select 'C32', 'C3',-4 double
14 union all select 'C41', 'C4',-3 double
all the 15 union select 'C42', 'C4', 13 from dual
all the 16 union select 'C111","C11", 16 of the double
all the 17 union select 'C121","C12", 8 double
18)
19, data1
20 in accordance with
(21)
22 Select parent
23, child
24, lpad ('-', (level 1) * 3, '-'). parent tree_structure
25, amount
26, case when connect_by_isleaf = 1 then amount 0 otherwise end amount_leaf
27 data
starting 28 with parent = 'P '.
29 to connect
30 per parent prior child =
31)
32 Select parent as a node
33, tree_structure
34, amount_sum
35 of Data1
model 36
size 37 by
(38)
39 children
40, parent
41)
42 measures
(43)
44 amount_leaf as the amount
45, tree_structure
46, 0 amount_sum
47)
automatic control of 48 rules
(49)
50 amount_sum [none, none] = amount [cv (), cv ()] + nvl (sum (amount_sum) [all cv (child)], 0)
(51);ŒIL TREE_STRUCTURE AMOUNT_SUM BLINK
--- ------------------------- ----------
P P 50
C ---C 24
C1 ------C1 16
C11 ---------C11 16
C1 ------C1 8
C12 ---------C12 8
C ---C 14
C2 ------C2 5
C2 ------C2 9
C ---C 2
C3 ------C3 6
C3 ------C3 -4
C ---C 10
C4 ------C4 -3
C4 ------C4 1315 selected lines.
-
SQL query for data of the quarter... Help, please
Dear Experts,
Please help with this query...
I have data as below:
Year Quarter MRR MORR % ---- -------- --- ---- 2012 1ST QUARTER 10 Q2 30 Q3 50 Q4 60 2013 1ST QUARTER 20 Q2 30 Now I need to caluclate MORR % as column values below
for 2012 T2 MRR % = (Q2MRR-Q1MRR) / (30-10) Q1 * 100 / 10 * 100
for 2012, T3 MRR % = (Q4MRR-Q3MRR) / Q2 * 100
for 2012 T4 MRR % = (Q1MRR-Q4MRR) / Q1 * 100 here q1 2013 and the 4th quarter of 2012...
like this he wll go...
Please help with me query calculate values in the column % MRR.
Best regards
ASP.
Maybe NOT TESTED! No database at your fingertips
Select the year, quarter, mrr,.
ratio_to_report (q_mrr) on pct_mrr (partition by order of the year by quarter)
(select the year, quarter, mrr,)
MRR - lag (mrr, 1, 0) on q_mrr (partition by order of the year by quarter)
t
)
Concerning
Etbin
-
Is it possible to use the record type or a PL/SQL table in the Select statement
Hi all
My requirement is that.
I want to write a query and write a function, function, I want to return multiple columns at the same time in a Select statement.
I select the return values in the Select no statement in a PL/SQL block.
Is it possible to use the PL/SQL Table or Variable of Type record, or any other method in the statement Select?
Please help me understand the solution.
Kind regards830960 wrote:
do we like it?In general, Yes, if the function is a function table, you can do something like:
select t.col1, t.col2, f.col1, f.col2, f.col3 from table_name t, table(some_table_function(param1,...paramN)) f /
SY.
-
Body of function from PL/SQL query SQL - problem with where Cluase return
Hi all
I have problem with sub PL/SQL. Where clause does not filter the values even when I change the value: P7_INVESTIGATOR. I have marked with an asterisk for where clause where I want the values to filtered.
DECLARE
v_sql varchar2 (5000);
v_inv VARCHAR2 (100);
Start
v_inv: = UPPER(:P7_INVESTIGATOR);
v_sql: = ' select TBLCASES. INVESTIGATOR as an INVESTIGATOR,';
v_sql: = v_sql | "TBLCASES. CASENUMBER as CASENUMBER,';
v_sql: = v_sql | "TBLCASES. OPENDATE as OPENDATE,';
v_sql: = v_sql | "TBLCASES. ESTCOMPLETE as DATE_CIBLE,';
v_sql: = v_sql | "TBLCASES. STATUS of STATUS ';
v_sql: = v_sql | "TBLCASES. Case CODE case CODE as,';
v_sql: = V_sql | "TBLCASES. FAIR_HOTLINE as FAIRHotline,';
v_sql: = v_sql | "TBLCASES. NYSIG as NYSIGCase,';
v_sql: = v_sql | "TBLCASES. The REGION';
v_sql: = v_sql | "TBLCASES. PROGAREA as PROGArea ';
v_sql: = v_sql | ' from TBLCASES where 1 = 1';
**************************************************************
If v_inv <>null then
v_sql
: = v_sql | "and UPPER (trim (tblcases.investigator)) = UPPER (trim (v_inv))';
END IF;
***************************************************************
v_sql: = v_sql | "order by tblcases.investigator";
Return v_sql;
end;
Thank youwrote:
Or it is possible to write it this way:if v_inv is not null then v_sql := v_sql ||' and UPPER(trim(tblcases.investigator)) = UPPER(trim(:P7_INVESTIGATOR))'; END IF ;
In this case we will use bind variables and we all know that it is very important.
Lev
Of cause, it is the best option. and I strongly suggest the OP to use.
But it depends on how the sql is used later.
Without knowing that, we cannot be sure if the item is available here. -
Dear friends,
Version of DB - 11.1.0.7... , I'm stuck with SQL basics today... need your help...
The slot SQL tells me "cache them locks library" in the database that I will put up as a proactive measure.
I'll be it works via shell script and include the table gv instance_name $ instance ... I'm a little confused as to how a 3rd table "gv$ instance ' can be introduced into the query in order to make the instance_name in the result set...
SELECT * FROM)
SELECT / * + LEADING (a) USE_HASH (u) * /.
instance_name, INST_ID select, blocking_inst_id, blocking_session, username, session_id, sql_id, current_obj #,.
DECODE (sql_opcode, 1, 'CREATE TABLE', 2, 'INSERT') as "order."
Event, mod(P1,16) p1, p2, p3
COUNT (*) totalseconds
, SUM (CASE WHEN wait_class = 'Application' THEN 1 ELSE 0 END) 'Application '.
Of
(SELECT
a.*
, TO_CHAR (CASE WHEN session_state = 'WAITING' THEN ELSE null END p1, '0XXXXXXXXXXXXXXX') p1hex
, TO_CHAR (CASE WHEN session_state = "PENDING" THEN p2 ELSE null END, '0XXXXXXXXXXXXXXX') p2hex
, TO_CHAR (CASE WHEN session_state = "PENDING" THEN ELSE null END p3, '0XXXXXXXXXXXXXXX') p3hex
SGS $ active_session_history one) a
u dba_users
WHERE
a.user_id = u.user_id
AND sample_time BETWEEN sysdate-90 /(24*60) AND sysdate
- AND a test of ('library cache lock', 'library cache pin")
AND event like '% library '.
GROUP BY
INST_ID select, blocking_inst_id, blocking_session, username, session_id, sql_id, current_obj #,.
DECODE (sql_opcode, 1, 'CREATE TABLE', 'INSERT', 2),
event, mod (p1, 16), p2, p3
Having count (*) > 5
ORDER BY
TotalSeconds DESC
, INST_ID select, blocking_session, username, session_id, sql_id, current_obj #, 'Order', event
)
WHERE
ROWNUM < = 20
/
replace
instance_name
by
(select instance_name gv$ instance where INST_ID select = a.inst_id) instance_name
or select... in... a, u, gv$ instance where... and gv$ instance.inst_id (+) = a.inst_id...
-
SQL query to search for the line that contains the identifier for each consecutive group
Hello
I'm on 11.2.0.3 Enterprise Edition.
I have a strange request here - do not know if this is possible without going to procedure...
Given these data of the sample:
create table test_status ( status varchar2(10), revision_id number, revision_timestamp timestamp); insert into test_status values ('PROPOSED', 1, systimestamp); insert into test_status values ('PROPOSED', 2, systimestamp); insert into test_status values ('PROPOSED', 3, systimestamp); insert into test_status values ('ACTIVE', 4, systimestamp); insert into test_status values ('ACTIVE', 5, systimestamp); insert into test_status values ('PROPOSED', 6, systimestamp); insert into test_status values ('PROPOSED', 7, systimestamp); insert into test_status values ('ACTIVE', 8, systimestamp); insert into test_status values ('ACTIVE', 9, systimestamp); insert into test_status values ('FINISHED', 10, systimestamp); insert into test_status values ('FINISHED', 11, systimestamp); insert into test_status values ('FINISHED', 12, systimestamp);
Gives me:
SQL> select * 2 from test_status 3 order by revision_id; STATUS REVISION_ID REVISION_TIMESTAMP ---------- ----------- ----------------------------- PROPOSED 1 25-SEP-14 04.49.47.954000 PM PROPOSED 2 25-SEP-14 04.49.47.962000 PM PROPOSED 3 25-SEP-14 04.49.47.966000 PM ACTIVE 4 25-SEP-14 04.49.47.969000 PM ACTIVE 5 25-SEP-14 04.49.47.972000 PM PROPOSED 6 25-SEP-14 04.49.47.976000 PM PROPOSED 7 25-SEP-14 04.49.47.979000 PM ACTIVE 8 25-SEP-14 04.49.47.982000 PM ACTIVE 9 25-SEP-14 04.49.47.987000 PM FINISHED 10 25-SEP-14 04.49.47.991000 PM FINISHED 11 25-SEP-14 04.49.47.996000 PM FINISHED 12 25-SEP-14 04.49.48.000000 PM 12 rows selected. ws selected.
I want to get this result:
STATUS REVISION_ID REVISION_TIMESTAMP ---------- ----------- ---------------------------- PROPOSED 3 25-SEP-14 04.49.47.966000 PM ACTIVE 5 25-SEP-14 04.49.47.972000 PM PROPOSED 7 25-SEP-14 04.49.47.979000 PM ACTIVE 9 25-SEP-14 04.49.47.987000 PM FINISHED 12 25-SEP-14 04.49.48.000000 PM
Then query the table ordered by Revision_Id, I would get the line containing the highest revision for each consecutive group of status values. I am able to get the line containing the highest revision for each separate status, value, but I can't deal with the scenario where a state value reappears later. In the case of the real world, it is a workflow and I need to take into account the fact that an element through the workflow may be redirected to the back front she proceeds forward again.
Hope it makes sense.
Thank you
John
Hi, John,.
John OToole (Dublin) wrote:
Hello
I'm on 11.2.0.3 Enterprise Edition.
I have a strange request here - do not know if this is possible without going to procedure...
...
Do not no stinkin' procedure:
WITH got_grp_id AS
(
SELECT the status, revision_id, revision_timestamp
ROW_NUMBER () OVER (ORDER BY revision_id)
-ROW_NUMBER () (PARTITION STATUS
ORDER BY revision_id
) AS grp_id
OF test_status
)
SELECT status
MAX (revision_id) AS revision_id
MAX (revision_timestamp) DUNGEON (DENSE_RANK LAST ORDER BY revision_id)
AS revision_timestamp
OF got_grp_id
GROUP BY status, grp_id
ORDER BY revision_id
;
For an explanation of the technique of Difference sets used here, see
-
SQL query to find out the version of discoverer
Hello
As a developer, is there a query sql DB the dorsal (or script) that can be run on DB to find out the version of Oracle Discoverer installed?
The query will be different if the discoverer is used with the Oracle Applications (R12.1.3) compared to a Scout running on a plain stand alone Oracle database (Oracle applications not)?
Thank you
GG.Hello gg
The VER_NAME and the VER_DESCRIPTION are usually never filled and can be ignnored.
The VER_RELEASE is the NLY version as you rightly summised. This version is 100% compatible with the discoverer 11g and if you already have it you can go from 10g to 11g without changing anything in the EUL
VER_MIN_CODE_VER is the minimum version of Oracle Discoverer which can be used with this EUL. In this case, 10.1.2.45.20 is 10g Release 2
VER_EUL_TIMESTAMP is the date and time, this version of the EUL was published by Oracle - again you can ignore it
Important fields are VER_RELEASE and VER_MIN_CODE_VER
Hope this helps
Best wishes
Michael -
SQL query date with century / year
We have a database of oracle with about 6 million documents. There is a date field called Date entered from 1985 to the present day.
Most of these recordings was entered into before January 1, 2000.
If I run a query like
Select count (*) (TableName) where entered_date < 1 January 00 ' I get 0
If I do
Select count (*) (TableName) where entered_date < 31 December 99 ' I get 0
BUT IF I DO
Select count (*) (TableName) where entered_date < 1 January 00 ' get 6 million documents
or
Select count (*) in the TREASURY.ctrc where entrydate > 31 December 99 ' get 6 million documents
I tried the same queries using 4 digit years but get the same results. He thinks that 2000 is at least 1999
How to do this?
Thank youHello
975204 wrote:
There are 6 million documents on the table
about two-thirds have a date prior to 1 January 2000How do you know this? Knowledge of the application, you can find out that two-thirds of them are supposed to have dates from before 2000, but if
SELECT COUNT (*) FROM TABLE_NAME WHERE ENTRYDATE < TO_DATE ( '01-JAN-2000' , 'DD-MON-YYYY' ) ;
Returns the value 0, which has strong enough evidence that none of them actually do.
When I look at the dates, they appear as December 31, 86
Another example of why use 2 digit years is a bad idea.
I can't actually provide these confidential customer data dump
Seriously; You can provide an output DUMP? You already said that it displays as December 31, 86, so even if the fact that 1 entry in the table of the line 6 million was made on December 31, 1986 was such a big secret, he is already out, and you don't cause any harm more by showing the results of DUMP.
I ran the query with the same format as the date, that is to say
SELECT COUNT (*) FROM THE DEPARTMENT OF FINANCE. CRTC WHERE ENTRYDATE< to_date="" (="">
"DD-MON-YY."
)but same results
If the column is defined as a DATE type, Oracle made a distinction based on the way the data is displayed, which means that she think that December 31, 86 is different from December 31, 1986?No, all the DATE columns have the same format. A DATE can be displayed in one way of the other, but it is stored in the form of or.
Should I convert all the data from one year to 4 digits?
A 4-digit year dates should be always displayed.
Run an update query that said if year > = 80 and<= 99="" add="" 19="" in="" front="" of="" the="" year,="" else="" add="" 20="" in="" front="" of="" the="">=>
We will find out exactly what the problem is, first of all.
Have you seen the Ascheffer message? ^ 1 ^ it was dated just a couple of minutes before your last post, so you might not notice. Run it to see what are the years of 4 real numbers.
If it shows, for example, there are a lot of entrydates in the years 2080 to 2099, and if you decide that all who should really be 100 years earlier, use ADD_MONTHS to remedy:UPDATE table_name SET entrydate = ADD_MONTHS ( entrydate , -100 * 12 ) WHERE entrydate >= TO_DATE ( '01-JAN-2080' , 'DD-MON-YYYY' ) AND entrydate < TO_DATE ( '01-JAN-2100' , 'DD-MON-YYYY' ) ;
Published by: Frank Kulash, 15 March 2013 18:09
^ 1 ^ you see of course, message Ascheffer; I was still typing the message above when you posted another.
-
SQL query: How to list the values in the IN operator
Hello
I'm going through a list of values to the location of < > in < list >
I don't want to use dynamic cursors (REF CURSOR). Is this possible using Oracle SQL?
Please let me know.
My program:
DECLARE
...
list_of_ids: = '10, 20, 30';
...
SELECT MAX (sal) IN the max_sal FROM Employees WHERE emp_id IN (list_of_ids);
...
END;
/
Thanks in advance,
NikoYou do not want a list separated by commas. You want to move a collection. Then
CREATE TYPE num_tbl AS TABLE OF NUMBER; DECLARE l_list_of_ids num_tbl := num_tbl( 10, 20, 30 ); BEGIN ... SELECT max(sal) INTO max_sal FROM employee WHERE emp_id IN (SELECT * FROM TABLE( l_list_of_ids )); ... END; /
Justin
Maybe you are looking for
-
Hi, I just bought a 6 s, 16 gb iphone, but I notice im short of storage so I start searching the web, some pages to say that you can change the iphone and pay the difference, but I prefer to ask here, can I really change my iphone to get better stora
-
Communication between LabVIEW and MCU based on Modbus Protocol
Hello I am a first year student in the port.and series applications see you, my projiect needs to communicate between LV and MCU based on Modbus Protocol.all configure it are correct, but the lv to send false information which is not suitable for mod
-
XPS from Dell with Vista system
I have a XPS from Dell with Vista system. When the computer enters standby mode, it continues to run and does not respond when you click the mouse or press a key on the keyboard. I have to turn off the computer and then it takes about 20 minutes be
-
A person called and said sending error messages computer and they can repair only by phone
Why did someone Windows is calling to tell me that my computer sends error messages and only they can fix it over the phone? Is anyone of windows or another? Please write me back
-
Cannot access shared folders WRT610N
I have an external hard drive (Seagate FreeAgent) formatted with a single NTFS partition. I created two new users, two new groups (one for each user) and two new actions (also one for each user). When you try to map a network share or user is able