//1、我写了一个存储过程如下mysql的:begin
declare wlm varchar(20);
declare fwm varchar(17);
declare cx_wlm varchar(20);
declare cx_fwm varchar(20);
declare s1 varchar(20);
select wlm,fwm from wlm_fwm where wlm='00000410000744035';
insert into cx_wlm(cx_wlm,cx_fwm)
values(wlm,fwm);
end// 2、我用查询语句的单独查询
select wlm,fwm from wlm_fwm where wlm='00000410000744035'; 这个时候可以得到结果// 3、我在存储过程中执行的时候得到的结果为
columm'cx_wlm' cannot be null
declare wlm varchar(20);
declare fwm varchar(17);
declare cx_wlm varchar(20);
declare cx_fwm varchar(20);
declare s1 varchar(20);
select wlm,fwm from wlm_fwm where wlm='00000410000744035';
insert into cx_wlm(cx_wlm,cx_fwm)
values(wlm,fwm);
end// 2、我用查询语句的单独查询
select wlm,fwm from wlm_fwm where wlm='00000410000744035'; 这个时候可以得到结果// 3、我在存储过程中执行的时候得到的结果为
columm'cx_wlm' cannot be null
declare wlm varchar(20);
declare fwm varchar(17);
declare cx_wlm varchar(20);
declare cx_fwm varchar(20);
declare s1 varchar(20); select wlm into wlm from wlm_fwm where wlm='00000410000744035';
select fwm into fwm from wlm_fwm where wlm='00000410000744035';
insert into cx_wlm(cx_wlm,cx_fwm)
values(wlm,fwm);
这样可以不的 end
+------+----------+------+-------+
| id | name | age | score |
+------+----------+------+-------+
| 1 | a | 21 | 66 |
| 2 | b | 22 | 77 |
| 3 | c | 23 | 88 |
| 4 | d | 24 | 99 |
| 5 | e | 23 | 100 |
| 6 | FFFFFFFF | 1111 | 60 |
+------+----------+------+-------+
6 rows in set (0.00 sec)mysql> select * from a;
+------+----------------+------+------+
| id | source | des | u |
+------+----------------+------+------+
| 1 | b | b | 10 |
| 1 | a | b | 10 |
| 1 | a | b | 10 |
| 1 | b | b | 10 |
| 1 | b | b | 10 |
| 1 | b | b | 10 |
| 1 | root@localhost | b | 10 |
| 1 | root@localhost | b | 10 |
| 1 | root@localhost | b | 10 |
+------+----------------+------+------+
10 rows in set (0.00 sec)mysql> drop procedure if exists insert_a;
Query OK, 0 rows affected (0.00 sec)mysql> delimiter $$
mysql> create procedure insert_a()
-> begin
-> declare s varchar(20);
-> declare d varchar(17);
->
-> select name into s from aa where id=6;
-> select age into d from aa where id=6;
->
-> insert into a(source,des)
-> values(s,d);
-> end;$$
Query OK, 0 rows affected (0.00 sec)mysql> delimiter ;
mysql> call insert_a();
Query OK, 1 row affected (0.03 sec)mysql> select * from a;
+------+----------------+------+------+
| id | source | des | u |
+------+----------------+------+------+
| 1 | b | b | 10 |
| 1 | a | b | 10 |
| 1 | a | b | 10 |
| 1 | b | b | 10 |
| 1 | b | b | 10 |
| 1 | b | b | 10 |
| 1 | root@localhost | b | 10 |
| 1 | root@localhost | b | 10 |
| 1 | root@localhost | b | 10 |
| NULL | FFFFFFFF | 1111 | NULL |
+------+----------------+------+------+
11 rows in set (0.00 sec)
建议你列出你的表结构,并提供测试数据以及基于这些测试数据的所对应正确结果。
参考一下这个贴子的提问方式http://topic.csdn.net/u/20091130/20/8343ee6a-417c-4c2d-9415-fa46604a00cf.html
1. 你的 create table xxx .. 语句
2. 你的 insert into xxx ... 语句
3. 结果是什么样,(并给以简单的算法描述)
4. 你用的数据库名称和版本(经常有人在MS SQL server版问 MySQL)
这样想帮你的人可以直接搭建和你相同的环境,并在给出方案前进行测试,避免文字描述理解上的误差。
重新换了一个需求,希望得到指点 http://topic.csdn.net/u/20101231/11/3dc1b93f-8db1-432b-b447-265b247e44fc.html
这里面按照你的需求写了一个 http://topic.csdn.net/u/20101231/11/3dc1b93f-8db1-432b-b447-265b247e44fc.html