🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: borland.public.intrabuilder.data.sql
2 messages
2 total messages Started by Werner Renhardt Mon, 27 Jul 1998 00:00
Concatenation of strings and numerical-values in SQL
#78
Author: Werner Renhardt
Date: Mon, 27 Jul 1998 00:00
18 lines
1286 bytes
Concatenation of strings and numerical-values in SQL:

I have a table  e.g. (a Paradox-Table named "Table.db") with the columns:
  TabID    (Integer - long)
  TabName  (alphanumeric)

I want to generate a Query which concatenates 'TabID' and 'TabName'.
(  SELECT TabID, (TabID || TabName) As TabIDName FROM "Table.db"
   <- but this works only when TabID is already a String-value;
      Auto-Conversion of numerical values to strings does not work. )

My Problem:
 How can I cast the numerical value 'TabID' to a String-value?
 I've found no function (e.g. Str(<Number>))
 I've found no operator (e.g. &  (Ampersand) in ACCESS which implicit
                         casts numerical values to Strings)
 There is no hint in the 'Localsql.hlp' of BDE
 and the IntraBuilder-Helpfile
Re: Concatenation of strings and numerical-values in SQL
#79
Author: Ken Mayer [TeamB]
Date: Tue, 28 Jul 1998 00:00
41 lines
1950 bytes
"Werner Renhardt" <werner@kangaroo.nwy.at> wrote:

>Concatenation of strings and numerical-values in SQL:

Can't do it. SQL doesn't allow it.

>      Auto-Conversion of numerical values to strings does not work. )

It does this in IntraBuilder only when using IntraBuilder specific
commands.

> How can I cast the numerical value 'TabID' to a String-value?
> I've found no function (e.g. Str(<Number>))
> I've found no operator (e.g. &  (Ampersand) in ACCESS which implicit
>                         casts numerical values to Strings)
> There is no hint in the 'Localsql.hlp' of BDE
> and the IntraBuilder-Helpfile

Rather than using SQL to do this, try creating a calculated field in
the rowset using a query object:
// note that the following is untested and taken from somewhere else:
q = new query();
q.sql = "select * from mytable";
f = new Field();
f.fieldName = "My Calculated Field";
// note: this will fire for each row ...
// "this" refers to the field, "parent" is the fields
// array ... (substitute 'field1' with the name of the
// field, and of course, you would want to set your
// calculation for what you need
f.beforeGetValue = {|| this.parent["numfield"].value +
  this.parent["charfield"].value };
q.rowset.fields.add( f );
q.active = true;

Ken
---
Ken Mayer [TeamB]
Golden Stag Productions
http://www.mindspring.com/~hirschv/homepage.htm
http://www.mindspring.com/~hirschv/dbase/dbase.htm
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads