How to do a delete in an 'artificial' master/detail relationship.
Posted in 1998
Topics: Stored Procedures & SPL, Connectivity: ODBC / JDBC / .NET, Triggers, Constraints & Referential Integrity
Just a note to let you know that we solved the delete of an "artificial" master detail record. Here is the code for you to look at (just incase you're curious). Thanks :-) IN THE SQL DELETE EVENT OF THE "MASTER" TABLE: VARIABLE ok BOOLEAN VARIABLE selStmt ixSqlstmt = NEW ixSqlStmt() VARIABLE deleted_row ixRow VARIABLE dbStatus INTEGER VARIABLE person_id CHAR(*) LET person_id = theRow.getVal(WNperson.SFper_id.getColNum()).getValueStr() Clipped --this gets the primary key of the deleted row from the 'master' super table so I can use it later as the foreign key in the child table. --this deletes the row in the master table let dbStatus = doSQLDelete( theRow ) --this checks the child table to see if there is a cooresponding record CALL selstmt.execDirect("Select per_id From login Where " || "per_id = "||"'"||person_id||"' ") CALL selStmt.fetch() Returning deleted_row IF selStmt.getODBCErrorCode() = selStmt.SQL_Success --if it does exist in the login table Then CASE MESSAGEBOX( NEW ixString("Delete Login Information?"), --title of box NEW ixString("Would you like to delete the login information for this person?"), ixqueryIcon, --icon displayed in box ixyesNo, --button(s) to be displayed in box 1 ) WHEN ixYesButton display "yes" CALL selstmt.execDirect("Delete From login Where " || --delete it "per_id = "||"'"||person_id||"' ") CALL selStmt.execute() IF selStmt.getODBCErrorCode() = selStmt.SQL_Success THEN CALL MESSAGEBOX( NEW ixString("Delete Successful."), NEW ixString("Login information was deleted successfuly."), ixinfoIcon, ixokbutton) returning ok END IF WHEN ixNoButton display "NO" RETURN true END CASE END IF RETURN dbStatus Kathy Hildebrand kathy@htscm.com <mailto:kathy@htscm.com> :-) Designer/Programmer -----Original Message----- From: Kathy Hildebrand Sent: Monday, June 25, 2001 12:36 PM To: 'tsmail@informix.com' Subject: FW: New Era Question Our serial number is AAC#A208458-208460. Thanks, Kathy Hildebrand kathy@htscm.com <mailto:kathy@htscm.com> :-) Designer/Programmer -----Original Message----- From: Jay A. Eakins [SMTP:jeakins@informix.com] <mailto:[SMTP:jeakins@informix.com]> Sent: Thursday, June 25, 1998 12:11 PM To: tsmail@atlas.na.informix.com; <mailto:tsmail@atlas.na.informix.com;> khildebrand@HTSCM.com <mailto:khildebrand@HTSCM.com> Cc: jeakins@atlas.na.informix.com <mailto:jeakins@atlas.na.informix.com> Subject: Re: New Era Question Hi Kathy: In order to open a new technical support case via email, please direct the request to tsmail@informix.com. I am forwarding your request to this email address for a case to be opened, and you will be provided with a case number. Please forward your NewEra serial number to tsmail@informix.com for support status confirmation. Thanks you. -- Jay Eakins Informix Technical Support At 11:18 AM 6/25/98 -0700, khildebrand@HTSCM.com wrote: >>>> Hi Jay, I'm having a new era problem. We are using version 2.20 WC! (SE) and the application framework class. My screen consists of two supertables connected to two different database tables. They kind of act like a master detail. One is for personnel and the other is for login information. When a user deletes a person from the personnel supertable, I want to check the login table for that persons id from the person table. If it exists, I want to display a message to ask them if they would like to also delete that persons login data. If they answer yes, I build an SQL and to the delete, if no, the box just closes. Everything is working fine except for one thing.....getting the persons id of the record being deleted. I tried getting in most of the personnel supertable events, and in the cell events of the first cell to get focus when a record is focus on. These work fine if you are querying and updating, but deleting is a hang up. I guess when you click on the delete icon in the App Framework, the current record becomes the record BEFORE the deleted record in the dataset. My question: In what event can I do the getText() to get data from the person id field of the row that is being deleted? I attached the .wif just incase you want to look at it. The supertable that I'm doing all of this on is the 'person'. Thanks! <<KAPERSON.WIF>> Kathy Hildebrand <mailto:kathy%40htscm.com>kathy@htscm.com :-) Designer/Programmer Attachment Converted: "C:\\Eudora\\Attach\\KAPERSON.WIF" <<<<