From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Michael Mauger Newsgroups: gmane.emacs.help Subject: Re: Sql-Mode - getting query results from MS SQL Server 2000 Date: Fri, 17 Jun 2005 15:47:25 +0000 (UTC) Message-ID: References: <20050615192935.GC14624@inkedmn.com> <20050616213805.GH14624@inkedmn.com> NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Trace: sea.gmane.org 1119023847 28851 80.91.229.2 (17 Jun 2005 15:57:27 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Fri, 17 Jun 2005 15:57:27 +0000 (UTC) Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Fri Jun 17 17:57:23 2005 Return-path: Original-Received: from lists.gnu.org ([199.232.76.165]) by ciao.gmane.org with esmtp (Exim 4.43) id 1DjJCd-0002hD-OU for geh-help-gnu-emacs@m.gmane.org; Fri, 17 Jun 2005 17:56:20 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1DjJIH-0006qN-3T for geh-help-gnu-emacs@m.gmane.org; Fri, 17 Jun 2005 12:02:09 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1DjJGP-0006C5-7j for help-gnu-emacs@gnu.org; Fri, 17 Jun 2005 12:00:14 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1DjJGH-00069Y-5W for help-gnu-emacs@gnu.org; Fri, 17 Jun 2005 12:00:06 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1DjJGG-00066r-Gu for help-gnu-emacs@gnu.org; Fri, 17 Jun 2005 12:00:04 -0400 Original-Received: from [80.91.229.2] (helo=ciao.gmane.org) by monty-python.gnu.org with esmtp (TLS-1.0:RSA_AES_128_CBC_SHA:16) (Exim 4.34) id 1DjJDn-0006ym-KY for help-gnu-emacs@gnu.org; Fri, 17 Jun 2005 11:57:31 -0400 Original-Received: from list by ciao.gmane.org with local (Exim 4.43) id 1DjJ59-0001Jd-PH for help-gnu-emacs@gnu.org; Fri, 17 Jun 2005 17:48:40 +0200 Original-Received: from prxy.bkb.com ([204.167.53.77]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Fri, 17 Jun 2005 17:48:35 +0200 Original-Received: from mmaug by prxy.bkb.com with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Fri, 17 Jun 2005 17:48:35 +0200 X-Injected-Via-Gmane: http://gmane.org/ Original-To: help-gnu-emacs@gnu.org Original-Lines: 75 Original-X-Complaints-To: usenet@sea.gmane.org X-Gmane-NNTP-Posting-Host: main.gmane.org User-Agent: Loom/3.14 (http://gmane.org/) X-Loom-IP: 204.167.53.77 (Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0; bkbrel07)) X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:27521 X-Report-Spam: http://spam.gmane.org/gmane.emacs.help:27521 Brett Kelly inkedmn.com> writes: > > Sometime around Thu, Jun 16, 2005 at 12:15:57PM -0600, Kevin Rodgers said: > > Brett Kelly wrote: > > > I'd like to be able to type in a sql query and have it return a > > resultset in a > > > different buffer (a la Query Analyzer). Here's what I'm doing now: > > > - Create a new buffer, do M-x sql-ms RET, then enter the relevant > > connection > > > information (user, password, server, dbname). This gives me no errors. > > > - Type in my SQL statement (I've tried simple "select" statements, as > > well as > > > more complicated "create proc" type stuff) > > > - Highlight the relevant code with the mouse, and choose Send Region > > from the > > > SQL menu. > > > > > > Now, if I'm understanding this correctly, I should see the results in > > a new > > > buffer, but I'm not. > > > > From the commentary at the top of sql.el excerpted below, I guess that > > you are typing your SQL statement directly into the sql-interactive-mode > > *SQL* buffer. If you enter them in some other sql-mode buffer, Send > > Region should cause the *SQL* buffer with the results to be displayed > > (see sql-pop-to-buffer-after-send-region). > > > > ;; This file provides a sql-mode and a sql-interactive-mode. The > > ;; interactive mode had to provide a command-line history; the other > > ;; mode had to provide "send region/buffer to SQL interpreter" > > ;; functions. > > > > ;; sql-interactive-mode is used to interact with a SQL interpreter > > ;; process in a SQLi buffer (usually called `*SQL*'). The SQLi buffer > > ;; is created by calling a SQL interpreter-specific entry function. Do > > ;; *not* call sql-interactive-mode by itself. > > > > ;; sql-mode can be used to keep editing SQL statements. The SQL > > ;; statements can be sent to the SQL process in the SQLi buffer. > > > > -- > > Kevin Rodgers > > Well, I guess that was my core "goal" - to get emacs to behave as much as > possible like Query Analyzer... > > I spend probably half of every day writing sql code, just thought it'd be nice > to be able to write/run sql stuff in something other than query analyzer. > > Thanks for the help! > A couple of issues with MS under Emacs -- you must follow the command with the "go" to get them to execute, and you may not get a prompt. Are you able to type sql commands directly in the *SQL* buffer and have them return results? Are you including the trailing "go" in the region sent? If you are getting the "Sent string to buffer *SQL*" message, then Emacs thinks the interpreter is live and has sent the string. The next step in the code is to either pop or display the buffer. Do you have any settings in your .emacs that might impact where a buffer is displayed (pop-up-frames, display-buffer- reuse-frames, special-display-buffer-names, special-display-regexps, same- window-buffer-names, or same-window-regexps)? I can speak to the fact that Emacs can be used very effectively as a replacement for Query Analyzer. I used Emacs as a front-end for MS and Oracle in parallel for over a year. I'd usually have interactive sessions on both databases active at the same time. More questions: what version of Emacs and sql-mode are you using? What's the value of sql-ms-program?