表的插入问题,高手请进,有高分相送

lianmeng8848 2003-05-14 01:45:30
请教,错在哪?不要紧张
1、我的意思是把人员信息表记录插入工资表,并且把25,0,0,2003,3 分别插入出勤天数,奖金,安装费,工资年度,工资月份中,
2、其中人员信息表的序号(integer),姓名(alpha 8),日工资(integer),工资表的编号(long integer),姓名(alpha 8),日工资(number),出勤天数(long integer),奖金(number),安装费(number),工资年度(number),工资月份(number),
3、在delphi的 SQL Explorer运行

insert into 工资表(编号,姓名,日工资,出勤天数,奖金,安装费,工资年度,工资月份)
select distinct 序号,姓名,日工资,25,0,0,2003,3 from 人员信息表


的报错提示为‘Type mismatch in expression’;请教。。。错在哪?



4、实际的例子见下:
var
temp,asql:string;
i:integer;date1,date2:tdatetime;
begin
table1.Filter:='工资年度='+se_year.Text +' and 工资月份='+se_month.Text ;
table1.Filtered:=true;
if table1.RecordCount=0 then
begin
temp:='select distinct 序号,姓名,日工资

,25,0,0,'+se_year.Text+','+se_month.text+' from 人员信息表.db';
asql:='insert into 工资表(编号,姓名,日工资,出勤天数,奖金,安装费,工资年度,工资月

份) ' +
' select distinct 序号,姓名,日工资,25,0,0,'+se_year.Text+','+se_month.text+'

from 人员信息表.db;';
query1.SQL.Text :=asql;
query1.ExecSQL;
table1.Refresh;
table1.First;

for i:=0 to table1.recordcount-1 do
begin
query1.Close;
query1.sql.Text:='select sum(安装费) from 安装记录表.db where 主安装人='''
+table1.Fields[1].AsString+''''+' and 安装日期>=:d1 and 安装日期<:d2';

date1:=encodedate(se_year.Value,se_month.Value ,1);
date2:=encodedate(se_year.Value,se_month.Value+1,1);
query1.ParamByName('d1').AsDateTime:=date1;
query1.ParamByName('d2').AsDateTime:=date2;
query1.Open;
各位大虾,就是上面的,跟踪在table1.Refresh,提示的信息是‘Type mismatch in

expression’;请教。。。错在哪?

...全文
31 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
xuejinlong 2003-05-14
  • 打赏
  • 举报
回复
既 源程序这段代码

asql:='insert into 工资表(编号,姓名,日工资,出勤天数,奖金,安装费,工资年度,工资月

份) ' +
' select distinct 序号,姓名,日工资,25,0,0,'+se_year.Text+','+se_month.text+'


应该改为

asql:='insert into 工资表(编号,姓名,日工资,出勤天数,奖金,安装费,工资年度,工资月

份) ' +
' select distinct 序号,姓名,日工资,''25'',''0'',''0'','''+se_year.Text+''','''+se_month.text+''''
xuejinlong 2003-05-14
  • 打赏
  • 举报
回复
不,应该这样

insert into 工资表(编号,姓名,日工资,出勤天数,奖金,安装费,工资年度,工资月份)
select distinct 序号,姓名,日工资,''25'',''0'',''0'',''2003'',''3'' from 人员信息表

firetoucher 2003-05-14
  • 打赏
  • 举报
回复
应该是你的两个表结构不匹配
xuejinlong 2003-05-14
  • 打赏
  • 举报
回复
insert into 工资表(编号,姓名,日工资,出勤天数,奖金,安装费,工资年度,工资月份)
select distinct 序号,姓名,日工资,25,0,0,2003,3 from 人员信息表
group by 序号

1,593

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 网络通信/分布式开发
社区管理员
  • 网络通信/分布式开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧