Subject Re: [firebird-support] TIME datatype
Author Martijn Tonies
>>> Old InterBase versions used to convert datetime literals in a fairly
>>> unreliable manner. It got cleaned up at v.6 and you need to cast time
>>> literals in a lot of places where IB 5 and lower didn't require it.
>>
>>Now, that is strange. I have tried the following code in Firebird
>>2.1.1 on Linux and I get it to run successfully.
>>
>>---------------------------------- begin code
>>---------------------------------------------------
>>CREATE or alter PROCEDURE TP returns (Endtime TIME)
>>
>>AS
>>
>>DECLARE VARIABLE Starttime TIME;
>>
>>begin
>>
>>StartTime = '08:00';
>>
>>EndTime = StartTime;
>>suspend;
>>end
>>---------------------------------- end code
>>-------------------------------------------
>>
>>Is this supposed to be a bug?
>
> Not if it works. ;-)
>
>>Shouldn't I have to cast the string to a time just as you described?
>
> If you got it to work with an assignment, then apparently not.
>
> Note, not all contexts of date literals usage require the cast. Pre-IB 6,
> it was allowed in any context where a Dialect 1 DATE was being passed as a
> constant value. Post IB 6, with Dialect 3 databases, some do, some don't.
> The trick is to know which contexts need the cast and which don't...and
> then another version comes out and the rules change again.
>
> So, IMO, it's wise to do the cast in all contexts but particularly in a
> situation where not casting causes an exception.

Doesn't only converting the datatype require a cast? And a string literal
according to the SQL standards?

So assigning a TIME to another shouldn't require one?

With regards,

Martijn Tonies
Upscene Productions
http://www.upscene.com

Download Database Workbench for Oracle, MS SQL Server, Sybase SQL
Anywhere, MySQL, InterBase, NexusDB and Firebird!

Database questions? Check the forum:
http://www.databasedevelopmentforum.com