I have created this table with Postgresql 9.3:
CREATE TABLE usuarios.token_usrpwd
(
id_token serial NOT NULL,
token character varying,
fechahora_creacion character varying,
CONSTRAINT token_usrpwd_pkey PRIMARY KEY (id_token)
)
WITH (
OIDS=FALSE
);
ALTER TABLE usuarios.token_usrpwd
OWNER TO postgres;
Then I created the function:
CREATE OR REPLACE FUNCTION eiel.insert_usuario_tokenpwd(character varying, character varying)
RETURNS boolean AS
$BODY$
DECLARE
token_obtenido ALIAS FOR $1;
fechahora_obtenido ALIAS FOR $2;
BEGIN
INSERT INTO usuarios.token_usrpwd (token,fechahora_creacion) VALUES (token_obtenido,fechahora_obtenido);
IF found THEN
RETURN TRUE;
ELSE
RETURN FALSE;
END IF;
END;
$BODY$
LANGUAGE plpgsql
Function and the table are both created correctly. Then when I call the function from the SQL console it inserts the row without problem:
SELECT eiel.insert_usuario_tokenpwd('190e526a2a54ff915d735026f9b64d8f','20150603112531')
But the problem comes when I call the same query from my php:
$insql= "SELECT eiel.insert_usuario_tokenpwd('190e526a2a54ff915d735026f9b64d8f','20150603112531')";
$queryresult = pg_query($database_connection, $insql) or die("Error in query: $insql . " . pg_last_error($database_connection));
Then an error happens and says :
Warning: pg_query(): Query failed: ERROR: no existe la función eiel.insert_usuario_tokenpwd(unknown, unknown)
LINE 1: SELECT eiel.insert_usuario_tokenpwd('190e526a2a54ff915d73502...
^
HINT: Ninguna función coincide en el nombre y tipos de argumentos. Puede ser necesario agregar conversión explícita de tipos. in F:\ms4w\apps\EIELv3\xfunctions.php on line 432
Error in query: SELECT eiel.insert_usuario_tokenpwd('190e526a2a54ff915d735026f9b64d8f','20150603112531') . ERROR: no existe la función eiel.insert_usuario_tokenpwd(unknown, unknown)
LINE 1: SELECT eiel.insert_usuario_tokenpwd('190e526a2a54ff915d73502...
^
HINT: Ninguna función coincide en el nombre y tipos de argumentos. Puede ser necesario agregar conversión explícita de tipos.
That means that the function does not exist.
HINT: No function matches the given name and argument types. You might need to add explicit type casts.
I had looked for info at this forum and others and tryed solutions like adding casts :: character varying or giving solutions like:
Postgres function creates but does not execute
or
No function matches the given name and argument types
but still doesn’t works. Any idea what is happening or if I am missing something?
Any idea would be appreciated
Thanks in Advance.