// Update Big Dean's business info businessId = 27; // Big Dean's actual address and hours address = "1615 Ocean Front Walk, Santa Monica, CA 90401"; phone = "(310) 393-2666"; hours = "Mon-Thu: 11am-10pm, Fri-Sat: 11am-11pm, Sun: 11am-10pm"; try { // First get column names from INFORMATION_SCHEMA cols = queryExecute(" SELECT COLUMN_NAME FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_SCHEMA = 'payfrit' AND TABLE_NAME = 'Businesses' ORDER BY ORDINAL_POSITION "); colNames = []; for (c in cols) { arrayAppend(colNames, c.COLUMN_NAME); } // Check if we have the columns we need hasAddress = arrayFindNoCase(colNames, "BusinessAddress") > 0; hasPhone = arrayFindNoCase(colNames, "BusinessPhone") > 0; hasHours = arrayFindNoCase(colNames, "BusinessHours") > 0; // Add columns if missing if (!hasAddress) { queryExecute("ALTER TABLE Businesses ADD COLUMN BusinessAddress VARCHAR(255)"); } if (!hasPhone) { queryExecute("ALTER TABLE Businesses ADD COLUMN BusinessPhone VARCHAR(50)"); } if (!hasHours) { queryExecute("ALTER TABLE Businesses ADD COLUMN BusinessHours VARCHAR(255)"); } // Update with new info queryExecute(" UPDATE Businesses SET BusinessAddress = :address, BusinessPhone = :phone, BusinessHours = :hours WHERE BusinessID = :bizId ", { address: address, phone: phone, hours: hours, bizId: businessId }); // Get updated record updated = queryExecute(" SELECT BusinessID, BusinessName, BusinessAddress, BusinessPhone, BusinessHours FROM Businesses WHERE BusinessID = :bizId ", { bizId: businessId }); writeOutput(serializeJSON({ "OK": true, "MESSAGE": "Updated Big Dean's info", "COLUMNS_EXISTED": { "address": hasAddress, "phone": hasPhone, "hours": hasHours }, "BUSINESS": { "BusinessID": updated.BusinessID, "BusinessName": updated.BusinessName, "BusinessAddress": updated.BusinessAddress, "BusinessPhone": updated.BusinessPhone, "BusinessHours": updated.BusinessHours } })); } catch (any e) { writeOutput(serializeJSON({ "OK": false, "ERROR": e.message, "DETAIL": e.detail })); }