def union_sql(view_name, *tables):
if not tables:<EOL><INDENT>raise Exception("<STR_LIT>")<EOL><DEDENT>ret = "<STR_LIT>"<EOL>pre = "<STR_LIT>" % view_name<EOL>for table in tables:<EOL><INDENT>ret += pre + table<EOL>pre = "<STR_LIT>"<EOL><DEDENT>return ret<EOL>
This function generates string containing SQL code, that creates
    a big VIEW, that consists of many SELECTs.

    >>> utils.union_sql('global', 'foo', 'bar', 'baz')
    'CREATE VIEW global SELECT * FROM foo UNION SELECT * FROM bar UNION SELECT * FROM baz'