Re: Ideas for bringing data into MySQL from a flatfile
Agreed.
If it is adding new records - that won't help in an update.
Bill
Agreed.
If it is adding new records - that won't help in an update.
Bill
<Miva MyQUERY_ERROR="nonfatal,nodisplay"> <Miva MvIMPORT_ERROR="nonfatal,nodisplay"> code to connect to MySQL DB <MvDBCOMMAND NAME = "williams_MySQL_schema" COMMAND = "manualcommit"> <MvIMPORT FILE = "import.dat" FIELDS = "l.id,l.price" DELIMITER = "|" > <MvIF EXPR = "{ g.MvIMPORT_ERROR }" > <BR>Error loading importfile (<MvEVAL EXPR = "{ g.MvIMPORT_ERROR }" >) <MvIMPORTSTOP> <MvELSE> <MvASSIGN NAME = "l.a" VALUE = "{ l.a+1 }" > <br /><MvEVAL EXPR = "{ l.a }" >. Update record <MvEVAL EXPR = "{ l.id }" >, set price to <MvEVAL EXPR = "{ l.price }" > <MvQUERY NAME = "db_alias" QUERY = "UPDATE products SET price=? WHERE product_id=?" FIELDS="l.price,l.id"> <MvIF EXPR = "{ g.MvQUERY_ERROR }" > <MvASSIGN NAME = "l.errors" INDEX="{miva_array_max(l.errors)+1}" VALUE = "{l.id}" > --- Error <MvELSE> <MvASSIGN NAME = "l.count" VALUE = "{ l.count+1 }" > --Success <MvIF EXPR = "{ NOT fmod( l.count,50) }"> <MvCOMMENT>This is to commit every 50 updates and then force the display of the browser</MvCOMMENT> <MvCOMMIT> <MvEVAL EXPR = "{ miva_output_flush() }" > </MvIF> </MvIF> </MvIF> </MvIMPORT> <MvIF EXPR = "{ NOT g.MvIMPORT_ERROR }"> <MvIF EXPR = "{ l.count GE 1 }"> <MvCOMMIT> </MvIF> <h1>Result:</h1> <MvEVAL EXPR = "{ l.count }" > records imported. <MvEVAL EXPR = "{ miva_array_max(l.errors) }" > records skipped. <br /> Skipped:<br /> <MvEVAL EXPR = "{ l.errors }" > </MvIF>
Comment