Q&A

  • 조인한 것인데 에러가 생기네여


IF RADIOGROUP1.ITEMINDEX = 4 THEN

QUERY1.CLOSE;

QUERY2.Close;

QUERY1.SQL.CLEAR;

QUERY2.SQL.Clear;

SSQL := FORMAT('SELECT DBPGM.PGMID, DBPGM.PGMTITLE FROM DBPGM, DBSUB WHERE DBPGM.PGMID = DBSUB.PGMID AND DBSUB.SUBPGM1 =''%S''', [TRIM(EDIT1.TEXT)]);

SSQL := FORMAT('SELECT DBPGM.PGMID, DBPGM.PGMTITLE FROM DBPGM, DBSUB WHERE DBPGM.PGMID = DBSUB.PGMID AND DBSUB.SUBPGM2 =''%S''', [TRIM(EDIT1.TEXT)]);

SSQL := FORMAT('SELECT DBPGM.PGMID, DBPGM.PGMTITLE FROM DBPGM, DBSUB WHERE DBPGM.PGMID = DBSUB.PGMID AND DBSUB.SUBPGM3 =''%S''', [TRIM(EDIT1.TEXT)]);

SSQL := FORMAT('SELECT DBPGM.PGMID, DBPGM.PGMTITLE FROM DBPGM, DBSUB WHERE DBPGM.PGMID = DBSUB.PGMID AND DBSUB.SUBPGM4 =''%S''', [TRIM(EDIT1.TEXT)]);

SSQL := FORMAT('SELECT DBPGM.PGMID, DBPGM.PGMTITLE FROM DBPGM, DBSUB WHERE DBPGM.PGMID = DBSUB.PGMID AND DBSUB.SUBPGM =''%S''', [TRIM(EDIT1.TEXT)]);

TRY

//QUERY1.SQL.ADD(SSQL);

QUERY1.OPEN;

SHOWMESSAGE(QUERY1.SQL.TEXT);

STRINGGRID1.Cells[0,0] := '프로그램아이디';

STRINGGRID1.Cells[1,0] := '프로그램제목';

STRINGGRID1.CELLS[0,1]:=QUERY1.FIELDS[0].ASSTRING;

STRINGGRID1.CELLS[1,1]:=QUERY1.FIELDS[1].ASSTRING;

QUERY1.SQL.CLEAR;



EXCEPT

Query1.Close;

APPLICATION.MESSAGEBOX('검색도중 에러발생', '에러', MB_OK+MB_ICONINFORMATION);

EXIT;

//Query1.FREE;

end;

Query1.CLOSE;



NO SQL ..... available이라는 에러가 생기네여..

조인이 들어가니까 또 막히네여...

위의 코딩내용좀 봐주세여..

무엇이 잘못되었는지 답변 기다리겠습니다.





1  COMMENTS
  • Profile
    김광섭 2001.02.06 02:35
    초보 wrote:

    >

    > IF RADIOGROUP1.ITEMINDEX = 4 THEN

    > QUERY1.CLOSE;

    > QUERY2.Close;

    > QUERY1.SQL.CLEAR;

    > QUERY2.SQL.Clear;

    > SSQL := FORMAT('SELECT DBPGM.PGMID, DBPGM.PGMTITLE FROM DBPGM, DBSUB WHERE DBPGM.PGMID = DBSUB.PGMID AND DBSUB.SUBPGM1 =''%S''', [TRIM(EDIT1.TEXT)]);

    > SSQL := FORMAT('SELECT DBPGM.PGMID, DBPGM.PGMTITLE FROM DBPGM, DBSUB WHERE DBPGM.PGMID = DBSUB.PGMID AND DBSUB.SUBPGM2 =''%S''', [TRIM(EDIT1.TEXT)]);

    > SSQL := FORMAT('SELECT DBPGM.PGMID, DBPGM.PGMTITLE FROM DBPGM, DBSUB WHERE DBPGM.PGMID = DBSUB.PGMID AND DBSUB.SUBPGM3 =''%S''', [TRIM(EDIT1.TEXT)]);

    > SSQL := FORMAT('SELECT DBPGM.PGMID, DBPGM.PGMTITLE FROM DBPGM, DBSUB WHERE DBPGM.PGMID = DBSUB.PGMID AND DBSUB.SUBPGM4 =''%S''', [TRIM(EDIT1.TEXT)]);

    > SSQL := FORMAT('SELECT DBPGM.PGMID, DBPGM.PGMTITLE FROM DBPGM, DBSUB WHERE DBPGM.PGMID = DBSUB.PGMID AND DBSUB.SUBPGM =''%S''', [TRIM(EDIT1.TEXT)]);

    > TRY

    > //QUERY1.SQL.ADD(SSQL);

    > QUERY1.OPEN;

    > SHOWMESSAGE(QUERY1.SQL.TEXT);

    > STRINGGRID1.Cells[0,0] := '프로그램아이디';

    > STRINGGRID1.Cells[1,0] := '프로그램제목';

    > STRINGGRID1.CELLS[0,1]:=QUERY1.FIELDS[0].ASSTRING;

    > STRINGGRID1.CELLS[1,1]:=QUERY1.FIELDS[1].ASSTRING;

    > QUERY1.SQL.CLEAR;

    >

    > EXCEPT

    > Query1.Close;

    > APPLICATION.MESSAGEBOX('검색도중 에러발생', '에러', MB_OK+MB_ICONINFORMATION);

    > EXIT;

    > //Query1.FREE;

    > end;

    > Query1.CLOSE;

    >

    > NO SQL ..... available이라는 에러가 생기네여..

    > 조인이 들어가니까 또 막히네여...

    > 위의 코딩내용좀 봐주세여..

    > 무엇이 잘못되었는지 답변 기다리겠습니다.

    >

    위 sql 문장이 들어가는 부분은 알어보기가 힘드네요.

    일케 한번 해보시는게 어떨지요. 조인인경우

    query1.Close;

    query1.Sql.Clear;

    query1.Sql.Add(' Select t1.field1, t2.field2, t1,field3 from table1 t1,table2 t2');

    query1.Sql.Add(' Where t1.field1 = t2.field );

    query1.Sql.Add(' t1.field3 = :t1.field3);

    prepare;

    query1.ParamByName('t1.field3).AsString := trim(edit1.text);

    query1.Open;

    sql에 바로쓰면

    ParamByName쓰는게 귀찮으면

    세번째 쿼리문을

    query1.Sql.Add(' t1.field3 = "'+trim(edit1.text)+'"';

    이렇게 바꾸시면 됩니다.



    중요한건 sql 문장을 한 눈에 알어 볼 수 있게 코딩하시는게 좋겠죠.

    나중에 유지보수도 쉽구요 ^^

    그럼, 즐코~