public object GetPrimaryKey(Util.SqlHelper sqlHelper, string dataBaseName, string tableName) { object pk = sqlHelper.ExecuteScalar("select column_name from user_cons_columns where constraint_name=(select constraint_name from user_constraints where upper(table_name)=upper('" + tableName + "') and constraint_type='P')"); return(pk == null ? null : pk.ToString().FirstLetterToUpper()); }
public object GetPrimaryKey(Util.SqlHelper sqlHelper, string dataBaseName, string tableName) { return (sqlHelper.ExecuteScalar(string.Format( "select pg_attribute.attname as name from pg_constraint inner join pg_class on pg_constraint.conrelid = pg_class.oid inner join pg_attribute on pg_attribute.attrelid = pg_class.oid and pg_attribute.attnum = pg_constraint.conkey[1] inner join pg_type on pg_type.oid = pg_attribute.atttypid where pg_class.relname = '{0}' and pg_constraint.contype='p'", tableName))); }
public object GetPrimaryKey(Util.SqlHelper sqlHelper, string dataBaseName, string tableName) { object pk = sqlHelper.ExecuteScalar("select name from sysibm.syscolumns where upper(tbname) = upper('" + tableName + "') and keyseq > 0 order by keyseq asc"); return(pk == null ? null : pk.ToString().FirstLetterToUpper()); }