pg_select SELECT problem
meagon opened this issue · 4 comments
CREATE TABLE tab (id int, t varchar);
INSERT INTO tab VALUES (0, 'str00'), (1, 'str11');
SELECT pgv_select('vars', 'r1', 'str1');
ERROR: function pgv_select(unknown, unknown, unknown) is not unique
LINE 1: SELECT pgv_select('vars', 'r1', 'str1');
^
HINT: Could not choose a best candidate function. You might need to add explicit type casts.
how call i get the record the contains string 'str1'
To fix this error for string types you should pass type for the third argument, which is the same as the key type:
SELECT pgv_select('vars', 'r1', 'str1'::varchar);
To execute pgv_select() function you should insert some data to r1 variable:
SELECT pgv_insert('vars', 'r1', tab) FROM tab;
It is not clear from README, but the third argument is the key to select. The key is the first column. If you will execute the query:
SELECT pgv_insert('vars', 'r1', row(id, t)) FROM tab;
then the key is id. If you will execute the query:
SELECT pgv_insert('vars', 'r1', row(t,id)) FROM tab;
then the key is t.
if varchar if not the first column type, pgv_select will not select releated relation;
will it later add more where clause types?
pgv_select() already supports other types: string, numeric, date types. But I am not sure that I understand your question correctly.
I added more information about functions into README.