If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > Informix > Informix 4GL SQL question

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 07-21-11, 09:09
HDNightster HDNightster is offline
Registered User
 
Join Date: Mar 2011
Posts: 3
Informix 4GL SQL question

Hello, I am trying to concatenate 2 SQL fields in Informix 4GL.

This SQL works fine in DBACCESS, however in 4GL it does not like the “||” symbol.

Code:
Select
   c_busname,
   c_last || ‘, ‘ || c_first
from
   cust
where 
   c_customer = customer_id
I tried “+”, but that does not work as well. I need to concatenate the first and last names for customers into one field on a screen. Thank you for any help you can provide.

David
Reply With Quote
  #2 (permalink)  
Old 07-21-11, 18:09
Luis Santos Luis Santos is offline
Registered User
 
Join Date: Jun 2009
Location: Lisboa, Portugal
Posts: 51
Wink

Hi,

You can΄t do like that if you are doing it in a 4GL program, you must do the select in a indirect form like this:

Code:
define   alfa     char(100),
         a_bustname   like cust.c_bustname,
         a_last           like cust.c_last,
         a_first          like cust.c_first,
         alfa_concat    char(???)   # ??? you must see if you can put in a fixed 
                                            #dimention

# i presume that custumer_id is another number variable, if not then you must quote like "\"" before and after... 

let alfa = "select c_busname, c_last, c_first from cust 
    where c_customer = ", customer_id

prepare alfa_exec from alfa

declare alfa_cursor cursor for alfa_exec

foreach alfa_cursor into a_bustname, a_last, a_first

   let alfa_concat = a_last, a_first

   {
    now you have in alfa_cancat the concatenation of the two data from
    the a_last and a_first, where you can use for what you want to do with
    it...
   } 

end foreach
I hope it would help you...
__________________
LS

Last edited by Luis Santos; 07-21-11 at 18:17.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On