Custom SQL and ParamUrl OR Record:field_value

Is this possible to use the current record field (any of the fields) or query parameter.

I added a dynamic block, and then added a custom query. Here is part of it

JOIN imports im
    ON im.id = ii.import_id
JOIN individuals i
    ON i.id = ii.individual_id
WHERE im.audience_builder_id = {URL_PARAM:externalId}
  AND at.name IS NOT NULL

I know I need to consider SQL injection but just curious can I pass an id into the url then into the query of that block or better yet.

JOIN imports im
    ON im.id = ii.import_id
JOIN individuals i
    ON i.id = ii.individual_id
WHERE im.audience_builder_id = {CurrentRecord:externalId}
  AND at.name IS NOT NULL

Just reference the loaded records information?

Right now I get an error like the attached as if it is not being transformed from variable to the numeric value.