[prev in list] [next in list] [prev in thread] [next in thread] 

List:       mdbtools-dev
Subject:    Re: [mdb-dev] Perl Answer and another Question about spaces in column names
From:       "Kyle R. Burton" <mortis () voicenet ! com>
Date:       2003-08-06 21:38:04
[Download RAW message or body]

> A few days back I posted to ask how you could use mdb-tools command line 
> utilities from within perl.  A few folks replied but I didn't really follow 
> alot of it, Im not that familar with perl or mdb-tools.  Just bang the 
> following snippit of code into your perl script:
> 
> 
> open AFILE, "|mdb-sql db1.mdb>fred.txt";
> 
> print AFILE <<"ENDOFQUERY" ;
> 
> list tables
> go
> quit
> 
> ENDOFQUERY
> 
> close(AFILE);
> 
> the lines btw print AFILE <<"ENDOFQUERY" ; and ENDOFQUERY are just as you would 
> enter them at the command line.  So I hope this helps someone in future.  I am 
> guessing these emails are stored somewhere online.
> 
> I do have another question.  I want to select all the contents of two columns 
> from a table.  But at the moment I can't select anything from the table because 
> the table name has an underscore in it!  Anybody know the correct way to format 
> such a query?

You can try enclosing it in single or double quotes:

  select 'col_1','col2' from table
  go

  select "col_1","col2' from table
  go

The patch that was sent in for sql/lexer.l fixes the underscore issue - it
makes more characters valid in table and column names, and in strings,
specifically the patch allows any alphanumerics and the underscore in
a bare (un-quoted) name, and additionaly allows spaces in a double quoted
string.  MS Access allows a surprising variety of characters in table
names, so these additions alone are not enough to cover all the 
possibilities.  I've seen table or column namess with the following
characters in them: ~@#$%&*()-_=+,<>/\{}

Hope this helps.

Kyle

  

-- 

------------------------------------------------------------------------------
Wisdom and Compassion are inseparable.
        -- Christmas Humphreys
mortis@voicenet.com                            http://www.voicenet.com/~mortis
------------------------------------------------------------------------------


-------------------------------------------------------
This SF.Net email sponsored by: Free pre-built ASP.NET sites including
Data Reports, E-commerce, Portals, and Forums are available now.
Download today and enter to win an XBOX or Visual Studio .NET.
http://aspnet.click-url.com/go/psa00100003ave/direct;at.aspnet_072303_01/01
_______________________________________________
mdbtools-dev mailing list
mdbtools-dev@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mdbtools-dev
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic