Fill field column if other column is not empty
Sanjshah
Posts: 7 Bronze 1
Hi,
Is it possible to only complete a field if another column field is not empty?
I have managed from the documentation to find how to do this however I do have another question, is it possible to select a random value condition depending on the value?
random.choice('a','b','c') if Approved == "Yes" or Approved == "No" else "Awaiting"
Thanks in advance.
Tagged:
Best Answer
-
Alex B Posts: 1,157 Diamond 4Hi @Sanjshah,
SQL Data Generator uses IronPython and it appears this is still version 2.7 included with the install so a lot of newer functionality is not available (e.g. random.choices). You may be able to use something like the following to get a random selection from the list fooimport clr clr.AddReference("System") from System import Random random = Random() def main(config): # config["column_name"] is the column name # config["column_type"] is the column datatype # config["column_size"] is the column size # config["n_rows"] is the number of rows # config["seed"] is the current random seed foo = list('abcde') val = '' if (col2 == 1) or (col2 == 2): val = foo[int(random.Next(len(foo)))] else: val = 'awaiting' return val
And it gives you output like this:
I hope that helps!
Kind regards,
Alex
Answers
https://documentation.red-gate.com/display/SDG4/Example+Python+scripts
Redgate Software