• Index
  •  » Talend Open Studio for Data Integration » Usage, Operation
  •  » Salesforce SOQL not returning correct value

#1 2012-07-04 15:18:28

npaustian
New member
Registered: 2012-07-04
Posts: 5

Salesforce SOQL not returning correct value

Tags: [Salesforce, SOQL]

Hi,

Can anyone explain me why this select:

"SELECT Id, Unit_Price__c, CreatedById, CreatedDate, Deal_Type__c FROM Equipment_Data__c"

Returns a null value "Unit_Price__c" while

"SELECT Id, Unit_Price__c, CreatedById, CreatedDate FROM Equipment_Data__c"

Returns a correct value...

I'm really puzzled with this!? So any help is appriciated.. smile

Thanks in advance.

Offline

#2 2012-07-04 15:57:31

npaustian
New member
Registered: 2012-07-04
Posts: 5

Re: Salesforce SOQL not returning correct value

Just to clarify further, this is SOQL Select from SalesForce.com...

If I do:
"SELECT Unit_Price__c, Deal_Type__c FROM Equipment_Data__c", I will get the correct Deal_Type__c, but no value for Unit_Price.

If I do:
"SELECT Unit_Price__c FROM Equipment_Data__c", I will get the correct Unit_Price__c

Unit_Price__c is a "Number(16,2)" field and Deal_Type__c is a "Picklist" field....

Any ideas?

Offline

#3 2012-07-05 20:13:41

elcalvomike
Member
Registered: 1970-01-01
Posts: 37

Re: Salesforce SOQL not returning correct value

you have to change your query to get the value of the picklist for SOQL. use

SELECT Unit_Price__c,  toLabel(Deal_Type__c) FROM Equipment_Data__c

Offline

#4 2012-07-06 08:36:18

npaustian
New member
Registered: 2012-07-04
Posts: 5

Re: Salesforce SOQL not returning correct value

It unfortunately doesn't work. For info I that both of the below return correct values:

"SELECT Deal_Type__c FROM Equipment_Data__c" (without toLabel) and the
"SELECT Unit_Price__c FROM Equipment_Data__c"

But when I combine them as:

"SELECT Unit_Price__c, Deal_Type__c FROM Equipment_Data__c" or even "SELECT Unit_Price__c, toLabel(Deal_Type__c) FROM Equipment_Data__c" I only get the Deal_Type__c value - not the Unit_Price__c

Offline

#5 2012-07-09 10:24:43

npaustian
New member
Registered: 2012-07-04
Posts: 5

Re: Salesforce SOQL not returning correct value

This is my code, if it help anyone to help me smile

Code:

Private Sub btnRtvOutlook_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnRtvOutlook.Click

        ' *** Delete all records in databse, which has been uploaded today
        Dim myConnection As New System.Data.SqlClient.SqlConnection(myConnString)
        Dim myQuery As String = "DELETE FROM tblXIST_ESR_OPP WHERE DATEDIFF(day, UPLOAD_TIME, GETDATE()) = 0"
        Dim myCommand As New System.Data.SqlClient.SqlCommand(myQuery, myConnection)

        myCommand.Connection = myConnection

        myCommand.Connection.Open()
        myCommand.ExecuteScalar()
        myCommand.Parameters.Clear()
        myCommand.Connection.Close()
        myConnection.Close()

        ' *** INSERT TODAYS OUTLOOK INFORMATION INTO THE DATABASE
        Dim qs As String

        'This one works perfectly at returns the Unit_Revenue__c result being "26000"
        'qs = "SELECT Id, Unit_Revenue__c FROM Equipment_Data__c"

        'This one also works and returns the deal type perfectly being "Cash"
        'qs = "SELECT Id, Deal_Type__c FROM Equipment_Data__c"

        'This one also works, and return both field being "26000 - Cash" 
        'qs = "SELECT Id, Unit_Revenue__c, Deal_Type__c FROM Equipment_Data__c"

        'This one doesn't work, it only returns "- - 14-06-2012 11:09:59"
        qs = "SELECT Id, Unit_Revenue__c, Deal_Type__c, CreatedDate FROM Equipment_Data__c"

        Dim qr As apex.QueryResult = binding.query(qs)

        If (qr.size = 0) Then

        Else
            For i As Integer = 1 To qr.records.GetUpperBound(0)
                Dim equipment As apex.Equipment_Data__c = CType(qr.records(i), apex.Equipment_Data__c)
        
        '*** HERE I NORMALLY HAVE A FUNCTION THAT RETURNS THE VALUES INTO A SQL DATABASE, BUT
        '*** I HAVE CUT IT OUT TO REDUCE PLACES OF ERRORS AND ARE ONLY RETURNING VALUES IN MSGBOX

                MsgBox(equipment.Unit_Revenue__c & " - " & equipment.Deal_Type__c & " - " & equipment.CreatedDate)


            Next
        End If

End Sub

Offline

  • Index
  •  » Talend Open Studio for Data Integration » Usage, Operation
  •  » Salesforce SOQL not returning correct value

Board footer

Powered by FluxBB