Link to home
Start Free TrialLog in
Avatar of Gerhardpet
GerhardpetFlag for Canada

asked on

Update a hstore field in PostgreSQL database

We support a system where custom fields in the system are stored as hstore fields. Like this

select query
select udf_data from inventory

Open in new window


""LocOver"=>"", "freight"=>"0", "3M Codes"=>"", "V_Partno"=>"110SP-60", "brokerage"=>"0", "Dentsply C"=>"""

Here is the data for one record. LocOver, freight, 3M Code, V_Partno, brokerge, Dentsply are the field names in the system

I want to update

I want to update the udf_data column with the values from inventory.part_no column from the udf_data V_Partno

So the update statement should be like this:

update customers
set udf_data = misc1
where udf_data ?| '{cust_type}'

But the hstore has a particular update statement like this:

update customers set udf_data = udf_data || '"cust_type"=>"test"'::hstore

Which does not work. Can anyone help?
ASKER CERTIFIED SOLUTION
Avatar of earth man2
earth man2
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Gerhardpet

ASKER

That worked thanks!