Questions tagged [database]

The tag has no usage guidance, but it has a tag wiki.

Filter by
Sorted by
Tagged with
1
vote
2answers
877 views

Converting Database.SaveResult error messages in more friendly feedback messages

I am implementing an interface from where you can update & insert records in SFDC, through a CSV file. After I process the files accordingly to my specifications, I want to perform an Update and ...
0
votes
0answers
30 views

Api Integration Issue

I have created an api integration in salesforce. From client's website a request will send to Salesforce in form of JSON. This will create record in Salesforce. Sometimes multiple requests are sent ...
3
votes
2answers
128 views

How to rollback DML after catching exception in unit test

I have a custom business logic that will block certain profiles from editing/creating/deleting an account. Because of other requirements, mainly around Record Types, I can't use profiles and ...
10
votes
1answer
168 views

SOQL: (WHERE x IN(a,b)) does return 2 records, but (WHERE x = a OR x = b) returns only 1 record… Why?

I'm trying to retrieve some ContentVersion records, but I'm having a lot of issues with it. After some research it seems as if the records are divided into two 'sets' as it were, and Salesforce in ...
1
vote
0answers
16 views

Heroku & Salesforce - Database question for multiple environments [closed]

Along with our production org, we have 3 full sync sandboxes, Mule APIs and Heroku. We are in the process of setting up an app, which is really just going to hold a postgreSQL database that is written ...
0
votes
1answer
42 views

Setting up MC with dedicated db

We have a new MC account we would like to start setting up. We have purchased a dedicated db sku for this account. Are there any implactions or things we should know while setting up this new MC ...
117
votes
2answers
6k views

Any reason to skip DML on empty lists?

In parts of my code I have DML statements with an if around to only do the DML if the list is not empty: if( !recordsToUpdate.isEmpty() ) { update recordsToUpdate; } Couldn't I just write? ...
8
votes
2answers
4k views

Can I tell how many records in a Database.QueryLocator()?

According to the documentation, in a batch a Database.QueryLocator can retrieve up to 50 million records. A maximum of 50 million records can be returned in the Database.QueryLocator object. If more ...
11
votes
4answers
10k views

Is manual Database.setSavepoint() and rollback needed on Trigger exception?

When something wents wrong in my synchronous trigger do I have to manually take care of this by before making a Database.setSavepoint() and rollback in the catch statement? Or is Salesforce.com ...
1
vote
2answers
2k views

Old style JOIN (ANSI JOINs) syntax is not allowed. Please use standard syntax

A client has asked me to write a rather complex SQL query to be used on Salesforce. When trying to implement the finished query on the Queries page I get the following error: Old style JOIN (ANSI ...
0
votes
0answers
15 views

Unable to get related data in apex when using dynamic SOQL [duplicate]

I have a requirement where I have to query certain fields dynamically based on a string that contains the fields. However, when trying to obtain the values, I get 'Invalid field' error. A simple ...
2
votes
1answer
25 views

What would be an ideal use case where you would use sObject.addError() over savepoints and rollbacks?

I came across two methods of preventing errors while inserting, updating or deleting the records in salesforce. Let's say I am performing any one DML operation, and I want the transaction to stop if ...
0
votes
2answers
27 views

Can two email messages be inserted at the same time with email to case?

I am setting up a trigger for when email messages are after inserted and we use email-to-case. Is there any way that the email-to-case inbound or normal sf outbound message system could result in two ...
1
vote
2answers
1k views

Salesforce DB connect with SQL Management Studio

I'm trying to connect SQL Server Management Studio to Salesforce so I can see tables and columns but unable to connect. Do I need any ADO.net connector or Salesforce plugin for this to work? Do I need ...
1
vote
0answers
38 views

Database.saveResult showing only one error at a time

I am trying to write an apexrest service that takes in fields for the Opportunity Object. There are certain restrict picklists on the Opportunity object that I've created. Additionally there are other ...
0
votes
0answers
45 views

Error saving data to an external object

When trying to save data in an external object the following error occurs: FATAL_ERROR|System.UnexpectedException: A callout was unsuccessful because of pending uncommitted work related to a process, ...
0
votes
1answer
27 views

Multiple contacts for a single person? [closed]

I'm integrating Salesforce with a system that will act as the source of employee records. In the source system, each employee human can be represented by multiple employee records - one per ...
3
votes
2answers
145 views

Deleting Big Object Workaround Without Using Database.deleteImmediate

Known Issue for not being able to deletg Big Objects with database.deleteImmediate still open. This is the only method mentioned in docs to do this. Workaround to delete 1 X 1 is a joke. Any other ...
2
votes
0answers
141 views

Reliable Salesforce JDBC to be used with DataGrip

Do you recommend any particular JDBC for Salesforce (can be paid) which is reliable enough to be used for commercial purposes along with DataGrip (or similar) software? I've been checking similar ...
0
votes
1answer
94 views

How to use insertAsync with processSave

I am trying to understand how insertAsync(sobjects, callback) works with processSave(saveResult) I went through the following two documentations, but couldn't find an example anywhere https://...
2
votes
1answer
226 views

Salesforce DB query cache (how long?)

How long does Salesforce keep results of a query in its internal database. We know that the first execution of a query takes the longest. Subsequent queries are much faster due to the caching ...
0
votes
1answer
49 views

How can I find problematic records in a dml action?

Let's assume I have a list of 100 new records that I want to insert, 10 of these records are missing information which will result in DML exception. Is there a way for me to create a list and include ...
1
vote
1answer
380 views

Throw a DML exceptions in Apex Batch Class for testing

Below is my batch apex class that updates Account object for example: global class abc implements Database.Batchable<sObject>{ global Database.QueryLocator start(Database.BatchableContext ...
2
votes
1answer
93 views

Salesforce Relational Database ACID

I was reading about relational databases and found that Salesforce is built on Oracle's Relational Database. Based on my understanding, Relational Databases "promise" the following ACID principle: ...
0
votes
1answer
76 views

Database Apex class benefits [closed]

The pros and cons of using Database apex class oposite to SOQL direct queries or DML - in which cases we should use database class?
0
votes
1answer
81 views

Accessing data of Sandbox from Scratch Org

I want to be able to query, insert and update records of a Sandbox from a Scratch org, only during the development phase. I know that scratch orgs are meant to be populated with just a little amount ...
2
votes
2answers
48 views

SOQL - Best practise : what method choosing while retrieving datas?

There are multiple ways of let's say instanciate a list of contacts using SOQL ; My question is : is there a difference between each other, and is there a best practise ? Examples String name = '%a%'...
0
votes
2answers
294 views

Does Database.Update(records, false) roll back the failed records?

If I call Database.update(records, false); will only the failed records be rolled back or will there be no rollback whatsoever? Imagine this scenario, record is updated, kicks of an insert (inside ...
0
votes
1answer
1k views

Database.Query does not return fields with null value

Hi i'm executing this query using Database.Query(query) Where query is SELECT field1__c, field2__c, field3__c FROM Object1__c On the current record, field3__c is NULL but when i query on the ...
1
vote
2answers
796 views

Data replication from MS SQL to Salesforce

I'm trying to setup our MSSQL server to "replicate" new insert/updates to Salesforce, but it appears that there is no official way to do it via Salesforce. Is there a recommended way? Background: I'm ...
0
votes
0answers
41 views

Duplicate record not added to Database DuplicateRecordSet

We have activated the standard duplicate rules and matching rules for Account. Generally, they seem to work and the duplicate records get written into the tables DuplicateRecordSet and ...
1
vote
1answer
26 views

Object relationships

I have two objects Parent__c and Child__c, Child__c object have a lookup to Parent__c. This code is clear to me, Child__c has a Parent__c field through which it can access to the Parent__r object: [...
0
votes
2answers
628 views

SObject.addError() method does not prevent DML Operation [duplicate]

I want to prevent DML operations during certain processing-situations and provoke a Database.SaveResult with an Database.Error[]-List. According to SObject class documentation, the method addError() ...
2
votes
1answer
143 views

Unable to Create/Update Fields CreatedDate - Database.Merge Leads

I am trying to merge leads with the Database.merge method of syntax merge(masterRecord, duplicateIds, allOrNone), but I'm getting the following error: Unable to create/update fields: CreatedDate. ...
0
votes
1answer
38 views

What is the behavior of date/time fields regarding daylight saving time?

A user located in São Paulo/Brasil is on the UTC-3 timezone. As I write this post it is actually UTC-2 because of daylight saving time. That means that records created today will have the value of ...
0
votes
1answer
516 views

How to add 'LIMIT :' to String in Database.query?

I have Database.query that sorts records by a few filters (or any filter). I want to set the limit for it. How should a write it? return Database.query('SELECT Id, Name FROM Stereo_System__c' + ...
0
votes
1answer
395 views

Querying external database from Salesforce Marketing Cloud

I have an external database containing contacts and transactions. How do I query that database from SFMC to update data extensions for e.g. contacts or transaction data extensions? I don't need to ...
0
votes
1answer
191 views

Help with a schema, custom object to track product stock on Orders

How can I track product stock levels across locations? Our business process is basically this: When an oppy is closed won a trigger will automatically create a contract (not used by us - consider ...
0
votes
3answers
138 views

Salesforce database : how does it work

I don't really know how to ask that question, in Salesforce we have objects, and if I want to update some object (for example) I use an soql query like Account a = [select name from Account where id ...
3
votes
2answers
3k views

Database Query Locator vs Simple Query

I want to know what is the difference between Database.QueryLocator() and simple SOQL Query i.e. List<Inventory__c> invent = [Select Id,Quantity__c,AccountId__c,Name,Expiry_Date__c From ...
0
votes
2answers
415 views

Test Coverage for Custom Error Logging

I created a custom object to store errors in my code. So I am updating some of my classes to take advantage of this object, but I am now running into issues with test coverage. I am taking advantage ...
2
votes
1answer
2k views

SOQL Order by multiple fields with specific values

I have a problem with sorting data with SOQL query. I am sorting data with SELECT Id, Name, CreatedDate, Status FROM Account ORDER BY CreatedDate ASC; But i want to add one more field to sort with. ...
1
vote
1answer
687 views

Exception in Database.save result in trigger context

1) In my opportunityLineitemtrigger, I have a method which updates the opportunity. system.debug('######'); database.saveresult [] rst = database.update(oppList,true); system.debug('######'+rst); ...
0
votes
4answers
285 views

How can I access variable in switch case outside of switch block?

I am trying to upsert a dynamic sObject list of records using Database.Upsert, I want to be able to use AllOrNone parameter however this returns an error saying that my toUpsert variable must be a ...
1
vote
2answers
568 views

Dynamic field for Database.Upsert

I am trying to use a dynamic field for my Database.Upsert command as follows: String extField = objVariable + fieldVariable; Database.UpsertResult[] up = Database.upsert(toUpsert, extField); This ...
0
votes
0answers
125 views

Search and view data from external database

I have a business requirement to create a way for users to search and view results from an external database (Snowflake) in Salesforce. I have created a simple visualforce page and need to send a ...
0
votes
1answer
652 views

Can I pull DISTINCT customers with SQL based on most recent row record only?

So, I have a data extension where data is being saved. My data extension (CustomerSourceDE) looks something like this: Id (text) NULLABLE Email (Email) NULLABLE Customer_FirstName (Text) NULLABLE ...
10
votes
1answer
194 views

FOR UPDATE returns old values

I use FOR UPDATE locking in a query but when the first execution completed, the second execution (started while records were locked) seems to use the old data set. I played around for a while and ...
0
votes
1answer
104 views

Database.query not working with RecordTypeId

I'm making a call to db to retrieve the RecordTypeId from a record of an Object (both values passed as parameters in the function). The point is that when I'm trying to save the code it gives me this ...
2
votes
0answers
143 views

Salesforce Optimistic Record Locking and JavaScript Updates

Is there a way to implement field only updates for Salesforce? Even if fields could be updated concurrently through JavaScript/JavaScript remoting calls, would Salesforce still save the record using ...