Let's look at how the XBase database(s) work internally to store data first.

In a given XBase database, each database table is stored in a file of the corresponding name. For example, the table USER whould have been stored as USER.dbf.

When you construct an SQL to query data inside USER, you would do something like this:
$dbname = "USER"; $sql = "select USERNAME from $dbname";
And this should work fine.

Now what happens if you have spaces in the filenames, say, "User Names Database.dbf" on windows, which is valid, the SQL query becomes:
$dbname = "User Names Database"; $sql = "select USERNAME from $dbname";
And of cause it will not work, because the SQL string becomes
select USERNAME from User Names Database
which is an invalid SQL statement.

I haven't tried this, but to resolve the long name issue on Windows boxes, you could patch the database names by adding single quotes around it:
$dbname = "User Names Database"; $tblname = "'" . $dbname . "'"; # or $tblname = '"' . $dbname . '"'; $sql = "select USERNAME from $tblname";
And this should work because the new SQL string becomes
select USERNAME from 'User Names Database'
I think this might resolve the long filename issue on Windows machines.

Update: Ok, I tried my solution, but it didn't work on my Sybase database. It's more of a database implementation issue. **blush**

Try it anyway to see if it works or not. Otherwise the quick solution is to change spaces in the filenames to underscores.


In reply to Re: Long file names in .dbf databases by Roger
in thread Long file names in .dbf databases by talwyn

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.