Select Node From Where Repl_state

TaSMania

ADSM.ORG Member
Joined
Nov 17, 2015
Messages
126
Reaction score
1
Points
0
why is this select statement not working? I want to query for nodes that is NOT enabled.
I can find couple doing Q N * F=D on smaller server under 100 nodes and see replication state: n/a or none

Select node_name from nodes where repl_state='enabled' or 'disabled' or 'none'
is it repl_state or replstate?
I have in my table as REPL_STATE
and per command, we user UPDATE NODE REPLSTATE=enabled
 
The right syntax is:

Select node_name from nodes where repl_state='ENABLED' or repl_state='DISABLED' or repl_state='NONE'

If you want to see the replication state as a table entry for all state, in order or ascending by repl_state:

Select node_name,repl_state from nodes where repl_state='ENABLED' or repl_state='DISABLED' or repl_state='NONE' order by repl_state,node_name

Just remember that select statements are case sensitive UNLESS you specify otherwise (as part of the select statement itself).
 
The right syntax is:

Select node_name from nodes where repl_state='ENABLED' or repl_state='DISABLED' or repl_state='NONE'

If you want to see the replication state as a table entry for all state, in order or ascending by repl_state:

Select node_name,repl_state from nodes where repl_state='ENABLED' or repl_state='DISABLED' or repl_state='NONE' order by repl_state,node_name

Just remember that select statements are case sensitive UNLESS you specify otherwise (as part of the select statement itself).
Is that select statement not the same as simply saying "SELECT node_name FROM nodes" since you give repl_state all possible values or am I misunderstanding something?

You could run this also if you wanted all upd n lines:
SELECT 'upd n '||node_name||' repls=enabled' FROM nodes WHERE repl_state='DISABLED' or repl_state IS NULL or repl_state='NONE'

Or perhaps cleaner:
SELECT 'upd n '||node_name||' repls=enabled' FROM nodes WHERE repl_state IN ('DISABLED', NULL, 'NONE')
 
Is that select statement not the same as simply saying "SELECT node_name FROM nodes" since you give repl_state all possible values or am I misunderstanding something?

You could run this also if you wanted all upd n lines:
SELECT 'upd n '||node_name||' repls=enabled' FROM nodes WHERE repl_state='DISABLED' or repl_state IS NULL or repl_state='NONE'

Or perhaps cleaner:
SELECT 'upd n '||node_name||' repls=enabled' FROM nodes WHERE repl_state IN ('DISABLED', NULL, 'NONE')

The SELECT statement I gave covers all conditions and ordered by repl_state, and is generally a generic select statement. Alternatively, one can list only enabled, disabled, none or NULL by removing appropriate where statements.
 
Last edited:
The SELECT statement I gave covers all conditions and ordered by repl_state, and is generally a generic select statement. Alternatively, one can list only enabled, disabled, none or NULL but removing appropriate where statements.
Right, my point was just that it is excessive to have the WHERE statement in this case (if you wanted all records regardless of the value stored in the repl_state column).

Just nitpicking on my part, but; instead of having DB2 examine all repl_state values and seeing if they are equal to any of the valid repl_state values I think it would be better to just fetch records in that case without examining them :)
 
Back
Top