Skip to content Skip to sidebar Skip to footer

What Syntax Is Used To Select A Constant Field Value From A Javadb Database?

I'm using UNION ALL to combine the results of several SELECT queries into one ResultSet. I use constant field values to identify which statement produced each row. This works well

Solution 1:

Remove the brackets from around your list of fields in the SELECT clause.

select0, ID, NAME_FIRST, NAME_LAST
from person 
where ID=500unionallselect1, COMMTYPE_ID, NULL, NULLfrom person_commtype 
where PERSON_ID=500

Solution 2:

The problem is that Apache Derby doesn't support

selectnullfrom test

Instead you have to cast the null to the right type:

selectcast(nullasvarchar(255)) from test

So the query would look like:

select0, ID, NAME_FIRST, NAME_LAST
from person where ID=500unionallselect1, COMMTYPE_ID, 
    cast(NULLasvarchar(255)), 
    cast(NULLasvarchar(255))
from person_commtype where PERSON_ID=500

You also have to remove the brackets around your column list, because that's not standard SQL syntax.

Solution 3:

Try putting your numbers in single quotes.

select
    ('0', ID, NAME_FIRST, NAME_LAST)
from person 
where ID=500unionallselect 
    ('1', COMMTYPE_ID, NULL, NULL)
from person_commtype 
where PERSON_ID=500

Post a Comment for "What Syntax Is Used To Select A Constant Field Value From A Javadb Database?"