RBase 6.5++ In rewriting some old code using TGR2000, it is amazing how often the Declare Cursor & Fetch can be replaced by one properly written Select/View. At the recent R:BASE Developers' Conference, with many great speakers, I particularly enjoyed Bill, Harlan and Larrys' presentations. If you've designed your data base properly, think about using a good Select/View instead Declare Cursor or lots of level breaks and expressions in reports. Program maintenance is a lot easier.
Since Larry seems to always come up with the most elegant solutions, I've been challenging myself to look for a "Lustigism" every time I come across a complex while loop or cumbersome report. In the example below I ended up with two sub-selects. There is probably a cleaner way of doing this, but at least it's not a Declare Cursor. ... A two-column unique index needs to be maintained when the application allows the user to change a key column from "A" to "B" for all tables. The utility program allows the user to replace every occurrence of "A" with "B", or to "merge" all A's with B's. For example, where part ABC2 and ABC-2 are really the same part and all the history needs to use just ABC2. So, in a row where you have two FK columns as: Column_A (FK Unique Multi-Column) Column_B (FK Unique Multi-Column) the user can't add a new row if the values of A & B are the same as an existing row. But the user can change all occurrences of Column_A values to "X" if it won't create a duplicate pair. (I need to check for an error condition in every table where the PK column exists prior to changing any table.) SELECT COUNT (*) INTO xcount FROM table_name1 WHERE Column_A IN + (SELECT Column_A from table_name1 WHERE + (Column_A + Column_B) = (Column_A + .newvalueB)) AND Column_A IN + (SELECT Column_A from table_name1 WHERE + (Column_A + Column_B) = (Column_A + .oldvalueB)) If xcount is zero, then it's OK to change. I have found that allowing users to change, merge, delete key column values is no easy task. Anyone else up against this? TIA, Dennis ***** Dennis Fleming IISCO http://www.TheBestCMMS.com Phone: 570 775-7593 Fax: 570 775-9797 ================================================ TO SEE MESSAGE POSTING GUIDELINES: Send a plain text email to [EMAIL PROTECTED] In the message body, put just two words: INTRO rbase-l ================================================ TO UNSUBSCRIBE: send a plain text email to [EMAIL PROTECTED] In the message body, put just two words: UNSUBSCRIBE rbase-l ================================================ TO SEARCH ARCHIVES: http://www.mail-archive.com/rbase-l%40sonetmail.com/
