Simple sql stetment with 2 SUM - wrong result :-(
Hi guys,
here's a simple question that drives me crazy.
when I do this,
SELECT SUM(CSV_net.cur_amount) AS net_Accumulated
from csv_net_production as csv_net
where ID='5530500'
GROUP BY ID I get: 35188 //this is the right answer.
but when I'm doing this:
SELECT SUM(CSV_net.cur_amount) AS net_Accumulated, SUM(CSV.cur_amount) AS accumulated
from csv_net_production AS csv_net, csv_production AS CSV
where csv.ID='5530500'
AND csv_net.ID=csv.ID
GROUP BY csv.IDI get:
598196 607476 //wrong anser.
can anyone advise why?
thanks
thanks DrClap
ok, I can see that 17*35188=527820
but how can I correct the statement and have the right results ??
Similar Messages
-
SQL count(*) return a wrong result
Hi all, i've got 2 table F_1 and F_2. I also have a view VW based on the previous table that create the join clause.
If i execute
select * from
F_1 F_1,
VW VW,
F_2 F2
where
F_1.SEQ_LINE = VW.LINEA
AND
TO_NUMBER(VW.TESTA) = TO_NUMBER(F_2.SEQ_LINE)
i obtain 506 rows (the correct result). If i execute
select count(*) from
F_1 F_1,
VW VW,
F_2 F2
where
F_1.SEQ_LINE = VW.LINEA
AND
TO_NUMBER(VW.TESTA) = TO_NUMBER(F_2.SEQ_LINE)
the result is 0. Any idea?
Thanks, DecaXDHi all, TO_NUMBER was a copy paste error.
The table (dummy data) is
CREATE TABLE "F1"
( "C1" VARCHAR2(5),
"SEQ_LINE" NUMBER(8,0)
-- Records of F1
INSERT INTO "F1" VALUES ('aaa', '1');
INSERT INTO "F1" VALUES ('bbb', '4');
INSERT INTO "F1" VALUES ('ccc', '6');
CREATE TABLE "D2"
( "C1" VARCHAR2(5),
"SEQ_LINE" NUMBER(8,0)
-- Records of F2
INSERT INTO "F2" VALUES ('aaa1', '2');
INSERT INTO "F2" VALUES ('aaa2', '3');
INSERT INTO "F2" VALUES ('bbb1', '5');
INSERT INTO "F2" VALUES ('ccc1', '7');
The view is
select F2.SEQ_LINE LINEA ,max(F1.SEQ_LINE) TESTA from F1,F2
where F2.SEQ_LINE > F1.SEQ_LINE
group by F2.SEQ_LINE
ORDER BY 1,2 -
Device profilling with WLC - wrong result with Nokia
Hi,
I have created a Wireless Device Policy Classification into a WLC with 8.0.110.0
The WLC configured to local profile, profile the nokia device (with windows-mobile) as a Windows-Workstations.
How is possible?
Regards.
Mirko Severi.Hi, Scott.
Thanks for your help.
In this case, my device is Lumia 635 and its MAC is B8-4F-D5-D6-3F-3C
In the oui there is
B8-4F-D5 (hex) Microsoft Corporation
B84FD5 (base 16) Microsoft Corporation
1 Microsoft Way
Redmond Washington 98052
UNITED STATES.
The WLC profiling the device right!
Is possible to put an exception?
Regards.
Mirko -
SUM function resulting WRONG values when some cell contains a string
A very strange problem that can result in wrong financial calculations and big mistakes...
If we have SUM function for some range of cells and one of them is treated as text string (I mean it's number in fact but Number is sure it's text string). than SUM function calulates ALL cells except this sell silently without errors and results in wrong result.
For example we have cells and values
A B
=====
1| 15 USD
2| 0 USD
3| 37 USD
4| 1 USD
5| 3 USD
here the function SUM(B1:B5) should provide the result "56 USD"
But if cell B5 is treated as text string (it can be still displayed as "3 USD" so we don't know it's treated as text string for some reason) than SUM(B1:B5) swill answer "53 USD".
The problem is we DON'T know cell B5 is treated as text and we are fully sure that we have the correct sum of all 5 cells, in reality we see sum of 4 cells only....
I think anybody working with financial or other important data can imagine how dangerous this SUM behaviour is.... I encountered several times that when importing data from Excel or by other ways numbers are imported as text strings. So if I have a lot of cells I'm not sure if all those cells are correctly styled or some of them for some unknown reason is treated as text string.
In Microsoft Excel there is a very right solution. In MS Excel if any cell in the SUM is wrong format the SUM function simply provides error as a result. But in Numbers SUM doesn't tell us about error, it simply provides us with a wrong result!
With formal logic the way SUM works in Numbers is total idiotism. If I ask to SUM B1:B5 than I definitely ask to sum ALL 5 cells, not 4, not 3, not 6 but 5 definite cells. If Numbers can't sum those exactly those 5 cells the only answer of the function should be ERROR.
But Apple Numbers answers me some result of summing those cells that it's able to sum. Apple Numbers SUM function is not confused that I asked for SUM of 5 (not 4 or 3) cells and I expect to have this sum as a result.
In fact Apple uses the right logic when we use another formula. If we use =B1B2+B3+B4B5 and any cell contains text string that we'll have error result the sam as in Microsoft Excel. So in this example Numbers behaves correctly.
So why SUM (B1:B5) can provide totally different result as =B1B2+B3+B4B5?alexb2 wrote:
So when I set format for my number as my local currency it's displayed as 123 XXX (XXX is my currency but it's not in latin). I see it's not only displayed but also stored as 123 XXX. That's different from Excel that stores only numbers in cells and shows number with prefix or suffix - Numbers storex number with prefix or suffix.
No, you get this behavior because the original sheet is displaying values as currencies. I assumes that the import process pass it as a string because he doesn't recognize it as a currency value. As far as I know, Numbers stores the currency entries as a pure number and an indicator of the used currency.
Here is an example.
(a) the description of the numerical value (I underlined it: 456)
<sf:number-cell sf:flags="4" sf:value="456" sf:col="1" sf:row="2">
<sf:cell-style-ref sfa:IDREF="SFTCellStyle-46"/>
<sf:content-size sfa:w="58.659881591796875" sfa:h="14"/>
</sf:number-cell>
(b) the description of the format (I underlined the used currency: XAM)
<sf:cell-style sfa:ID="SFTCellStyle-46" sf:cell-style-default-line-height="12" sf:parent-ident="tabular-Basic-body-cell-style-id">
<sf:property-map>
<sf:SFTCellStylePropertyNumberFormat>
<sf:number-format sfa:ID="SFTNumberFormat-23" sf:format-type="1" sf:format-string="#,##0.00 ¤;-#,##0.00 ¤" sf:format-decimal-places="2" sf:format-currency-code="XAM" sf:format-negative-style="0" sf:format-show-thousands-separator="true" sf:format-fraction-accuracy="-3" sf:format-use-accounting-style="false"/>
</sf:SFTCellStylePropertyNumberFormat>
<sf:SFTCellStylePropertyImplicitFormatType>
<sf:number sfa:number="256" sfa:type="i"/>
</sf:SFTCellStylePropertyImplicitFormatType>
<sf:SFTCellStylePropertyFormatType>
<sf:number sfa:number="257" sfa:type="i"/>
</sf:SFTCellStylePropertyFormatType>
</sf:property-map>
</sf:cell-style>
Of course, if the original currency string is not recognized, it can't be described as such a feature and the value is treated as a simple string.
So may be at some moment my 123 XXX is treated like string value.
Yes, find and replace is a nice tool when importing data - thanks for the tip. the last problem is with already Numbers files that were imported not today (or even createde as Numbers file) where some cell becomes string value after some editing.
Here again, if you edit a currency string and replace it to a not recognized one, the result will be logically a string.
There is an other way to give this result:
copy a value from a cell formatted as XAM currency (just an example)
paste it in a cell whose format is currency Euro (once again it's just an example).
The result will be a string.
The culprit is not the program, it's the user.
I had several times this situation and last time I found error only because I have my budget in 2 programs - in Numbers and in another special budgeting program. As each program has advantages I have in fact 2 instances of the same budget.
And when I changed some string in Numbers and another program I noticed the sum is different. I was sure it's another program somewhere buggy but noticed than Numbers simply ignores one of the budget strings and sums without it... In fact it was even not the string I changed, I remember I changed the buggy string about a week ago but I haven't compared budgets that time so my budget had a mistake for some time till I noticed it. If I used only Numbers without copy of budget in another program may be even today I won't notice the mistake.
The same situation happened not once.
I think that the choice made by Apple for SUM() is correct. You feel that it is wrong. It's useless to debate more, we will not change the behavior of the function.
I try to give a workaround.
The neater one is to add columns as I described in my first response.
The given formula will clearly flag cells which aren't containing numerical values. If you move the SUM from the original range to the new one, the oddities will be flagged automatically.
Here is an alternate workaround:
The currency is XAM.
In B4 I introduced a typo so the value is no longer a numerical one.
Given that, the sum in the footer doesn't count the 34 (which is the normal behavior).
In column C1 I entered =1*B
which flagged the bad cell.
The alternate is to use an auxiliary table like aux1
In A1 I entered:
=IF(ISERROR(INDIRECT(ADDRESS(ROW(),COLUMN(),,,"main"))),"",IF(ISBLANK(INDIRECT(A DDRESS(ROW(),COLUMN(),,,"main"))),"",1*INDIRECT(ADDRESS(ROW(),COLUMN(),,,"main") )))
Exactly the same formula in B1, C1, D1, …
So, the table will automatically grab the contents of the main table (just take care to insert more columns in aux1 than in main)
In the footer row of aux1, insert a sum formula for columns where there is required.
Looking at this footer will flag columns where a value may be "wrong" so, it will be necessary (but easy) to scan the column's content to find the red triangle(s).
Yvan KOENIG (from FRANCE lundi 13 octobre 2008 13:27:40) -
Simple SQL Query and Parameters and LOV
Newbie and trying to work thru building a simple sql query with a single table query and use a parameter and lov.
Can anyone point me to an example.
simple query:
select cust_id, name_desc, name_add1, name_add2, name_city
from customer_table
where cust_id = :cust_parm
This works in straight sql and in the query builder by prompting for the customer ID. When building a parameter using LOV or search, it doesn't seem to detect the variable.
Thanks..
DDIf you are using version 11g, then as soon as you save the query in the data model, it should notice the parameter and ask if you want to add the parameter to the data model. What version of BIP are you using?
What happens if you exclude the parameter from the query and simply hard-code the criteria? Can you generate XML data?
From your wording, it sounds like you're trying to create a parameter from the LOV dialog. LOVs and parameters are totally distinct. After each are created separately, then you configure the parameter to use the LOV. -
Simple query with like return wrong result
Hi,
I run simple query with like.
If I use parameter I get wrong results.
If I use query without parameter results are ok.
My script:
ALTER SESSION SET NLS_SORT=BINARY_CI;
ALTER SESSION SET NLS_COMP=LINGUISTIC;
-- drop table abcd;
create table abcd (col1 varchar2(10));
INSERT INTO ABCD VALUES ('122222');
insert into abcd values ('111222');
SELECT * FROM ABCD WHERE COL1 LIKE :1; -- wrong result with value 12%
COL1
122222
*111222*
select * from abcd where col1 like '12%'; -- result ok
COL1
122222
I use Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
and query run in Oracle SQL Developer 3.1.07.Hi,
welcome to the forum.
When you put some code please enclose it between two lines starting with {noformat}{noformat}
i.e.:
{noformat}{noformat}
SELECT ...
{noformat}{noformat}
You should specify exactly how you run your code.
If I run this statement in SQL Plus:SQL> ALTER SESSION SET NLS_SORT=BINARY_CI;
Session altered.
SQL> ALTER SESSION SET NLS_COMP=LINGUISTIC;
Session altered.
SQL>
SQL> -- drop table abcd;
SQL> create table abcd (col1 varchar2(10));
Table created.
SQL>
SQL> INSERT INTO ABCD VALUES ('122222');
1 row created.
SQL> insert into abcd values ('111222');
1 row created.
SQL>
SQL> SELECT * FROM ABCD WHERE COL1 LIKE :1;
SP2-0552: Bind variable "1" not declared.
SQL>
I got this error. So I wonder how you set value 12%
Please specify exactly how you run your test as we cannot reproduce your problem.
Regards.
Al -
SQL SUM and Group By Function Wrong Result
Hi All,
I have a SQL view with all the payment transaction for a property per month and trying to sum all the transactions per month per property. For some months the total is not correct. For example for property 3856, in Jan 2014, the total should come to
728 but the query lists 2184.
Trans Date
Amount
Prop Code
31/1/2014
728
3856
31/1/2014
-2184
3856
31/1/2014
2184
3856
Output Required
Year Month Amount Prop Code
2014 1 728 3856
My Query
Select [Prop Code], year(ttp.[Trans Date]) AS [Year], Month(ttp.[Trans Date]) AS [Month], SUM(ttp.[Payment Amount]) as Total
FROM vw_tenant_payments as ttp
GROUP BY [Prop Code], year(ttp.[Trans Date]), Month(ttp.[Trans Date])Hi All,
I got it, it skipped my mind to restrict the payment type to RENT as even the deposit is in the transaction view
Select
[Prop Code],year(ttp.[Trans
Date])AS[Year],Month(ttp.[Trans
Date])AS[Month],SUM(ttp.[Payment
Amount])asTotal
FROM
vw_tenant_payments
asttp
Where
[Account Code]
='RENT'and[Prop
Code] ='3856'
GROUP
BY[Prop
Code],year(ttp.[Trans
Date]),Month(ttp.[Trans
Date])
Order
by[Prop
Code],[Month] -
Can anyone tell me what is wrong with the simple sql?
Hi,
I have a simple SQL (see attached). It returns records when it does not include the Order By sorting clause. However, if it includes the Order By clause, Oracle says no data found. Anyone can give me some ideas what could cause the problem?
Thanks in advance.
SELECT ih.item_key, e.episode_key, e.episode_date, wp.work_package_key, p.patient_name, c.codes_key
FROM work_package wp, episodes e, item_header ih, patients p, codes c, station_element se, station_data sd
WHERE wp.work_item_key = e.episode_key
and e.episode_key = ih.item_key
and ih.logical_parent_key = p.patient_key
and e.episode_type = c.code_value
and wp.asgn_station_key = se.item_key
and se.station_name like 'DICT FIX%'
and sd.station_key = wp.asgn_station_key
and (sd.facility = '0' or sd.facility = 1)
and wp.on_hold <> 'Y' and c.code_type = 'CEPT'
and c.setup_group = 1
ORDER BY e.episode_date, e.medrec_no;Hmmm...can you post a SQL Plus session that demonstrates this?
-
How to compare result from sql query with data writen in html input tag?
how to compare result
from sql query with data
writen in html input tag?
I need to compare
user and password in html form
with all user and password in database
how to do this?
or put the resulr from sql query
in array
please help me?Hi dejani
first get the user name and password enter by the user
using
String sUsername=request.getParameter("name of the textfield");
String sPassword=request.getParameter("name of the textfield");
after executeQuery() statement
int exist=0;
while(rs.next())
String sUserId= rs.getString("username");
String sPass_wd= rs.getString("password");
if(sUserId.equals(sUsername) && sPass_wd.equals(sPassword))
exist=1;
if(exist==1)
out.println("user exist");
else
out.println("not exist"); -
When I send an email with Mail, I often confuse the account which I'm using. The result is that I send a message with the wrong account! Is there a way to avoid this (for example a reminder before the email is sent)?
Hi, thanks for the answer, I did that already. Unfortunatly this doesn't help me at all, as I often forget to check the menu. For me composing the message is writing the text, the subject, the person to who is addressed and than press "send".
I often forget to check the "from", and this is a problem because the software select itself one of the accounts.
Isn't there a way at least to put as a default a blank field instead of one of the accounts? or an account which doesn't work so if I forget to specify the "from" I will be rnotofied that the message can't be sent.
I guess this could be a rather common problem for many people!
Thanks
Sergio -
Every time I create an account with iCloud then try to open it I get an error message: wrong ID or password. Also when I enter my birth date I am told it is incorrect. I have done this several times with the same results.
Oldcameraman
Please do not duplicate a thread. The threads are answered as soon as possible. We are not Adobe. Just user to user.
I have answered your most recent of the duplicates
Premier Elements 13 Organizer Works. Editor doesn't. Log in doesn't work
It is uncertain just how far we can go to help you since you do not appear to have Premiere Elements any
longer.Seems you demanded a refund from Adobe Chat, got it, and now are left with a non purchased program which I
am not sure can be used.
Duplicates tend to confuse the person asking the question as well as those attempting to reply. As I suggested in the
above mentioned thread, try to sort out your situation with Adobe via its Adobe Chat.
ATR -
SQL Server 2012 Time(7) DataType values Comparison giving wrong result. Please help
We have a Table with StartTime and EndTime columns in Time(7) datatype, so we want to count the rows for each hour from 6 AM to 5 AM. If a record in table is as StartTime= 7 PM to EndTime = 5 AM (a shift of an employee) then the result is wrong beacause
being time(7) datatype the EndTime(5AM)< StartTime(7PM) in 24 hours format so following query gives wrong results.
select
* from EmpSchedule
where (StartTime>='19:00:00.0000000'
OR EndTime>='19:00:00.0000000')
Please help me out. ThanksDECLARE @clockIns TABLE (employeeID INT, startDateTime DATETIME, endDateTime DATETIME)
INSERT INTO @clockIns (employeeID, startDateTime, endDateTime)
VALUES
(1, '2014-07-01 19:01:00.000', '2014-07-02 04:27:00.000'),
(2, '2014-07-01 18:01:00.000', '2014-07-02 05:27:00.000'),
(3, '2014-07-01 19:01:00.000', '2014-07-02 05:27:00.000'),
(4, '2014-07-01 18:01:00.000', '2014-07-02 04:27:00.000')
SELECT *
FROM @clockIns
WHERE datepart(HOUR,startDateTime) BETWEEN 19 AND 23
OR datepart(HOUR,startDateTime) BETWEEN 0 AND 4
OR datepart(HOUR,endDateTime) BETWEEN 19 AND 23
OR datepart(HOUR,endDateTime) BETWEEN 0 AND 4
Try this out. -
Calculations with Sum Distinct Aggregations
Hi,
I got a problem. I use in one of my analysis a Pivot Table. One of my measures which I sum up has multiple entries in my tables. So I decided to use a Sum Distinct aggregation. The Sum Distinct aggregation works perfect. But when I want to do basic calculations with the measure I get wrong results. It seems that in the calculation the aggregation is just a SUM and not a Sum Distinct. In the calculation I subtract the measure from a constant. But I only get wrong result with the redundant entries.
Pivot table:
Name --- Days available --- Days worked (measure)--- Days left (= Days available minus Days worked)
Mr. A --- 60 --- 5 ---- 55
Mr. A --- 60 --- 10 --- 50
Mr. A --- 60 --- 35 --- 25
---------- Sum ---- 50 --- -45 (wrong result)
Is there a solution to this problem?
thx
Edited by: Backlit on 31.07.2011 11:29Hi,
and thx for the quick answer. But unfortunately the Server Complex Aggregate aggregation doesn't solve my problem. I also think I didn't express my self clear enough.
My problem is, that I have the same tuple multiple times in my database table. When I sum this data up - I get wrong results. To avoid this I used the SUM DISTINCT aggregation. This worked very fine. But now I'm facing an other problem. I have to perform a simple subtraction.
I have a fixed non measure value. I have to subtract the Sum Distinct measure from this fix value for a specified time periode.
it looks like this:
Pivot table
Name --- Days available(non measure) --- Work date --- Days worked (SUM) measure --- Days worked SUM(Distinct) measure
Mr.A --- 40 --- 1.5 --- 6 --- 3
Mr.A --- 40 --- 1.5 --- 6 --- 3
Mr.A --- 40 --- 2.5 --- 6 --- 3
Mr.A --- 40 --- 3.5 --- 6 --- 3
Mr.A --- 40 --- 3.5 --- 6 --- 3
Mr.A --- 40 --- 3.5 --- 6 --- 3
SUM ---- 40 --- .... ---- 6 --- 3 -> Days left: 34 (wrong result - should be 37)
I get the right result - but when I now try to calculate "Days available - Days worked SUM(Distinct)" I get the same results like I would do the calculation with
"Days available - Days worked SUM".
And is there a way to hide the multiple values in Days worked?
thx -
Password change fails in SQL Developer with verify function...
A couple of months ago I enforced a password verify function on our 11.2.0.3 databases and also one legacy 10.2.0.4 database.
At the time I tested on my account (which had elevated privileges...doh!). Now some users are hitting expiry, they can't change it via SQL Developer.
If I create a user with 'create session' privilege and set their profile to one that uses the verify function (see both below), I then log in to SQL Developer (we have tried with versions 3.1 (Windows) and 3.2 (Linux) with same failure results.
BTW,.. the password verify function enforces the following:
password must be minimum of 8 characters
password must not be the same as the user name, or user name (1-100)
password must contain at least a single digit
password must contain at least a single character
1. Works = I log into the local server and run command line SQLPlus, type 'password' and update. I can successfully change my password.
2. Fails = I log into the local server and run command line SQLPlus, type 'alter user <me> identified by <newpwd>;' I get:
TEST: SUTEMP > alter user sutemp identified by carport9999;
alter user sutemp identified by carport9999
ERROR at line 1:
ORA-28221: REPLACE not specified
This error is because the account does not have the 'alter user' privilege. I'm okay with this, as I don't want our users having this privilege.
3. I start SQL Developer 3.2, type 'alter user <me> identified by <newpwd>;' I get the same ORA-28221 error as above. That is fine, and as expected.
4. Now in SQL Developer, I type 'password', set a valid password, but I get 'Failed to change password' in the Script Output tab.
I have a database 'after servererror on database' trigger set, and querying the database table it is logging into, I see a record with a date stamp matching my failure with a server_error=28221 (the same as above).
So I'm wondering if I'm doing something wrong here, or if this is a bug in SQL Developer. I don't want standard users having 'alter user' privileges, but I do want to enforce password verification.
I get the same result on three 11.2.0.3 databases (haven't tried any more but suspect same results for others) and one legacy 10.2.0.4 database, and using SQL Developer 3.1 and 3.2.
DBA_PROFILE used:
PROFILE
RESOURCE_NAME
RESOURCE LIMIT
CTRU
COMPOSITE_LIMIT
KERNEL DEFAULT
CTRU
SESSIONS_PER_USER
KERNEL 10
CTRU
CPU_PER_SESSION
KERNEL DEFAULT
CTRU
CPU_PER_CALL
KERNEL DEFAULT
CTRU
LOGICAL_READS_PER_SESSION KERNEL DEFAULT
CTRU
LOGICAL_READS_PER_CALL
KERNEL DEFAULT
CTRU
IDLE_TIME
KERNEL DEFAULT
CTRU
CONNECT_TIME
KERNEL DEFAULT
CTRU
PRIVATE_SGA
KERNEL DEFAULT
CTRU
FAILED_LOGIN_ATTEMPTS
PASSWORD 10
CTRU
PASSWORD_LIFE_TIME
PASSWORD 180
CTRU
PASSWORD_REUSE_TIME
PASSWORD DEFAULT
CTRU
PASSWORD_REUSE_MAX
PASSWORD 5
CTRU
PASSWORD_VERIFY_FUNCTION PASSWORD VERIFY_FUNCTION_11G
CTRU
PASSWORD_LOCK_TIME
PASSWORD .002
CTRU
PASSWORD_GRACE_TIME
PASSWORD 21
16 rows selected.
Verify Function used:
$ cat utlpwdmg.sql
Rem
Rem $Header: utlpwdmg.sql 02-aug-2006.08:18:05 asurpur Exp $
Rem
Rem utlpwdmg.sql
Rem
Rem Copyright (c) 2006, Oracle. All rights reserved.
Rem
Rem NAME
Rem utlpwdmg.sql - script for Default Password Resource Limits
Rem
Rem DESCRIPTION
Rem This is a script for enabling the password management features
Rem by setting the default password resource limits.
Rem
Rem NOTES
Rem This file contains a function for minimum checking of password
Rem complexity. This is more of a sample function that the customer
Rem can use to develop the function for actual complexity checks that the
Rem customer wants to make on the new password.
Rem
Rem MODIFIED (MM/DD/YY)
Rem suren 05/09/13 - customise for NIHI use
Rem asurpur 05/30/06 - fix - 5246666 beef up password complexity check
Rem nireland 08/31/00 - Improve check for username=password. #1390553
Rem nireland 06/28/00 - Fix null old password test. #1341892
Rem asurpur 04/17/97 - Fix for bug479763
Rem asurpur 12/12/96 - Changing the name of password_verify_function
Rem asurpur 05/30/96 - New script for default password management
Rem asurpur 05/30/96 - Created
Rem
-- This script sets the default password resource parameters
-- This script needs to be run to enable the password features.
-- However the default resource parameters can be changed based
-- on the need.
-- A default password complexity function is also provided.
-- This function makes the minimum complexity checks like
-- the minimum length of the password, password not same as the
-- username, etc. The user may enhance this function according to
-- the need.
-- This function must be created in SYS schema.
-- connect sys/<password> as sysdba before running the script
CREATE OR REPLACE FUNCTION verify_function_11G
(username varchar2,
password varchar2,
old_password varchar2)
RETURN boolean IS
n boolean;
m integer;
differ integer;
isdigit boolean;
ischar boolean;
ispunct boolean;
db_name varchar2(40);
digitarray varchar2(20);
punctarray varchar2(25);
chararray varchar2(52);
i_char varchar2(10);
simple_password varchar2(10);
reverse_user varchar2(32);
BEGIN
digitarray:= '0123456789';
chararray:= 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
-- Check for the minimum length of the password
IF length(password) < 8 THEN
raise_application_error(-20001, 'Password length less than 8');
END IF;
-- Check if the password is same as the username or username(1-100)
IF NLS_LOWER(password) = NLS_LOWER(username) THEN
raise_application_error(-20002, 'Password same as or similar to user');
END IF;
FOR i IN 1..100 LOOP
i_char := to_char(i);
if NLS_LOWER(username)|| i_char = NLS_LOWER(password) THEN
raise_application_error(-20005, 'Password same as or similar to user name ');
END IF;
END LOOP;
-- Check if the password contains at least one letter, one digit
-- 1. Check for the digit
isdigit:=FALSE;
m := length(password);
FOR i IN 1..10 LOOP
FOR j IN 1..m LOOP
IF substr(password,j,1) = substr(digitarray,i,1) THEN
isdigit:=TRUE;
GOTO findchar;
END IF;
END LOOP;
END LOOP;
IF isdigit = FALSE THEN
raise_application_error(-20008, 'Password must contain at least one digit, one character');
END IF;
-- 2. Check for the character
<<findchar>>
ischar:=FALSE;
FOR i IN 1..length(chararray) LOOP
FOR j IN 1..m LOOP
IF substr(password,j,1) = substr(chararray,i,1) THEN
ischar:=TRUE;
GOTO endsearch;
END IF;
END LOOP;
END LOOP;
IF ischar = FALSE THEN
raise_application_error(-20009, 'Password must contain at least one digit, and one character');
END IF;
<<endsearch>>
-- Check if the password differs from the previous password by at least
-- 3 letters
IF old_password IS NOT NULL THEN
differ := length(old_password) - length(password);
differ := abs(differ);
IF differ < 3 THEN
IF length(password) < length(old_password) THEN
m := length(password);
ELSE
m := length(old_password);
END IF;
FOR i IN 1..m LOOP
IF substr(password,i,1) != substr(old_password,i,1) THEN
differ := differ + 1;
END IF;
END LOOP;
IF differ < 3 THEN
raise_application_error(-20011, 'Password should differ from the old password by at least 3 characters');
END IF;
END IF;
END IF;
-- Everything is fine; return TRUE ;
RETURN(TRUE);
END;
alter profile ctru limit password_verify_function verify_function_11g;
alter profile default limit password_verify_function verify_function_11g;
alter profile web_and_it limit password_verify_function verify_function_11g;okay,... I just saw another website which shows I should put in the 'replace <oldpwd>' clause in.
This works in SQL Developer: alter user sutemp identified by carport999 replace garage999;
So why does the 'password' command fail? (Developers: it would also be helpful to have the ORA- error displayed as opposed to 'Failed to change password') -
Wrong results after upgrading 10g database to 11.2.0.2.6
Hi,
Do anyone know, why the following query results are different?
Not Working query:
sql1:
select col1 from tab1
where col1 = (select '123' from dual)
Working query:
sql2:
select col1 from tab1
where col1 = '123';
Both the sql1 and sql2 are returning same reseults in 10g database , but not in 11g.Pl post OS details along with sample outputs and explain plans from the the sql1 statement from the two databases. These MOS Docs may help also
Things to Consider Before Upgrading to 11.2.0.2 to Avoid Poor Performance or Wrong Results [ID 1320966.1]
Wrong Results on 11.2.0.2 with Function-Based Index and OR Expansion [ID 1264550.1]
Wrong Results/No Rows for Sql Involving Functions in 11.2.0.2. [ID 1380679.1]
HTH
Srini
Maybe you are looking for
-
LocalDrive, remoteDrive error being logged to Windows Application event log
Post Author: yday CA Forum: Data Integration Hi all,We are finding the following error messages being constantly logged to the Windows application event log:Event ID: 4096Source: Data Integrator"The error: localDrive: LocalDrive1; localDriveValue: "
-
Transfering archive logs in standby database
hi, i am trying to create a standby database for a a test scenario using oracle 10g R2 and windows xp Primary DB = primary standby DB=stby iam able to ping databases from each other using tnsping , but iam not able to transfer archive logs from prima
-
I lost my iphone yesterday , What I have to do?
yesterday I lost my iphone ,I do not know where but it might stolen too. I want to know what is the first step for finding it ? where I have to go in Milan . please help me , my iphone was my friend and I can tolerate without it.
-
TRANSACTION NOTIFICATION PARA ORDENES DE PRODUCCION
BUENAS TARDES. ALGUIIEN QUE ME PUEDA DECIR PARA QUE SIRVEN LAS SIG. LINEAS DEL TRANSACTION NOTIFICATION @num_of_cols_in_key int, @list_of_key_cols_tab_del nvarchar(255) SE QUE ESTE TOMA EL VALOR DEL CAMPO CLAVE DE LA TABLA SOBRE LA CUAL HACEMOS EL CO
-
I am excited at the prospect of getting JavaCAPS installed on my Mac.. But it is not going well.. I have the MacOSX_en-US.zip and ran the JavaCAPS.app inside.. Of course, my machine has JDK preloaded in /System/Library/Frameworks/JavaVM.framework/Ver