Subject Re: [firebird-support] Re: update statement Excel Sheet
Author Thomas Steinmaurer
Hello,

> I dont know whats wrong, Thats why I asking, its simple and should work easly.
>
> I tried to use IBexpert V2.5.0.49 and RazorSQL V5.6.3 to excute the command and still getting the same error msg. also I copied the sql you just sent to me as it is and still giving the same error msg
> when is invalid.
>
> my firebird server is V1.0.3.973 maybe its old thats why ?

Yes. The CASE construct has been added in V1.5.

Regards,
Thomas

> Regards.
>
> Ahmad sarhan
>
>
> --- In firebird-support@yahoogroups.com, Alan J Davies<Alan.Davies@...> wrote:
>>
>> Hi mahdoom_a, I've just created this table MNGRNT (like yours)
>>
>> RFRNC AQNO
>> 50001
>> 50002
>> 50003
>>
>> I then ran this code:
>> update mngrnt
>> set rfrnc=
>> case
>> when aqno = 50001 then '155'
>> when aqno = 50002 then '166'
>> when aqno = 50003 then '1331'
>> end
>>
>> This is the message - successful update
>> Plan
>> PLAN (MNGRNT NATURAL)
>>
>> 3 record(s) was(were) updated in MNGRNT
>>
>> This is the table after update
>> RFRNC AQNO
>> 155 50001
>> 166 50002
>> 1331 50003
>>
>> You must be doing something that you're not telling us because this
>> "just works" and is as simple as it gets really.
>>
>> What else are you trying to do?
>> Regards
>> Alan
>>
>> Alan J Davies
>> Aldis
>>
>> On 02/07/2012 16:23, mahdoom_a wrote:
>>> aqno is intger
>>> rfrnc is varchar
>>>
>>> I tried another format of case statement
>>> like:
>>>
>>> update mngrnt set rfrnc = case aqno
>>> when 50001 then '155'
>>> when 50002 then '166'
>>>
>>> end
>>>
>>> I got same SQL error but unknown token is aqno
>>>
>>> Regards.
>>>
>>> --- In firebird-support@yahoogroups.com
>>> <mailto:firebird-support%40yahoogroups.com>, Alan J Davies
>>> <Alan.Davies@> wrote:
>>> >
>>> > What is aqno? An integer or character field?
>>> > If its an integer try without ' '
>>> > Is it in the same table as rfrnc?
>>> > Otherwise there is nothing wrong with the code.
>>> > Alan
>>> >
>>> > Alan J Davies
>>> > Aldis
>>> >
>>> >
>>> >
>>> > On 02/07/2012 07:40, mahdoom_a wrote:
>>> > > Great Alan,
>>> > >
>>> > > I tried this
>>> > >
>>> > > update mngrnt
>>> > > set rfrnc=
>>> > > case
>>> > > when aqno = '50001' then 155
>>> > > when aqno = '50002' then 166
>>> > > when aqno = '50003' then 1331
>>> > > end
>>> > >
>>> > > I got SQL error
>>> > >
>>> > > Invalid token.
>>> > > Dynamic SQL Error.
>>> > > SQL error code = -104.
>>> > > Token unknown - line 4, char 1.
>>> > > when.
>>> > >
>>> > > 'when' is identified(in bold black)but I don't know why its invalid.
>>> > >
>>> > > Best Regards
>>> > >
>>> > > Ahmad Sarhan
>>> > >
>>> > >
>>> > > --- In firebird-support@yahoogroups.com
>>> <mailto:firebird-support%40yahoogroups.com>
>>> > > <mailto:firebird-support%40yahoogroups.com>, Alan J Davies
>>> > > <Alan.Davies@> wrote:
>>> > > >
>>> > > > update T1
>>> > > > set Col1 =
>>> > > > case
>>> > > > when Col2 = No1
>>> > > > then Val1
>>> > > > when Col2 = No2
>>> > > > then Val2
>>> > > > when Col2 = No3
>>> > > > then Val3
>>> > > > end
>>> > > >
>>> > > >
>>> > > > Alan J Davies
>>> > > > Aldis
>>> > > >
>>> > > >
>>> > > >
>>> > > > On 01/07/2012 17:53, Hans wrote:
>>> > > > > Using the SQL CASE in your update statement may work.
>>> > > > >
>>> > > > > Best Regards
>>> > > > > Hans
>>> > > > >
>>> > > > > Sent from my iWatuski
>>> > > > >
>>> > > > > On 2012-07-01, at 9:17 AM, "Ahmad F. Sarhan"<mahdoom_a@
>>> > > > > <mailto:mahdoom_a%40yahoo.com>> wrote:
>>> > > > >
>>> > > > > Hey everyone,
>>> > > > > I need your help in one of 2 questions please,
>>> > > > >
>>> > > > > 1st.
>>> > > > >
>>> > > > > i need to update my table with multi values , each value has
>>> its own
>>> > > > > condition
>>> > > > > I mean
>>> > > > > update T1
>>> > > > > set Col1 = Val1 where Col2 = No1
>>> > > > > set Col1 = Val2 where Col2 = No2
>>> > > > > set Col1 = Val3 where Col2 = No3
>>> > > > > .
>>> > > > > .
>>> > > > > .
>>> > > > > Set Col1 = Val 600 where Col2 = No600
>>> > > > >
>>> > > > > and so on. I tried the simple lines as I wrote above but its not
>>> > > working.
>>> > > > >
>>> > > > > 2nd.
>>> > > > >
>>> > > > > I want to update my Table from excel sheet how can firebird
>>> read from
>>> > > > > excel sheet.
>>> > > > >
>>> > > > > Thanks
>>> > > > >
>>> > > > > ~{ Ahmad F. Sarhan }~
>>> > > > >
>>> > > > > [Non-text portions of this message have been removed]
>>> > > > >
>>> > > > > ------------------------------------
>>> > > > >
>>> > > > > ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
>>> > > > >
>>> > > > > Visit http://www.firebirdsql.org and click the Resources item
>>> > > > > on the main (top) menu. Try Knowledgebase and FAQ links !
>>> > > > >
>>> > > > > Also search the knowledgebases at http://www.ibphoenix.com
>>> > > > >
>>> > > > > ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
>>> > > > > Yahoo! Groups Links
>>> > > > >
>>> > > > >
>>> > > >
>>> > >
>>> > >
>>> >
>>>
>>>
>>
>
>
>
>
> ------------------------------------
>
> ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
>
> Visit http://www.firebirdsql.org and click the Resources item
> on the main (top) menu. Try Knowledgebase and FAQ links !
>
> Also search the knowledgebases at http://www.ibphoenix.com
>
> ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
> Yahoo! Groups Links
>
>
>