我正在使用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;
.

我无法得到支持。我甚至尝试了空字符串而不是相同的错误。您能否引导我用雷亚斯塔替替素值的正确使用?我正在使用dbexpress桥驱动程序。

有帮助吗?

解决方案 3

我在我存储的proc中使用以下查询时,它会解决:

SELECT DBINFO('sqlca.sqlerrd1') FROM SYSTABLES WHERE tabname = '<tablename>'
.

并在存储的proc中返回相同的值。

其他提示

getlastautogenValue支持返回:

  1. 插入/帖子中使用的最后一个自动增量字段值 所有数据源;
  2. 在execsql中使用的最后一个自动增量值 / execproc for本机firedac驱动程序;
  3. 本机FileDAC驱动程序序列/生成器的最后一个值。getLastautogenValue参数是一个发电机/序列名称。
  4. firedac xe5没有用于Informix的本机驱动程序。所以,(2)和(3)不支持Informix。您的代码是execute的插入,因此不支持(1)。因此,您正在获得“不支持的能力”。

您可以通过在插入查询后立即执行以下查询来解决方法:

SELECT DBINFO('sqlca.sqlerrd1') FROM SYSTABLES WHERE tabname = 'systables'
.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top