[GENERAL] unable to call a function
i've write this function that search if inside a specified table there's a specified value: CREATE FUNCTION check_if_if_exist(id INTEGER, table_name character(50), table_column character(20) ) RETURNS BOOLEAN AS $$ BEGIN RETURN EXECUTE 'SELECT EXISTS(SELECT * FROM table_name WHERE table_column = id)'; END; $$ LANGUAGE plpgsql but when i try to call it i always receive an error and the function will not call. where is the problem? -- View this message in context: http://postgresql.1045698.n5.nabble.com/unable-to-call-a-function-tp5762590.html Sent from the PostgreSQL - general mailing list archive at Nabble.com. -- Sent via pgsql-general mailing list (pgsql-general@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-general
Re: [GENERAL] unable to call a function
ok, i've modify mi function, but now i'm not able to execute it: SELECT check_if_exist(10, table, col); ERROR: column "table" does not exist -- View this message in context: http://postgresql.1045698.n5.nabble.com/unable-to-call-a-function-tp5762590p5762599.html Sent from the PostgreSQL - general mailing list archive at Nabble.com. -- Sent via pgsql-general mailing list (pgsql-general@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-general
Re: [GENERAL] unable to call a function
ok, i've modify mi function, but now i'm not able to execute it: SELECT check_if_exist(10, table, col); ERROR: column "table" does not exist -- View this message in context: http://postgresql.1045698.n5.nabble.com/unable-to-call-a-function-tp5762590p5762600.html Sent from the PostgreSQL - general mailing list archive at Nabble.com. -- Sent via pgsql-general mailing list (pgsql-general@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-general
Re: [GENERAL] unable to call a function
something gone wrong the same... REATE OR REPLACE FUNCTION check_if_if_exist(id integer, table_name character, table_column character) RETURNS boolean AS $BODY$ DECLARE res BOOLEAN; BEGIN EXECUTE 'SELECT EXISTS(SELECT * FROM'||table_name|| 'WHERE'||table_column||'='||$1||')' INTO res USING id; RETURN res; END; select check_if_exist(10, 'prova', 'identificatore'); RROR: function check_if_exist(integer, unknown, unknown) does not exist LINE 1: select check_if_exist(10, 'prova', 'identificatore'); ^ HINT: No function matches the given name and argument types. You might need to add explicit type casts. -- View this message in context: http://postgresql.1045698.n5.nabble.com/unable-to-call-a-function-tp5762590p5762605.html Sent from the PostgreSQL - general mailing list archive at Nabble.com. -- Sent via pgsql-general mailing list (pgsql-general@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-general
Re: [GENERAL] unable to call a function
so thanks to all for the answers. But i'm going to be frustrated, no one of your solutions seems to work, and i can't understand why, because i've write another two functions that works well... I always obtain error: or unknown function (if i pass args without ' ') or "column not exist". i've noticed that on my postgres server, there's two database: one i've created for my scope, and another named postgres (i think created by default). Maybe should i specify on wich database my function should work (also if function compare only inside my personal database)? -- View this message in context: http://postgresql.1045698.n5.nabble.com/unable-to-call-a-function-tp5762590p5762649.html Sent from the PostgreSQL - general mailing list archive at Nabble.com. -- Sent via pgsql-general mailing list (pgsql-general@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-general
Re: [GENERAL] unable to call a function
ok, now it works with varchar args. thanks -- View this message in context: http://postgresql.1045698.n5.nabble.com/unable-to-call-a-function-tp5762590p5762891.html Sent from the PostgreSQL - general mailing list archive at Nabble.com. -- Sent via pgsql-general mailing list (pgsql-general@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-general
[GENERAL] function with unknown params
i've declared and implemented e function like: CREATE OR REPLACE FUNCTION acquistoLotto(m_g INTEGER, grossista VARCHAR(20), produttore BIGINT, costo INTEGER, dat DATE, descr VARCHAR(120), num_prod INTEGER) RETURNS VOID AS $$ but when i'm trying to call it like select acquistoLotto(0, 'grossista', 52187073424, 10, 22/1/2013, 'ciao ciao ciao', 10); an error occours: ERROR: function acquistolotto(integer, unknown, bigint, integer, integer, unknown, integer) does not exist How it's possible that the second and the sixth args it's unknown type? i've create another function that takes varchar as args and call in the same way and no errors occours. -- View this message in context: http://postgresql.1045698.n5.nabble.com/function-with-unknown-params-tp5763215.html Sent from the PostgreSQL - general mailing list archive at Nabble.com. -- Sent via pgsql-general mailing list (pgsql-general@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-general
Re: [GENERAL] function with unknown params
ok, it works. But why on error message i had that two unknown data type? if was an error on date type, why it don't signal that? -- View this message in context: http://postgresql.1045698.n5.nabble.com/function-with-unknown-params-tp5763215p5763224.html Sent from the PostgreSQL - general mailing list archive at Nabble.com. -- Sent via pgsql-general mailing list (pgsql-general@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-general
[GENERAL] function query error: column does not exist
i've a function takes as argument some values of few types, and make some INSERT operation using that values. I've occour an error while calling that function, the error is on a varchar variable. this is the insert code: >EXECUTE 'INSERT INTO table VALUES('||value1||','[...]','||value_char||')'; and the error is on value_char. pg told me that "column does not exist". Why? -- View this message in context: http://postgresql.1045698.n5.nabble.com/function-query-error-column-does-not-exist-tp5763460.html Sent from the PostgreSQL - general mailing list archive at Nabble.com. -- Sent via pgsql-general mailing list (pgsql-general@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-general
[GENERAL] function returning select result to JDBC
I need to write a function (invoked by a jdbc client) that returns select query result. That function could return also set of row. How should i declare return type of function? -- View this message in context: http://postgresql.1045698.n5.nabble.com/function-returning-select-result-to-JDBC-tp5763565.html Sent from the PostgreSQL - general mailing list archive at Nabble.com. -- Sent via pgsql-general mailing list (pgsql-general@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-general