Q&A

  • [급질문]Query가 자꾸 에러나서 Index로 바꿨거든요...근데..
안되네요....



Caption에서 걸리네요..



맞는거 같은데...좀 봐주세요...

======================================================================

procedure TSARGC002Rm.QRBand1BeforePrint(Sender: TQRCustomBand;

var PrintBand: Boolean);

var

PYmon : integer;

Minputdate,Myear,Mmonth,Pmonth,MYmon : String;

begin

MinputDate := inttostr(inputdate);

Myear := copy(MinputDate, 1,4);

Mmonth := copy(MinputDate, 5,2);



if (Mmonth = '01') or (Mmonth = '02') or (Mmonth = '03') then

begin

Myear := Inttostr(StrtoInt(Myear)-1);

Pmonth := '12';

end

else if (Mmonth = '04') or (Mmonth = '05') or (Mmonth = '06') then

Pmonth := '03'

else if (Mmonth = '07') or (Mmonth = '08') or (Mmonth = '09') then

Pmonth := '06'

else if (Mmonth = '10') or (Mmonth = '11') or (Mmonth = '12') then

Pmonth := '09';



MYmon := (copy(Myear,1,4) + copy(Pmonth,1,2));

PYmon := strtoint(MYmon);





QRLabel9.caption :='';

QRLabel10.caption := '';

QRLabel11.caption := '';

QRLabel12.caption := '';

QRLabel13.caption := '';

QRLabel14.caption := '';

QRLabel15.caption := '';



if SAOCAPMTable.fieldbyname('ACapital').AsFloat <>0 then

begin

SabcapmTable.Insert;

SabcapmTable.FieldByName('RecDate').AsInteger := InputDate;

SabcapmTable.FieldByName('CapCode').AsInteger := 1;

SabcapmTable.FieldByName('Capital').AsFloat := SAOCAPMTable.fieldbyname('ACapital').AsFloat;

SabcapmTable.Post;

SabcapmTable.FlushBuffers;

end;



if SAOCAPMTable.fieldbyname('BCapital').AsFloat <>0 then

begin

SabcapmTable.Insert;

SabcapmTable.FieldByName('RecDate').AsInteger := InputDate;

SabcapmTable.FieldByName('CapCode').AsInteger := 2;

SabcapmTable.FieldByName('Capital').AsFloat := SAOCAPMTable.fieldbyname('BCapital').AsFloat;

SabcapmTable.Post;

SabcapmTable.FlushBuffers;



end;



if SAOCAPMTable.fieldbyname('REarning').AsFloat <>0 then

begin

SabcapmTable.Insert;

SabcapmTable.FieldByName('RecDate').AsInteger := InputDate;

SabcapmTable.FieldByName('CapCode').AsInteger := 3;

SabcapmTable.FieldByName('Capital').AsFloat := SAOCAPMTable.fieldbyname('REarning').AsFloat;

SabcapmTable.Post;

SabcapmTable.FlushBuffers;

end;



if SAOCAPMTable.fieldbyname('Reserves').AsFloat <>0 then

begin

SabcapmTable.Insert;

SabcapmTable.FieldByName('RecDate').AsInteger := InputDate;

SabcapmTable.FieldByName('CapCode').AsInteger := 4;

SabcapmTable.FieldByName('Capital').AsFloat := SAOCAPMTable.fieldbyname('Reserves').AsFloat;

SabcapmTable.Post;

SabcapmTable.FlushBuffers;

end;



if SAOCAPMTable.fieldbyname('CSurplus').AsFloat <>0 then

begin

SabcapmTable.Insert;

SabcapmTable.FieldByName('RecDate').AsInteger := InputDate;

SabcapmTable.FieldByName('CapCode').AsInteger := 5;

SabcapmTable.FieldByName('Capital').AsFloat := SAOCAPMTable.fieldbyname('CSurplus').AsFloat;

SabcapmTable.Post;

SabcapmTable.FlushBuffers;

end;



if SAOCAPMTable.fieldbyname('Others').AsFloat <>0 then

begin

SabcapmTable.Insert;

SabcapmTable.FieldByName('RecDate').AsInteger := InputDate;

SabcapmTable.FieldByName('CapCode').AsInteger := 9;

SabcapmTable.FieldByName('Capital').AsFloat := SAOCAPMTable.fieldbyname('Others').AsFloat;

SabcapmTable.Post;

SabcapmTable.FlushBuffers;

end ;



SAOCAPMTable.IndexName := 'Reportingindex';

SAOCAPMTable.IndexFieldNames := 'RYYMM';

SAOCAPMTable.setkey;



SAOCAPMTable.FieldByName('RYYMM').asinteger := PYmon;





//이 부분에서 에러가 나요... DBAccessViolation error요....

if not SAOCAPMTable.Findkey([PYmon]) <> true then

begin

{ with Query1 do

begin

close;

sql.clear;

sql.add('select * from SAOCAPM');

sql.add('where RYYMM = PYmon');

// parambyname('pDate').AsInteger = strtoint(MYmon);

open;

end;}





QRLabel9.caption := inttoStr(SAOCAPMTable.FieldByName('RYYMM').Asinteger);

QRLabel10.caption := FloattoStr(SAOCAPMTable.FieldByName('ACapital').AsFloat);

QRLabel11.caption := FloattoStr(SAOCAPMTable.FieldByName('BCapital').AsFloat);

QRLabel12.caption := FloattoStr(SAOCAPMTable.FieldByName('REarning').AsFloat);

QRLabel13.caption := FloattoStr(SAOCAPMTable.FieldByName('Reserves').AsFloat);

QRLabel14.caption := FloattoStr(SAOCAPMTable.FieldByName('CSurplus').AsFloat);

QRLabel15.caption := FloattoStr(SAOCAPMTable.FieldByName('Others').AsFloat);

end;

end;



procedure TSARGC002Rm.SabcapmTableFilterRecord(DataSet: TDataSet;

var Accept: Boolean);

begin

{Minputdate := Inttostr(Inputdate);

ShowMessage(Copy(MInputDate,1,4));

yy := StrtoInt(Copy(MInputDate,1,4));

ShowMessage(Copy(MInputDate,6,2));

mm := StrtoInt(Copy(MInputDate,6,2));

md := (mm-3) mod 3;



if Md < 0 then

begin

yy := yy-1;

mm := 12;

end

else begin

mm:=((mm-3) div 3)*3+3;

end;

QRLabel9.caption := format('%4d.%2d',[YY,MM]);}

end;

end.



================================================================================

답변부탁해요...

3  COMMENTS
  • Profile
    아폴론 2001.02.22 20:42
    >

    > //이 부분에서 에러가 나요... DBAccessViolation error요....

    > if not SAOCAPMTable.Findkey([PYmon]) <> true then



    디비를 보았는데 FindKey는 키로 선언이 되어있어야 해요 근데 SAOCAPM 디비는

    Unique 만 키로 선언이 되어 있어요 그러므로 위의 PYmon 이라는 것은 200101

    이라는 Integer값이 들어 있는데 Unique 필드에는 어떤 키값이 들어 있나요?

    Unique 값이 200101 이런 유형이 아니라면 에러를

    냅니다.

    그리고 not ... findkey ([..]) <> true 이말은 결국 참이라는말인데(맞나?)

    그냥 if SAOCAPMTable.Findkey([PYmon]) then 이렇게 해보세요



    > begin

    > { with Query1 do

    > begin

    > close;

    > sql.clear;

    > sql.add('select * from SAOCAPM');

    > sql.add('where RYYMM = PYmon');

    > open;

    > end;}



    그리고 Qrlable로 써도 되나요..보아하니...QRDBtext로 써야 하는 거 같은데...

    Query쓰면 레이블 쓰지 말아야 하나요..

    그리고



    sql.add('where RYYMM = PYmon');

    넘어가기는 하는데 PYmon에서 디비엔진에러가 뜨네요...

    Query말고 Index로 하는 방법이 있다던데...

    데이타가 많지는 않거든요...많지 않으면 Index도 가능하다고 해서 해봤는데...그것도 걸리네요..

    어떻게 해야 하나요...

    >

    > QRLabel9.caption := inttoStr(SAOCAPMTable.FieldByName('RYYMM').Asinteger);

    > QRLabel10.caption := FloattoStr(SAOCAPMTable.FieldByName('ACapital').AsFloat);

    > QRLabel11.caption := FloattoStr(SAOCAPMTable.FieldByName('BCapital').AsFloat);

    > QRLabel12.caption := FloattoStr(SAOCAPMTable.FieldByName('REarning').AsFloat);

    > QRLabel13.caption := FloattoStr(SAOCAPMTable.FieldByName('Reserves').AsFloat);

    > QRLabel14.caption := FloattoStr(SAOCAPMTable.FieldByName('CSurplus').AsFloat);

    > QRLabel15.caption := FloattoStr(SAOCAPMTable.FieldByName('Others').AsFloat);

    > end;

    > end;



    그리구 요 위 큐알레이블 이것은 출력폼에 한번만 보여줄때 사용 합니다.

    밴드중 타이틀이나 페이지헤더 등 이런 부분에 한번 만 출력하죠

    만약 디테일 밴드를 갖다 놓고 여러줄에 겹처 디비의 레코드값들을 출력 한다면

    디테일 밴드위에 QRDBText 를 가져다 놓고 퀵레포트를 쿼리랑 연결하고 큐알디비텍스트

    속성중 데이타셋에 쿼리를 연결하고 데이타 필드에 해당 필드를 연결하면 됩니다

    복잡한것 같은데 한번 해보면(물론 해 보셨겠지만..) 금방 임니다.

    음.. 어이구 대화라도 하면서 하면 금방이겠구만... 얼릉 끝내고 제우스한테는

    언제가지? 내가 알기로는
  • Profile
    아이리스 2001.02.22 22:47
    감사합니다...드디어
  • Profile
    아폴론 2001.02.22 19:24


    이론~ 아이리스님아



    //이 부분에서 에러가 나요... DBAccessViolation error요....

    if not SAOCAPMTable.Findkey([PYmon]) <> true then

    begin

    { with Query1 do

    begin

    close;

    sql.clear;

    sql.add('select * from SAOCAPM');

    sql.add('where RYYMM = PYmon');

    // parambyname('pDate').AsInteger = strtoint(MYmon);

    open;

    end;}

    위문장에는 파라미터가 없는데 파람바이네임을 주니 당연히 에러징~



    if not SAOCAPMTable.Findkey([PYmon]) <> true then

    begin

    with Query1 do begin

    close;

    sql.clear;

    sql.add('select * from SAOCAPM');

    sql.add('where RYYMM = PYmon');

    open;

    end;

    end;

    위처럼 where절에 직접대은해 줄 수도 있고 파라미터를 줄 수도 있어요.

    파라미터는 동적으로 할때 쓰죠.











    아이리스 wrote:

    > 안되네요....

    >

    > Caption에서 걸리네요..

    >

    > 맞는거 같은데...좀 봐주세요...

    > ======================================================================

    > procedure TSARGC002Rm.QRBand1BeforePrint(Sender: TQRCustomBand;

    > var PrintBand: Boolean);

    > var

    > PYmon : integer;

    > Minputdate,Myear,Mmonth,Pmonth,MYmon : String;

    > begin

    > MinputDate := inttostr(inputdate);

    > Myear := copy(MinputDate, 1,4);

    > Mmonth := copy(MinputDate, 5,2);

    >

    > if (Mmonth = '01') or (Mmonth = '02') or (Mmonth = '03') then

    > begin

    > Myear := Inttostr(StrtoInt(Myear)-1);

    > Pmonth := '12';

    > end

    > else if (Mmonth = '04') or (Mmonth = '05') or (Mmonth = '06') then

    > Pmonth := '03'

    > else if (Mmonth = '07') or (Mmonth = '08') or (Mmonth = '09') then

    > Pmonth := '06'

    > else if (Mmonth = '10') or (Mmonth = '11') or (Mmonth = '12') then

    > Pmonth := '09';

    >

    > MYmon := (copy(Myear,1,4) + copy(Pmonth,1,2));

    > PYmon := strtoint(MYmon);

    >

    >

    > QRLabel9.caption :='';

    > QRLabel10.caption := '';

    > QRLabel11.caption := '';

    > QRLabel12.caption := '';

    > QRLabel13.caption := '';

    > QRLabel14.caption := '';

    > QRLabel15.caption := '';

    >

    > if SAOCAPMTable.fieldbyname('ACapital').AsFloat <>0 then

    > begin

    > SabcapmTable.Insert;

    > SabcapmTable.FieldByName('RecDate').AsInteger := InputDate;

    > SabcapmTable.FieldByName('CapCode').AsInteger := 1;

    > SabcapmTable.FieldByName('Capital').AsFloat := SAOCAPMTable.fieldbyname('ACapital').AsFloat;

    > SabcapmTable.Post;

    > SabcapmTable.FlushBuffers;

    > end;

    >

    > if SAOCAPMTable.fieldbyname('BCapital').AsFloat <>0 then

    > begin

    > SabcapmTable.Insert;

    > SabcapmTable.FieldByName('RecDate').AsInteger := InputDate;

    > SabcapmTable.FieldByName('CapCode').AsInteger := 2;

    > SabcapmTable.FieldByName('Capital').AsFloat := SAOCAPMTable.fieldbyname('BCapital').AsFloat;

    > SabcapmTable.Post;

    > SabcapmTable.FlushBuffers;

    >

    > end;

    >

    > if SAOCAPMTable.fieldbyname('REarning').AsFloat <>0 then

    > begin

    > SabcapmTable.Insert;

    > SabcapmTable.FieldByName('RecDate').AsInteger := InputDate;

    > SabcapmTable.FieldByName('CapCode').AsInteger := 3;

    > SabcapmTable.FieldByName('Capital').AsFloat := SAOCAPMTable.fieldbyname('REarning').AsFloat;

    > SabcapmTable.Post;

    > SabcapmTable.FlushBuffers;

    > end;

    >

    > if SAOCAPMTable.fieldbyname('Reserves').AsFloat <>0 then

    > begin

    > SabcapmTable.Insert;

    > SabcapmTable.FieldByName('RecDate').AsInteger := InputDate;

    > SabcapmTable.FieldByName('CapCode').AsInteger := 4;

    > SabcapmTable.FieldByName('Capital').AsFloat := SAOCAPMTable.fieldbyname('Reserves').AsFloat;

    > SabcapmTable.Post;

    > SabcapmTable.FlushBuffers;

    > end;

    >

    > if SAOCAPMTable.fieldbyname('CSurplus').AsFloat <>0 then

    > begin

    > SabcapmTable.Insert;

    > SabcapmTable.FieldByName('RecDate').AsInteger := InputDate;

    > SabcapmTable.FieldByName('CapCode').AsInteger := 5;

    > SabcapmTable.FieldByName('Capital').AsFloat := SAOCAPMTable.fieldbyname('CSurplus').AsFloat;

    > SabcapmTable.Post;

    > SabcapmTable.FlushBuffers;

    > end;

    >

    > if SAOCAPMTable.fieldbyname('Others').AsFloat <>0 then

    > begin

    > SabcapmTable.Insert;

    > SabcapmTable.FieldByName('RecDate').AsInteger := InputDate;

    > SabcapmTable.FieldByName('CapCode').AsInteger := 9;

    > SabcapmTable.FieldByName('Capital').AsFloat := SAOCAPMTable.fieldbyname('Others').AsFloat;

    > SabcapmTable.Post;

    > SabcapmTable.FlushBuffers;

    > end ;

    >

    > SAOCAPMTable.IndexName := 'Reportingindex';

    > SAOCAPMTable.IndexFieldNames := 'RYYMM';

    > SAOCAPMTable.setkey;

    >

    > SAOCAPMTable.FieldByName('RYYMM').asinteger := PYmon;

    >

    >

    > //이 부분에서 에러가 나요... DBAccessViolation error요....

    > if not SAOCAPMTable.Findkey([PYmon]) <> true then

    > begin

    > { with Query1 do

    > begin

    > close;

    > sql.clear;

    > sql.add('select * from SAOCAPM');

    > sql.add('where RYYMM = PYmon');

    > // parambyname('pDate').AsInteger = strtoint(MYmon);

    > open;

    > end;}

    >

    >

    > QRLabel9.caption := inttoStr(SAOCAPMTable.FieldByName('RYYMM').Asinteger);

    > QRLabel10.caption := FloattoStr(SAOCAPMTable.FieldByName('ACapital').AsFloat);

    > QRLabel11.caption := FloattoStr(SAOCAPMTable.FieldByName('BCapital').AsFloat);

    > QRLabel12.caption := FloattoStr(SAOCAPMTable.FieldByName('REarning').AsFloat);

    > QRLabel13.caption := FloattoStr(SAOCAPMTable.FieldByName('Reserves').AsFloat);

    > QRLabel14.caption := FloattoStr(SAOCAPMTable.FieldByName('CSurplus').AsFloat);

    > QRLabel15.caption := FloattoStr(SAOCAPMTable.FieldByName('Others').AsFloat);

    > end;

    > end;

    >

    > procedure TSARGC002Rm.SabcapmTableFilterRecord(DataSet: TDataSet;

    > var Accept: Boolean);

    > begin

    > {Minputdate := Inttostr(Inputdate);

    > ShowMessage(Copy(MInputDate,1,4));

    > yy := StrtoInt(Copy(MInputDate,1,4));

    > ShowMessage(Copy(MInputDate,6,2));

    > mm := StrtoInt(Copy(MInputDate,6,2));

    > md := (mm-3) mod 3;

    >

    > if Md < 0 then

    > begin

    > yy := yy-1;

    > mm := 12;

    > end

    > else begin

    > mm:=((mm-3) div 3)*3+3;

    > end;

    > QRLabel9.caption := format('%4d.%2d',[YY,MM]);}

    > end;

    > end.

    >

    > ================================================================================

    > 답변부탁해요...