Data Generator and Check Contstraints.

slowderslowder Posts: 7
edited December 19, 2014 8:02AM in SQL Data Generator
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?

Comments

  • Yes.

    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?
  • Hello,

    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.
    aliiiiii
Sign In or Register to comment.