SoftTree Technologies SoftTree Technologies
Technical Support Forums
RegisterSearchFAQMemberlistUsergroupsLog in
[7.0.132 beta] FR - Test Data generator

 
Reply to topic    SoftTree Technologies Forum Index » SQL Assistant View previous topic
View next topic
[7.0.132 beta] FR - Test Data generator
Author Message
ssandu



Joined: 26 Feb 2007
Posts: 95
Country: Romania

Post [7.0.132 beta] FR - Test Data generator Reply with quote
Is it possible to have data generated based on a regular expression ?
For example I need to generate some bank accounts data and I need to respect some special formatting (first 5 letters, 4 numbers, 2 letters, 5 numbers and so on).
Mon Jul 07, 2014 1:42 am View user's profile Send private message
SysOp
Site Admin


Joined: 26 Nov 2006
Posts: 7948

Post Reply with quote
Yes, it is possible. You can create a file containing sample account numbers. It's fairly easy to create such things in Excel. And then you can choose that file as a source of data for a column in the target table. The data generator will pick accounts from that file randomly but their format will be exactly as you specified.

Alternatively, you can use a table with existing account number values as a data source for a column in another table that you want to populate using the data generator.
Mon Jul 07, 2014 2:12 am View user's profile Send private message
ssandu



Joined: 26 Feb 2007
Posts: 95
Country: Romania

Post Reply with quote
Thank you
It was nice to specify a regex in the test data generator when datatype is char of a specified length
Or on value type could be a new one Random(regex).
It's just an idea.
Mon Jul 07, 2014 3:32 am View user's profile Send private message
SysOp
Site Admin


Joined: 26 Nov 2006
Posts: 7948

Post Reply with quote
I can submit an enhancement request on your behave if you clarify for me how you would use a regular expression to generate random strings.
We can randomize simple values, such as numbers, dates, strings from a dictionary paragraph, but I don't understand how it can be done with a regular expression with multiple parts?
Mon Jul 07, 2014 8:08 am View user's profile Send private message
ssandu



Joined: 26 Feb 2007
Posts: 95
Country: Romania

Post Reply with quote
For example I want to generate IBAN's
I will use this regex [a-zA-Z]{2}[0-9]{2}[a-zA-Z0-9]{4}[0-9]{3}([a-zA-Z0-9]?){0,16}
or I want to generate romanian SSN's and I need this regex ^\d{1}\d{2}(0[1-9]|1[0-2])(0[1-9]|[12]\d|3[01])(0[1-9]|[1-4]\d| 5[0-2]|99)\d{4}$
Thank you
Mon Jul 07, 2014 8:34 am View user's profile Send private message
SysOp
Site Admin


Joined: 26 Nov 2006
Posts: 7948

Post Reply with quote
thank you. What I don't understand is how to randomize the result. what kind of random value your regular expression should be applied to in order to produce the required result?

The regular expression is a kind of data "formatting" rule, not a data generation rule. What is the raw value it needs to be applied to?


Last edited by SysOp on Mon Jul 07, 2014 10:52 pm; edited 1 time in total
Mon Jul 07, 2014 8:39 am View user's profile Send private message
ssandu



Joined: 26 Feb 2007
Posts: 95
Country: Romania

Post Reply with quote
Never mind.
I thought it might be useful but it seems it's not practical.
Thank you again
Mon Jul 07, 2014 9:44 am View user's profile Send private message
SysOp
Site Admin


Joined: 26 Nov 2006
Posts: 7948

Post Reply with quote
I was researching this topic and came across implementation of PHP function called ReverseRegex that can produce values using regular expression based patterns and lexers and data collections. Here is the link to that
https://github.com/icomefromthenet/ReverseRegex

So it's definitely doable, but not a simple solution. In the databases it's actually much easier to achieve the same result using SQL expressions for concatenating substrings and random values used as substringsi n the for the expressions, for example you can use the data gen to populate an intermediate table with several regular columns and a add a database calculated computed column to that table that will calculate the final value. You can then specify that computed column as a data source for another table.

for example

Code:
CREATE TABLE temp_accounts_list
(
   part1 varchar(5),
   part2 varchar(10),
   part3 varchar(5),
   acct_num AS part1 + '-' + part2 + '-' + part3
)


Have SQL assistant data generator populate part1., part2, part3 columns in that table with random values, you can specify valid characters for each part, for example, digits-only for part1. Then use acct_num as a data source for another table which you want to populate. The end result should be the required random account number.
Mon Jul 07, 2014 11:07 pm View user's profile Send private message
Display posts from previous:    
Reply to topic    SoftTree Technologies Forum Index » SQL Assistant All times are GMT - 4 Hours
Page 1 of 1

 
Jump to: 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


 

 

Powered by phpBB © 2001, 2005 phpBB Group
Design by Freestyle XL / Flowers Online.