def proc_create_query(prname, prtext, argslist=None):
    """Base method for creating procedure with given name, body and args."""
    prtext = prtext.replace("'", "''")
    TEMPLATE = """
    CREATE OR REPLACE FUNCTION {prname}({argstext}) RETURNS VOID AS'
        {prtext}'
    LANGUAGE plpgsql;
    """
    argstext = ", ".join(argslist) if argslist else ''
    return TEMPLATE.format(prname=prname, prtext=prtext, argstext=argstext)