Results 1 to 2 of 2
  1. #1
    Join Date
    Mar 2011
    Posts
    3

    Unanswered: 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

  2. #2
    Join Date
    Jun 2009
    Location
    Lisboa, Portugal
    Posts
    78

    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...
    Last edited by Luis Santos; 07-21-11 at 19:17.
    LS

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •