def METHOD_NAME(pgcnx):
	print "-----------------------------"
	print "-- Creating SQL Functions on Composite Types"
	print "--  it is also possible to create functions that return"
	print "--  values of composite types."
	print "-----------------------------"
	print
	print "-- before we create more sophisticated functions, let's "
	print "-- populate an EMP table"
	print
	print "CREATE TABLE EMP ("
	print "    name    text,"
	print "    salary  int4,"
	print "    age     int4,"
	print "    dept    varchar(16)"
	print ")"
	pgcnx.query("""CREATE TABLE EMP (
        name        text,
        salary      int4,
        age         int4,
        dept        varchar(16))""")
	print
	print "INSERT INTO EMP VALUES ('Sam', 1200, 16, 'toy')"
	print "INSERT INTO EMP VALUES ('Claire', 5000, 32, 'shoe')"
	print "INSERT INTO EMP VALUES ('Andy', -1000, 2, 'candy')"
	print "INSERT INTO EMP VALUES ('Bill', 4200, 36, 'shoe')"
	print "INSERT INTO EMP VALUES ('Ginger', 4800, 30, 'candy')"
	pgcnx.query("INSERT INTO EMP VALUES ('Sam', 1200, 16, 'toy')")
	pgcnx.query("INSERT INTO EMP VALUES ('Claire', 5000, 32, 'shoe')")
	pgcnx.query("INSERT INTO EMP VALUES ('Andy', -1000, 2, 'candy')")
	pgcnx.query("INSERT INTO EMP VALUES ('Bill', 4200, 36, 'shoe')")
	pgcnx.query("INSERT INTO EMP VALUES ('Ginger', 4800, 30, 'candy')")
	wait_key()
	print
	print "-- the argument of a function can also be a tuple. For "
	print "-- instance, double_salary takes a tuple of the EMP table"
	print
	print "CREATE FUNCTION double_salary(EMP) RETURNS int4"
	print "   AS 'SELECT $1.salary * 2 AS salary' LANGUAGE 'sql'"
	pgcnx.query("""CREATE FUNCTION double_salary(EMP) RETURNS int4
        AS 'SELECT $1.salary * 2 AS salary' LANGUAGE 'sql'""")
	print
	print "SELECT name, double_salary(EMP) AS dream"
	print "FROM EMP"
	print "WHERE EMP.dept = 'toy'"
	print pgcnx.query("""SELECT name, double_salary(EMP) AS dream
        FROM EMP WHERE EMP.dept = 'toy'""")
	print
	print "-- the return value of a function can also be a tuple. However,"
	print "-- make sure that the expressions in the target list is in the "
	print "-- same order as the columns of EMP."
	print
	print "CREATE FUNCTION new_emp() RETURNS EMP"
	print "   AS 'SELECT \'None\'::text AS name,"
	print "              1000 AS salary,"
	print "              25 AS age,"
	print "              \'none\'::varchar(16) AS dept'"
	print "   LANGUAGE 'sql'"
	pgcnx.query("""CREATE FUNCTION new_emp() RETURNS EMP
        AS 'SELECT \\\'None\\\'::text AS name,
            1000 AS salary,
            25 AS age,
            \\\'none\\\'::varchar(16) AS dept'
        LANGUAGE 'sql'""")
	wait_key()
	print
	print "-- you can then project a column out of resulting the tuple by"
	print "-- using the \"function notation\" for projection columns. "
	print "-- (ie. bar(foo) is equivalent to foo.bar) Note that we don't"
	print "-- support new_emp().name at this moment."
	print
	print "SELECT name(new_emp()) AS nobody"
	print pgcnx.query("SELECT name(new_emp()) AS nobody")
	print
	print "-- let's try one more function that returns tuples"
	print "CREATE FUNCTION high_pay() RETURNS setof EMP"
	print "   AS 'SELECT * FROM EMP where salary > 1500'"
	print "   LANGUAGE 'sql'"
	pgcnx.query("""CREATE FUNCTION high_pay() RETURNS setof EMP
        AS 'SELECT * FROM EMP where salary > 1500'
        LANGUAGE 'sql'""")
	print
	print "SELECT name(high_pay()) AS overpaid"
	print pgcnx.query("SELECT name(high_pay()) AS overpaid")