Solved

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

Posted on 2009-04-06
1
468 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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

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!
These days, all we hear about hacktivists took down so and so websites and retrieved thousands of user’s data. One of the techniques to get unauthorized access to database is by performing SQL injection. This article is quite lengthy which gives bas…
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…

749 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