<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def union_sql(view_name, *tables):
 """This function generates string containing SQL code, that creates a big VIEW, that consists of many SELECTs. 'CREATE VIEW global SELECT * FROM foo UNION SELECT * FROM bar UNION SELECT * FROM baz' """


    if not tables:
        raise Exception("no tables given")

    ret = ""
    pre = "CREATE VIEW %s AS SELECT * FROM " % view_name

    for table in tables:
        ret += pre + table
        pre = " UNION SELECT * FROM "

    return ret