Re: defncopy query "order by" different for ASE

John Kendall <[email protected]>
Newsgroups gmane.comp.db.tds.freetds
Message-ID <[email protected]>
I figured it out.  Getting the right headers in the right order slowed me down.
Here is my patch for consideration.
Cheers,
John


*** src/apps/defncopy.c	2016-06-19 02:00:01.000000000 -0700
--- src/apps/defncopy.c-patch	2016-08-23 18:17:24.897056456 -0700
*************** int getopt(int argc, const char *argv[],
*** 80,86 ****
--- 80,88 ----
  #include <locale.h>
  #endif
  
+ #include <freetds/tds.h>
  #include <sybfront.h>
+ #include <dblib.h>
  #include <sybdb.h>
  #ifndef MicrosoftsDbLib
  #include "replacements.h"
*************** main(int argc, char *argv[])
*** 220,232 ****
  					 " and		o.name = '%s'"
  					 " and		o.uid = user_id('%s')"
  					 " and		o.type not in ('U', 'S')" /* no user or system tables */
! 					 " order by 	c.number, c.colid"
  					;
  		static const char query_table[] = " execute sp_help '%s.%s' ";
  
  		parse_argument(argv[i], &procedure);
  
! 		erc = dbfcmd(dbproc, query, procedure.name, procedure.owner); 
  	
  		/* Send the query to the server (we could use dbsqlexec(), instead) */
  		erc = dbsqlsend(dbproc);
--- 222,235 ----
  					 " and		o.name = '%s'"
  					 " and		o.uid = user_id('%s')"
  					 " and		o.type not in ('U', 'S')" /* no user or system tables */
! 					 " order by 	c.number, %s c.colid"
  					;
  		static const char query_table[] = " execute sp_help '%s.%s' ";
  
  		parse_argument(argv[i], &procedure);
  
! 		erc = dbfcmd(dbproc, query, procedure.name, procedure.owner, 
! 			     (dbproc->tds_socket->conn->tds_version == 0x500) ? "c.colid2, ":"");
  	
  		/* Send the query to the server (we could use dbsqlexec(), instead) */
  		erc = dbsqlsend(dbproc);




> On Aug 22, 2016, at 12:55 AM, John Kendall <[email protected]> wrote:
> 
> 
>> On Aug 18, 2016, at 8:16 PM, James K. Lowden <[email protected]> wrote:
>> 
>> On Wed, 17 Aug 2016 23:55:43 +0000
>> John Kendall <[email protected]> wrote:
>> 
>>> It should be a quick patch, but I'm not sure the best way to
>>> determine if the server is ASE and MS SQL.  
>> 
>> Test for TDS version 5.  
> 
> Excellent idea, thank you!
> 
> However after trying for a few hours, I'm going to have to ask how to get the tds_version.
> I assume I get it from dbproc, but I never seem to have the right headers (or something).
> 
> Thanks, anyone.
> 
> John
> 
> 
> 
>> --jkl
>> 
>> _______________________________________________
>> FreeTDS mailing list
>> [email protected]
>> http://lists.ibiblio.org/mailman/listinfo/freetds
>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.