0

I am getting the below error for the following Block-

SQL Error [42601]: ERROR: syntax error at or near "int"

Position: 14

BLOCK

declare id int;
    col_1 int; 
    col_1_input int = '21bb232s-3r22-8ns1-ad31-2f78c1c52b7a'; 
    audit_datetime timestamp(3);
    audit_datetime_input timestamp(3) = '1612-09-10 12:02:20';
    audit_action varchar(100);

Kindly help me in pointing my mistake.

2
  • 2
    v_col_1_input int = '21bb232s-3r22-8ns1-ad31-2f78c1c52b7a'; It is impossible Commented Sep 15, 2021 at 11:03
  • 1
    Please show us your complete function or procedure Commented Sep 15, 2021 at 11:04

1 Answer 1

1

First of all the types like smallint, integer, bigint and int store whole numbers, that is, numbers without fractional components, of various ranges. Attempts to store values outside of the allowed range will result in an error.

You add a text in a int value and this is not allowed:

v_col_1_input int = '21bb232s-3r22-8ns1-ad31-2f78c1c52b7a'; 

Second to avoid the error you should add $$ LANGUAGE plpgsql to your code:

DO $$
declare 
...
begin
...
end;
$$ LANGUAGE plpgsql
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.