Data Generator and Check Contstraints.
slowder
Posts: 7
Given the check constraint:
CONSTRAINT c_BillingTransaction__InvoiceID_ReceiptID
CHECK (InvoiceID IS NULL OR ReceiptID IS NULL)
Is there an easy way to have data generator understand if you fill in InvoiceID, you must have a NULL receiptID and vice versa?
CONSTRAINT c_BillingTransaction__InvoiceID_ReceiptID
CHECK (InvoiceID IS NULL OR ReceiptID IS NULL)
Is there an easy way to have data generator understand if you fill in InvoiceID, you must have a NULL receiptID and vice versa?
Comments
Set InvoiceID column to be a Python Script
Set ReciptID column to be a 'standard generator' (I tested with "IDs")
Example Python script is
# Basic generator template
def main(config):
if ReceiptID:
return NULL
else: return 1
#############
Does that help?
SQL Data Generator has the ability to run a Python script, so if you have a Python script, variable declarations typically begin with the dollar-sign ($). The question must be, how to get a generated column value and use that in a SQL query. This sounds like you would need a combination of two generators - cross-column and SQL statement.