SQL Error - Admin Console | Community
Skip to main content
ukender
Level 3
August 24, 2020
Solved

SQL Error - Admin Console

  • August 24, 2020
  • 1 reply
  • 2819 views

Dear All

 

I'm getting the below error while executing the script in admin console. could you please help me on this.

 

Thanks in Advance

 

SELECT CreateSequenceIfNecessary('NeoCustomId', '1000', 'cache 1000');

create or replace function GetNeoCustomId() returns integer as '
declare
iId integer;
begin
select into iId NextVal(''NeoCustomId'');
return iId;
end;
' language plpgsql
;
create or replace function GetNewNeoCustomIds(integer) returns text as '
declare
strIds text;
i integer;
iId integer;
begin
strIds = '''';
for i in 1 .. $1 loop
select NextVal(''NeoCustomId'') into iId ;
if i > 1 then
strIds := strIds || '','';
end if;
strIds := strIds || cast(iId as text);
end loop;
return strIds;
end;
' language plpgsql
;

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by DavidKangni

Hi,

Looks like you're trying to use a  script dedicated to Postgresql to create a sequence on SQL database.

 

You should try this instead


INSERT INTO XtkNewId(sSequence, IdSeed) VALUES ('NeoCustomId', 1);

 

Thanks,

David

1 reply

DavidKangni
Community Advisor
DavidKangniCommunity AdvisorAccepted solution
Community Advisor
August 24, 2020

Hi,

Looks like you're trying to use a  script dedicated to Postgresql to create a sequence on SQL database.

 

You should try this instead


INSERT INTO XtkNewId(sSequence, IdSeed) VALUES ('NeoCustomId', 1);

 

Thanks,

David

David Kangni
ukender
ukenderAuthor
Level 3
August 24, 2020

Hi David Thanks for the response. Yes you are right, I am trying to create a custom sequence for one of the table. The reason for custom sequence is xtkNewId had reached its limit and started with negative values. I have found the above code for creating the custom sequence. So as per your suggestion if I insert the record into xtkNewid will it generate sequence unique primary key (same as xtkNewId)?

 

  • Also would like to know, what will be the impact for the existing primary key in the table. Let's say I have a table called XYZ and its Primary key is AB (autopk = true). Now, if I go for the custom sequence will there be any impact for the existing AB records?