Subject | Re: [firebird-support] Working with SQL (might be using loop) |
---|---|
Author | Tomasz Tyrakowski |
Post date | 2018-10-04T09:34:12Z |
On 04.10.2018 at 10:34, Vishal Tiwari vishualsoft@...
[firebird-support] wrote:
than a real world problem (and shouldn't you do your homework by yourself?).
Can you give some justification for this kind of text transformation via
SQL?
1 and 3 can be done in a stored procedure or execute block statement,
where you have loops at your disposal and you can traverse a string
character by character, I can't think of a simple query doing that.
2 is an easy one, a simple iif and substring should suffice, e.g.:
select
iif(substring(AFIELD from 1 for 1) in ('0','1'), '-', '+') || AFIELD
from SOMETABLE
regards
Tomasz
--
__--==============================--__
__--== Tomasz Tyrakowski ==--__
__--== SOL-SYSTEM ==--__
__--== http://www.sol-system.pl ==--__
__--==============================--__
[firebird-support] wrote:
> Hi,Don't take offense, but it looks to me like an academic homework rather
> I am trying to get below stuff using SQL only.
> 1. If I have any statement like "World is good enough to enjoy..." then in I need to get SQL out put as"WorlD IS GooD EnougH TO EnjoY..." that is first and last character of each word should be capital letter and rest should be in small letters.
>
> 2. If I give any number like 007, 10002, 5645 then if the first digit of the integer value is 0 or 1 then a minus sign should be prefixed and if it is not 0 or 1 then it should prefix + sign. We can enter integer value in string format as well if needed. like -007, -10002, +5645...
> 3. Also, I need to make odd position character in capital letter in a given statement like "World is good enough to enjoy..." should be output as "WoRlD Is GoOd EnUuGh To EnJoY..."
> SQL for every above points could be sepearte.
>
> Thanks In Advance.
>
> With Best Regards.
> Vishal
than a real world problem (and shouldn't you do your homework by yourself?).
Can you give some justification for this kind of text transformation via
SQL?
1 and 3 can be done in a stored procedure or execute block statement,
where you have loops at your disposal and you can traverse a string
character by character, I can't think of a simple query doing that.
2 is an easy one, a simple iif and substring should suffice, e.g.:
select
iif(substring(AFIELD from 1 for 1) in ('0','1'), '-', '+') || AFIELD
from SOMETABLE
regards
Tomasz
--
__--==============================--__
__--== Tomasz Tyrakowski ==--__
__--== SOL-SYSTEM ==--__
__--== http://www.sol-system.pl ==--__
__--==============================--__