SQL and PL/SQL show different results.
I checked the following behaviors using various tools/applications.
If you run the following SQL:
procedure GetDurchschnAlterGes (reference date, cur_Besch to t_CURSOR) is
Start
Open the cur_besch FOR
Select i.anztext AS 'Amt. "
r.anztext AS "Revier."
OE.anztext AS 'Sachgebiet. "
g.anztext AS 'Einheit ',.
t.anztext AS "Teileinheit."
Count (*) AS 'Anzahl total.
ADaten mi,
AKalender KAL,
AInspektion I,.
ARevier R,.
Aoeausdruck OE,
AGruppe G,.
ATeileinheit T
WHERE kal.datum = reference
-Join Kalender
AND mi.idkalender = kal.id
-Join auf - Inspektion
AND I.ID = MI. INSPEKTIONID
-Join auf Revier-
AND R.ID = MI. REVIERID
-Join auf OE-
AND oe.ID = MI.idoeausdruck
-Join Group
AND G.ID = MI. GRUPPEID
-Join Teileinheit
AND T.ID = MI. TEILEINHEITID
-Group OF the st. OEAUSDRUCK, bv.anztext, kg.kattext;
Group BY grouping sets ((i.anztext, r.anztext, oe.anztext, g.anztext, t.anztext), (i.anztext, r.anztext, oe.anztext, g.anztext), (i.anztext, r.anztext, oe.anztext), (i.anztext, r.anztext), (i.anztext))
order of i.anztext, r.anztext, oe.anztext, g.anztext, t.anztext;
end GetDurchschnAlterGes;
I get a count for "i.anztext" which is the number of set of records in the table "ADaten".
Using this SQL, the results are correct.
Select i.anztext AS 'Amt. "
r.anztext AS "Revier."
OE.anztext AS 'Sachgebiet. "
g.anztext AS 'Einheit ',.
t.anztext AS "Teileinheit."
Count (*) AS 'Anzahl total.
ADaten mi,
AKalender KAL,
AInspektion I,.
ARevier R,.
Aoeausdruck OE,
AGruppe G,.
ATeileinheit T
WHERE kal.datum = to_date ('15.01.2003 ',' JJ.) MM.yyyy')
-Join Kalender
AND mi.idkalender = kal.id
-Join auf - Inspektion
AND I.ID = MI. INSPEKTIONID
-Join auf Revier-
AND R.ID = MI. REVIERID
-Join auf OE-
AND oe.ID = MI.idoeausdruck
-Join Group
AND G.ID = MI. GRUPPEID
-Join Teileinheit
AND T.ID = MI. TEILEINHEITID
Group BY grouping sets ((i.anztext, r.anztext, oe.anztext, g.anztext, t.anztext), (i.anztext, r.anztext, oe.anztext, g.anztext), (i.anztext, r.anztext, oe.anztext), (i.anztext, r.anztext), (i.anztext))
order of i.anztext, r.anztext, oe.anztext, g.anztext, t.anztext;
The only difference is that the parameter 'Date' is not used and a constant value is passed.
Could someone pls check and possibly give me a clue what I'm doing wrong?
Thank you in advance.
Thomas
> kal.datum = reference
Variable has the same name as the column name.
Change the name of the variable or the prefix with the scope, for example "GetDurchschnAlterGes.datum".
Tags: Database
Similar Questions
-
V$ SQL shows erratic results for extract folder
Hello
I came across a scenario where the gathering statistical table checking its value of cursor.
I have here for the first time (line 02) queries the table V$ SQL I have only one entry of the cursor.
And then when I again run same sql and checked V$ SQL again what I got is another record (line 27) for the same SQL_ID.
Yet once I check it twice more, but all I got is only two records.
I was questioning this table for this kind of scenario for a week.
But this is the first time I've had two records in the table V$ SQL for same SQL_ID
Your contribution would be very appreciated.
SQL> --See first excution, it'll illustrate Hard parse, first load and execution SQL> select count(1) from foo31; COUNT(1) ---------- 23 SQL> select child_number,executions,parse_calls,loads,invalidations from v$sql t where upper(sql_text) like '%SELECT COUNT(1) FROM FOO31'; CHILD_NUMBER EXECUTIONS PARSE_CALLS LOADS INVALIDATIONS ------------ ---------- ----------- ---------- ------------- 0 1 1 1 0 SQL> --Second excution, then showed soft parsing SQL> select count(1) from foo31; COUNT(1) ---------- 23 SQL> select child_number,executions,parse_calls,loads,invalidations from v$sql t where upper(sql_text) like '%SELECT COUNT(1) FROM FOO31'; CHILD_NUMBER EXECUTIONS PARSE_CALLS LOADS INVALIDATIONS ------------ ---------- ----------- ---------- ------------- 0 1 1 1 0 0 1 1 1 0 SQL>
You did not include the sql code in your query. How do we know that you don't see two pieces of identification different sql in your results?
-
Screen and keyboard are showing different letters
as the title suggests some letters are mixed up when I type someone can help thanks.
What language do you use for your type of keyboard? I know that in Widows XP I had the same problem when you try to use the Romanian. Z Y and Z and so on.
-
Original printer disk is Dell V515w but I lost it. A friend installed a DellV310-V510 series. I can't use my fax machine. How can I download original disc on my computer.
Select your model of printer on the Dell support site, then download and install the drivers:
http://www.Dell.com/support/drivers/DriversHome/NeedProductSelectionTo see if you have Windows 32 or 64-bit:
- Open system by clicking the Start button, right-click computer, and then clicking Properties.
- Under system, you can view the type of system, it will say 32 or 64 bits.
Vista - add a printer:
http://Windows.Microsoft.com/en-us/Windows-Vista/add-or-remove-a-printer -
Msinfo32 and Device Manager show different number of cpu in win 2008 R2 guest OS
Hello group,
This inconsistency happened only on a single server running windows 2008 r2.
Poster 6vCPU Device Manager but the msinfo32 only 4.
Could you please guide me in the right direction on how to understand this situation/problem.
I checked the msconfig and some other items, but before making the changes, I would like to know if its designed that way in any specific combination.
Kindly let me know if you need further details to help me understand the process or the issue in the case.
Thank you.
What edition of Windows Server 2008 R2 do you have? If it is standard, so it has 4 CPU limit.
-
I changed the banner images. It was modified in dreamweaver, but browsers of the source of the page shows the old image. I save after I edited the new codes. Thank you
You have downloaded the new images on the server?
-
SQL query return different result 11 GR 1 material and GR 11, 2
Problem: SQL returns different results in 11 GR 1 material and GR 11, 2 games.
Example script:
create the table tab_main
(
SOS number (2) not null,
contract number (2) null
)
/create the table tab_sub
(
number (2) of contract non-null,.
SOS number (2) null
)
/insert into tab_main values (1, 10);
insert into tab_main values (2, 20);
insert into tab_main values (3, null);
insert into tab_main values (4, null);insert into tab_sub values (1, 10);
insert into tab_sub (20, 2) values;
commit;The SQL code:
SELECT *.
OF tab_main.
tab_sub
WHERE tab_main.sos = tab_sub.sos (+) AND
tab_main. Contract = tab_sub.contract (+) and
tab_main. Contract not in (select 1 of the double);The above query gives more results
-by 11.2.0.4
1 10 10 1
2 20 20 2-in 11.1.0.7
1 10 10 1
2 20 20 2
4
3
Please tell us what could be the reason for the behaviour of offset lines thie.
Thank youPiesset
I think it is probably a bug in 11.1.0.7 (and possibly other versions), I get the same results as your 11.2.0.4 9.2.0.7, 10.2.0.3 and 11.2.0.3, and this is the result, I expect.
Your not in the paragraph is equivalent to:
SELECT *.
OF tab_main, tab_sub
WHERE tab_main.sos = tab_sub.sos (+) AND
tab_main. Contract = tab_sub.contract (+) and
tab_main. Contract <> 1;
Since you have null values in tab_main.contract they are lost by the predicate since null = value is never true (or false).
John
-
Different results of exactly the same query
Hello
I wrote a function to calculate the days between 2 dates. If I am running in SQL Developer or directly on the oracle server, I get the results I expected. However, if I run on a client by using ODBC, or PHP connection via the OCI8 extension, I get an incorrect result.
The function takes 2 parameters: 1st and 2nd date and should output the number of non-working days (weekends and holidays) between 2 dates. The coding is not very pretty, but it does not work very well as I said since the client SQL Developer.
Here is the code:
The problem is only with certain dates. For example, if I use the date '17-SEP-2012' for the two input parameters, I'm waiting for a result draw. In the SQL Developer client, I get the expected result. However, using ODBC or PHP OCI8 (which I believe is using a direct connection to TNS in the DB), the result returned is '1', which is incorrect ("17-SEP-2012" has been a MONDAY ""). If I use the current date (20-SEP-2012), I get the expected (zero) result in both the SQL Developer client and ODBC/PHP client.create or replace FUNCTION NON_WORKDAYS(fromdate IN DATE, todate IN DATE) --Function to calculate non working days between 2 given dates (Weekends & Bank Holidays) --Update: Added in a calendar for bank holidays. Bank holidays are listed to the end of 2013 RETURN NUMBER IS BANK_HOLS NUMBER; ret NUMBER; BEGIN SELECT count(mydate) INTO ret FROM (SELECT TO_DATE (fromdate, 'dd-mon-yyyy hh24:mi:ss') + LEVEL - 1 mydate FROM DUAL CONNECT BY LEVEL < = TO_DATE (todate, 'dd-mon-yyyy hh24:mi:ss') - TO_DATE (fromdate, 'dd-mon-yyyy hh24:mi:ss') + 1) WHERE TO_CHAR (mydate, 'DY') IN ('SAT', 'SUN'); select count(mydate) into BANK_HOLS from ( SELECT TO_DATE (fromdate, 'dd-mon-yyyy hh24:mi:ss') + LEVEL - 1 mydate FROM DUAL CONNECT BY LEVEL < = TO_DATE (todate, 'dd-mon-yyyy hh24:mi:ss') - TO_DATE (fromdate, 'dd-mon-yyyy hh24:mi:ss') + 1 ) WHERE TO_CHAR (mydate, 'DD-MM-YYYY') IN ('03-01-2011', '22-04-2011', '25-04-2011', '29-04-2011', '02-05-2011', '30-05-2011', '29-08-2011', '26-12-2011', '27-12-2011', '02-01-2012', '06-04-2012', '09-04-2012', '07-05-2012', '04-06-2012', '05-06-2012', '12-07-2012', '27-08-2012', '25-12-2012', '26-12-2012', '01-01-2013', '29-03-2013', '01-04-2013', '06-05-2013', '27-05-2013', '12-07-2013', '26-08-2013', '25-12-2013', '26-12-2013' ); ret:= ret + BANK_HOLS; RETURN ret; end;
I also tried to use variants of SYSDATE in place and place the date string, to see if I get different results (i.e. today is 20-SEP-2012, so I used SYSDATE-3 to 17-SEP-2012).
To be clear, I call the function in a select statement: select (sysdate-3, sysdate-3) non_workdays of the double; or select non_workdays (TO_DATE('17-SEP-2012'), TO_DATE('17-SEP-2012')) of double;
I have spent hours and hours of troubleshooting this, and it makes me crazy!
I also checked the view V$ SQLAREA the Oracle DB to see what is actually passed to the ODBC client database engine. I was expecting the statement became corrupted somehow, that's why I get strange results, but this was not the case. The statement in the column SQL_FULLTEXT of V$ SQLAREA, showed exactly the statement I performed on the ODBC Client. I tried with the oracle instantclient and full client (10g).
Can someone help save my sanity please? I am eternally grateful!
Sorry for the massive post!
Published by: user12199535 on 20-Sep-2012 12:20Your code is a mess. You convert DATE to DATE, e.g. TO_DATE (fromdate, 'dd-mon-yyyy hh24:mi:ss'). TO_DATE function first parameter is a string, while fromdate is the date. That's why Oracle implicitly converts fromdate to the string of default date format that is client dependent and therefore can produce different results on different customers boxes. In addition, your code is dependent on NLS. If the customer has other date language settings, for example German, Sun and SAT are false. And there is no need to separately calculate the weekends and holidays:
create or replace FUNCTION NON_WORKDAYS(fromdate IN DATE, todate IN DATE) --Function to calculate non working days between 2 given dates (Weekends & Bank Holidays) --Update: Added in a calendar for bank holidays. Bank holidays are listed to the end of 2013 RETURN NUMBER IS BANK_HOLS NUMBER; ret NUMBER; BEGIN SELECT count(mydate) INTO ret FROM ( SELECT trunc(fromdate) + LEVEL - 1 mydate FROM DUAL CONNECT BY LEVEL < = trunc(todate) - trunc(fromdate) + 1 ) WHERE TO_CHAR(mydate,'DY','NLS_DATE_LANGUAGE = ENGLISH') IN ('SAT','SUN') OR mydate IN ( DATE '2011-01-03', DATE '2011-04-22', DATE '2011-04-25', DATE '2011-04-29', DATE '2011-05-02', DATE '2011-05-30', DATE '2011-08-29', DATE '2011-12-26', DATE '2011-12-27', DATE '2012-01-02', DATE '2012-04-06', DATE '2012-04-09', DATE '2012-05-07', DATE '2012-06-04', DATE '2012-06-05', DATE '2012-07-12', DATE '2012-08-27', DATE '2012-12-25', DATE '2012-12-26', DATE '2013-01-01', DATE '2013-03-29', DATE '2013-04-01', DATE '2013-05-06', DATE '2013-05-27', DATE '2013-07-12', DATE '2013-08-26', DATE '2013-12-25', DATE '2013-12-26' ); RETURN ret; end; /
SY.
P.S. I think that I converted your vacation to literals correctly, but still double check date. -
Different results from the same calculations between SQL and PL/SQL
This SQL statement:
Gives the 89.5 result.select 1074 * (4 / 48) from dual;
However this PL/SQL block
Gives a different result:declare tmp NUMBER; begin SELECT 1074 * (4 / 48) into tmp from dual; dbms_output.put_line('Result '||tmp); end;
Result 89.49999999999999999999999999999999999996
If I change and give my variable tmp, a precision and scale, (38.36) say the result is 89.5.
Ed. I did about 10g (10.2.0.4.0) and 11g (11.1.0.7.0) with the same result in both.
Published by: kendenny on July 9, 2010 10:19 for more informationWhat is your current value of NUMLARGEUR in SQL * more (I assume that you use as your tool)?
SQL> set numwidth 50 SQL> select 1074 * (4 / 48) from dual; 1074*(4/48) -------------------------------------------------- 89.49999999999999999999999999999999999996
-
generated querys SQL are different between DEV and PROD environment
Hello
I have a problem with the results of the querys in response, I get different results with the same repository, the same query in Answers (catalog), same OS... between DEV environment and PROD environment. The generated SQL querys are also different.
The BI vesion is 10.1.3.4
Any idea on this issue?
Concerning
GuillermoYou have two queries in dev because you use for a table of two logical source:
* VEIS_HECHOS_ACUMULADOS
* and VEIS_HECHOS_GLOBALHow OBIEE select this table? This tables are selected if:
* all of the columns in the answer belongs to the source table
logical level of each source table is defined with the same parameters for the table two sourceThis is the case for you?
-
dba_segments shows different information for the owner and a Tablespace
Hi gurus,
Environment - 10.2.0.4. (stand-alone).
I have a table space which is used only by a single schema. When you query dba_segments, it gives me different results. If someone could please shed some light on this.
SQL > select count (*), segment_type in dba_segments where owner = 'TEST' by order of segment_type by 2; group
COUNT (*) SEGMENT_TYPE
---------- ------------------
INDEX OF 73
TABLE 55
2 selected lines.
SQL > select count (*), segment_type in dba_segments where nom_tablespace = group 'TEST_DATA' by order of segment_type by 2;
COUNT (*) SEGMENT_TYPE
---------- ------------------
INDEX 22
TABLE 604
2 selected lines.
I check the stats and they were collected at the DB level.
Please guide.
Kind regards
Lancerique.Hello
You think there is no other users use the tablespace 'TEST_DATA '.
Can you post the result of the following query:
SELECT DISTINCT TABLESPACE_NAME, OWNER OF dba_segments WHERE nom_tablespace = 'TEST_DATA ';
-
I noticed that 'clean and vectors.vi values' product of different results when it is used in LV8.0 and LV7.0.
The attached VI is saved in LV7.0. The default values show the results by operating this VI in LV7.0.
Using the same entries, try running this VI in 8.0 and you will see the results change.
Someone has any ideas why this is happening?
-
shows different images on the same chassis with half and full resolution
In the same framework, don't know why I'm using half resolution or high resolution, the same show different picture frame
sometimes half resolution shows the picture right on some frames, but sometimes not, and vice versa.
for example.
at 02:00 I put picture called "pic5" on the chassis, but full resolution shows the photo of "pic6", and although I use half of the resolution to see a preview, it shows "pic5.
but at 03:00 I put picture called "pic4" on the chassis, full resolution shows the 'pic4' photo, but half resolution to preview, it shows "pic5.
and while I'm making, it uses the result of full resolution
I had used Edition > purge > all memory and hidden, to address this problem sometimes, but not everytime.
How do I do with it?
I had used edit > purge > all memory and hidden, to address this problem sometimes, but not everytime.
How do I do with it?
Well Yes, it is a cache problem. You should try to remove all your cache completely-> memory and disk cache preferences
-
SQL query (or pl / sql) show this week activities
I need your friends to help to create the sql query (or pl / sql) show of this week's activities, my table is called activity and it has a date field (contains the date of the creation of the application)
depends on what you describe as 'this week '...
you could do something like
WHERE your_date_field > = trunc(sysdate,'IW') AND your_date_field< trunc(sysdate="" +="">
which would give you anything from Monday to Sunday from the current week
HTH
-
We are seeing different results for the property of the HostSystem 'configManager. snmpSystem' from vCenter and when you access from host.
I think that the result should be no different. Is this another known issue or am I missing something here?
To confirm this behavior, we tried to show the property to the host through the Explorer managed objects (MOB) and also by the VMware Remote CLI scripts. Join the results of the CLI script that was running on our test systems.
Best regards
Damodar
Greetings, I just wanted you guys to know this problem that you are experiencing is a known problem with VMware and our engineers groups are working on it. Sorry for the inconvenience to you.
Maybe you are looking for
-
How can I find and recover a missing CG Omega font file? It appears in Word 2003 documents saved earlier and still works, but is not ion the Word 2003 menu fonts dropdown or Windows file / make. Thanks in advance for your support.
-
where the autofil on Vista?
I'm filling out College applications and really do not have to keep adding time and time again the same information. I can't find the autofil and not really need. Help, please!
-
reinstalled office 2010 microsoft Starter
I updated my phone reset factory and by mistake, I did not go to the top and my office starter 2010 went, then how I can reinstall it back?
-
How to virtualize Windows XP in Windows 8 Pro?
How to virtualize Windows XP in Windows 8 Pro?