CREATE OR REPLACE FUNCTION mt_f_avl_oee_period(i_station character varying,i_type int)
RETURNS integer AS
$BODY$
DECLARE
v_start_hour character varying;
v_end_hour character varying;
v_start_time character varying;
v_end_time character varying;
v_start_datetime timestamp;
v_end_datetime timestamp;
v_type int := 0;
v_rtn int;
/*
v_test9_count int;
v_test9_success int;
v_runningtime double precision;
v_availablerate double precision;
*/
BEGIN
-- hour = even, minute > 30
-- exists
--
if i_type = 1 then
SELECT EXTRACT(HOUR FROM CURRENT_TIME - interval '2 hours' ) into v_start_hour; --two hours ago
SELECT EXTRACT(HOUR FROM CURRENT_TIME ) into v_end_hour; --get 'hour' of current time
select v_start_hour || ':30' into v_start_time;
select v_end_hour || ':30' into v_end_time;
select mt_f_avl_oee_period_e(i_station, to_char( CURRENT_Date, 'YYYY-MM-DD'), v_start_time
postgreSQL 存储过程及存储过程调用
最新推荐文章于 2025-03-13 13:40:25 发布