4

I have to select true in a variable when a field is not null, my attempt is this but does not compile, do you have a working solution?

        SELECT  CASE blob_data WHEN NULL THEN FALSE ELSE TRUE END
          INTO v_blob_found
          FROM docs dd
         WHERE dd.id=my_id
Luca C.
  • 11,714
  • 1
  • 86
  • 77
  • How did you declare `v_blob_found`? – Robert Aug 12 '14 at 08:19
  • 2
    SQL, whether it's a `select` or a `select into` statement, does not support Boolean literals. In this situation `TRUE` or `FALSE` will be treated as identifiers, thus `..does not compile` . – Nick Krasnov Aug 12 '14 at 08:37

1 Answers1

3

You can try somthing like this:-

SELECT  CASE WHEN blob_data IS NULL THEN 'FALSE' ELSE 'TRUE' END
INTO v_blob_found
FROM docs dd
WHERE dd.id=my_id
Ankit Bajpai
  • 13,128
  • 4
  • 25
  • 40