Re: [firebird-support] Working with SQL (might be using loop)

2018-10-04 Thread blackfalconsoftw...@outlook.com [firebird-support]
These type of string operations are better done at the client side in C#, 
VB.NET, Java, or any other high level language.  Using any variant of SQL to do 
such tasks would be quite onerous.
 

 However, if this is a homework assignment and you need some assistance, please 
let me know and I would be glad to write up some tips on what SQL operations 
should be considered.
 

 Steve Naidamast
 Sr. Software Engineer



Re: [firebird-support] Working with SQL (might be using loop)

2018-10-04 Thread Tomasz Tyrakowski t.tyrakow...@sol-system.pl [firebird-support]
On 04.10.2018 at 10:34, Vishal Tiwari vishuals...@yahoo.co.in 
[firebird-support] wrote:
> Hi,
> 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

Don't take offense, but it looks to me like an academic homework rather 
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 ==--__
__--==--__