0

I am facing an issue when I try to run my procudere. I have a table where I have all values stored in text format and try to convert to int or timestamp

CREATE OR REPLACE PROCEDURE public.textnummerictest(
)
LANGUAGE 'sql'
AS $BODY$
create or replace procedure textnummerictest()
language plpgsql
as $$
begin
 insert into sensorhistory_test(
  datetime,
  sensorid     )
 select from sensorhistory_temp (
  cast(sensorid as integer),
  datetime::timestamp       )
 end; $$
$BODY$;

ALTER PROCEDURE public.textnummerictest()
OWNER TO postgres;

Always getting the error Syntaxerror near end.

Any help really appreciated

5
  • You have a create or replace inside another create or replace Commented Mar 4, 2022 at 7:47
  • well this is added by pgadmin for any reason. the original script is between $BODY$ Commented Mar 4, 2022 at 7:53
  • Then it's a pgAdmin bug. Remove everything before the first $BODY$ and then remove the final $BODY$ as well. Commented Mar 4, 2022 at 7:54
  • I did so, but now end;$$ is red underlined and I get the same error Commented Mar 4, 2022 at 7:56
  • Well there is so much wrong with that statement, that it's really hard to fix. You are missing a ; at the end of the INSERT. And your procedure doesn't have a variable or parameter named sensorid or datetime. And select from .. should be select * from ... as well. Commented Mar 4, 2022 at 8:00

1 Answer 1

1

I found the error....

there must be a ';' before end...

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.