I just discovered the RETURNING command for Postgres, however, I am unable to get it to work despite reading the two threads related to it. :(
I want to save a new security group name, and then get the ID back so I can do other work with it. It bugs out at the "dim rs as RecordSet = ps.SQLSelect(GroupName)" line every-time.
My code is:
Function SaveGroupName(GroupID as integer, GroupName as string) As integer dim b as integer dim sql as String if groupID = 0 then sql = "INSERT INTO sec_groups(name) VALUES ($1) RETURNING id;" Dim ps As PostgreSQLPreparedStatement //Build prepared statement ps = self.Prepare(sql) dim rs as RecordSet = ps.SQLSelect(GroupName) If rs <> Nil Then Do Until rs.EOF b = rs.Field("id").IntegerValue self.Commit rs.MoveNext Loop end if return rs.Field("id").IntegerValue else end if if self.Error then return 0 end if End Function