<?xml version="1.0" encoding="windows-1252"?>
<node id="43756" title="Re: Topics in Perl Programming: Table-Mutation Tolerant Database Fetches with DBI" created="2000-11-28 19:08:46" updated="2005-07-21 01:24:47">
<type id="11">
note</type>
<author id="3737">
Dominus</author>
<data>
<field name="doctext">
Says [princepawn]:
&lt;blockquote&gt;&lt;i&gt;
&amp;gt; How does one write Perl code such that it can work&lt;br&gt;
&amp;gt; without modification in the face of labeling,&lt;br&gt;
&amp;gt; destructive, or positional field mutations? 
&lt;/i&gt;&lt;/blockquote&gt;

It's going to take a lot of effort to do it in Perl
or in any other language.  
Here's a small table with only two columns:

&lt;code&gt;
	ID1	ID2
	-----------
	119	666
	437	112
&lt;/code&gt;

Now switch the order of the two columns, 
and change the names so that ID1 is now called ID2 and ID2 is now called ID1:

&lt;code&gt;
	ID1	ID2
	-----------
	666	119
	112	437
&lt;/code&gt;

Now how are you going to write a program that magically copes with that?
This is not a Perl problem; it's an impossible problem.
Even looking at the database schema is not going to work.
&lt;p&gt;

The only solution is for the database itself to carry its own
description. One way is to install a special row 
into each table:

&lt;code&gt;
	ID1	ID2
	-----------
	"id2"	"id1"
	...     ...
&lt;/code&gt;

then the program can select this row, examine it to
see whether the column names or the order have changed,
and it can make the appropriate allowances.
</field>
<field name="root_node">
43748</field>
<field name="parent_node">
43748</field>
</data>
</node>
