Solved

I need to fill a column in a Pervasive SQL table with sequential numbers

Posted on 2009-04-06
1
476 Views
Last Modified: 2012-05-06
I have created a new empty table with only one column, I need to fill this column with sequential numbers from 0 to 2000. I could do it manual but the time it would take along with possibility of errors makes this method not first choose. There must be a script I could use in the Pervasive SQL Control Center to do this simple task, but I have been unable to come up with one.  

Thanks.
0
Comment
Question by:dental99
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 18

Accepted Solution

by:
mirtheil earned 250 total points
ID: 24081440
There's not a way to do it with one query but you could write a Stored Procedure.  Something like:
create procedure popTable(in :NumRecords INT);
begin
DECLARE :i INTEGER;
SET :i = 0;
WHILE :i <= :NumRecords DO
INSERT INTO test1 (f1) values (:i);
SET :i = :i + 1;
END WHILE;
end;

or (creating the table in the procedure):
create procedure popTable(in :NumRecords INT);
begin
exec ('CREATE TABLE test1 (f1 integer);');
DECLARE :i INTEGER;
SET :i = 0;
WHILE :i <= :NumRecords DO
INSERT INTO test1 (f1) values (:i);
SET :i = :i + 1;
END WHILE;
end;

and then executing the Stored Procedure:

CALL popTest(2000);
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
Shadow IT is coming out of the shadows as more businesses are choosing cloud-based applications. It is now a multi-cloud world for most organizations. Simultaneously, most businesses have yet to consolidate with one cloud provider or define an offic…
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

734 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question