emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[O] [babel] Verbatim output from SQL command


From: Sebastien Vauban
Subject: [O] [babel] Verbatim output from SQL command
Date: Tue, 18 Oct 2011 15:20:29 +0200
User-agent: Gnus/5.110018 (No Gnus v0.18) Emacs/23.3 (windows-nt)

#+BABEL:   :engine msosql :cmdline -S <SERVER> -U <USER> -P <PASS> -d 
<DATABASE> -n -w 700

* Show code of stored procedure

Despite telling Babel that I'd like to see the output as it is, it displays it
in a 4-column table.

See http://i.imgur.com/neDO3.png for the original layout in SQL Query Analyser
(1 column, 34 lines).

Babel seems to interpret every *leading space* as *one empty column*. Normal,
feature, bug?

Is there some workaround to this?  I thought stating "scalar" would really
completely override any interpretation...

** Code

This is an example of code run against a Microsoft SQL server.

#+begin_src sql :eval yes :results output scalar
EXEC sp_helptext 'dt_setpropertybyid'
#+end_src

#+results:
| Text                                    |                                     
                                    |                                           
                                                  |                             
               |
|-----------------------------------------+-------------------------------------------------------------------------+---------------------------------------------------------------------------------------------+--------------------------------------------|
| /*                                      |                                     
                                    |                                           
                                                  |                             
               |
|                                         |                                     
                                    |                                           
                                                  |                             
               |
| **                                      | If the property already exists, 
reset the value; otherwise add property |                                       
                                                      |                         
                   |
|                                         |                                     
                                    |                                           
                                                  |                             
               |
| **                                      |                                     
                                    | id -- the id in sysobjects of the object  
                                                  |                             
               |
|                                         |                                     
                                    |                                           
                                                  |                             
               |
| **                                      |                                     
                                    | property -- the name of the property      
                                                  |                             
               |
|                                         |                                     
                                    |                                           
                                                  |                             
               |
| **                                      |                                     
                                    | value -- the text value of the property   
                                                  |                             
               |
|                                         |                                     
                                    |                                           
                                                  |                             
               |
| **                                      |                                     
                                    | lvalue -- the binary value of the 
property (image)                                          |                     
                       |
|                                         |                                     
                                    |                                           
                                                  |                             
               |
| */                                      |                                     
                                    |                                           
                                                  |                             
               |
|                                         |                                     
                                    |                                           
                                                  |                             
               |
| create procedure dbo.dt_setpropertybyid |                                     
                                    |                                           
                                                  |                             
               |
|                                         |                                     
                                    |                                           
                                                  |                             
               |
|                                         | @id int,                            
                                    |                                           
                                                  |                             
               |
|                                         |                                     
                                    |                                           
                                                  |                             
               |
|                                         | @property varchar(64),              
                                    |                                           
                                                  |                             
               |
|                                         |                                     
                                    |                                           
                                                  |                             
               |
|                                         | @value varchar(255),                
                                    |                                           
                                                  |                             
               |
|                                         |                                     
                                    |                                           
                                                  |                             
               |
|                                         | @lvalue image                       
                                    |                                           
                                                  |                             
               |
|                                         |                                     
                                    |                                           
                                                  |                             
               |
| as                                      |                                     
                                    |                                           
                                                  |                             
               |
|                                         |                                     
                                    |                                           
                                                  |                             
               |
|                                         | set nocount on                      
                                    |                                           
                                                  |                             
               |
|                                         |                                     
                                    |                                           
                                                  |                             
               |
|                                         | declare @uvalue nvarchar(255)       
                                    |                                           
                                                  |                             
               |
|                                         |                                     
                                    |                                           
                                                  |                             
               |
|                                         | set @uvalue = 
convert(nvarchar(255), @value)                            |                     
                                                                        |       
                                     |
|                                         |                                     
                                    |                                           
                                                  |                             
               |
|                                         | if exists (select * from 
dbo.dtproperties                               |                                
                                                             |                  
                          |
|                                         |                                     
                                    |                                           
                                                  |                             
               |
|                                         |                                     
                                    |                                           
                                                  | where address@hidden and 
address@hidden) |
|                                         |                                     
                                    |                                           
                                                  |                             
               |
|                                         | begin                               
                                    |                                           
                                                  |                             
               |
|                                         |                                     
                                    |                                           
                                                  |                             
               |
|                                         |                                     
                                    | --                                        
                                                  |                             
               |
|                                         |                                     
                                    |                                           
                                                  |                             
               |
|                                         |                                     
                                    | -- bump the version count for this row as 
we update it                                      |                             
               |
|                                         |                                     
                                    |                                           
                                                  |                             
               |
|                                         |                                     
                                    | --                                        
                                                  |                             
               |
|                                         |                                     
                                    |                                           
                                                  |                             
               |
|                                         |                                     
                                    | update dbo.dtproperties set 
address@hidden, address@hidden, address@hidden, version=version+1 |             
                               |
|                                         |                                     
                                    |                                           
                                                  |                             
               |
|                                         |                                     
                                    |                                           
                                                  | where address@hidden and 
address@hidden  |
|                                         |                                     
                                    |                                           
                                                  |                             
               |
|                                         | end                                 
                                    |                                           
                                                  |                             
               |
|                                         |                                     
                                    |                                           
                                                  |                             
               |
|                                         | else                                
                                    |                                           
                                                  |                             
               |
...

Best regards,
  Seb

-- 
Sebastien Vauban




reply via email to

[Prev in Thread] Current Thread [Next in Thread]