informix中,如何实现这样简单的过程?
现在存在a,b,c...公司,然后每个公司都有g1,g2,g3...数据库表格?如何用一个变量实现:
select * from g1 where 字段 =a
select * from g2 where 字段 =a
select * from g3 where 字段 =a
select * from g4 where 字段 =a
....
在查询b公司数据的是后把字段该成b
informix中有没有可以设置一个变量的函数
可以实现
定义: company_name = a
select * from g1 where 字段 =@company_name
select * from g2 where 字段 =@company_name
select * from g3 where 字段 =@company_name
select * from g4 where 字段 =@company_name
....
这样的东西那?只要求用informix环境下的sql语句实现.
问题点数:10、回复次数:10Top
1 楼sy_315(apollo)回复于 2004-08-03 13:46:40 得分 0
为什么没有来呢?分数不可以再加嘛Top
2 楼sy_315(apollo)回复于 2004-08-03 17:24:08 得分 0
upTop
3 楼wenlq(when)回复于 2004-08-04 19:15:28 得分 1
用存储过程就可以Top
4 楼sy_315(apollo)回复于 2004-08-05 17:58:15 得分 0
informix的存储过程怎么写
oracle的存储过程我会写Top
5 楼hudaojin(方圆)回复于 2004-08-11 16:58:53 得分 2
define __company_name char(20);
let __company_name = '我的小公司';
select * from g1 where 字段 = __company_name;
select * from g2 where 字段 = __company_name;
select * from g3 where 字段 = __company_name;
select * from g4 where 字段 = __company_name;
这样就行了Top
6 楼chenyansong(Batistuta)回复于 2004-09-07 11:43:09 得分 1
关注!Top
7 楼sindycsdn(sindy)回复于 2004-09-07 14:16:52 得分 2
create procedure read_address (lastname char(15))
returning char(15) as pfname, char(15) as plname,
char(20) as paddress1, char(15) as pcity,
char(2) as pstate, char(5) as pzipcode;
define p_fname, p_city char(15);
define p_add char(20);
define p_state char(2);
define p_zip char(5);
select fname, address1, city, state, zipcode
into p_fname, p_add, p_city, p_state, p_zip
from customer
where lname = lastname;
return p_fname, lastname, p_add, p_city, p_state, p_zip;
end procedure;
Top
8 楼tyffly(tyffly)回复于 2004-09-07 19:39:34 得分 1
或者用ec写Top
9 楼yessie()回复于 2004-12-15 09:42:39 得分 1
用shell可以,带变量进去就可以了Top
10 楼lzx130(小牛)回复于 2004-12-29 10:57:56 得分 2
给个例子你参考;
drop procedure pf_deleteValid;
create procedure pf_deleteValid(as_policyno char(20), as_endorseno char(20))
returning integer;
define li_count integer;
select count(*) into li_count
from datacenter:F_DealFee
where policyno = as_policyno
and endorseno = as_endorseno;
if (li_count > 0) then
let li_count = 1;
else
let li_count = 0;
end if;
if (li_count = 0) then
select count(*) into li_count
from datacenter:F_Fee
where policyno = as_policyno
and endorseno = as_endorseno
and ifcheck = '0';
if (li_count > 0) then
let li_count = 1;
else
let li_count = 0;
end if;
end if;
return li_count;
end procedure;
处sql语句以外,语法和4gl差不多Top




