-- With no parameters
CREATE OR REPLACE FUNCTION funcdv_t01() RETURNS text AS
'SELECT ''ashesh''::text'
LANGUAGE 'sql';

CREATE OR REPLACE FUNCTION funcdv_t02a(text) RETURNS text AS
'SELECT $1' LANGUAGE 'sql';

CREATE OR REPLACE FUNCTION funcdv_t02b(integer DEFAULT 100) RETURNS integer AS
'SELECT $1+100' LANGUAGE 'sql';

CREATE TYPE dept_type AS (id numeric(2,0), dname character varying(14), loc character varying(13));

-- With Multiple parameters and with default values (user defined type)
CREATE OR REPLACE FUNCTION funcdv_t03(a integer DEFAULT 100, b dept_type DEFAULT  (12, 'abc', 'abc')) RETURNS dept_type AS
'SELECT $2' LANGUAGE 'sql';

-- Function as a defualt value
CREATE OR REPLACE FUNCTION funcdv_t04(text DEFAULT now())  RETURNS text AS
'SELECT $1'
LANGUAGE 'sql';

-- Multiple parameter and one default value
CREATE OR REPLACE FUNCTION funcdv_t05(IN integer, OUT b integer, IN integer DEFAULT 3) RETURNS integer AS
'SELECT $1' LANGUAGE 'sql';

-- Multiple parameter with one default value, but last parameter is out
CREATE OR REPLACE FUNCTION funcdv_t06(IN a integer, OUT b integer, IN c integer DEFAULT 3, OUT d text)
RETURNS record AS 'SELECT $1, CAST ($1 AS text)'
LANGUAGE 'sql';

-- Operation on function return value as default value
CREATE OR REPLACE FUNCTION funcdv_t07(timestamp without time zone DEFAULT ((now() - interval '23 hours')::timestamp without time zone))
RETURNS timestamp without time zone AS
'SELECT $1' LANGUAGE 'sql';

-- Multiple default value with user defined type value explicitly casting in a record format
CREATE OR REPLACE FUNCTION funcdv_t08(a integer DEFAULT 4, b dept_type DEFAULT  ROW((12)::numeric(2,0), 'abc'::character varying(14), 'xyz'::character varying(13)))
RETURNS integer AS
'SELECT $1' LANGUAGE 'sql';

-- All the following commented testcases fails

-- CREATE OR REPLACE FUNCTION funcdv_t09(IN a integer, OUT b integer, IN c integer DEFAULT 3, INOUT d text)
-- RETURNS record AS 'SELECT $1, $2'
-- LANGUAGE 'sql';

-- CREATE OR REPLACE FUNCTION funcdv_t10(IN a integer, OUT b integer, IN c integer DEFAULT 3, VARIADIC anyarray)
-- RETURNS record AS 'SELECT $1, CAST ($1 AS text)'
-- LANGUAGE 'sql';

-- CREATE OR REPLACE FUNCTION funcdv_t11(IN a integer DEFAULT 3, IN c integer)
-- RETURNS record AS 'SELECT $1, CAST ($2 AS text)'
-- LANGUAGE 'sql';

