getLastautogenValue를 사용하여
-
22-12-2019 - |
문제
나는 firedac tfdquery를 사용하여 아래의 코드 스 니펫을 사용하여 Informix 데이터베이스의 값을 삽입하고 있습니다.
with QHeaderQuery do
begin
if not (Prepared) then
begin
{DatabaseName := Sessions.CurrentSession.Databases[0].DatabaseName;
SessionName := Sessions.CurrentSession.SessionName;}
Connection := FDManager.Connections[0];
SQL.Clear;
SQL.Add('insert into asptheade ( ');
SQL.Add('theade_trans, theade_store, theade_register, theade_location, ');
SQL.Add('theade_date, theade_cashier, theade_type, theade_name, ');
SQL.Add('theade_salesperson, theade_group, theade_group_disc, ');
SQL.Add('theade_comm_flag, theade_comm_price, theade_cust_code, ');
SQL.Add('theade_sub_total, ');
SQL.Add('theade_tax_total, theade_disc_total, theade_grand_total, ');
SQL.Add('theade_change_amt, theade_drawertime, theade_posted_date, theade_gratuity) ');
SQL.Add('values ( :d0, :d1, :s2, :s3, ');
SQL.Add(' current year to second, :s4, :s5, :s6, ');
SQL.Add(':s7, :s8, :f9, ');
SQL.Add(':s10, :s11, :s12, :f13, ');
SQL.Add(':f14, :f15, :f16, :f17, :f18, :f19, :f20 ) ');
Prepared := True;
end;
{SQL.Add( Format( 'values ( %d, %d, "%s", "%s", ', }
Params[0].AsInteger := FTrans;
Params[1].AsInteger := FStore;
Params[2].AsString := FRegister;
Params[3].AsString := FLocation;
{SQL.Add( Format( ' current, "%s", "%s", "%s", ', }
Params[4].AsString := FCashier;
Params[5].AsString := FTransType;
Params[6].AsString := FStatementText;
{SQL.Add( Format( '"%s", "%s", %f, ',}
Params[7].AsString := FSalesPerson;
Params[8].AsString := FDiscGroup;
Params[9].AsFloat := FDiscRate * 100;
{SQL.Add( Format( '"%s", "%s", "%s", %f, ',}
Params[10].AsString := FCommFlag;
Params[11].AsString := FCommPrice;
Params[12].AsString := FCustCode;
Params[13].AsFloat := FSubTotal;
{SQL.Add( Format( '%f, %f, %f, %f ) ',}
Params[14].AsFloat := FTaxTotal;
Params[15].AsFloat := FDiscTotal;
Params[16].AsFloat := FGrandTotal;
Params[17].AsFloat := FChangeAmt;
Params[18].AsDateTime := FDrawerTime;
Params[19].AsDateTime := FServiceDate;
Params[20].AsFloat := FGratuity;
Execute;
FValid := True;
end;
FTrans := FDManager.Connections[0].GetLastAutoGenValue('asptheade');
QHeaderQuery.Close;
.
기능을 지원하지 않는 기능을 취하고 있습니다.나는 심지어 동일한 오류 대신 빈 문자열을 시도했습니다.GetLastautogenValue의 적절한 사용으로 나를 안내 할 수 있습니까?dbExpress 브리지 드라이버를 사용하고 있습니다.
해결책 3
내 저장된 proc에서 다음 쿼리를 사용하여 작업을 수행했습니다.
SELECT DBINFO('sqlca.sqlerrd1') FROM SYSTABLES WHERE tabname = '<tablename>'
.
저장된 proc에서 동일한 값을 반환합니다.
다른 팁
getLastAutogenValue는 다음과 같은 반환을 지원합니다 :
- 삽입 / 게시물에서 사용되는 마지막 자동 증분 필드 값 모든 데이터 소스;
- execsql에서 사용 된 마지막 자동 증분 값 / Native Firedac 드라이버를위한 ExecProc;
- 원시 Firedac 드라이버를위한 시퀀스 / 생성기의 마지막 값입니다.getLastAutogenValue 인수는 생성기 / 시퀀스 이름입니다.
Firedac XE5에는 Informix 용 네이티브 드라이버가 없습니다.따라서 (2) 및 (3)은 Informix에서 지원되지 않습니다.코드가 Execute와 함께 삽입되므로 (1)도 지원되지 않습니다.결과적으로 "기능을 지원하지 않음"을 받고 있습니다.
삽입 쿼리 직후에 다음 쿼리를 실행하여 해결 방법 :
SELECT DBINFO('sqlca.sqlerrd1') FROM SYSTABLES WHERE tabname = 'systables'
. 제휴하지 않습니다 StackOverflow