|
POST
|
Hi Michelle, Here is a small sample I put together with your outline: --Create Leaf table
create table leaf (ROUTEID INT, CYCLE VARCHAR(10), LAST_EDIT DATE);
--Insert records
INSERT INTO LEAF VALUES (1, 'CYCLE1', '10/23/2015');
INSERT INTO LEAF VALUES (1, 'CYCLE2', '1/23/2015');
INSERT INTO LEAF VALUES (1, 'CYCLE3', '3/23/2015');
INSERT INTO LEAF VALUES (2, 'CYCLE1', '5/23/2015');
INSERT INTO LEAF VALUES (2, 'CYCLE2', '12/23/2015');
INSERT INTO LEAF VALUES (2, 'CYCLE3', '7/23/2015');
--Create the select statement with a pivot
SELECT ROUTEID, CYCLE1, CYCLE2, CYCLE3 FROM
(SELECT ROUTEID, CYCLE, LAST_EDIT FROM LEAF) LEAF_PIV
PIVOT (MAX(LAST_EDIT) FOR CYCLE IN (CYCLE1, CYCLE2, CYCLE3)) PIV Results: In addition, this query does work for me in ArcMap/ArcCatalog if I cast the dates to varchar. What field types do you have for your last_edit field?
... View more
10-23-2015
07:49 AM
|
1
|
3
|
1225
|
|
POST
|
You can change the "owner" and "table" variables to be your feature class, table or raster. So if the feature class you want to get information for appears as "gis.abc.polygons" the variable would be: owner = 'abc' table = 'polygons'
... View more
08-07-2015
02:16 PM
|
0
|
0
|
1976
|
|
POST
|
Here is a sample of a single feature class: import arcpy, os, datetime, time
gdb = r"Database Connections\Connection to cwells.sde"
conn = arcpy.ArcSDESQLExecute(gdb)
owner = 'sde'
table = 'alex'
sql = """SELECT
create_date,modify_date
FROM sys.tables
where UPPER(SCHEMA_NAME(schema_id)) = '{0}' AND
UPPER(OBJECT_NAME(object_id)) = '{1}'"""
dates = conn.execute(sql.format(owner.upper(), table.upper()))
print (owner + '.' + table).upper()
print "Create Date: {0}".format(dates[0][0])
print "Modify Date: {0}".format(dates[0][1])
OUTPUT
SDE.ALEX
Create Date: 8/3/2015 10:55:11 AM
Modify Date: 8/3/2015 11:00:51 AM
... View more
08-07-2015
11:49 AM
|
1
|
4
|
1976
|
|
POST
|
I'm not sure of your exact question, but are you asking if its possible to return a date for a single feature class only?
... View more
08-07-2015
08:35 AM
|
0
|
6
|
1976
|
|
POST
|
Hi Said, This is something that can be done by sending SQL queries to your SDE repository tables to get the created UNIX time from the sde_table_registry and convert that to a more standard time. I have attached a script I have used to perform this in the past and write it out to a logfile. However, this should be enough to get you started on how to access and convert the registration time in your Enterprise Geodatabase. import arcpy, os, datetime, time
workPath = r"Database Connections\Connection to cwells.sde"
arcpy.CreateDatabaseView_management(workPath, viewName, "select database_name, owner, table_name, registration_date from sde.sde_table_registry")
for row in arcpy.SearchCursor(os.path.join(workPath, viewName)):
tableName = row.getValue("DATABASE_NAME") + "." + row.getValue("OWNER") + "." + row.getValue("TABLE_NAME")
cDate = row.getValue("REGISTRATION_DATE")
dTime = time.strftime('%d-%b-%Y %H:%M:%S', time.localtime(cDate))
... View more
08-07-2015
08:03 AM
|
1
|
8
|
1976
|
|
POST
|
Hi Said, When you say modified date, do you mean table structure or last updated/added row?
... View more
08-07-2015
07:36 AM
|
0
|
0
|
1976
|
|
POST
|
Hi Jake, You could try describing the table prior to the list fields. Once the object is described, look for the dataset ID (DSID) property. Anything not registered with the geodatabase will return -1. If the value doesn't equal or is greater than -1, perform the arcpy.ListFields() operation. >>> tblList = arcpy.ListTables()
>>> for tbl in tblList:
... desc = arcpy.Describe(tbl)
... print desc.DSID
...
-1
... View more
07-30-2015
11:00 AM
|
1
|
1
|
1180
|
|
POST
|
Hi Bledar, Can you please post a snippet of the SQL you are using?
... View more
05-28-2015
08:18 AM
|
0
|
6
|
1492
|
|
POST
|
Hi Jose, With a direct connect in SDE command line, you have a few options for the syntax. The -s option is not needed here as this will be grabbed from your Net Service Name (TNS names) or EZ Connect string. If possible, can you please confirm the following?: 1. Is the 64-bit Oracle 11g client installed on this machine? 2. Are you using EZ connect or TNS names? 3. Is your Oracle listener using a port other than 1521? If you are using the EZ connect syntax would be similar to the following: sdemon -o info -I users -i sde:oracle11g:<server>/<SID> -u username -p password If you are using TNS names the syntax would be similar to the following: sdemon -o info -I users -i sde:oracle11g:<TNS Name> -u username -p password
... View more
05-11-2015
07:34 AM
|
1
|
0
|
731
|
|
POST
|
Hi Stacy, Try out the Assign Default To Field (Data Management) tool. feature_class = "Roads"
fields = arcpy.ListFields(feature_class)
for field in fields:
if field.name == "Project_Name":
arcpy.AssignDefaultToField_management(feature_class, "Project_Name", "Test_Project")
... View more
05-06-2015
09:36 AM
|
0
|
0
|
3612
|
|
POST
|
Can you please post the results from the following query? select instance_id, instance_name, status from sde.instances;
... View more
05-01-2015
06:25 AM
|
1
|
2
|
790
|
|
POST
|
Hi Tom, You could try this out in Python using the GetCount_management() tool. import arcpy
arcpy.env.workspace = <GDB>
fcList = arcpy.ListFeatureClasses()
for fc in fcList:
result = arcpy.GetCount_management(fc)
count = int(result.getOutput(0))
if count == 0:
arcpy.Delete_management(fc) Get Count (Data Management): ArcGIS Help (10.2, 10.2.1, and 10.2.2)
... View more
04-10-2015
08:40 AM
|
2
|
4
|
4503
|
|
POST
|
Hi Michael, It is possible to do this using arcpy.mapping.Layer(): import arcpy
mxd = arcpy.mapping.MapDocument(<mxdFile>)
lyr = arcpy.mapping.Layer(<queryLayer>)
oldConn = lyr.workspacePath
lyr.findAndReplaceWorkspacePath(<newSDEconn>, <oldSDEconn>)
mxd.save() Just a note, you won't be able to use the replaceDataSource method for query layers because the dataSource property does not return the name of the tables used in the query layer. lyr = arcpy.mapping.Layer(<queryLayer>)
print lyr.dataSource
output = u'Database Connections\\ConnectionFile.sde\\SDE.%queryLayer'
... View more
04-09-2015
11:23 AM
|
2
|
1
|
1188
|
|
POST
|
Sounds good. Just something to keep in mind with conversions here is that SQL Server doesn't have support for a Transform or Reproject function. Is it possible to reproject spatial data using SQL Server?
... View more
02-26-2015
11:01 AM
|
1
|
3
|
11466
|
|
POST
|
Hi Aaron, SQL Server does also support STX and STY for the geometry type: STX (geometry Data Type) In addition, are you looking to convert the Feet units of a Projected Coordinate System to Decimal Degrees? Chris
... View more
02-26-2015
10:44 AM
|
1
|
5
|
11466
|
| Title | Kudos | Posted |
|---|---|---|
| 3 | 10-09-2025 08:31 AM | |
| 12 | 09-27-2022 06:23 AM | |
| 3 | 03-28-2024 05:12 AM | |
| 3 | 12-20-2023 06:42 AM | |
| 6 | 08-31-2023 05:42 PM |
| Online Status |
Offline
|
| Date Last Visited |
Thursday
|