Sto tentando di creare una funzione che restituisce un gruppo di risultati SELEZIONATO. quando chiamo la mia Postgres funzione come questa select * from tst_dates_func()
ottengo un errore come illustrato di seguito:La funzione con query SQL non ha destinazione per i dati dei risultati
ERROR: query has no destination for result data
HINT: If you want to discard the results of a SELECT, use PERFORM instead.
CONTEXT: PL/pgSQL function "tst_dates_func" line 3 at SQL statement
********** Error **********
ERROR: query has no destination for result data
SQL state: 42601
Hint: If you want to discard the results of a SELECT, use PERFORM instead.
Context: PL/pgSQL function "tst_dates_func" line 3 at SQL statement
Qui è la funzione che ho creato:
CREATE OR REPLACE FUNCTION tst_dates_func()
RETURNS TABLE(date_value date, date_id int, date_desc varchar) as
$BODY$
BEGIN
select a.date_value, a.date_id, a.date_desc from dates_tbl a;
END;
$BODY$
LANGUAGE plpgsql;
io non sono sicuro perché sto ottenendo l'errore precedente . Vorrei eseguire select * from tst_dates_func();
e recuperare i dati. O unire ulteriormente il set di risultati, se necessario. Qual è il problema qui?
Si prega di consultare gli esempi del manuale: http://www.postgresql.org/docs/current /static/plpgsql-control-structures.html#PLPGSQL-STATEMENTS-RETURNING e http://www.postgresql.org/docs/current/static/sql-createfunction.html#SQL-CREATEFUNCTION-EXAMPLES –
LANGUAGE dovrebbe essere SQL, non dovrebbe? –
Ho bisogno che sia la funzione plpgsql. Inoltre, dato che il linguaggio è SQL, avrei bisogno di inserire l'istruzione della query in stringa con le virgolette e non voglio farlo. –