0

我正在尝试创建一个生成工具租金的报告,因为它需要是交互式的,我希望用户能够输入工具的部分名称或全名以显示该工具的所有租金。

TTITLE CENTER ==================== SKIP 1-
CENTER 'U  T O O L' skip 1-
CENTER ==================== SKIP 1 - 
LEFT 'Rental Report ' SKIP 1 -
LEFT ============ SKIP 2-
RIGHT 'Page:' -
FORMAT 999 SQL.PNO SKIP 2 

set pagesize 50

column MEMBERNAME HEADING 'Member Name'  format a20
column TOTAL HEADING 'Total Cost' format L9,999.99

compute sum label 'Total Cost: ' of TOTAL on MEMBERNAME
Break on Rental_ID on Member_ID on MEMBERNAME on Member_ID on Tel SKIP 1

select Member.Member_ID, SUBSTR(Member.FName,0,10) || SUBSTR(' ',0,10) ||
SUBSTR(Member.SName,0,15) as MEMBERNAME, Member.Tel,
Rental.Rental_ID,
Tool.Name, 
Rental.DateOut,
Rental.DateIn,
Rental_Line.Qty,
Rental_Line.Price,
Rental_Line.Qty*Rental_Line.Price as TOTAL
from Rental_Line
INNER JOIN Rental
on Rental.Rental_ID = Rental_Line.Rental_ID
INNER JOIN Member
on Rental.Member_ID = Member.Member_ID
INNER JOIN Tool_Instance
on Rental_Line.Tool_Instance_ID = Tool_Instance.Tool_Instance_ID
INNER JOIN Tool
on Tool_Instance.Tool_ID = Tool.Tool_ID
where Tool.Name = '%&_%';
4

2 回答 2

0

您可以创建一个接收参数的存储过程,例如:

CREATE PROCEDURE rentalReport(toolName IN varchar)
AS
--your query here
where Tool.Name = toolName

不确定确切的语法,没有使用过 Oracle db ..

更多信息: http: //www.ics.com/files/docs/dx/tut6.html

于 2012-11-29T22:03:19.730 回答
0

您应该使用ACCEPT命令 - 它使用户能够与您的脚本进行交互。像这样:

09:26:55 SYSTEM@dwal> create table t (key number primary key, value varchar2(10));

Table created.

09:27:15 SYSTEM@dwal> insert into t values (1, 'abcdef');

1 row created.

09:27:20 SYSTEM@dwal> insert into t values (2, 'ghijkl');

1 row created.

09:27:32 SYSTEM@dwal> commit;

Commit complete.

09:28:48 SYSTEM@dwal> accept search_str char prompt "enter parameter > ";
enter parameter > def
09:30:01 SYSTEM@dwal> select * from t where value like '%&search_str.%';

       KEY VALUE
---------- ----------
         1 abcdef
于 2012-12-06T01:37:11.283 回答