INSERT & UPDATE

Started by Hillensbeck, Prestonalmost 24 years ago2 messagesgeneral
Jump to latest
#1Hillensbeck, Preston
PHillensbeck@sfbcic.com

I am trying to UPDATE a column after an INSERT, and getting a NULL result,
let me show you some code... This is from a PHP page by the way

$sql="BEGIN WORK; INSERT INTO checking (check_date, check_amount,
check_number, check_payee, check_trans_type) VALUES ('$check_date',
'$check_amount', '$check_number', '$check_payee', '$check_trans_type');
UPDATE checking SET check_post_balance = (check_pre_balance -
$check_amount::money); COMMIT WORK;";

After the INSERT, I am trying to update the check_post_balance column to
check_pre_balance MINUS what the check_amount was. I have tried many
variations on this and all I get are NULL results. Can anyone see what in
the heck I am doing wrong? :) Thanks in advance!

Preston

#2Martijn van Oosterhout
kleptog@svana.org
In reply to: Hillensbeck, Preston (#1)
Re: INSERT & UPDATE

On Fri, Apr 19, 2002 at 01:44:55PM -0500, Hillensbeck, Preston wrote:

I am trying to UPDATE a column after an INSERT, and getting a NULL result,
let me show you some code... This is from a PHP page by the way

$sql="BEGIN WORK; INSERT INTO checking (check_date, check_amount,
check_number, check_payee, check_trans_type) VALUES ('$check_date',
'$check_amount', '$check_number', '$check_payee', '$check_trans_type');
UPDATE checking SET check_post_balance = (check_pre_balance -
$check_amount::money); COMMIT WORK;";

After the INSERT, I am trying to update the check_post_balance column to
check_pre_balance MINUS what the check_amount was. I have tried many
variations on this and all I get are NULL results. Can anyone see what in
the heck I am doing wrong? :) Thanks in advance!

I imagine the you get NULL out because check_pre_balance is also NULL?

--
Martijn van Oosterhout <kleptog@svana.org> http://svana.org/kleptog/

Show quoted text

Canada, Mexico, and Australia form the Axis of Nations That
Are Actually Quite Nice But Secretly Have Nasty Thoughts About America