View Single Post

   
  #9 (permalink)  
Old 02-27-2008, 05:22 AM
Jan M. Nelken
 
Posts: n/a
Default Re: Want to write a standard user defined function in the db2

Maroon wrote:
> Hava you worked other database( Mysql ) before? I mentioned a example.
> Anyway.
> concat_ws add the string that are given to its parameter.
> and md5 will implement a algoritham like ssh
>
> Look...
> This is a table:- Student
> Column :- roll, name, marks
> The data:-
> roll name marks
> 1 a 87
> 2 b 83
> 3 c 75
> Query:-
> select roll, myfun("roll","name","marks") as md5 from student.
> Here:- myfun is the user defined function that i want to
> write.
>
> The output will be
> roll md5
> 1 sdfsdf98874
> 2 sadfsdf4566
> 3 gffdsgasd34
>


Are you trying to encrypt contents of columns name and marks for each roll?

As in:
select roll, encrypt(roll concat name concat marks) from student;

You may modify this depending on column types for roll, name and marks.
Review online searchable documentation available at:

http://publib.boulder.ibm.com/infoce...help/index.jsp

Or you are trying to calculate MD5 checksum of the contents of columns name and
marks for each student?

You may look up alghoritms for MD5 calculations on the internet - I would
recommend concatenation of character representation of columns roll, name and
marks as a single input argument to MD5 user written function - so invocation
could be:

select roll, MD5(roll concat name concat marks) from student;


Jan M. Nelken
Reply With Quote