I have solved my problem by going back to an old method I used until MySQL got smart and offered up insert_id "Returns the auto generated id used in the last query."

I wished DB2 had something like this...

But until then... here is my solution...

if ( Connect2DB() )
{
// Create Record With Target In Agent Field
$sTarget = md5( date( 'ymdHis' ).$sIP ) ;
$rResult = RunQuery( 'INSERT INTO '.$sSchema.'zTest ( Agent ) VALUES ( \''.$sTarget.'\' );' ) ;

// Retrieve Auto Incremented ID
$rResult = RunQuery( 'SELECT ID FROM '.$sSchema.'zTest WHERE Agent = \''.$sTarget.'\' ;' ) ;
$aRow = db2_fetch_assoc( $rResult ) ;

LogIt( 'New ID: '.$aRow[ 'ID' ] ) ;

// Update Record With Accurate Data
$rResult = RunQuery( 'UPDATE '.$sSchema.'zTest SET '.$sSets.' WHERE ID = '.$aRow[ 'ID' ].' ;' ) ;

db2_close( $_SESSION[ 'DB' ] ) ;
}

With MySQLi this is as simple as:

$oDB->query( INSERT INTO MyTable SET Clmn='Data' ) ;
$nID = $oDB->insert_id ;



*** So does DB2 support INSERT INTO MyTable SET fld=val, fld=val
or only INSERT INTO MyTable ( Fields ) VALUES ( Values )

So I have spent almost 2 days fighting this one thing.


On 2015-12-04 12:24, Buck Calabro wrote:
On 12/4/2015 1:00 PM, Rob wrote:
I did notice that when I created the tables in SiN...( Sounds funny )..
that it reported that the tables would not be journaled.

I have since gone into SiN and dropped the table.

I then created the table from the PHP script.
Unless I deeply misunderstand something, you still do not have a table
which is journaled. In order to journal a table, one needs to:
1) Issue STRJRNPF against it - see your system admins!
2) Create the table in a schema which in turn was created with the SQL
CREATE SCHEMA statement. This schema will automatically journal tables
created within it.

This may not turn out to be the issue for this particular problem, but
it is useful to know, so I'm leaving it here for the archives.



---
This email has been checked for viruses by Avast antivirus software.
https://www.avast.com/antivirus


As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:
Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.