My final stumbling block prior to finishing is using the LAST_INSERT_ID() function in conjunction with rev.
In short my table pireps has incrementing rows for each insert.
my insert looks like so:(shortened)
put "INSERT INTO phpvms_pireps (pilotid,code,aircraft) VALUES ('"&tpilotid&"','"&tcode&"','"&tAircraft&"')" into tSQL
that gives me
0001 010 AVA B747
0002 010 AVA B747
0003 010 AVA B747 etc
What i want to do is use the LAST_INSERT_ID(); function in mysql to grab the last id number in this example 0003, then insert it with some other variables into another table named pirepcomments.
i have tried this code.
Code: Select all
--construct the SQL
put "INSERT INTO phpvms_pireps (pilotid,code,aircraft,flightnum,depicao,arricao,flighttime,flighttime_stamp,distance,submitdate,`load`,fuelused,fuelunitcost,fuelprice,price,flighttype,gross,pilotpay,expenses,revenue,source) VALUES ('"&tpilotid&"','"&tcode&"','"&tAircraft&"','" &tFlightnum&"','" &tDepicao&"','"& tArricao&"','"&tflighttime&"','"&tflighttime&"','"&tdistancedata&"','"&tsubmitdate&"','"&tload&"','"&tfuelused&"','"&tfuelunitcost&"','"&tfuelprice&"','"&tpricedata&"','"&tflighttype&"','"&tgross&"','"&tpilotpay&"','"&texpenses&"','"&trevenue&"','"&tsource&"')" into tSQL
--send the comments
put "INSERT INTO phpvms_pirepcomments SELECT LAST_INSERT_ID ( ),pirepid,pilotid,comments,submitdate from phpvms_pireps WHERE pirepid,pilotid,comments,submitdate = ('"&tpilotid&"','"&tcomments&"','"&tsubmitdate&"')" into tpirepcomments
-- send the SQL to the database,
revExecuteSQL gConnectionID,tSQL,tpirepcomments
put tSQL,tpirepcomments
Code: Select all
INSERT INTO phpvms_pirepcomments SELECT LAST_INSERT_ID ( ),pirepid,pilotid,comments,submitdate from phpvms_pireps WHERE pirepid,pilotid,comments,submitdate = ('001','first automated pirep subission','2011,3,29,14,41,0,3')
Any prod in the right direction would be a blessing.
Thanks
Alex