function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
NicolaiPNicolaiP 

SOQL behaves really strange!

Hi,

 

I have an odd problem with a SELECT string, trying to get data from Salesforce.

 

If I use "SELECT Unit_Price__c FROM Equipment_Data__c", it perfectly returns the Unit_Price__c

 

If I use "SELECT Deal_Type__c  FROM Equipment_Data__c", it perfect returns the Deal_Type__c

 

But if I use "SELECT Unit_Price__c, Deal_Type__c FROM Equipment_Data__c", it only receives the Deal_Type__c correct, but return a "null" value for Unit_Price__c

 

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

 

What is wrong?

 

Any help really appreciated.

 

Best regards,

Nicolai 

 

 

Best Answer chosen by Admin (Salesforce Developers) 
npaustiannpaustian

Hi again,

 

I found out that it was an error ind the wdsl file. So now the problem is solved! :)

 

Thanks everybody

 

Best regards,

Nicolai

All Answers

Jia HuJia Hu
check the record returned from
SELECT Unit_Price__c, Deal_Type__c FROM Equipment_Data__c
does have Deal_Type__c value

I mean some records may have Unit_Price__c only or both,
some records may have Deal_Type__c only or both,
and some records may have Unit_Price__c only, but not have Deal_Type__c
NicolaiPNicolaiP

All records has both values. I tested the exact same SOQL SELECT in Force.com Explorer, and here it perfectly returns all the records and all of them have a value in both fields...?

SuperfellSuperfell

post your code.

npaustiannpaustian

Here you go: :)

 

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

 

npaustiannpaustian

Hi again,

 

I found out that it was an error ind the wdsl file. So now the problem is solved! :)

 

Thanks everybody

 

Best regards,

Nicolai

This was selected as the best answer
OstermanGOstermanG

I'm having a similar problem. What was the issue with the WSDL file?

 

Thanks,

 

-Greg