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: =?iso-8859-1?Q?Pochet_Fr=E9d=E9ric?= <Frederic dot Pochet at cockerill-sambre dot com>
Subject: TR: Insert & Select
Date: Apr 13 1999 7:09AM


> ----------
> De : 	Pochet Frédéric
> Date :	mardi 13 avril 1999 9:06
> A :	'jrisley@fedex.com'
> Objet :	RE: Insert & Select
> 
> hello Jason,
> 
> In isql you can do the following:
> 	1> insert  (col .... col) values (val ... val)
> 	2> select @@identity
> 	3> go
> 
> I think you can issue the same batch from sybperl.
> 
> Best regards
> 
> F.Pochet
> 
> ----------
> De :
> jrisley@nex-web4.corp.fedex.com[SMTP:jrisley@nex-web4.corp.fedex.com]
> Date :	vendredi 9 avril 1999 0:37
> A :	SybPerl Discussion List
> Objet :	Insert & Select
> 
> 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
> 
>