Hi Michael
>> The issue is that trailing whitespace has been truncated
>> from the last output.
>> When the same SQL is run using isql, the output is as expected.
>> So, this appears to be an issue either with DBI or with DBD::Sybase.
> This isn't DBI, and it isn't DBD::Sybase. The last query probably
> creates a work table, where "foo " is treated as a varchar, which causes
> the trailing whitespace to be removed. You could check this assumption
> by turning on showplan.
Thanks for the suggestion. It sounds spot on in that, to quote from the
documentation:
"Data in variable-length columns is stripped of trailing blanks...
Data in variable-length variables and parameters retains all trailing
blanks, but is not padded to the defined length. Character literals
are treated as variable-length datatypes."
The third SQL statement certainly does create a work table to do the sort.
I can even see how that maps onto the above documentation: it would
appear that character literals are treated like variables, but for the
creation of an intermediate work table.
In real life, I was actually selecting the text of stored procedures
from syscomments. I cannot quite see how this matches the documentation,
but do not think this is very important.
My confusion arises from the fact that the same SQL statement,
when run via isql, does not remove the trailing whitespace:
SQL
======================================
select "*" + "foo " + "*" from master..sysengines
select "*" + "foo " + "*" order by 1
select "*" + "foo " + "*" from master..sysengines order by 1
go
======================================
OUTPUT
======================================
------
*foo *
(1 row affected)
------
*foo *
(1 row affected)
------
*foo *
(1 row affected)
======================================
Can you give any guidance about this discrepancy?
NB You have led me to a fix for my problem anyway :-)
I now select text from syscomments
where id = {n}
order by {all columns of index}
to avoid a work table.
Best wishes
Kevin
+ANYTHING+BELOW+WAS+ADDED+AFTER+I+HIT+SEND+
Visit our website at http://www.ubswarburg.com
This message contains confidential information and is intended only
for the individual named. If you are not the named addressee you
should not disseminate, distribute or copy this e-mail. Please
notify the sender immediately by e-mail if you have received this
e-mail by mistake and delete this e-mail from your system.
E-mail transmission cannot be guaranteed to be secure or error-free
as information could be intercepted, corrupted, lost, destroyed,
arrive late or incomplete, or contain viruses. The sender therefore
does not accept liability for any errors or omissions in the contents
of this message which arise as a result of e-mail transmission. If
verification is required please request a hard-copy version. This
message is provided for informational purposes and should not be
construed as a solicitation or offer to buy or sell any securities or
related financial instruments.