我有SELECT导出两个日期之间的销售信息(日期,数字)。
import cv2
import numpy as np
imgloc = 'path\Dosen_py.png'
img = cv2.imread(imgloc)
hight = np.shape(img)[0]
beam = np.zeros((hight,10,3))
gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
gray_3_channel = cv2.cvtColor(gray, cv2.COLOR_GRAY2BGR)
horizontal = np.hstack((img,beam,gray_3_channel))
small = cv2.resize(horizontal, (0,0), fx=0.5, fy=0.5)
cv2.imwrite("combi.png",small)
cv2.imshow("Combi",small)
cv2.waitKey()
但我想通过程序做到这一点。怎么做?我尝试过:
SELECT SALE_DATE, SALE_NUM
from SALES
where sale_date between '&fromdate' AND '&todate';
程序开始:
create or replace procedure SALE_DATES(var_saledate in SALES.SALE_DATE%TYPE)
AS
BEGIN
DECLARE Cursor c4 IS
SELECT SALE_DATE, SALE_NUM
from SALES
where sale_date = var_saledate AND var_saledate between '&fromdate' AND '&todate';
BEGIN FOR item IN c4
LOOP
DBMS_OUTPUT.PUT_LINE
('Date= ' || item.sale_date || ', Sale number: ' || item.sale_num);
END LOOP;
END;
END;
我应该在括号中使用什么参数?
答案 0 :(得分:2)
两个参数,以便您可以传递日期范围...我已经使用了更多标准命名约定,并且更清楚地说明了这一点。
CREATE OR REPLACE PROCEDURE get_sales
(P_from_date IN DATE
,P_to_date IN DATE
)
AS
CURSOR C_get_sales
IS
SELECT
s.sale_date
,s.sale_num
FROM
sales s
WHERE s.sale_date BETWEEN P_from_date AND P_to_date
;
BEGIN
FOR R_this_sale IN C_get_sales LOOP
DBMS_OUTPUT.PUT_LINE
('Date= ' || R_this_sale.sale_date || ', Sale number: ' || R_this_sale.sale_num)
;
END LOOP;
END;
答案 1 :(得分:1)
SQL> set serveroutput on; -- for dbms_output.put_line to take effect
SQL> CREATE OR REPLACE PROCEDURE SALE_DATES( v_sale_date_from
sales.sale_date%type, v_sale_date_to sales.sale_date%type )
AS
Cursor c4 IS
select SALE_DATE, SALE_NUM
from SALES
where sale_date between v_sale_date_from AND v_sale_date_to ;
BEGIN
FOR item IN c4
LOOP
DBMS_OUTPUT.PUT_LINE ('Date= ' || item.sale_date || ', Sale number: ' || item.sale_num);
END LOOP;
END;/
SQL> exec SALE_DATES(to_date('&dt1','dd.mm.yyyy'),to_date('&dt2','dd.mm.yyyy'));/
-- assuming your nls_date_format is dd.mm.yyyy, when prompted enter 19.12.2017 as an example.