get sequence nextval in postgres

2911
2
01-21-2011 10:05 AM
by Anonymous User
Not applicable
Original User: dwoods

I have been using the C# code sample that uses IQueryDef to get the nextval from a sequence in our Oracle database.  Now I am trying to port the code to postgres.  I would prefer to keep it in ArcObjects rather than make a db connection and run it in PostgreSQL.  Does anyone have a working code snippet?  I have tried many variations with the original code sample to no avail. This is what I was using in Oracle:

            IFeatureWorkspace featureWorkspace = workspace as IFeatureWorkspace;
            IQueryDef queryDef;
            ICursor cursor;
            IRow row;
            double seqValue;

            queryDef = featureWorkspace.CreateQueryDef();
            queryDef.SubFields = "owner.seq_name.nextval";
            queryDef.Tables = "sys.dual";
            cursor = queryDef.Evaluate();
            row = cursor.NextRow();
            seqValue = double.Parse(row.get_Value(0).ToString());
0 Kudos
2 Replies
by Anonymous User
Not applicable
Original User: vtammineni

I have been using the C# code sample that uses IQueryDef to get the nextval from a sequence in our Oracle database.  Now I am trying to port the code to postgres.  I would prefer to keep it in ArcObjects rather than make a db connection and run it in PostgreSQL.  Does anyone have a working code snippet?  I have tried many variations with the original code sample to no avail. This is what I was using in Oracle:

            IFeatureWorkspace featureWorkspace = workspace as IFeatureWorkspace;
            IQueryDef queryDef;
            ICursor cursor;
            IRow row;
            double seqValue;

            queryDef = featureWorkspace.CreateQueryDef();
            queryDef.SubFields = "owner.seq_name.nextval";
            queryDef.Tables = "sys.dual";
            cursor = queryDef.Evaluate();
            row = cursor.NextRow();
            seqValue = double.Parse(row.get_Value(0).ToString());


You are using Postgresql ArcSDE ?
0 Kudos
by Anonymous User
Not applicable
Original User: dwoods

Yes.  Postgresql version 8.3.7 and ArcSDE vers 9.3 sp1.
0 Kudos