I am trying to execute the following query:
select
d.ro_number
,d.ro_closed_date
,d.customer_name
,d.veh_year
,d.veh_make
,d.veh_model
,d.op_code_name
,r.vin
,r.customer_email
,r.customer_contact_phone
, substr(r.customer_contact_phone, 1, 3) as contact_number
from public.declined_work d
inner join public.ro_closed r
on d.ro_number = r.ro_number
I am receiving the following error:
ERROR: function substr(text[], integer, integer) does not exist
LINE 12: , substr(r.customer_contact_phone, 1, 3) as contact_number
^
HINT: No function matches the given name and argument types. You might need to add explicit type casts.
SQL state: 42883
Character: 172
"customer_contact_phone" is data type "text."
I am relatively new to postgres, but to not to SQL in general. I am a bit baffled at what the issue is. I also tried the syntax as in this example
substring('Thomas' from 2 for 3)
But that did not work either.
I tried changing the function to substring as I was told substr doesn't exist in postgres, but I got the same error when I executed this:
select
d.ro_number
,d.ro_closed_date
,d.customer_name
,d.veh_year
,d.veh_make
,d.veh_model
,d.op_code_name
,r.vin
,r.customer_email
,r.customer_contact_phone
,substring(r.customer_contact_phone, 1, 3) as contact_number
from public.declined_work d
inner join public.ro_closed r
on d.ro_number = r.ro_number
I thought maybe it is an error due to the data type being text, but that doesn't make any sense to me. The values in that column look like this:
{7147019909, 5246627378}
Thanks in advance.