Home » SQL & PL/SQL » SQL & PL/SQL » Update without cursor (Oracle 11G)
Update without cursor [message #649368] Wed, 23 March 2016 12:44 Go to next message
Sam D.
Messages: 17
Registered: December 2015
Location: USA
Junior Member
Hi! I need to change the encryption of user passwords (well... hashes) from old package to new package.
Sample table
CREATE TABLE USERS
(
USERS_ID NUMBER NOT NULL,
USERS_FIRST_NAME VARCHAR2(20 BYTE) NOT NULL,
USERS_LAST_NAME VARCHAR2(20 BYTE) NOT NULL,
USERS_DISPLAY_NAME VARCHAR2(50 BYTE),
USERS_PASSWORD VARCHAR2(255 BYTE) NOT NULL,
USERS_NAME VARCHAR2(30 BYTE) NOT NULL,
USERS_EMAIL VARCHAR2(48 BYTE),
USERS_PHONE VARCHAR2(40 BYTE)
)

So, I need to decrypt existing passwords using "legacy" package (LEGACY_CRYPT.DECRYPT()) and encrypt using new package NEW_CRYPT.ENCRYPT().

Can it be done without Cursors?

Many thanks in advance,
Re: Update without cursor [message #649369 is a reply to message #649368] Wed, 23 March 2016 12:48 Go to previous messageGo to next message
BlackSwan
Messages: 26766
Registered: January 2009
Location: SoCal
Senior Member
Sam D. wrote on Wed, 23 March 2016 10:44
Hi! I need to change the encryption of user passwords (well... hashes) from old package to new package.
Sample table
CREATE TABLE USERS
(
USERS_ID NUMBER NOT NULL,
USERS_FIRST_NAME VARCHAR2(20 BYTE) NOT NULL,
USERS_LAST_NAME VARCHAR2(20 BYTE) NOT NULL,
USERS_DISPLAY_NAME VARCHAR2(50 BYTE),
USERS_PASSWORD VARCHAR2(255 BYTE) NOT NULL,
USERS_NAME VARCHAR2(30 BYTE) NOT NULL,
USERS_EMAIL VARCHAR2(48 BYTE),
USERS_PHONE VARCHAR2(40 BYTE)
)

So, I need to decrypt existing passwords using "legacy" package (LEGACY_CRYPT.DECRYPT()) and encrypt using new package NEW_CRYPT.ENCRYPT().

Can it be done without Cursors?

Many thanks in advance,


It can NOT be done. PERIOD!
HASHES != encrypted
Re: Update without cursor [message #649370 is a reply to message #649368] Wed, 23 March 2016 12:49 Go to previous messageGo to next message
John Watson
Messages: 8931
Registered: January 2010
Location: Global Village
Senior Member
If it a hash, you can't de-crypt it. Punkt.
Re: Update without cursor [message #649371 is a reply to message #649370] Wed, 23 March 2016 12:56 Go to previous messageGo to next message
Sam D.
Messages: 17
Registered: December 2015
Location: USA
Junior Member
OK, let's say it's just encrypted text. Let's forget about hashes. Is it possible then?

Many thanks in advance,
Re: Update without cursor [message #649373 is a reply to message #649371] Wed, 23 March 2016 13:01 Go to previous messageGo to next message
John Watson
Messages: 8931
Registered: January 2010
Location: Global Village
Senior Member
You haven't bothered to shoe the code in those functions. Can;t you do something like this -
orclz> update dept set dname=upper(lower(dname));

4 rows updated.

orclz>

Re: Update without cursor [message #649374 is a reply to message #649371] Wed, 23 March 2016 13:05 Go to previous messageGo to next message
BlackSwan
Messages: 26766
Registered: January 2009
Location: SoCal
Senior Member
>Is it possible then?
You should be asking the folks who encrypted the data; not anyone here.
What is encryption key & algorithm?
Re: Update without cursor [message #649376 is a reply to message #649368] Wed, 23 March 2016 13:23 Go to previous messageGo to next message
Michel Cadot
Messages: 68645
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator

Quote:
So, I need to decrypt existing passwords using "legacy" package (LEGACY_CRYPT.DECRYPT()) and encrypt using new package NEW_CRYPT.ENCRYPT().

Can it be done without Cursors?

update USERS set USERS_PASSWORD = NEW_CRYPT.ENCRYPT(LEGACY_CRYPT.DECRYPT(USERS_PASSWORD));

Re: Update without cursor [message #649387 is a reply to message #649376] Wed, 23 March 2016 16:46 Go to previous message
Sam D.
Messages: 17
Registered: December 2015
Location: USA
Junior Member
Many thanks to all
Previous Topic: Compound Trigger
Next Topic: connection issue-how to reset ?
Goto Forum:
  


Current Time: Thu Apr 25 02:04:55 CDT 2024