Below is the code that I have written to handle the case of when the user
selects the update button on the form.  The update button is of type submit.
I 
assume that what is in fdat are all the items that are on the form.  I have
created an array that holds the names of each of the form elements:

@noteTableArray =
(
  'note.note_key',
  'note.incident_key',
  'note.employee_key',
  'note.note_datetime',
  'note.note'
);

(Of course, my understanding of Perl is limited (been a few years) and my
understanding of Embperl is very limited (been working with it for 2 weeks).
I come from a C background but have been working
with VB and Java the last couple of years.)

[### if update button has been selected, we need to insert the data entered
into the notes table ###]
[$ if ($fdat{'update'}) $]
[-
#-------------------
# define some common vars
#-------------------
$DSN = GetDSN();
$Table = 'note';

$DBIx::Recordset::Debug = 2;

#-------------------
# execute our search query to get the max note_key value in the notes table
#-------------------
DBIx::Recordset::Undef ('set');
*set = DBIx::Recordset -> Search ({'!DataSource' => $DSN,'!Table' =>
$Table,'$fields' => 'MAX(note.note_key) AS dave'}) ;

#-------------------
# get the max note_key value and add 1 and save it out to the form data var.
#-------------------
$fdat{'note.note_key'} = $set{dave} + 1;
push @debugMessage, "set{dave} = $set{dave}";
push @debugMessage, "note.note_key = $fdat{'note.note_key'}";

#-----------------
# different than above but should produce the same results
#----------------
DBIx::Recordset::Undef ('set');
undef $fdat{'!DataSource'};
undef $fdat{'!Table'};
undef $fdat{'!Fields'};
undef $fdat{'=search'};
$fdat{'!DataSource'} =  GetDSN();
$fdat{'!Table'}      = 'note';
$fdat{'!Fields'}     = 'MAX(note.note_key) AS dave';
$fdat{'=search'}     = 'ok';

*set = DBIx::Recordset->Execute({%fdat});
push @debugMessage, "another one set{dave} = $set{dave}";


#-------------------
#set up our DBIx object to insert the data
#-------------------
DBIx::Recordset::Undef ('set');
$fdat{'!DataSource'} = GetDSN();
$fdat{'!Table'}      = 'note';
$fdat{'!Fields'}     = join(", ", @noteTableArray);
$fdat{'!LongNames'}  = 1;
$fdat{'!PrimKey'}    = 'note.note_key';
$fdat{'=insert'}     = 'ok';

eval
{
  *set = DBIx::Recordset->Execute(\%fdat);
  $set->Commit();
};
if( $@ )
{
  Validation::WriteOracleError(\$@, \@outputMessage);
}
-]

Here is what is in fdat, udat and idat when the notes form is displayed:
Debug Messages 
fdat{!Table} = unanet_employee 
fdat{=search} = ok 
fdat{!Filter} = 
fdat{!DataSource} = DBI::db=HASH(0x502ed8c) 
fdat{IncidentKey} = 10149 
fdat{!Fields} = employee_key, first_name || ' ' || last_name as name 
udat{UnanetFullName} = David Boyd 
udat{UnanetUsername} = DBOYD 
udat{LastRequestTime} = 999087883 
udat{UnanetEmployeeKey} = 27 
udat{Username} = irs_app 
udat{DataSource} = Nisys05 
udat{Timeout} = 3600 
udat{UserRights} = 
udat{LogonTime} = 999087407 
udat{Schema} = irs 
udat{DBH} = DBI::db=HASH(0x502ed8c) 
idat{update} = Update 
idat{note.incident_key} = 10149 
idat{close} = Close 

Here is what is in fdat and udat after the update button has been selected
Debug Messages 

set{dave} = 10036 
note.note_key = 10037 
another one set{dave} = 
fdat{=insert} = ok 
fdat{!PrimKey} = note.note_key 
fdat{!Table} = note 
fdat{update} = Update 
fdat{note.employee_key} = 1 
fdat{=search} = ok 
fdat{!Filter} = 
fdat{!LongNames} = 1 
fdat{!DataSource} = DBI::db=HASH(0x502ed8c) 
fdat{note.note_datetime} = 8/29/2001 
fdat{note.note_key} = 10037 
fdat{note.incident_key} = 10149 
fdat{!Fields} = note.note_key, note.incident_key, note.employee_key,
note.note_datetime, note.note 
udat{UnanetFullName} = David Boyd 
udat{UnanetUsername} = DBOYD 
udat{LastRequestTime} = 999087804 
udat{UnanetEmployeeKey} = 27 
udat{Username} = irs_app 
udat{DataSource} = Nisys05 
udat{Timeout} = 3600 
udat{UserRights} = 
udat{LogonTime} = 999087407 
udat{Schema} = irs 
udat{DBH} = DBI::db=HASH(0x502ed8c) 

results find in the log file:

DB:  Use already open dbh for Nisys05 (id=193, numOpen = 0)
DB:   use cached meta data for note
DB:  New Recordset driver=Oracle  placeholders NOT supported
DB:  SelectWhere <!Table>=<note> type = !
DB:  SelectWhere <!Filter>=<> type = !
DB:  SelectWhere <$fields>=<MAX(note.note_key) AS dave> type = $
DB:  SelectWhere <!DataSource>=<DBI::db=HASH(0x502ed8c)> type = !
DB:  FLUSH Recordset id = 193  DBIx::Recordset=HASH(0x4ff27f0) 
DB:  'SELECT MAX(note.note_key) AS dave FROM note        ' bind_values=<>
bind_types=<>
DB:  Undef HTML::Embperl::DOC::_8::set
DB:  FLUSH Recordset id = 193  DBIx::Recordset=HASH(0x4ff27f0) 
DB:  Row::DESTROY
DB:  FLUSH Recordset id = 193  DBIx::Recordset=HASH(0x4ff27f0) 
DB:  Disconnect (id=193, numOpen = 0)
DB:  FLUSH Recordset id = 193  DBIx::Recordset=HASH(0x4ff27f0) 
DB:  Disconnect (id=193, numOpen = 0)
DB:  DESTROY (id=193, numOpen = 0)
DB:  Use already open dbh for Nisys05 (id=194, numOpen = 0)
DB:   use cached meta data for note
DB:  New Recordset driver=Oracle  placeholders NOT supported
DB:  Execute =search 
DB:  SelectWhere <!Table>=<note> type = !
DB:  SelectWhere <note.employee_key>=<1> type = n
DB:  SelectWhere <update>=<Update> type = u
DB:  SelectWhere <=search>=<ok> type = =
DB:  SelectWhere <!Filter>=<> type = !
DB:  SelectWhere <note.note>=<this is another test of the notes function>
type = n
DB:  SelectWhere <note.note_datetime>=<8/29/2001> type = n
DB:  SelectWhere <!DataSource>=<DBI::db=HASH(0x502ed8c)> type = !
DB:  SelectWhere <note.note_key>=<10037> type = n
DB:  SelectWhere <note.incident_key>=<10149> type = n
DB:  SelectWhere <!Fields>=<MAX(note.note_key) AS dave> type = !
DB:  FLUSH Recordset id = 194  DBIx::Recordset=HASH(0x4ffdde0) 
DB:  'SELECT MAX(note.note_key) AS dave FROM note WHERE   (
(note.employee_key = ?))  and  (  (note.note = ?))  and  (
(note.note_datetime = ?))  and  (  (note.note_key = ?))  and  (
(note.incident_key = ?))      ' bind_values=<1 this is another test of the
notes function 8/29/2001 10037 10149> bind_types=<3 12 9 3 3>
DB:  Undef HTML::Embperl::DOC::_8::set
DB:  FLUSH Recordset id = 194  DBIx::Recordset=HASH(0x4ffdde0) 
DB:  Row::DESTROY
DB:  FLUSH Recordset id = 194  DBIx::Recordset=HASH(0x4ffdde0) 
DB:  Disconnect (id=194, numOpen = 0)
DB:  FLUSH Recordset id = 194  DBIx::Recordset=HASH(0x4ffdde0) 
DB:  Disconnect (id=194, numOpen = 0)
DB:  DESTROY (id=194, numOpen = 0)
DB:  Use already open dbh for Nisys05 (id=195, numOpen = 0)
DB:   use cached meta data for note
DB:  New Recordset driver=Oracle  placeholders NOT supported
DB:  Execute =search =insert 
DB:  Primary Key note.note_key found -> note.note_key= ? 
DB:  FLUSH Recordset id = 195  DBIx::Recordset=HASH(0x3eb3990) 
DB:  'SELECT note.note_key, note.incident_key, note.employee_key,
note.note_datetime, note.note FROM note WHERE note.note_key= ?       '
bind_values=<10037> bind_types=<3>
DB:  FLUSH Recordset id = 195  DBIx::Recordset=HASH(0x3eb3990) 





---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to