Results 1 to 3 of 3

Thread: mysql isnull()

  1. #1
    Join Date
    Feb 2004
    Location
    earth
    Posts
    96

    Unanswered: mysql isnull()

    Hello,

    Does anyone know what is the alternative of having mysql isnull() to return the same output as below here for db2?
    mysql> SELECT ISNULL('techonthenet.com');
    -> 0

    mysql> SELECT ISNULL('');
    -> 0

    mysql> SELECT ISNULL(NULL);
    -> 1

    mysql> SELECT ISNULL(28);
    -> 0

    Thanks in advance

  2. #2
    Join Date
    Jul 2013
    Location
    Moscow, Russia
    Posts
    666
    Provided Answers: 55
    Hi,

    try this:
    Code:
    create function isnull(v varchar(4000))
    returns int
    contains sql
    deterministic
    no external action
    return case when v is null then 1 else 0 end
    If your function has to accept blob parameters, create another function with the same name and and blob(...) parameter.
    Regards,
    Mark.

  3. #3
    Join Date
    Feb 2004
    Location
    earth
    Posts
    96
    Hello Mark,

    Thank you very much for your reply. It is a good solution and it works.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •