This depends largely on the situation, but unfortunately it's unlikely that you can get that save file back. It'd be good if you could be a bit more specific about what you were doing before it corrupted and whether or not you've ever used cheating devices with it. For now I'll answer based on what you've said in the post.
3DS software is pretty good with save files and shouldn't corrupt unless they're treated incorrectly. Usually if they corrupt, it's because the save file has been tampered with by a hacking/ cheating device, for example Action Replay, PokEdit or powersaves. If this is the case, you cannot get your save file back and you'll have to start over. For this reason, I don't recommend you use any hacking or exploiting software to modify your game, as the risk of your game corrupting because of it is very real.
If you've never used hacks or exploits on your game, the corrupted save file may be caused due to the system reading the game card incorrectly. I've had this happen before, and my game worked as normal after I ejected the card, put it back in and tried again. Going against what you may have heard, I recommend that you don't blow into the cartridge slot or onto the cartridge itself, as condensation can potentially cause more issues.
If ejecting the cartridge and trying again didn't work, it's likely a technical failure with the cartridge itself that probably can't be fixed. You'll have to start over with a new save file. I don't think 3DS Pokemon games back up past save files like DS ones did, so you won't have any past save files to go back to unfortunately.
It's also worth mentioning that if your game is preowned, its previous owner may have used one of the aforementioned hacking programs to modify their game, increasing the chance that issues like this will occur. While clearing the save file should generally fix problems arising from this, the possibility remains.
Hope this was useful in some way, good luck getting your save file back!