QoQ and leading space(s) suppression

Ask a Question related to Coldfusion Database Access, Design and Development.

  1. #1

    Default QoQ and leading space(s) suppression


    I am facing a peculiar problem with QoQ on CFMX 6.1

    My script performs the following:

    <cfquery name="Q1" datasource="DATASOURCE1">
    SELECT *
    FROM tblPAYMENTS
    </cfquery>

    Three rows are returned in the result set. One of the rows is as follows:

    FIELD_1 = 'A'
    FIELD_2 = ' 06 M3'

    If I do a CFDUMP of query Q1, FIELD_2 does contain string listed above,
    including the leading space
    Frustated Guest

  2. Similar Questions and Discussions

    1. multiline textfield 'leading space' bug *still* not fixed!
      I can't believe this bug is still in the flash player - it has been a known issue since flash player 5!! In case you haven't come across it, this...
    2. Error suppression
      Hi All, I know that I can prepend functions with an '@' character in order to get them to not output any errors, but I am wondering is there any...
    3. #25951 [Opn->Fbk]: Error suppression operator + reference return statement => corrupt func. params
      ID: 25951 Updated by: iliaa@php.net Reported By: dand at codemonkey dot ro -Status: Open +Status: ...
    4. #25951 [Opn]: Error suppression operator + reference return statement => corrupt func. params
      ID: 25951 User updated by: dand at codemonkey dot ro Reported By: dand at codemonkey dot ro Status: Open Bug Type: ...
    5. #25951 [NEW]: Error suppression operator + reference return statement => corrupt func. params
      From: dand at codemonkey dot ro Operating system: Debian Linux 3.0 PHP version: 4.3.3 PHP Bug Type: Unknown/Other Function...
  3. #2

    Default Re: QoQ and leading space(s) suppression

    Don't allow the leading spaces in the first place.
    Dan Bracuk Guest

  4. #3

    Default Re: QoQ and leading space(s) suppression

    Don,

    I do not own the data I am retrieving, and the spaces are part of the data
    structure, meaning they belong there.

    I was wondering why QoQ cannot preserve the original data.

    Thank you.

    -Mauricio

    Frustated Guest

  5. #4

    Default Re: QoQ and leading space(s) suppression

    Just replace spaces in the original select with something else so you can put
    the spaces back in when you're finished qith your QofQ.

    here's an example:

    <cfquery name="Q1" datasource="DATASOURCE1">
    SELECT FIELD_1, REPLACE(FIELD_2,' ','^^^') AS FIELD_2
    FROM tblPAYMENTS
    </cfquery>

    Your data will look like this:

    FIELD_1 = 'A'
    FIELD_2 = '^^^06^^^M3'

    Then run the QofQ:

    <cfquery name="Q2" dbtype="query">
    SELECT FIELD_2
    FROM Q1
    WHERE FIELD_1 = 'A'
    </cfquery>

    once the QofQ is run you can replace the '^^^' strings with spaces to get the
    original text:

    <cfoutput>
    #Replace(Q2.FIELD_2, '^^^', ' ', 'ALL')#
    </cfoutput>

    cheers.

    efecto747 Guest

  6. #5

    Default Re: QoQ and leading space(s) suppression

    > Next, I perform a QoQ like the following:
    >
    > <cfquery name="Q2" dbtype="query">
    > SELECT FIELD_2
    > FROM Q1
    > WHERE FIELD_1 = 'A'
    > </cfquery>
    >
    > Now, when I do a CFDUMP of Q2, FIELD_2 value is '06 M3' (The leading spaces
    > get suppressed or trimmed).
    >
    > How do I get around that problem?
    Other people seem to be offering suggestions as to how to work around this:
    good.

    Have you raised it as a bug in CF?

    --
    Adam
    Adam Cameron Guest

  7. #6

    Default Re: QoQ and leading space(s) suppression

    > Have you raised it as a bug in CF?

    Actually, I was being pre-emptive there.

    I cannot replicate what you say is happening on CFMX7.0. I'm using a
    MS-SQL Server DB, with this driver:
    "macromedia.jdbc.sqlserver.SQLServerDriver is 3.3".

    I have created this table:

    CREATE TABLE [Table1] (
    [id_col] [int] IDENTITY (1, 1) NOT NULL ,
    [space_col] [varchar] (50) NULL
    ) ON [PRIMARY]

    I have populated it thus:

    1 [no leading space]
    2 [ leading space]
    3 [trailing space ]
    4 [ both ]

    (I have put the square brackets in here simply to demonstrate where the
    spacing is: the square brackets are NOT in the actual data).

    I then run this process:
    <cfquery name="q3" datasource="junk">
    select *
    from Table1
    </cfquery>
    <cfquery name="q4" dbtype="query">
    select *
    from q3
    </cfquery>
    <hr />
    <cfoutput query="q3">
    [#id_col#][#space_col#]<br />
    </cfoutput>
    <hr />
    <cfoutput query="q4">
    [#id_col#][#space_col#]<br />
    </cfoutput>

    And the output - from both queries - includes all the spacing I would
    expect to see:

    [1][no leading space]
    [2][ leading space]
    [3][trailing space ]
    [4][ both ]
    [1][no leading space]
    [2][ leading space]
    [3][trailing space ]
    [4][ both ]

    What happens if you replicate the above situation? What DB / driver / CF
    version are you using?

    --
    Adam
    Adam Cameron Guest

  8. #7

    Default Re: QoQ and leading space(s) suppression

    Thank you, Adam.

    Code is attached:



    <cfquery name = "SALES" datasource="DATASOURCE">
    SELECT CHAR_CODE, CUST_ID
    FROM SALES
    WHERE CUST_ID = 1
    </cfquery>

    Result Set:

    ROW CHAR_CODE CUST_ID


    ---------- ------------------------------------------------ -------------
    000001 06 1
    000002 06 1


    <cfquery name = "qGetSales" dbtype="query">
    SELECT *
    FROM SALES
    WHERE CUST_ID = 1
    </cfquery>

    Result Set:

    ROW CHAR_CODE CUST_ID


    ---------- ------------------------------------------------ -------------
    000001 06 1
    000002 06 1

    Frustated Guest

Posting Permissions

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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139