Q&A

  • 빠른 답변 부탁드립니다.
오라클에서 다음과 같은 sql을 썼는데염....

birth는 생년월일을 나타내는 데이트형입니다..



select * from customer

where to_char(birth,'mm')>2

하면여..... 생일이 2월달 이후의 사람들이 검색이 되는데염

이걸 델파이에서 추가할려구 하거덩염.....



with query1 do

begin

close;

sql.clear;

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

sql.add('where to_char(birth,'MM')>2 ');

open;

end;



했더니염..... [



Error] Canalysis.pas(166): ')' expected but identifier 'MM' found

[Error] Canalysis.pas(166): Statement expected, but expression of type 'String' found

같이 에러가 나더라구염....

그래서 'MM'=>"MM"으루 바꿨더니....에러가 사라졌는뎅.....

런시키면여.....

ora-00904:열명이 부적합합니다....라고 나오는군염.....

위에 sql문을 어케 해서 넣어줘야하나염?????



1  COMMENTS
  • Profile
    sallyslaw 2001.08.28 01:58
    노력중인 초보 wrote:

    > 오라클에서 다음과 같은 sql을 썼는데염....

    > birth는 생년월일을 나타내는 데이트형입니다..

    >

    > select * from customer

    > where to_char(birth,'mm')>2

    > 하면여..... 생일이 2월달 이후의 사람들이 검색이 되는데염

    > 이걸 델파이에서 추가할려구 하거덩염.....

    >

    > with query1 do

    > begin

    > close;

    > sql.clear;

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

    > sql.add('where to_char(birth,'MM')>2 ');

    > open;

    > end;

    >

    > 했더니염..... [

    >

    > Error] Canalysis.pas(166): ')' expected but identifier 'MM' found

    > [Error] Canalysis.pas(166): Statement expected, but expression of type 'String' found

    > 같이 에러가 나더라구염....

    > 그래서 'MM'=>"MM"으루 바꿨더니....에러가 사라졌는뎅.....

    > 런시키면여.....

    > ora-00904:열명이 부적합합니다....라고 나오는군염.....

    > 위에 sql문을 어케 해서 넣어줘야하나염?????

    >



    아마 birth는 변수겠지요?



    sql.text := ' select * from customer where to_char(' + birth + ', ''mm'') > 2';



    위와 같이 하면 됩니다.