I am using pgadmin and postgrsql 9.6.8
I am not sold on doing it this way, but it is the only way I have found so far. I am just wanting to be able to use a replaceable variable or a parameter in a query in pgAdmin 4
This is the only way I have found to do it. It works for the branchToUse but is failing when I try and pass the date.
Here is the query:
SET search1.branchToUse = 'EUR';
SET search1.dateToUse = '2019-6-20';
select si.unique_id_no,si.customer_no, stop_name,si.shipment_type,stop_address,stop_city,assigned_driver,actual_driver,
si.datetime_created as "stop DT created",si.datetime_updated as "stop DT updated",rh.route_code,rh.datetime_last_updated,rh.updated_datetime from distribution_stop_information si
join distribution_route_headers as rh on si.route_code = rh.route_code
where (si.company_no =11 ) and (rh.company_no = 11) and
si.created_by='DI*' and
(si.route_date = current_setting('search1.dateToUse') and rh.route_date = current_setting('search1.dateToUse') ) and
(si.branch_id = current_setting('search1.branchToUse') and rh.branch_id = current_setting('search1.branchToUse'))
order by stop_address;
I am getting the following error - I am not sure how to do the requested cast:
ERROR: operator does not exist: date = text LINE 9: (si.route_date = current_setting('search1.dateToUse') and rh... ^ HINT: No operator matches the given name and argument type(s). You might need to add explicit type casts.