MySQL Forums
Forum List  »  MySQL Query Browser

Re: convert Oracle to mysql type
Posted by: irek kordirko
Date: February 27, 2012 02:46PM

I am not sure if MySql has a function similar to USER_ENV('CLIENT_INFO') in Oracle.
CLIENT_INFO is just a text stored in a session data by a client (whatever client - could be JDBC, OCI, sqlplus, toad etc.).
But you can simulate this by MySql session variables,
your 'client' (whatever it is) just must do:
set @client_info = 'some text'

and you can retrieve this text from a @client_info session variable.
If you do that in this way, then just replace USER_ENV('CLIENT_INFO') with @client_info in your code.

SUBSTRB ( text ,1,1 ) - retrieves the first letter from the text

DECODE( expr, val1, ret1, ret2 ) compares 'expr' with val1,
and when expr1=val1, returns 'ret1'. If they are not equal, then returns 'ret2'.
So
   DECODE ( 
         SUBSTRB ( USERENV ( 'CLIENT_INFO') ,1,1 ) ,  ' ' , NULL,
         SUBSTRB ( USERENV ( 'CLIENT_INFO') ,1,10 )
   )
checks if the first caracter of 'client_info' is a space,
and if yes -> returns NULL, otherwise returns first 10 characters from the 'client_info' string.

TO_NUMBER( str ) just converts a string to a number (or throws an exception if 'str' is not a number).



Edited 5 time(s). Last edit at 02/27/2012 02:55PM by irek kordirko.

Options: ReplyQuote


Subject
Written By
Posted
February 27, 2012 07:01AM
Re: convert Oracle to mysql type
February 27, 2012 02:46PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.