注文用のテーブルがあり、DATE タイプの 2 つの列 (delivery_date と order_date) があります。私のsqldeveloperでは、Java経由または手動で挿入したすべての日付は、今年の1月25日の10.01.25の形式になっています。ある日付と別の日付の間の注文の total_price を表示しようとすると、次のような形式を強制します。
create or replace function calc_Outlays (init_date IN DATE,final_date IN date)return number is
v_total_enc FORNECIMENTO.TOTAL_ENC_FORNEC%TYPE;
begin
select f.total_enc_fornec into v_total_enc from fornecimento f where f.data_entrega between init_date and final_date;
return v_total_enc;
Exception
When no_data_found then
Insert Into errors Values (0,'No supplyment costs found for dates between '||to_char(init_date)||' and '||to_char(final_date),systimestamp);
return -1;
end;
しかし、-1 が返されます。私は次のようなクエリを実行しようとさえします:select f.total_enc_fornec from fornecimento f where f.data_entrega = '10.01.24';
このように: このselect f.total_enc_fornec from fornecimento f where f.data_entrega = to_date('10.01.24','yy-mm-dd');
ように:select f.total_enc_fornec from fornecimento f where f.data_entrega < to_date('10.01.24');
そして何も返されません! しかし、私が実行すると:select f.total_enc_fornec from fornecimento f where f.data_entrega <= sysdate;
想定どおりに結果が出力されます...
これどうやってするの?私は明らかにパラメータも関数も正しく渡しておらず、クエリ自体も実行していません
ところで、ある年/月/日のすべての注文を選択したい場合は? たとえば、抽出関数を使用します。方法を教えてください。試してみましたが、同じ問題を抱えていて、少なくとも概念は単純です笑。