File: identity.pl

package info (click to toggle)
libdbd-odbc-perl 1.24-1
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 1,012 kB
  • ctags: 398
  • sloc: perl: 6,314; ansic: 4,875; makefile: 29; sql: 8
file content (24 lines) | stat: -rw-r--r-- 707 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#!perl -w
# $Id: identity.pl 11680 2008-08-28 08:23:27Z mjevans $


use strict;
use DBI;

my $dbh = DBI->connect("DBI:ODBC:PERL_TEST_SQLSERVER",,, {RaiseError => 1});

# create a temp table with an identity property on a column:
my $sql = qq{CREATE TABLE #TEMP1 (MyCol INT NOT NULL IDENTITY)};
$dbh->do($sql);

# Set the identity insert property for this table on
# this should allow me to explicitly give a value to be inserted into the # identity column:

$sql = qq{SET IDENTITY_INSERT #TEMP1 ON};
$dbh->do($sql);		# Added by JLU
# now try to insert an explicit value into this identity column:

$sql = qq{INSERT INTO #TEMP1 (MyCol) VALUES (1)};
$dbh->do($sql);

$dbh->disconnect;