Q&A

  • 며칠째 고민중....Parameter type 에러!!..김종언님 좀 봐줘요..
임시테이블생성후 프로그램 다시돌릴때

1.이미 bmt750t(임시테이블)이 존재한다는 메시지와

2.Field_el is of unknowm type라는 메시지가 발생합니다...뭐가 잘못된건지 통 감이 잡히질 않네요.....바쁘시더라도 꼭 좀 봐주세요..며칠째 고민중입니다..

첫번째에러는 함수값의 반환에서 문제가 있는건지...

두번째에러는 임시테이블의 필드정의와 파라미터로 값을 insert할때이 타입이 잘못된건지...쩝 ..감이 잡히지 않네요...

아래는 전체소스입니다.





type

TForm1 = class(TForm)

Panel1: TPanel;

Image1: TImage;

Bevel1: TBevel;

Label1: TLabel;

ComboBox1: TComboBox;

ComboBox2: TComboBox;

ComboBox3: TComboBox;

CheckBox1: TCheckBox;

Label2: TLabel;

ComboBox4: TComboBox;

Label3: TLabel;

ComboBox5: TComboBox;

CheckBox2: TCheckBox;

CheckBox3: TCheckBox;

Label4: TLabel;

ComboBox6: TComboBox;

PageControl1: TPageControl;

TabSheet1: TTabSheet;

TabSheet2: TTabSheet;

StringGrid1: TStringGrid;

querybitbtn1: TBitBtn;

BitBtn2: TBitBtn;

BitBtn3: TBitBtn;

BitBtn4: TBitBtn;

DataSource1: TDataSource;

Query1: TQuery;

Database1: TDatabase;

Query2: TQuery;

procedure BitBtn4Click(Sender: TObject);

procedure querybitbtn1Click(Sender: TObject);

function havingtable(table_name:string):integer;

private

{ Private declarations }

public

{ Public declarations }

end;



var

Form1: TForm1;



implementation



{$R *.DFM}



procedure TForm1.BitBtn4Click(Sender: TObject);

begin

application.terminate;

end;



procedure TForm1.querybitbtn1Click(Sender: TObject);

var

i:integer;

begin

with query1 do

begin

if havingtable('bmt750t')<> -1 then // 임시 테이블(bmt750t)이 있으면

begin

close;

sql.clear;

sql.add('drop table bmt750t');

execsql;

end;



close;

sql.clear;

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

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

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

sql.add('el integer,');

sql.add('sl integer,');

sql.add('bo integer,');

sql.add('hn integer)');

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

with query2 do

begin

close;

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

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



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

parambyname('a_').asstring:='abc';

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

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

else

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

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

else

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

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

else

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

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





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



function tform1.havingtable(table_name:string):integer;

var

itemlist:tstringlist;

begin

itemlist:=tstringlist.create;

session.gettablenames('mydb','',false,false,itemlist);

result:=itemlist.indexof(table_name);

end;



end.

2  COMMENTS
  • Profile
    김종언 2000.12.05 03:38
    아고 머리야~~

    머가먼지.. 복잡하자나여... T_T

    임시테이블이 존재한다는 메세지가 나온다면... 혹시... 임시테이블 삭제할때... 임시테이블을 열고 있지나 않은지 한번 보시구여...

    field_el is of unknown type 라면... 필드타입이 정해지지 않았다는 것처럼 보이는데... 이런 경험은 처음이라 좀 어렵군요...



    그리고.. select 문을 날린 후에.. first를 넣어줬는데.. 쓸모없는 문장입니다...

    select를 날린후엔 항상 커서가 첫번째로 이동해있습니다.



    직접 시험해보지 않으면 에러를 잡기 힘들것 같아서... ^^;;



    일단 직접 잡아보세요... 앞쪽에 점을 찍으면... 점이 체크가 됩니다.. 그럼 실행시키구여. 그 문장이 실행될때.. 점에서 멈추게 됩니다. 그럼 F7을 누르면 한줄씩 실행됩니다... 그렇게 하면.. 어디서 문제인지 약간을 찾기가 쉬울거에요... 제가 지금 바빠서..

    퇴근해야징~~~ 헤헤... 그럼... 나중에..







    해결이 안되면.. DB랑 source 올리세요... 직접해볼께요.













    델이랑파이랑 wrote:

    > 임시테이블생성후 프로그램 다시돌릴때

    > 1.이미 bmt750t(임시테이블)이 존재한다는 메시지와

    > 2.Field_el is of unknowm type라는 메시지가 발생합니다...뭐가 잘못된건지 통 감이 잡히질 않네요.....바쁘시더라도 꼭 좀 봐주세요..며칠째 고민중입니다..

    > 첫번째에러는 함수값의 반환에서 문제가 있는건지...

    > 두번째에러는 임시테이블의 필드정의와 파라미터로 값을 insert할때이 타입이 잘못된건지...쩝 ..감이 잡히지 않네요...

    > 아래는 전체소스입니다.

    >

    >

    > type

    > TForm1 = class(TForm)

    > Panel1: TPanel;

    > Image1: TImage;

    > Bevel1: TBevel;

    > Label1: TLabel;

    > ComboBox1: TComboBox;

    > ComboBox2: TComboBox;

    > ComboBox3: TComboBox;

    > CheckBox1: TCheckBox;

    > Label2: TLabel;

    > ComboBox4: TComboBox;

    > Label3: TLabel;

    > ComboBox5: TComboBox;

    > CheckBox2: TCheckBox;

    > CheckBox3: TCheckBox;

    > Label4: TLabel;

    > ComboBox6: TComboBox;

    > PageControl1: TPageControl;

    > TabSheet1: TTabSheet;

    > TabSheet2: TTabSheet;

    > StringGrid1: TStringGrid;

    > querybitbtn1: TBitBtn;

    > BitBtn2: TBitBtn;

    > BitBtn3: TBitBtn;

    > BitBtn4: TBitBtn;

    > DataSource1: TDataSource;

    > Query1: TQuery;

    > Database1: TDatabase;

    > Query2: TQuery;

    > procedure BitBtn4Click(Sender: TObject);

    > procedure querybitbtn1Click(Sender: TObject);

    > function havingtable(table_name:string):integer;

    > private

    > { Private declarations }

    > public

    > { Public declarations }

    > end;

    >

    > var

    > Form1: TForm1;

    >

    > implementation

    >

    > {$R *.DFM}

    >

    > procedure TForm1.BitBtn4Click(Sender: TObject);

    > begin

    > application.terminate;

    > end;

    >

    > procedure TForm1.querybitbtn1Click(Sender: TObject);

    > var

    > i:integer;

    > begin

    > with query1 do

    > begin

    > if havingtable('bmt750t')<> -1 then // 임시 테이블(bmt750t)이 있으면

    > begin

    > close;

    > sql.clear;

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

    > execsql;

    > end;

    >

    > close;

    > sql.clear;

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

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

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

    > sql.add('el integer,');

    > sql.add('sl integer,');

    > sql.add('bo integer,');

    > sql.add('hn integer)');

    > 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

    > with query2 do

    > begin

    > close;

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

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

    >

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

    > parambyname('a_').asstring:='abc';

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

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

    > else

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

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

    > else

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

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

    > else

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

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

    >

    >

    > 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

    >

    > function tform1.havingtable(table_name:string):integer;

    > var

    > itemlist:tstringlist;

    > begin

    > itemlist:=tstringlist.create;

    > session.gettablenames('mydb','',false,false,itemlist);

    > result:=itemlist.indexof(table_name);

    > end;

    >

    > end.

  • Profile
    방경주 2000.12.05 01:34
    쿼리가 좀 이상한거 아닌가여? Insert 구문에 If문을 써서 비교를 하셨는데..



    제 짧은 머리로는 그렇게 되면 한 필드에 값이 들어가면 나머지는 그냥 건너뛸것 같은데..



    흠...이거 글루 설명하기가 힘드네여...ㅡㅡ;



    구러니까.....

    query1

    stkid trans

    1 el 111

    2 sl 222

    3 ...



    이렇게 되면...



    query2 에서...

    insert into bmt750t (prdcod,up2,el,sl,bo,hn)

    values ('...','abc','111','','','','')

    insert into bmt750t (prdcod,up2,el,sl,bo,hn)

    values ('...','abc','','222','','','')



    이런식으로 값이 입력됨.. 나머진 널값이 들어가는데....이것 때문이 아닌가여?



    이게 아님 ..... 다른 고수님들이 차자 주시겠죠....ㅡㅡ;



    꼭 해답을 찾으시길...헤헤..



    > 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

    > with query2 do

    > begin

    > close;

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

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

    >

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

    > parambyname('a_').asstring:='abc';

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

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

    > else

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

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

    > else

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

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

    > else

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

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

    >

    >

    > 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

    >

    > function tform1.havingtable(table_name:string):integer;

    > var

    > itemlist:tstringlist;

    > begin

    > itemlist:=tstringlist.create;

    > session.gettablenames('mydb','',false,false,itemlist);

    > result:=itemlist.indexof(table_name);

    > end;

    >

    > end.