Hi,
I created a function named CreateTable.
Code:
-- Function: createtable(text)
-- DROP FUNCTION createtable(text);
CREATE OR REPLACE FUNCTION createtable(text)
RETURNS numeric AS
$BODY$
BEGIN
EXECUTE 'Create table '||$1||'()';
return 0;
END;
$BODY$
LANGUAGE plpgsql VOLATILE
COST 100;
ALTER FUNCTION createtable(text)
OWNER TO postgres;
If I execute " createTable('XYZ') " in postgresql, it will create an empty XYZ table,
However if I run using java hibernate code, see below
Code:
String hql= "select createTable() from XTable ";
Query query = session.createQuery(hql);
List list = query.list();
String nextValue = (String)list.get(0).toString();
System.out.println(nextValue);
it won't work. Any idea?