REBOL [
    Title: "Result-set to lookup table"
    Purpose: {Given an SQL result set, which comes in the form of
    a block of blocks, AND, each sub-block contains only one string,
    create a single block out of those strings that can be used to
    look up those strings.}
]

;; [---------------------------------------------------------------------------]
;; [ This is a specialized function for a specific project.  It starts with    ]
;; [ the result set of an SQL query, which is a block of blocks, where each    ]
;; [ sub-block is a row of the result set.  In addition, each sub-block        ]
;; [ contains just one item.  In other words, the SQL query that created       ]
;; [ the result set selected only one column.  Convert this result set into    ]
;; [ just one big block that we can search with the "find" function and        ]
;; [ discover if something is in that list.                                    ]
;; [---------------------------------------------------------------------------]

LOOKUP-LIST-OF-RESULT-SET: func [
    ROWBLOCK
    /local LOOKUPTABLE  
] [
    LOOKUPTABLE: copy []
    foreach ROW ROWBLOCK [
        append LOOKUPTABLE first ROW ;; first and only item in the row
    ]
    return LOOKUPTABLE
]

;;Uncomment to test
;TBL1: LOOKUP-LIST-OF-RESULT-SET [
;    ["AAAA1"]
;    ["AAAA2"]
;    ["AAAA3"]
;    ["AAAA4"]
;    ["AAAA5"]
;]
;probe TBL1
;halt