How to calculate MD5 hash in DB2 9.5 - db2

Is there a function/package available in DB2 9.5 to calculate MD5 hash? Something similar to Oracle's DBMS_OBFUSCATION_TOOLKIT.MD5?

There is no built-in function to do this, but you can certainly create your own User Defined Function (UDF).
This Developerworks article contains an implementation: http://www.ibm.com/developerworks/data/library/techarticle/dm-0407tessarek/#UDFs

There is GET_HASH_VALUE function in DB2 9.7 part of DBMS_UTILITY system module.
Here is link from documentation :
http://pic.dhe.ibm.com/infocenter/db2luw/v9r7/index.jsp?topic=%2Fcom.ibm.db2.luw.sql.rtn.doc%2Fdoc%2Fr0055167.html
Hope this is what you were looking for.

Related

What is the equivalent of oracle VARRAY in postgresql

What is the equivalent of oracle varray in postgres.
Code :
TYPE xxx is varray(2000) of gt_name%rowtype .
gt_name is a cursor name.
The closest thing in PostgreSQL is an array. Figure out what data type gt_name is. if that is (for example), text, then you'd use the type text[].
See the documentation for details.

Oracle ORA_HASH alternative in Postgres(MD5)

I am trying to find an alternative to the ORA_HASH Oracle function in Postgres(edb). I know there are hashtext() and MD5(). Hashtext should be ideal, but it's not documented and so I can't use it for some reasons. I'd like to know if there is any way of using MD5() and getting the same value that you'd get in ORA_HASH giving the same value for both of them.
For example, this is how I use it and what I get in Oracle:
SELECT ORA_HASH('huyu') FROM dual;
----------------------------------
3284595515
I'd like to do something similar in postgres, so that if I pass the 'huyu' value, I'd get the exact same '3284595515' value.
Now, I know that ORA_HASH restores a number and MD5 restores hexadecimal value. I think I'd need the function that converts the hexadecimal 32 into a number, but I can't get the same value and I'm not sure if it is possible.
Thank you in advance for any suggestions
If you rely on the exact implementation of ORA_HASH, which is a proprietary hash function in a closed-source software, you are locked to this vendor, sorry.
I don't see how using PostgreSQL's hashtext is worse than ORA_HASH: it is documented (in the source), it's implementation is public, and it is not going to be removed, because it is required for hash partitioning.

SELECT ##VERSION in Progress OpenEdge?

I havent been able to find this in the docs so it may not exist - does openedge have a SELECT ##VERSION type of query to return the DB version?
Thanks!
You can get the version indirectly by querying _dbstatus._dbStatus-ShmVers
The mapping of _dbStatus-ShmVers to actual version numbers is described in this kbase: https://knowledgebase.progress.com/articles/Article/P39456
No, there is no such query that returns the OpenEdge database version. As an alternate, a User Defined Function (UDF) can be written to return the version information. This article describes the ways to get OpenEdge database version. You can use one of these approaches in the UDF to get the database version. UDF examples can be found here.

sha1 function in db2 AS400

In Mysql,
Sha1 function returns 40 byte length output for any input length.
For Example,
select sha1('ABCD');
output:fb2f85c88567f3c8ce9b799c7c54642d0c7b41f6
Similar to Mysql,
Please help me finding out what function is equivalent of sha1 in db2 iseries/AS400?
On DB2 for i, you can use ENCRYPT_AES, ENCRYPT_RC2, or ENCRYPT_TDES, but there is no SHA1 function. You can find documentation here:
https://www.ibm.com/support/knowledgecenter/ssw_ibm_i_73/db2/rbafzscaencryptaes.htm
While DB2 for i does not currently have a built-in SHA-1 function, you could perhaps write your own user defined function, using the Cryptographic Services APIs and the Calculate Hash API

How to get list of updated columns from within a trigger in IBM Db2 9.7?

I am using DB2 9.7 enterprise edition on Windows 7. I have created a trigger and now I need to know which columns have been updated, from within the trigger. In MS SQL 2008 there is a function called "COLUMNS_UPDATED()" that gives you just that. However, after a lot of searching I cannot find an equivalent function for DB2. Any ideas? Thanks.
DB2 does not have a comparable function like this. Compare OLD and NEW values in triggers.