Metaprogramming

David Hopwood david.nospam.hopwood@REDACTED
Thu Aug 24 21:18:43 CEST 2006


Yariv Sadan wrote:
>>
>>   Fields = [id, name, age],
>>   <|sql| SELECT @@Fields FROM @Table |>
> 
> FYI,
> 
> There's a (less slick but pure Erlang) runtime way of doing something
> similar with smerl:
> 
> -module(db).
> -compile(export_all).
> 
> meta_select(Fields, Table) ->
>   "SELECT " ++ cocat(Fields) ++ " FROM " ++ atom_to_list(Table).

But unlike Vlad's version, that's vulnerable to SQL injection attacks.

-- 
David Hopwood <david.nospam.hopwood@REDACTED>





More information about the erlang-questions mailing list