Is it "valid" for semantic functions to query outside of the grammar in attribute grammars? Is it valid (in the sense of formal grammars or formal language theory) to refer to outside of the grammar in attribute grammars?

What I mean is that since attribute grammars can contain semantic functions e.g.


  E1 → E2+T { E1.val := sum(E2.val, T.val) }


then could there (in the place of the sum function) be a function that does e.g. a SQL query?



Should add that this is technically feasible, but I want to know that if it's reasonable and in accord to the theory of attribute grammars and the practice of semantic analysis.
The sum function of your example itself is already stepping out of the strict scope of the grammar. Or you'd have to to explicitly include all the machinery used in your attributed grammar into it, in which case nothing forbids adding (some formalization of) SQL and a database to it.