|
wow that worked perfectly. Luc i can't thank you and the other's enough for all your help you have given me. Hopefully one day I will be able to help others and return the favor in which you have given me.
Thanks again.
|
|
|
|
|
Someday saying thank you... that rated a 5!
|
|
|
|
|
Hi All,
I ran into an issue when trying to Decrypt a password field that I had previously encrypted and was hoping someone could help. I'm using SQL Anywhere 10.
I encrypted the password field with no issues, using the following trigger when a new record was added to the table:
ALTER TRIGGER "encrypt_new_user_pwd" BEFORE INSERT
ORDER 1 ON "QAS"."tableName"
REFERENCING NEW AS newPwd
FOR EACH ROW
BEGIN
Set newPwd.pwdField = ENCRYPT(newPwd.pwdField , 'key')
END
The problem is I'm unable to decrypt the password of the newly created record (fieldID = 0002), using the following:
SELECT CAST (DECRYPT(pwdField, 'key') AS VARCHAR(100))
FROM "QAS"."tableName" WHERE fieldID = '0002'
In Sybase when trying to execute the above statement I get the following error:
Interactive SQL
The following error occurred while fetching results:
Decryption error: Input must be a multiple of 16 bytes in length for AES
SQLCODE=-851, ODBC 3 State="08001"
Do you have any idea what's causing this error?
The pwdField is of type VARCHAR and size 15.
Thanks,
Mel
|
|
|
|
|
This is just a guess but if you read the error message it says:
MWRivera wrote: Input must be a multiple of 16 bytes in length for AES
But you say:
MWRivera wrote: The pwdField is of type VARCHAR and size 15.
Is 15 a multiple of 16?
Make pwdField bigger and see if that helps.
|
|
|
|
|
Hi David,
Thanks for the reply. I changed the length of the field to 16 and this stopped the error message from displying, the only problem then was the password was showing up as squares. I then changed the length of the field to 80 (5x16=80) sticking with the multiple of 16 rule and it works great now.
Thanks for your help with this it lead to me working it out. The reason I was recieving squares I asume is because the encrypted version of the password was larger than 16 and so the full encrypted version of it was too big to fit in the password field, therefore when I tried to decrypt it, it wasn't all there to decrypt and hence the nonsense squares.
Thanks again,
Mel
|
|
|
|
|
Hello friends,
which is the better way to use transaction?
From Database
or from Application?
|
|
|
|
|
There is no answer to this, it depends on many factors I know the language. I've read a book. - _Madmatt
|
|
|
|
|
Hi,
I need some help with the database design for storing an expression tree. It should basically store a whole expression.
I'd want to query out data (in one or more result sets as necessary) so that I can finally evaluate it somehow in my front-end application. Just kind of need a table(s) structure to store and represent the relationship.
The expressions I plan to store in the database will be mostly logical expressions. Meaning they'd evaluate to a true or false mostly.
Here is a diagrammatic representation of what I want (as a result set(s)).modified on Thursday, March 4, 2010 8:31 AM
|
|
|
|
|
Hi,
I often use trees and what you essentially needs is the ID and Parent ID
for example:
ID | ParentID | Name
1 | 0 | A
2 | 1 | AA
3 | 1 | AB
4 | 0 | B
5 | 4 | BA
6 | 4 | BB
looks like:
[]
|
-A
--AA
--AB
-B
--BA
--BB
and so on...
... I hope you mean this
|
|
|
|
|
I am using VB.Net 2008 and ADO.Net to do a Batch Update to our Oracle database.
The updates are working, but there is a trigger on the table before the row is updated to enforce a member's termination termination date.
So if I was trying to set the termination date (via the batch update) to 31-Jan-2010 but the member had a claim that was processed on 2-Feb-2010 the trigger would force the termination date to be 2-Feb-2010.
However, the trigger is NOT executing when the batch update runs?
|
|
|
|
|
I would guess that triggers are disabled for batch updates then, probably as a database default. This is a sensible idea, you do NOT want triggers firing in volume and you should be managing your data not relying on a trigger. I hate the bloody things, always causing trouble, hiding under the hood and causing issues bah! Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Good idea. I'm not a DBA so do you know for sure if there is an admin option that disable a trigger for batch updates?
|
|
|
|
|
MB_KSU wrote: do you know
No idea, especially on OracleNever underestimate the power of human stupidity
RAH
|
|
|
|
|
Can any one please tell me how to call a stored procedure from case statement. Thanks In Advance
|
|
|
|
|
A Case statement in SQL is an embedded part of a Select statement so you can't call a stored procedure in the middle, only a function. However I guess you mean something more like the following:
If @Test = 1
Execute [Procedure1];
Else If @Test = 2
Execute [Procedure2];
Else If @Test = 3
Execute [Procedure3];
Else
Execute [Procedure4];
|
|
|
|
|
you can also use case when for this.
|
|
|
|
|
You are still not going to be able to exec another proc from withing the case statement! Case and Exec() do not go together! Never underestimate the power of human stupidity
RAH
|
|
|
|
|
No you can't.
To quote the Micosoft documentation[^]:
The CASE expression cannot be used to control the flow of execution of Transact-SQL statements, statement blocks, user-defined functions, and stored procedures. For a list of control-of-flow methods, see Control-of-Flow Language (Transact-SQL)[^].
The question was regarding calling stored procedures and that is clearly not possible from within a case statement.
|
|
|
|
|
Table 1 (UNITS)
ScanID ScanCount OrderID SerialNo ScanStatus ProductionNo
1981 1294 2 147639NZ301774 SHIPPED 10007627289
There are 1300 SerialNo's for ProductionNo That will end with status 'SHIPPED'
Table 2 (Unit_Logs)
LogID SerialNo ProductionNo Old_Status New_Status
1 147639NZ301774 10007627289 PACKED SHIPPED
There will be 1300 records with status changes from PACKED to SHIPPED
Needed RESULT:
ProductionNo PACKED SHIPPED
10007627289 1300 1300
This is what I have tried:
SELECT UNITS.ProductionNo, COUNT(UNITS.SerialNo) AS SHIPPED,
COUNT(UNIT_Logs.SerialNo) AS PACKED
FROM UNITS JOIN UNIT_Logs
ON UNITS.ProductionNo = UNIT_Logs.ProductionNo
GROUP BY UNITS.ProductionNo, UNITS.ScanStatus, UNIT_Logs.Old_Status
HAVING (UNITS.ScanStatus = 'SHIPPED') AND (UNIT_Logs.Old_Status = 'PACKED')
I added 1 log entry to the table, but the query returns nothing.
Think might need sub query, but not sure where to go from here.
|
|
|
|
|
HAVING is only meant to be used with aggregate functions.
Try something similar to this:
SELECT UNITS.ProductionNo, COUNT(UNITS.SerialNo) AS SHIPPED,
COUNT(UNIT_Logs.SerialNo) AS PACKED
FROM UNITS JOIN UNIT_Logs
ON UNITS.ProductionNo = UNIT_Logs.ProductionNo
WHERE (UNITS.ScanStatus = 'SHIPPED') AND (UNIT_Logs.Old_Status = 'PACKED')
GROUP BY UNITS.ProductionNo, UNITS.ScanStatus, UNIT_Logs.Old_Status
<edit>fixed layout</edit>"When did ignorance become a point of view" - Dilbert
modified on Wednesday, March 3, 2010 3:54 AM
|
|
|
|
|
SELECT UNITS.ProductionNo,
COUNT(UNITS.SerialNo) AS SHIPPED,
COUNT(UNIT_Logs.SerialNo) AS PACKED
FROM UNITS
JOIN UNIT_Logs
ON UNITS.ProductionNo = UNIT_Logs.ProductionNo
WHERE (UNITS.ScanStatus = 'SHIPPED') AND (UNIT_Logs.Old_Status = 'PACKED')
GROUP BY UNITS.ProductionNo
|
|
|
|
|
Hi,
Thanks for the replies.
This query only seems to make a 1 to 1 join.
So if there is only one log entry it returns both SHIPPED and PACKED as 1 instead of 1294.
ProductionNo SHIPPED PACKED
10007627289 1 1
if i remove:
WHERE (UNITS.ScanStatus = 'SHIPPED') AND (UNIT_Logs.Old_Status = 'PACKED')
ProductionNo SHIPPED PACKED
10007627289 1294 1294
I tried this mess. Will try a few more options with this.
SELECT UNITS.ProductionNo, COUNT(UNITS.SerialNo) AS SHIPPED
FROM UNITS
WHERE UNITS.Scanstatus='SHIPPED' AND
(SELECT COUNT(UNIT_Logs.SerialNo) AS PACKED FROM UNIT_Logs WHERE UNIT_Logs.Old_Status='PACKED')
GROUP BY UNITS.ProductionNo
|
|
|
|
|
Try this one.
SELECT u.ProductionNo,
u.SHIPPED,
l.PACKED
FROM
(
SELECT ProductionNo,
COUNT(SerialNo) AS SHIPPED
FROM UNITS
WHERE ScanStatus = 'SHIPPED'
GROUP BY ProductionNo
) u
LEFT OUTER JOIN
(
SELECT ProductionNo,
COUNT(SerialNo) AS PACKED
FROM UNIT_Logs
WHERE Old_Status = 'PACKED'
GROUP BY ProductionNo
) l
ON l.ProductionNo = u.ProductionNo
[Fixed typo]modified on Wednesday, March 3, 2010 7:56 AM
|
|
|
|
|
Wow. did not even know you could do this.
I get this error though:
Msg 156, Level 15, State 1, Line 8
Incorrect syntax near the keyword 'FROM'.
Msg 102, Level 15, State 1, Line 19
Incorrect syntax near 'l'.
I am going to break it down into components to make sure the parts work and then try and connect it back together again.
Thanks
|
|
|
|
|
Sorry found the problem. , before the FROM in the first bracket.
It works perfectly. Thanks for the help.
|
|
|
|