• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
call function postgresql 9.5

#2
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

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2019 MyBB Group.