I have been having trouble trying to convert a column from 'varchar' to 'money'. Apparently the default schema is wrong. When I try to save a field for PriceRule, this is the error I get:
SQL Error: Disallowed implicit conversion from data type varchar to data type money, 'PriceRule', column 'UnitPrice'. Use the CONVERT function to run this query.
Accordingly, I try to use the convert function to convert the field datatype.
In My Model:
public function beforeSave($options = array()){
$UnitPrice = $this->data["PriceRule"]["UnitPrice"];
$this->data["PriceRule"]["UnitPrice"] = 'CONVERT(money,$UnitPrice)';
}
This is the SQL it generates:
UPDATE [pricerule]
SET [pricepolicyid] = 1,
[producttypeid] = 1,
[unitprice] = 'CONVERT(money,$UnitPrice)',
[minquantity] = 1,
[maxquantity] = 4,
[modifiedby] = 1055,
[modifieddate] = '2016-08-16 11:18:11',
[active] = '1'
WHERE [pricerule].[priceruleid] = 62
This query does not run because the CONVERT function is created as a string, not a function.
I have been continuously trying to find work-arounds and have done endless digging on google and cannot seem to find anything helpful.
If anyone has a way to fix this, that would be great! Even an alternative, any help is awesome!
Thanks in advance!