...continued from "Problems with full outer join"I think that ANSI joins in Oracle doesn't work correctly. Or am I doing something wrong? The query looks like this:
It's a full outer join between one table (with a subquery) and an inline view with two tables You can see the returned rows in the listing below. The query returns one row where there is a match between t_trans and t_kontoavst.It also returns two rows from table t_kontoavst with no correspondence in t_trans.Finally it returns 26 rows from the table t_trans with no correspondence in t_kontoavst. But among them there are many rows in contradiction to the conditions:
and trunc(dat_trans) >= to_date('20040101','yyyymmdd')
and trunc(dat_trans) <= to_date('20050604','yyyymmdd')
Actually it seems to return all the 27 rows in t_trans (one of them joined to t_kontoavst).These conditions are actually not part of the join so I changed it to:
where trunc(dat_trans) >= to_date('20040101','yyyymmdd')
and trunc(dat_trans) <= to_date('20050604','yyyymmdd')
It's not clear to me if this where condition belongs to the joined result or just to the right joined inline view.With this change the correct rows from t_trans where returned but unfortunately the two rows from t_kontoavst with no correspondence in t_transdisappeared. I thought maybe that is because dat_trans is null for these two rows after the join. Therfore I also includeddat_trans to be null. This can only happen when t_trans is missing
where dat_trans is null
or (trunc(dat_trans) >= to_date('20040101','yyyymmdd')
and trunc(dat_trans) <= to_date('20050604','yyyymmdd'))
But that didn't change the result I have also tried right and left joins and it produces similar errors.One other thing i tried was to replace the inline view with one of the underlying tables t_trans. But the result was the same.Data returned from the original query (see query above):
Use ANSI standard JOIN syntax for example i have this code.
SELECT resv_num, unit_date FROM p_resv_unit ru, p_pm_unit_night pun WHERE pun.property_id = in_property_id AND pun.pm_unit_num = cvUnitNum AND pun.unit_date BETWEEN start_date AND end_date AND pun.resv_unit_id = ru.resv_unit_id;
[code]....
and is it a good idea to change it, because both ways it works?
I don't understand why the custid is the same for each customer, and why it's selecting every customer and not just those with more than 150 gallons ordered.
For this one use the oil tables that you set up and use a subquery. Select the minimum average fall use from the house table. Then show all customers whose number of gallons delivered times two is greater than the minimum.
To rewrite this sql which is in ANSI 92 standard to ANSI 89 standard.
SELECT "PROJECT"."X_SAMPLED_DATE", SAMPLE"."SAMPLE_NUMBER" FROM "SHIRE_PRD"."LimsUser"."SAMPLE" "SAMPLE" INNER JOIN "SHIRE_PRD"."LimsUser"."PROJECT" "PROJECT" ON"SAMPLE"."PROJECT"="PROJECT"."NAME" WHERE ("SAMPLE"."SAMPLE_TYPE"='EM' OR "SAMPLE"."SAMPLE_TYPE"='WATER') AND "SAMPLE"."STATUS"<>'X' AND("PROJECT"."X_SAMPLED_DATE">={ts '2011-05-01 00:00:00'} AND "PROJECT"."X_SAMPLED_DATE"<{ts '2011-06-01 00:00:00'}) ORDER BY "SAMPLE"."PRODUCT"
i running a sql-query in visual studio 2005 with the oracle dataset. currently my datetime is in format mm/dd/yyyy hh:mm:ss. I wish to split the datetime in dd/mm/yyyy only(without the hh:mm:ss)
EXEC (' SELECT XNP_TIMER_VIOLATION.VIOLATION_TIME,.. FROM XNP_TIMER_VIOLATION,.. ) AT npcrpt ;
merge into merge_st t using (select * from merge_st1) src on (t.id=src.id(+)) when matched then update set name=src.name;
I need to convert oracle joins to ANSI joins. I have tried below
update (select t1.name as t1_name,t2.name as t2_name from merge_st t1 lef outer join merge_st t2 on(t1.id=t2.id)) set t1_name=t2_name;
It statements shows error like cannot modify the non key preserved tables.I have cheked these table has contains whether primary key or not.there is no constraints for these tables.Our application, constaints handle in front end. so we cannot create any constraints in oracel database.how to convert oracle joins to ansi join?
have two queries that will return same columns from two different set of tables ( column mapping has been taken care of). The return type is out ref cursor. (P_SUPPLY_REORDER )
Query-2 Xcom -------------------------------------- select null as sMO_NO, xso.created_date as SPLY_ORD_DT, xso.fk_cust_id as cust_id, cust.cust_po_no as cust_PO_NO ,(sta.SHIP_TO_ATTN_FIRST_NAME||''||sta.SHIP_TO_ATTN_LAST_NAME) as attention_name, xsol.CARTONS_ORDERED as SPLY_ORD_QTY, [code].......
Now the requirement is One of four conditions are possible for each Supply Reorder Number:
. Both table queries return no records- Populate all the P_SUPPLY_REORDER output fields with nulls . SUPPLY_ORDER returns a record, but XCOM_ORDER_HEADER returns no records - Populate output fields with values from the join of SUPPLY_ORDER and SUPPLY_ORDER_LINE. . SUPPLY_ORDER returns no records, but XCOM_ORDER_HEADER returns one record - Populate output fields with values from the join of XCOM_ORDER_HEADER and XCOM_ORDER_LINES. . SUPPLY_ORDER returns a record, and XCOM_ORDER_HEADER returns a record; find out the latest order by comapring max(SPLY_ORD_DT) from SUPPLY_ORDER with max(CREATED_DATE) from XCOM_ORDER_HEADER. - If the latest order is in SUPPLY_ORDER, then populate output fields with values from the join of SUPPLY_ORDER and SUPPLY_ORDER_LINE. - If order dates are equal from both join results, then populate output fields with values from the join of SUPPLY_ORDER and SUPPLY_ORDER_LINE. - If the latest order is in XCOM_ORDER_HEADER, then populate output fields with values from the join of XCOM_ORDER_HEADER and XCOM_ORDER_LINES.
Question is how can we switch over the queries to pull respective dataset based on these conditions ( checking that which table join is going to return a row and then based upon latest order if both tables return a row) and all this logic as part of single SQL statement that is returned as OUT Ref Cursor.
i'm newbie in oracle and visual studio 2005..i running a sql-query in visual studio 2005 with the oracle dataset..i want the data that displayed is in the date range and the parameter is set by user..
I am using an query to fetch the data from oracle DB and fill dataset using oledb dataadapter in ASP.net.When i run the same query in PL/SQL i am getting 14952 records,but when i am filling it to dataset i am getting only 13700 records.
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 Microsoft Visual Studio 2010 : VB Express Microsoft .NET Framework : Version 4.0.30319 RTMRel
When I populate dataset using select query and use OracleCommandBuilder and update dataadapter, data is saved in database.
But if I put same select in store procedure and use this to populate dataset then data is not updated in db.
I get this error
Update requires a valid UpdateCommand when passed DataRow collection with modified rows.
at da1.Update(ds1, "req") where I am going wrong.
Dim conn As New OracleConnection Dim da1 As OracleDataAdapter = New OracleDataAdapter Dim ds1 = New DataSet With conn If .State = ConnectionState.Open Then .Close()
I have database jobs that upload the data in my applications.My problem is while copying the record of one application to another, the format of dates goes wrongFor example:
The date in one column is 01-JAN-1941 but in the other record while copying ot goes as 01-JAN-2041.
I have a strange problem with query with like and %.
When I run this script:
ALTER SESSION SET NLS_SORT = 'BINARY_CI'; ALTER SESSION SET NLS_COMP = 'LINGUISTIC'; -- drop table test1; CREATE TABLE TEST1(K1 NVARCHAR2(80)); INSERT INTO TEST1 VALUES ('gsdk');
When i change datatype in column to varchar2 this code work correct.
The execution plan:
PLAN_TABLE_OUTPUT SQL_ID d3d64aupz4bb5, child number 2 select * from TEST1 where k1 like N'Ł%' Plan hash value: 4122059633 Id Operation Name Rows Bytes Cost (%CPU) Time 0 SELECT STATEMENT 2 (100) * 1 TABLE ACCESS FULL TEST1 1 82 2 (0) 00:00:01
I have one issue My server is in france and it is in french timezone but when I query for sysdate it returns US time.
In '/etc/sysconfig/clock/' Zone= europe/paris UTC= true
echo $TZ variable is returning nothing.
sysdate = us time systimestamp= us time current_timestamp = french time current_date = french time dbtimezone= europe/warsove, sessiontimezone=+2.00( which is also europe timezone offset) tz_offset(dbtimezone)=+2.00, tz_offset(sessiontimezone)= +2.00 i.e europe os timezone= europe/paris.
This command "./emctl config agent getTZ" is also returning timezone as europe/paris
Also in "emd.properties" file "agentTZRegion" parameter is set to europe/paris
Oracle version= 11.2.0
Now I don't understand why this sysdate and systimestamp is returning "US time zone" while everything else is returning french time zone.
I am using pipelined functions. I've written a few with no problem this one seems to be giving an error when I am using techniques that appear very similar to ones that work.
I am doing this all in a package;
The type definition is;
TYPE SUSPECT_LINKAGES_FAC_RECORD IS RECORD ( PATIENT_ID TUMOR.TUMOR_PATIENT_ID%TYPE, CENTRAL_SEQ TUMOR.TUMOR_CENTRAL_SEQ%TYPE, MP_REVIEW_FLAG NUMBER(1), FACILITY_FLAG NUMBER );
The variable definition is;
OUT_REC SUSPECT_LINKAGES_FAC_RECORD;
The line with the error is;
PIPE ROW(OUT_REC);
This is the entire function;
FUNCTION GET_SUSPECT_LINKAGE_FAC_FLAGS RETURN SUSPECT_LINKAGES_TABLE PIPELINED AS CURSOR CURS_SUSPECT_LINKAGES IS SELECT * FROM TABLE(TUMOR_UTILITIES.GET_SUSPECT_LINKAGE_FLAGS()) order by 1,2,3 DESC; TEMP_REC SUSPECT_LINKAGES_RECORD; MATCH_COUNT NUMBER; OUT_REC SUSPECT_LINKAGES_FAC_RECORD;
[code].....
I get "PL-00382 expression is of wrong type" on both pipe row (out_rec); lines.
I have a strange problem with query with like and %.
When I run this script:
ALTER SESSION SET NLS_SORT = 'BINARY_CI'; ALTER SESSION SET NLS_COMP = 'LINGUISTIC'; -- SELECT * FROM NLS_SESSION_PARAMETERS; -- drop table test1; CREATE TABLE TEST1(K1 NVARCHAR2(80));
[code]....
When i change datatype to varchar2 this code work correct.
The execution plan:
PLAN_TABLE_OUTPUT ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ SQL_ID d3d64aupz4bb5, child number 2 ------------------------------------- select * from TEST1 where k1 like N'Ł%'
[code]....
Note - dynamic sampling used for this statement (level=2)
I have a show/hide region of type HTML with empty region source which I use to show/hide a subregion (tabular form)because I don't like the layout of a show/hide region when it is shownthis worked without a problem in APEX 4.1.1
however in 4.2 the tabular form is just a couple of pixels widehave been playing around with grids but can't seem to find the right combination of settingsthe layout is messed up
I put the app on apex.oracle.com : workspace : xonixrs login/password : demo/demo
We have a bunch of jobs scheduled using DBMS_JOB (yes, I know I should be using DBMS_SCHEDULER, but we haven't migrated there yet). We are running Oracle 11.2.0.3 on Windows Server 2003 x64.
For example, we have a job that is supposed to run every Wednesday at 20:00. The Interval we have set up is "NEXT_ DAY (TRUNC(SYSDATE), 'WEDNESDAY')+20/24". This has been working as intended. Today (Monday), however, the job kicked off at 11:52. It was the wrong day and the wrong time.
I don't see anything weird in my alert log. Where else should I check to figure out why this job ran today?
JOB LAST_DATE LAST_SEC NEXT_DATE NEXT_SEC INTERVAL WHAT 293 1/7/2013 11:52:46 AM 11:52:46 1/9/2013 8:00:00 PM 20:00:00 NEXT_DAY(TRUNC(SYSDATE), 'WEDNESDAY')+20/24 ACQUISITIONS.WORKLOAD_STATUS_UPDATE_NOTIF;
I have an issue trying to execute some queries using a dblink. When i run any query with numeric fields only display 4 digit and int the source database the fields have 5 digit. The dblink work between ans MSSQL database to an Oracle Database
Example: MSSQL select cardnumber from card cardnumber 19121 19122
Oracle (with dblink) select cardnumber from card@dblink1 cardnumber 1912 1912
I'm trying to call a custom made PL/SQL function in a SQL query. I want to supply the values of the parameters during the query. I can call the function if I "hard code" the parameter values, but when I try to supply them I get the ORA-06553 error.
This call works:
select pkg_tm_import_util.wb_screen_hr_refresh_func('','','','','','','','','','','','') from dual
However, this does not, but should be the same as the call that works: