Welcome to the nuBuilder Forums!

Register and log in to access exclusive forums and content available only to registered users.

Concatenation of field and string data

Questions related to nuBuilder Forte Reports and the Report Builder.
treed
Posts: 205
Joined: Mon May 18, 2020 12:02 am
Been thanked: 2 times
Contact:

Concatenation of field and string data

Unread post by treed »

Hello all, yes this has been a busy day and I'm getting more productive with nuBuilder I have so many questions. Can the report builder concatenate a string with field data??? Something like this: myfield +' My String'
kev1n
nuBuilder Team
Posts: 4416
Joined: Sun Oct 14, 2018 6:43 pm
Has thanked: 74 times
Been thanked: 472 times
Contact:

Re: Concatenation of field and string data

Unread post by kev1n »

Concat in SQL already with the CONCAT function.
treed
Posts: 205
Joined: Mon May 18, 2020 12:02 am
Been thanked: 2 times
Contact:

Re: Concatenation of field and string data

Unread post by treed »

Added this to my report sql and then the report would not open (reported as missing page). Removed it and report opens fine.
CONCAT(OrdBillToCity,", ",OrdBillToState," ",OrdBillToZip) AS BillCSZ,
CONCAT(OrdShipToCity, ", ",OrdShipToState," ",OrdShipToZip) AS ShipCSZ

When I run the whole sql statement for the report in PHPMyAdmin it runs fine.
SELECT
Orders.*,
OrdLine.*,
CONCAT(OrdBillToCity,", ",OrdBillToState," ",OrdBillToZip) AS BillCSZ,
CONCAT(OrdShipToCity, ", ",OrdShipToState," ",OrdShipToZip) AS ShipCSZ

FROM
Orders
JOIN OrdLine ON Orders.OrdID = OrdLine.OrdLineOrdID

Any idea what might be going on here?
Janusz
nuBuilder Team
Posts: 508
Joined: Fri Dec 28, 2018 1:41 pm
Location: Krakow, Poland
Has thanked: 10 times
Been thanked: 18 times

Re: Concatenation of field and string data

Unread post by Janusz »

maybe try:
SELECT * FROM ( your code ) t


SELECT * FROM
(SELECT
Orders.*,
OrdLine.*,
CONCAT(OrdBillToCity,", ",OrdBillToState," ",OrdBillToZip) AS BillCSZ,
CONCAT(OrdShipToCity, ", ",OrdShipToState," ",OrdShipToZip) AS ShipCSZ

FROM
Orders
JOIN OrdLine ON Orders.OrdID = OrdLine.OrdLineOrdID) t
If you like nuBuilder, please leave a review on SourceForge
treed
Posts: 205
Joined: Mon May 18, 2020 12:02 am
Been thanked: 2 times
Contact:

Re: Concatenation of field and string data

Unread post by treed »

Same results. Tried simplifying it to simply adding a CONCAT(" ") and still have the same results. And ... then just tried it with single quotes and IT WORKS!
treed
Posts: 205
Joined: Mon May 18, 2020 12:02 am
Been thanked: 2 times
Contact:

Re: Concatenation of field and string data

Unread post by treed »

So I think that implies that "problem" is somewhere in the nuBuilder parser where it turns the sql string into JSON. It's rather frustrating to have SQL that works in one place and not another not be able to tell why.
apmuthu
Posts: 249
Joined: Sun Dec 06, 2020 6:50 am
Location: Chennai, India, Singapore

Re: Concatenation of field and string data

Unread post by apmuthu »

If you must use double quotes, try escaping it with a backslash.
yvesf
Posts: 337
Joined: Sun Mar 14, 2021 8:48 am
Location: Geneva
Has thanked: 92 times
Been thanked: 11 times

Re: Concatenation of field and string data

Unread post by yvesf »

Hello,

When I save the sql query, the clause CONCAT is removed. Why ?

Code: Select all

SELECT
 patient.*,
    rendezvous.*,
CONCAT(patient.pat_nom,' ',patient.pat_prenom) AS PatientRV

FROM
    patient
        JOIN rendezvous ON patient.patient_id = rendezvous.rv_patient_id

WHERE
    ((rendezvous_id ='#RECORD_ID#'))
The section CONCAT(patient.pat_nom,' ',patient.pat_prenom) AS PatientRV is removed when saving the sql query. .
Capture.PNG
You do not have the required permissions to view the files attached to this post.
kev1n
nuBuilder Team
Posts: 4416
Joined: Sun Oct 14, 2018 6:43 pm
Has thanked: 74 times
Been thanked: 472 times
Contact:

Re: Concatenation of field and string data

Unread post by kev1n »

Pick "Edit Manually" from the SQL dropdown.
Keith-i
Posts: 88
Joined: Wed Jan 18, 2023 3:03 pm
Has thanked: 1 time
Been thanked: 1 time

Re: Concatenation of field and string data

Unread post by Keith-i »

I'm also having some problems with CONCAT for a report. I'm getting an SQL syntax error message from nuDebug when I include the CONCAT line in the SQL and the generated report is empty. Any ideas as to where I'm going wrong would be appreciated.

Code: Select all

SELECT
 tblRoads.*,
    tblProperties.*,   
    tblInstructions.JobNo,
    tblInstructions.FlatNo,
    tblInstructions.Valuation

CONCAT_WS(' ',tblProperties.BuildingName,tblProperties.UnitNo,tblProperties.UnitName,tblProperties.HouseNo) AS PropAddress

FROM
    tblRoads
        JOIN tblProperties ON tblProperties.id_Roads = tblRoads.idRoads
        JOIN tblInstructions ON tblInstructions.id_Properties = tblProperties.idProperties

WHERE
    ((tblRoads.idRoads = '#idRoads#'))
I'm using CONCAT_WS as many of my fields have null entries.
Post Reply