좀 어설프지만 이런식으로도 INSERT 가능하구요, ExecSQL의 리턴값은 실행된 쿼리문의 영향을 받는 열의 수라고 되어 있네요.
"ExecSQL returns the number of rows affected by the executed command. This becomes the value of the RowsAffected property."
SQLDataSet1은 SQLConnection과 연결되어 있습니다.
원하시는 답변이 되었으면 좋겠네요.
AnsiString str = "";
str = "INSERT INTO TABLE1 VALUES (NEXT VALUE FOR IDX_SEQ, ";
str += QuotedStr(MMSDatas.dt.FormatString("yyyy-mm-dd hh:nn:ss"));
str += ", ";
str += IntToStr(MMSDatas.byMode);
str += ")";
SQLDataSet1->CommandText = str;
try
{
SQLDataSet1->ExecSQL(true);
}
catch(const Exception& e)
{
OnShowMsgStatus(e.Message);
SQLDataSet1->Cancel();
}
수연 님이 쓰신 글 :
: 안녕하세요
: Firebird 2.5, DBExpress 4, C++ Builer 2007 쓰고 있는데...
:
: insert 후에 returning 으로 값을 받아 오는 예제가 delphi 로 된 건 찾았어요
:
:
: procedure TForm1.Button_testClick(Sender: TObject);
: var
: dataResult: TCustomSQLDataSet;
: begin
: dataResult := nil;
: dm.SQLConnection_sdi.Execute('select count(*) as cuenta from regoper',
: nil, @dataResult);
: try
: Edit_resultado.Text := dataResult.FieldValues['cuenta'];
: finally
: dataResult.Free;
: end;
: end;
:
: 그런데, C++ builder 로 해 볼려니까, 잘 안 되네요
:
: TCustomSQLDataSet* rstSet = new TCustomSQLDataSet(???);
: SQLConnection_sdi->Execute(???)
: 이런 부분이 잘 안 되는 것 같은데,
:
: 아시는 분 도움 좀 주세요
: 늘 감사합니다.
|