Unix Technical Forum

Re: Welcome to the pgsql-odbc list!

This is a discussion on Re: Welcome to the pgsql-odbc list! within the pgsql Interfaces odbc forums, part of the PostgreSQL category; --> Hello, This is my first post to the mailing list. I joined because I'm having an issue working with ...


Go Back   Unix Technical Forum > Database Server Software > PostgreSQL > pgsql Interfaces odbc

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 04-16-2008, 02:03 AM
Brien R. Givens
 
Posts: n/a
Default Re: Welcome to the pgsql-odbc list!


Hello,

This is my first post to the mailing list. I joined because I'm having an
issue working with PostgreSQL in ASP. I hope this is the right place to
discuss this issue. I'm confident of my code and have the same approach
working in MySQL, SQL Server, Oracle and Access which leads me to believe
the problem may be due to a bug in the ODBC driver.

The problem deals with sequence numbers in new records not being returned to
ASP after an update. I ran the test with two tables, the first using a
serial column, the second using an integer column manually attached to a
sequence:

Table One

CREATE TABLE test (pid serial, one int)


Table Two

CREATE TABLE test (pid int, one int)

CREATE SEQUENCE test_seq

CREATE FUNCTION test_fun() RETURNS TRIGGER AS 'BEGIN NEW.PID :=
NEXTVAL(''test_seq''); RETURN NEW; END; 'LANGUAGE PLPGSQL;

CREATE TRIGGER test_trg BEFORE INSERT ON test FOR EACH ROW EXECUTE PROCEDURE
test_fun();


ASP

Dim conn, rs

Set conn = Server.CreateObject("ADODB.Connection")
Set rs = Server.CreateObject("ADODB.recordset")

conn.Open "Driver={PostgreSQL};Server=localhost;Database=db; UID=uid;PWD=pwd"
rs.Open "SELECT * FROM test WHERE False", conn, adOpenUnspecified,
adLockPessimistic
rs.AddNew
rs("one") = 1
rs.Update
Response.Write TypeName(rs("pid").Value) & "<br>"


In both cases the output is "Empty". I used TypeName in the Response.Write
simply to illustrate that the value is empty; Response.Write rs("pid").Value
displays nothing in the browser.

I understand that I can use the currval to determine the value but for the
purposes of the project I'm working on I don't want to get into needing to
know the name of the sequence attached to the column. Also, this problem
has bigger implications - while this simple test has only the one stored
procedure modifying the one field, a more complex scenario may alter many
fields upon insert. These changes should be passed back to ASP when the
Update method is called.


---------------------------(end of broadcast)---------------------------
TIP 6: Have you searched our list archives?

http://archives.postgresql.org

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 12:48 AM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com