Postgres sequences using feature service

304
1
Jump to solution
10-23-2022 02:27 AM
kirken
by
New Contributor III

Hello!

I'm developing an add-in where I'm using ArcGIS Feature Service from Portal that has one layer and some tables related to it. Data is in Postgres database. I would like to know how to query sequence table. Does sequence table has to be added to service for that? Before starting to use feature service I queried sequences like in the code example below:  

 

 

 using (var tbl = f_layer.GetTable())
                    {
                        seqs = FaktikaUtils.GetAllSequences(tbl);
                    }  


public static List<string> GetAllSequences(Table Tbl)
        {
            List<string> seq_lst = new List<string>();
            using (Geodatabase gdb = Tbl.GetDatastore() as Geodatabase)
            {
                if (gdb.GetGeodatabaseType() == GeodatabaseType.RemoteDatabase))
                {
                    var conn = gdb.GetConnector() as DatabaseConnectionProperties;
                    if (conn.DBMS == EnterpriseDatabaseType.PostgreSQL)
                    {
                        QueryDef qd = new QueryDef
                        {
                            Tables = "information_schema.sequences",
                            SubFields = "sequence_name, sequence_catalog, sequence_schema"
                        };
                        using (RowCursor cur = gdb.Evaluate(qd, false))
                        {
                            while (cur.MoveNext())
                            {
                                using (Row row = cur.Current)
                                {
                                    seq_lst.Add($"{row["sequence_catalog"]}.{row["sequence_schema"]}.{row["sequence_name"]}");
                                }
                            }
                        }
                    }
                }
            }
            return seq_lst;
        }

 

 

 

Tags (1)
0 Kudos
1 Solution

Accepted Solutions
RichRuh
Esri Regular Contributor

One thing you might consider is whether you can use attribute rules to generate the sequence.

If you want to stick to the way you are doing it, you might create a registered view on the sequence table. Then you would add that view to your publishing map and republish it with your service.

I hope this helps,

--Rich

View solution in original post

0 Kudos
1 Reply
RichRuh
Esri Regular Contributor

One thing you might consider is whether you can use attribute rules to generate the sequence.

If you want to stick to the way you are doing it, you might create a registered view on the sequence table. Then you would add that view to your publishing map and republish it with your service.

I hope this helps,

--Rich

0 Kudos