Q&A

  • insert 할때 values값 에 대해
insert 할때 values부문에서 에러가 발생합니다..(표시된 부문).

values 에서 삽입할 값은 변수로 정의된 prdcod_,el_,sl_,bo_,hn_인데 이부분을 어떻게 정의해야되는지.....아래부문은 소스입니다

발생하는 에러 메시지 종류는 ,타입변환 혹은 const~과 관련된 에러입니다



procedure TForm1.querybitbtn1Click(Sender: TObject);

var

i:integer;

prdcod_:string;

el_:integer;

sl_:integer;

bo_:integer;

hn_:integer;



begin

with query1 do

begin

close;

sql.clear;

sql.add('drop table bmt750t');

execsql;



close;

sql.clear;

sql.add('create table bmt750T(');

sql.add('prdcod char(13),');

sql.add('up2 char(7),');

sql.add('el numeric(10),');

sql.add('sl numeric(10),');

sql.add('bo numeric(10),');

sql.add('hn numeric(10))');

execsql;

end;//with



with query1 do

begin

close;

sql.clear;

sql.add(' select * ');

sql.add(' from bmt750');

sql.add(' where stkyr+stkmm+stkdd>=20001129');

open;

first;



while not eof do

begin

prdcod_:='';

el_:=0;

sl_:=0;

bo_:=0;

hn_:=0;



prdcod_:=fieldbyname('prdcod').asstring;

if fieldbyname('stkid').asstring='el' then

el_:=fieldbyname('trans').asinteger + fieldbyname('netinp').asinteger

else

if fieldbyname('stkid').asstring='sl' then

sl_:=fieldbyname('trans').asinteger + fieldbyname('netinp').asinteger

else

if fieldbyname('stkid').asstring='bo' then

bo_:=fieldbyname('trans').asinteger + fieldbyname('netinp').asinteger

else

if fieldbyname('stkid').asstring='hn' then

hn_:=fieldbyname('trans').asinteger + fieldbyname('netinp').asinteger;

// end;



with query2 do

begin

close;

sql.add('insert into bmt750t (prdcod,up2,el,sl,bo,hn)');

sql.add('values (prdcod_,,el_,sl_,bo_,hn_)'); <===에러 발생부문

execsql;

close;

end;//with

next;

end;//while

end;//with



with query1 do

begin

i:=0;

close;

sql.clear;

sql.add('select prdcod,up2,el,sl,bo,hn');

sql.add('from bmt750t');

open;

first;

i:=1;

stringgrid1.rowcount:=recordcount+1;

while not eof do

begin

stringgrid1.cells[0,i]:=fieldbyname('prdcod').asstring;

stringgrid1.cells[1,i]:=fieldbyname('up2').asstring;

stringgrid1.cells[2,i]:=fieldbyname('el').asstring;

stringgrid1.cells[3,i]:=fieldbyname('sl').asstring;

stringgrid1.cells[4,i]:=fieldbyname('bo').asstring;

stringgrid1.cells[5,i]:=fieldbyname('hn').asstring;

next;

inc(i);

end;//while

close; //query1



sql.clear;

sql.add('drop table bmt750t');

execsql;

close;

end; //with



end; //처음 begin



end.

1  COMMENTS
  • Profile
    김종언 2000.12.04 20:24
    쩝... up2 라는 필드에 아무것도 넣지 않을거라면 없애버리면 되지 않을까요?



    sql.add('insert into bmt750t (prdcod,up2,el,sl,bo,hn)');

    sql.add('values (prdcod_,,el_,sl_,bo_,hn_)'); <===에러 발생부문

    아래처럼 고쳐보세요.



    sql.add('insert into bmt750t (prdcod, el, sl, bo, hn)');

    sql.add('values (prdcod_,el_,sl_,bo_,hn_)');



    아마 될겁니다.





    델이랑파이랑 wrote:

    > insert 할때 values부문에서 에러가 발생합니다..(표시된 부문).

    > values 에서 삽입할 값은 변수로 정의된 prdcod_,el_,sl_,bo_,hn_인데 이부분을 어떻게 정의해야되는지.....아래부문은 소스입니다

    > 발생하는 에러 메시지 종류는 ,타입변환 혹은 const~과 관련된 에러입니다

    >

    > procedure TForm1.querybitbtn1Click(Sender: TObject);

    > var

    > i:integer;

    > prdcod_:string;

    > el_:integer;

    > sl_:integer;

    > bo_:integer;

    > hn_:integer;

    >

    > begin

    > with query1 do

    > begin

    > close;

    > sql.clear;

    > sql.add('drop table bmt750t');

    > execsql;

    >

    > close;

    > sql.clear;

    > sql.add('create table bmt750T(');

    > sql.add('prdcod char(13),');

    > sql.add('up2 char(7),');

    > sql.add('el numeric(10),');

    > sql.add('sl numeric(10),');

    > sql.add('bo numeric(10),');

    > sql.add('hn numeric(10))');

    > execsql;

    > end;//with

    >

    > with query1 do

    > begin

    > close;

    > sql.clear;

    > sql.add(' select * ');

    > sql.add(' from bmt750');

    > sql.add(' where stkyr+stkmm+stkdd>=20001129');

    > open;

    > first;

    >

    > while not eof do

    > begin

    > prdcod_:='';

    > el_:=0;

    > sl_:=0;

    > bo_:=0;

    > hn_:=0;

    >

    > prdcod_:=fieldbyname('prdcod').asstring;

    > if fieldbyname('stkid').asstring='el' then

    > el_:=fieldbyname('trans').asinteger + fieldbyname('netinp').asinteger

    > else

    > if fieldbyname('stkid').asstring='sl' then

    > sl_:=fieldbyname('trans').asinteger + fieldbyname('netinp').asinteger

    > else

    > if fieldbyname('stkid').asstring='bo' then

    > bo_:=fieldbyname('trans').asinteger + fieldbyname('netinp').asinteger

    > else

    > if fieldbyname('stkid').asstring='hn' then

    > hn_:=fieldbyname('trans').asinteger + fieldbyname('netinp').asinteger;

    > // end;

    >

    > with query2 do

    > begin

    > close;

    > sql.add('insert into bmt750t (prdcod,up2,el,sl,bo,hn)');

    > sql.add('values (prdcod_,,el_,sl_,bo_,hn_)'); <===에러 발생부문

    > execsql;

    > close;

    > end;//with

    > next;

    > end;//while

    > end;//with

    >

    > with query1 do

    > begin

    > i:=0;

    > close;

    > sql.clear;

    > sql.add('select prdcod,up2,el,sl,bo,hn');

    > sql.add('from bmt750t');

    > open;

    > first;

    > i:=1;

    > stringgrid1.rowcount:=recordcount+1;

    > while not eof do

    > begin

    > stringgrid1.cells[0,i]:=fieldbyname('prdcod').asstring;

    > stringgrid1.cells[1,i]:=fieldbyname('up2').asstring;

    > stringgrid1.cells[2,i]:=fieldbyname('el').asstring;

    > stringgrid1.cells[3,i]:=fieldbyname('sl').asstring;

    > stringgrid1.cells[4,i]:=fieldbyname('bo').asstring;

    > stringgrid1.cells[5,i]:=fieldbyname('hn').asstring;

    > next;

    > inc(i);

    > end;//while

    > close; //query1

    >

    > sql.clear;

    > sql.add('drop table bmt750t');

    > execsql;

    > close;

    > end; //with

    >

    > end; //처음 begin

    >

    > end.