I have a stored procedure that tracks new records inserted in a table (change tracking is on). Pretty simple, code shown here:
create or replace procedure sp_audit_insert_counts(TABLENAME varchar, FILTER varchar,
STARTTIME timestamp_ltz, ENDTIME timestamp_ltz)
returns integer
language sql
as
$$
declare
iInsertCount integer default 0;
begin
select count(*) into :iInsertCount from identifier(:TABLENAME) changes(information => default) at(timestamp => :STARTTIME) end(timestamp => :ENDTIME) where metadata$action = 'INSERT' and metadata$isupdate = 'FALSE';
return iInsertCount;
end;
$$
;
However when I run the procedure, I get an error
Bind variable :STARTTIME not set
call sp_audit_insert_counts('TEST_TABLE', null, to_timestamp('2022-08-23 00:00:00'), to_timestamp('2022-08-23 09:00:00'))
If I hard code the time stamps in the procedure it work fine. What could be wrong?
Thanks in advance
Regards Sid