DELPHI中,执行Query的语句,出现 invalid use of keyword 在线等,急!!!! ( 积分: 100 )

  • 主题发起人 主题发起人 yeser_macao
  • 开始时间 开始时间
Y

yeser_macao

Unregistered / Unconfirmed
GUEST, unregistred user!
XY_product_code:=&nbsp;MemData_XY.FieldByName('product_code').asstring;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;XY_unit_cost:=&nbsp;MemData_XY.FieldByName('unit_cost').asfloat;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;with&nbsp;d_product_cost_XY_insert&nbsp;do<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;close;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;sql.Clear&nbsp;;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;sql.Add&nbsp;('insert&nbsp;d_product_cost&nbsp;(unit_code,product_code,unit_cost,cl_cost,jg_cost,sell_cost,o_date,o_name,');<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;sql.Add&nbsp;('weight_cost,weight_cost_1,cost_4,cost_5,cost_6,cost_7,cost_8)');<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;sql.Add&nbsp;('values&nbsp;(&quot;XY&quot;,:XY_product_code,:XY_unit_cost,0,0,0,null,null,0,0,0,0,0,0,0)');<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;parambyname('XY_product_code').asstring&nbsp;:=XY_product_code&nbsp;;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;parambyname('XY_unit_cost').asfloat&nbsp;:=XY_unit_cost&nbsp;;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;prepare;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;execsql;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;end;<br><br>执行时候,提示:EDBDngineError&nbsp;with&nbsp;message'Invalid&nbsp;use&nbsp;of&nbsp;keyword.Token:d_product_cost&nbsp;Line&nbsp;Number:1'.process&nbsp;stopped.Use&nbsp;Step&nbsp;or&nbsp;Run&nbsp;to&nbsp;continue<br><br>这个表里(d_product_cost&nbsp;)有一个ordinal_number&nbsp;字段为自动增加的,没有包含在语句里
 
给自增字段随意赋一个足够大的值即可(数据库会自动改回自增值)。
 
begin<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;XY_product_code:=&nbsp;MemData_XY.FieldByName('product_code').asstring;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;XY_unit_cost:=&nbsp;MemData_XY.FieldByName('unit_cost').asfloat;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;with&nbsp;d_product_cost_XY_insert&nbsp;do<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;close;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;sql.Clear&nbsp;;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;sql.Add&nbsp;('insert&nbsp;d_product_cost&nbsp;(ordinal_number,unit_code,product_code,unit_cost,cl_cost,jg_cost,sell_cost,o_date,o_name,');<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;sql.Add&nbsp;('weight_cost,weight_cost_1,cost_4,cost_5,cost_6,cost_7,cost_8)');<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;sql.Add&nbsp;('values&nbsp;(999999,&quot;XY&quot;,:XY_product_code,:XY_unit_cost,0,0,0,null,null,0,0,0,0,0,0,0)');<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;parambyname('XY_product_code').asstring&nbsp;:=XY_product_code&nbsp;;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;parambyname('XY_unit_cost').asfloat&nbsp;:=XY_unit_cost&nbsp;;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;prepare;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;execsql;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;end;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;MemData_XY.Next&nbsp;;<br>&nbsp;&nbsp;&nbsp;end;<br><br>还是同样的提示,能给出完整的写法吗?谢谢
 
你的语句里有&quot;XY&quot;,如果正确,表示一个叫XY的字段或函数,如果是字段则没有指定值,错误!。<br>如果是一个字符串常量,则应改为:''XY''
 
你的语句里有&quot;XY&quot;,如果正确,表示一个叫XY的字段或函数,如果是字段则没有指定值,错误!。<br>如果是一个字符串常量,则应改为:''XY''<br><br><br>XY&nbsp;我用了双引号,如果是单引号是通不过的,<br>你给的双引号,怎么看上去和我的不一样?<br>XY&nbsp;就是一个固定的值,要把它赋到unit_cost字段中
 
begin<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;XY_product_code:=&nbsp;MemData_XY.FieldByName('product_code').asstring;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;XY_unit_cost:=&nbsp;MemData_XY.FieldByName('unit_cost').asfloat;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;with&nbsp;d_product_cost_XY_insert&nbsp;do<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;close;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;sql.Clear&nbsp;;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;sql.Add&nbsp;('insert&nbsp;into&nbsp;d_product_cost&nbsp;(unit_code,product_code,unit_cost,cl_cost,jg_cost,sell_cost,o_date,o_name,');<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;sql.Add&nbsp;('weight_cost,weight_cost_1,cost_4,cost_5,cost_6,cost_7,cost_8)');<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;sql.Add&nbsp;('values&nbsp;(:XY,:XY_product_code,:XY_unit_cost,0,0,0,null,null,0,0,0,0,0,0,0)');<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;parambyname('XY_product_code').asstring&nbsp;:=XY_product_code&nbsp;;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;parambyname('XY_unit_cost').asfloat&nbsp;:=XY_unit_cost&nbsp;;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;parambyname('XY').asstring&nbsp;:=XY;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;prepare;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;execsql;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;end;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;MemData_XY.Next&nbsp;;<br>&nbsp;&nbsp;&nbsp;end;<br><br>找到问题了,原来少了一个&nbsp;into&nbsp;&nbsp;加上去就好了,昏啊
 
谢谢近来的两位朋友,虽然不是你们说的,但还是喊感谢你们给的提示!!<br><br>给分
 
后退
顶部