Board index » delphi » SQL help : SUBSTRING

SQL help : SUBSTRING

Help me Please ...

    I use Delphi's SQL to operate on dBASE , but when I use
Local SQL Reversed word SUBSTRING, I find a problem:

 SELECT
     SUBSTRING(CNAME FROM 10 FOR 4) AS NNAME
 FROM
    .....

    When it's finished, I find the field-length of NNAME is not 4, but
the same length of old fileld CNAME. I don't how can I get a field
which length is only 4.

    Anyhelp? Thanks

 

Re:SQL help : SUBSTRING


Hi,

to limit length of result of  

 SELECT
     SUBSTRING(CNAME FROM 10 FOR 4) AS NNAME
 FROM
     .....
 try CAST

 SELECT
     CAST(SUBSTRING(CNAME FROM 10 FOR 4 ) AS CHAR(4)) AS NNAME
 FROM
    .....

Peter Michael Franta
pfra...@world.net
Relate Systems Consultants P/L

Re:SQL help : SUBSTRING


On Mon, 20 Oct 1997 11:43:35 +0200, Jeff Ding

Quote
<DingJianF...@Sbell.com.cn> wrote:
>Help me Please ...

>    I use Delphi's SQL to operate on dBASE , but when I use
>Local SQL Reversed word SUBSTRING, I find a problem:

> SELECT
>     SUBSTRING(CNAME FROM 10 FOR 4) AS NNAME
> FROM
>    .....

>    When it's finished, I find the field-length of NNAME is not 4, but
>the same length of old fileld CNAME. I don't how can I get a field
>which length is only 4.

Use:
CAST( SUBSTRING(CNAME FROM 10 FOR 4) AS CHAR(4)) AS NNAME

Marek Prokop
Marek Prokop
proko...@czn.cz

Other Threads