mysql存储过程能不能输入多个参数的? 如果能。。请给一个例子。谢谢
解决如下:mysql>DELIMITER//mysql>CREATEPROCEDUREname2(dt1DATETIME,dt2DATETIME)->BEGIN->SEL...
解决如下:
mysql> DELIMITER //
mysql> CREATE PROCEDURE name2(dt1 DATETIME, dt2 DATETIME)
-> BEGIN
-> SELECT *
-> FROM table1
-> where time1>=dt1 and time1 <= dt2;
-> END;
-> //
Query OK, 0 rows affected (0.01 sec)
mysql> call name2('2001-01-01', '2012-10-10');
-> //
+---------------+---------------------+
| ip | time1 |
+---------------+---------------------+
| 192.168.1.105 | 2011-04-26 03:00:00 |
| 192.168.1.106 | 2011-04-27 02:00:00 |
+---------------+---------------------+ 展开
mysql> DELIMITER //
mysql> CREATE PROCEDURE name2(dt1 DATETIME, dt2 DATETIME)
-> BEGIN
-> SELECT *
-> FROM table1
-> where time1>=dt1 and time1 <= dt2;
-> END;
-> //
Query OK, 0 rows affected (0.01 sec)
mysql> call name2('2001-01-01', '2012-10-10');
-> //
+---------------+---------------------+
| ip | time1 |
+---------------+---------------------+
| 192.168.1.105 | 2011-04-26 03:00:00 |
| 192.168.1.106 | 2011-04-27 02:00:00 |
+---------------+---------------------+ 展开
3个回答
展开全部
mysql> DELIMITER //
mysql> CREATE PROCEDURE HelloWorld2(
-> IN vUserName VARCHAR(10),
-> OUT vOutValue VARCHAR(10),
-> INOUT vInOutValue VARCHAR(10))
-> BEGIN
-> SELECT CONCAT('Hello ', vUserName);
-> SET vOutValue = 'A';
-> SET vInOutValue = 'B';
-> END//
Query OK, 0 rows affected (0.00 sec)
mysql> call HelloWorld2('Edward', @a, @b)//
+-----------------------------+
| CONCAT('Hello ', vUserName) |
+-----------------------------+
| Hello Edward |
+-----------------------------+
1 row in set (0.00 sec)
Query OK, 0 rows affected (0.00 sec)
mysql> select @a//
+------+
| @a |
+------+
| A |
+------+
1 row in set (0.00 sec)
mysql> select @b//
+------+
| @b |
+------+
| B |
+------+
1 row in set (0.00 sec)
mysql> CREATE PROCEDURE HelloWorld2(
-> IN vUserName VARCHAR(10),
-> OUT vOutValue VARCHAR(10),
-> INOUT vInOutValue VARCHAR(10))
-> BEGIN
-> SELECT CONCAT('Hello ', vUserName);
-> SET vOutValue = 'A';
-> SET vInOutValue = 'B';
-> END//
Query OK, 0 rows affected (0.00 sec)
mysql> call HelloWorld2('Edward', @a, @b)//
+-----------------------------+
| CONCAT('Hello ', vUserName) |
+-----------------------------+
| Hello Edward |
+-----------------------------+
1 row in set (0.00 sec)
Query OK, 0 rows affected (0.00 sec)
mysql> select @a//
+------+
| @a |
+------+
| A |
+------+
1 row in set (0.00 sec)
mysql> select @b//
+------+
| @b |
+------+
| B |
+------+
1 row in set (0.00 sec)
参考资料: http://hi.baidu.com/wangzhiqing999/blog/item/0b145a84f1be9fd89023d961.html
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
多个参数的:
create or replace procedure BCS_ERPdataQuery_tu
( p_cursor IN OUT TYPES.cursorType,
v_company Varchar,
fromdate Varchar,
todate Varchar
)
is
str Varchar2(4000):='';
Begin
str:='select * from baan.ttisfc001'||v_company||'@BAAN26 t1
where t1.t$osta=1 and t1.t$pdno Like ''T10%''
and t1.t$prdt+ interval ''8'' hour>=to_date('''||fromdate||''',''yyyy-mm-dd hh24:mi:ss '')
and t1.t$prdt+ interval ''8'' hour<=to_date('''||todate||''',''yyyy-mm-dd hh24:mi:ss '')';
Open p_cursor For str;
end BCS_ERPdataQuery_tu;
create or replace procedure BCS_ERPdataQuery_tu
( p_cursor IN OUT TYPES.cursorType,
v_company Varchar,
fromdate Varchar,
todate Varchar
)
is
str Varchar2(4000):='';
Begin
str:='select * from baan.ttisfc001'||v_company||'@BAAN26 t1
where t1.t$osta=1 and t1.t$pdno Like ''T10%''
and t1.t$prdt+ interval ''8'' hour>=to_date('''||fromdate||''',''yyyy-mm-dd hh24:mi:ss '')
and t1.t$prdt+ interval ''8'' hour<=to_date('''||todate||''',''yyyy-mm-dd hh24:mi:ss '')';
Open p_cursor For str;
end BCS_ERPdataQuery_tu;
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询
广告 您可能关注的内容 |