Welcome Guest, Not a member yet? Register   Sign In
call function postgresql 9.5
#2

(This post was last modified: 12-28-2015, 08:06 AM by andresweb.)

I tried with a simpler function.


Code:
DROP FUNCTION sp_1()

CREATE OR REPLACE FUNCTION sp_1()
RETURNS TABLE(codigo character varying, nombre character varying)
AS
$$
BEGIN
RETURN QUERY SELECT sem_codigo, sem_nombre FROM semestre;
END;
$$
LANGUAGE 'plpgsql' VOLATILE;


pgadmin3 use it in this way:


Code:
SELECT codigo, nombre FROM sp_1();

so also


Code:
SELECT * FROM sp_1();


and works.

codeigniter but does not work.

Code:
$this->db->query('SELECT codigo, nombre FROM sp_1()');

or


Code:
$this->db->query('SELECT * FROM sp_1()')


the error is

ERROR: SELECT * with no tables specified is not valid LINE 1: SELECT * ^

SELECT *
Reply


Messages In This Thread
call function postgresql 9.5 - by andresweb - 12-27-2015, 08:02 PM
RE: call function postgresql 9.5 - by andresweb - 12-27-2015, 11:45 PM



Theme © iAndrew 2016 - Forum software by © MyBB