PEPPLER.ORG
Michael Peppler
Sybase Consulting
Menu
Home
Sybase on Linux
Install Guide for Sybase on Linux
General Sybase Resources
General Perl Resources
Freeware
Sybperl
Sybase::Simple
DBD::Sybase
BCP Tool
Bug Tracker
Mailing List Archive
Downloads Directory
FAQs
Sybase on Linux FAQ
Sybperl FAQ
Personal
Michael Peppler's resume

sybperl-l Archive

Up    Prev    Next    

From: jrisley at nex-web4 dot corp dot fedex dot com (Jason Risley)
Subject: Insert & Select
Date: Apr 8 1999 10:37PM

All,

I am using an 'id' field as an identity (primary key) type. I'm trying to
insert a record into the table and would like ot retrieve the id value that
the server generated for the particular insert. Does anyone have any sample
code that does this?

The following is what I have thus far:

	$sql = " begin "
		. " insert into work_request "
		. " (emp_num, status, priority, "
		. " prob_type, prob_desc, "
		. " email_addr, email_notify,  "
		. " created_by, created_date "
		. " VALUES (\"$form_data{'emp_num'}\", \"$form_data{'status'}\",
\"$form_data{'priority'}, "
		. " \"$form_data{'prob_type'}\", \"$form_data{'prob_desc'}", "
		. " \"$form_data{'email_addr'}\", \"$form_data{'email_notify'}\", "
		. " \"$form_data{'emp_num'}\", getdate() "
		. " end ";

	$dbh->ct_execute("$sql");
	while ( $dbh->ct_results($result) == CS_SUCCEED) {
		if ( $dbh->ct_fetchable($result) ) {
			while (@dat = $dbh->ct_fetch) {
			} # End of ct_fetchable
		}
		else {
		}
	} # End of ct_results


Any assistance is greatly appreciated!!
Jason