皆さん、こんにちは私はPostgreSQLでこの関数に問題があり、PostgreSQL言語を使用する必要があります。 ように、コードはこれです:私はエラーを取得するERROR:クエリに結果データの宛先がありませんDove:PL/pgSQL関数VOID
SELECT fnc_richiesta_attivazione_out_update_cdo(39, 'qqqqqqqq', '2016-08-03 23:00:00');
:
[42601] ERROR: query has no destination for result data Dove: PL/pgSQL function fnc_richiesta_attivazione_out_update_cdo(integer,character varying,timestamp without time zone) line 22 at SQL statement.
私はエラーを解決するが、私は実行する場合はすることはできません
CREATE OR REPLACE FUNCTION public.fnc_richiesta_attivazione_out_update_cdo(olo_rec_id INTEGER, current_uuid VARCHAR, requested_dco_date TIMESTAMP)
RETURNS VOID
AS
$$
DECLARE
flag_no_pah VARCHAR := 'N';
time_threshold INTEGER := 300;
rda_inserted_status INTEGER := 14;
invalid_status VARCHAR := 'N';
last_time_requested INTEGER;
limit_rows INTEGER;
n_richieste INTEGER;
capacita_max INTEGER;
c_requests INTEGER;
codice_olo_rec VARCHAR;
num_max_req VARCHAR:= 'NUM_MAX_RICHIESTE_PER_FILE';
BEGIN
SELECT valore INTO limit_rows FROM configurazione WHERE chiave = num_max_req;
SELECT num_richieste INTO n_richieste FROM conta_rda_inv WHERE olo = olo_rec_id;
SELECT codice_olo_amm INTO codice_olo_rec FROM configurazione_olo WHERE id = olo_rec_id;
SELECT EXTRACT(EPOCH FROM (current_date - (SELECT ora_ultimo_invio FROM conta_rda_inv WHERE olo = olo_rec_id))) INTO last_time_requested;
SELECT COUNT(id_richiesta) INTO c_requests FROM richieste WHERE id_lock = current_uuid;
UPDATE richieste SET id_lock = current_uuid, data_cut_over_richiesta = requested_dco_date WHERE id_richiesta IN (
SELECT id_richiesta
FROM richieste
WHERE id_lock IS NULL AND
codice_op_rec = codice_olo_rec AND
id_richiesta_stati = rda_inserted_status AND
flag_pah = flag_no_pah AND
(valido IS NULL OR valido <> invalid_status)
ORDER BY ts_ins ASC
LIMIT limit_rows
--) RETURNING *;
);
IF (n_richieste > capacita_max*2) THEN
UPDATE richieste SET id_lock = NULL WHERE id_lock = current_uuid;
ELSIF (c_requests < limit_rows AND last_time_requested < time_threshold) THEN
UPDATE richieste SET id_lock = NULL WHERE id_lock = current_uuid;
END IF;
END
$$
LANGUAGE plpgsql VOLATILE;
そして、ときに私が実行単一のSELECTが機能する
の結果'update ... returning'はどこかに格納する必要があります。 'select'ステートメントと同じように –
ありがとう!!! –