Class::DBI::Sybase patch (for IDENTITY columns)

[prev] [thread] [next] [Date index for 2004/10/19]

From: Michael Wojcikiewicz
Subject: Class::DBI::Sybase patch (for IDENTITY columns)
Date: 16:56 on 19 Oct 2004
------=_20041019115619_54266
Content-Type: text/plain; charset="iso-8859-1"
Content-Transfer-Encoding: 8bit

Attached is a patch (and full file) for allowing auto-generation of values
for IDENTITY columns in Sybase.  It relies on the fact that sp_help
returns the right info regarding IDENTITY columns (works in sybase
12.5.2).

Comments?  Suggestions?  Bugs??

--mike
------=_20041019115619_54266
Content-Type: application/octet-stream; name="ClassDBISybase.patch"
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename="ClassDBISybase.patch"

LS0tIC9tcy9kaXN0L3Blcmw1L1BST0ovQ2xhc3MtREJJLVN5YmFzZS8wLjEvbGliL3Blcmw1L0Ns
YXNzL0RCSS9TeWJhc2UucG0JV2VkIFNlcCAgMyAyMToyMToxMSAyMDAzCisrKyBTeWJhc2UucG0J
VHVlIE9jdCAxOSAxMjoyMDozNSAyMDA0CkBAIC0yMSw2ICsyMSw3IEBACiBUaGlzIGlzIGFuIGV4
dGVuc2lvbiB0byBDbGFzczo6REJJIHRoYXQgY3VycmVudGx5IGltcGxlbWVudHM6CiAKIAkqIEF1
dG9tYXRpYyBjb2x1bW4gbmFtZSBkaXNjb3ZlcnkuCisJKiBXb3JrcyB3aXRoIElERU5USVRZIGNv
bHVtbnMgdG8gYXV0by1nZW5lcmF0ZSBwcmltYXJ5IGtleXMuCiAJCiBJbnN0ZWFkIG9mIHNldHRp
bmcgQ2xhc3M6OkRCSSBhcyB5b3VyIGJhc2UgY2xhc3MsIHVzZSB0aGlzLgogCkBAIC0yOSwxMCAr
MzAsMTIgQEAKIERCRDo6U3liYXNlIGN1cnJlbnRseSBoYXMgYSBidWcgd2hlcmUgYSBzdGF0ZW1l
bnQgaGFuZGxlIGNhbiBiZSBtYXJrZWQgYXMKIGFjdGl2ZSwgZXZlbiB0aG91Z2ggaXQncyBub3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oKCkgaWYgJHN0aCAtPiB7
QWN0aXZlfTsKKyAgICAkc2VsZi0+X2Nyb2FrKCJDYW4ndCBnZXQgbGFzdCBpbnNlcnQgaWQiKSB1
bmxlc3MgZGVmaW5lZCAkaWQ7CisKKyAgICByZXR1cm4gJGlkOworfQorCiAxOwogCiBfX0VORF9f
Cg==
------=_20041019115619_54266
Content-Type: application/octet-stream; name="Sybase.pm"
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename="Sybase.pm"

cGFja2FnZSBDbGFzczo6REJJOjpTeWJhc2U7Cgo9aGVhZDEgTkFNRQoKQ2xhc3M6OkRCSTo6U3li
YXNlIC0gRXh0ZW5zaW9ucyB0byBDbGFzczo6REJJIGZvciBTeWJhc2UKCj1oZWFkMSBTWU5PUFNJ
UwoKICBwYWNrYWdlIE11c2ljOjpEQkk7CiAgdXNlIGJhc2UgJ0NsYXNzOjpEQkk6OlN5YmFzZSc7
CiAgTXVzaWM6OkRCSS0+c2V0X2RiKCdNYWluJywgJ2RiaTpTeWJhc2U6c2VydmVyPSRzZXJ2ZXIn
LCAndXNlcm5hbWUnLCAncGFzc3dvcmQnKTsKCiAgcGFja2FnZSBBcnRpc3Q7CiAgdXNlIGJhc2Ug
J011c2ljOjpEQkknOwogIF9fUEFDS0FHRV9fLT5zZXRfdXBfdGFibGUoJ0FydGlzdCcpOwogIAog
ICMgLi4uIHNlZSB0aGUgQ2xhc3M6OkRCSSBkb2N1bWVudGF0aW9uIGZvciBkZXRhaWxzIG9uIENs
YXNzOjpEQkkgdXNhZ2UKCj1oZWFkMSBERVNDUklQVElPTgoKVGhpcyBpcyBhbiBleHRlbnNpb24g
dG8gQ2xhc3M6OkRCSSB0aGF0IGN1cnJlbnRseSBpbXBsZW1lbnRzOgoKCSogQXV0b21hdGljIGNv
bHVtbiBuYW1lIGRpc2NvdmVyeS4KCSogV29ya3Mgd2l0aCBJREVOVElUWSBjb2x1bW5zIHRvIGF1
dG8tZ2VuZXJhdGUgcHJpbWFyeSB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AgcmV0dXJuICRpZDsKfQoKMTsKCl9fRU5EX18K
------=_20041019115619_54266--

Class::DBI::Sybase patch (for IDENTITY columns)
Michael Wojcikiewicz 16:56 on 19 Oct 2004

Re: Class::DBI::Sybase patch (for IDENTITY columns)
Michael Wojcikiewicz 17:28 on 19 Oct 2004

another Class::DBI::Sybase patch (0.3)
Michael Wojcikiewicz 15:44 on 20 Oct 2004

Generated at 11:34 on 01 Dec 2004 by mariachi v0.52