6 Replies Latest reply on Mar 17, 2016 7:07 AM by WolfShade

    How to load JSON file or CSV file into oracle database using ColdFusion ? Please tell me ASAP

    chaitanyab63285174

      Hi ColdFusion Team,

       

      How to load JSON file or CSV file into oracle database using ColdFusion ? Please tell me ASAP

       

      Thanks in Advance

        • 1. Re: How to load JSON file or CSV file into oracle database using ColdFusion ? Please tell me ASAP
          WolfShade Level 4

          That depends.  You can very easily insert the JSON or CSV data as a string into a varchar or text datatype on the database, no problem.

           

          However, if you need the JSON or CSV to be in an array (like a query object) so that it can be inserted into the database, then how the data was "flattened" would matter.

           

          I avoid CSV, if at all possible.  Never liked it.

           

          However, if you are using CF to create the JSON (or if you manually piece it together in JavaScript and it follows the CF format), then you should be able to use DeserializeJSON() to put it back into a query object and append the data into a database relatively easily.

           

          HTH,

           

          ^_^

           

          PS:  I just noticed that you addressed your post to "ColdFusion Team".  Just to make sure, the people at Adobe don't officially monitor these forums - these forums are primarily a user-to-user interaction.  Although sometimes Adobe staff do check in here to see what's going on.

          • 2. Re: How to load JSON file or CSV file into oracle database using ColdFusion ? Please tell me ASAP
            chaitanyab63285174 Level 1

            Hi WolfShade,

             

            *Could you please send me the total script code to load data from json/csv

            file to oracle database using cold fusion scripts*

            *Hope you do well reply me please ASAP *

             

             

             

            Thanks in advanceOn Wednesday, March 16, 2016, WolfShade <

            • 3. Re: How to load JSON file or CSV file into oracle database using ColdFusion ? Please tell me ASAP
              Carl Von Stetten Adobe Community Professional & MVP

              As much as I'd like to assist you, this is not a "write my code for me" kind of forum.  If you have specific questions, or have tried something and it isn't working, people will generally try to offer assistance.  But asking someone to write code for you is an unreasonable expectation.

               

              Even if you provided the structure of your json/csv data and the exact schema of the database table(s) in Oracle that you wish to write to, you should not expect forum members to provide you "the total script code to load data from json/csv file to oracle database".

               

              And, as WolfShade stated, very few Adobe ColdFusion developer team actively follow these forums - they are intended to provide peer-to-peer support.  Furthermore, most of the ColdFusion development team do not routinely write ColdFusion code and would be unlikely to be able to write this code for you.

               

              -Carl V. - Moderator

              • 4. Re: How to load JSON file or CSV file into oracle database using ColdFusion ? Please tell me ASAP
                WolfShade Level 4

                There are online resources that can point you in the right direction.  If you take a query object, and use SerializeJSON() on it, be sure to use the argument that allows CF to automatically convert it back to a query object, then CFDUMP the result, you can see the format that CF uses (which is different from JavaScript JSON format), and can build your JSON from scratch based upon that format.  I've done it.. it's a little extra coding, but worth the effort, IMHO.

                 

                HTH,

                 

                ^_^

                • 5. Re: How to load JSON file or CSV file into oracle database using ColdFusion ? Please tell me ASAP
                  chaitanyab63285174 Level 1

                  Hi WolfShade,

                   

                  Can you provide the sample code or related links it I'll very helpful to me

                   

                  Thanks in advance

                  • 6. Re: How to load JSON file or CSV file into oracle database using ColdFusion ? Please tell me ASAP
                    WolfShade Level 4

                    Here is the documentation for SerializeJSON.  I think in your case, the only argument you will need to use is the var (object to convert to JSON.)

                     

                    Here is the documentation for DeserializeJSON.  If you want to use SerializeJSON to convert a query into a string and want to convert it back to a query, you should use the var and strictMapping arguments in DeserializeJSON (set strictMapping to false.)

                     

                    You can SerializeJSON a query object, save it to a string, and output it.  This will let you see the format that SerializeJSON creates.  It's like:

                    {"COLUMNS":["COLUMN_A","COLUMN_B","COLUMN_C"],"DATA":[["VALUE_1A","VALUE_1B","VALUE_1C"],["VALUE_2A","VALUE_2B","VALUE_2C"],["VALUE_3A","VALUE_3B","VALUE_3C"],["VALUE_4A","VALUE_4B","VALUE_4C"]]}
                    
                    

                     

                    It takes extra coding and a fairly intense sense of what goes where, but you can write a JavaScript function that will duplicate the above format.  If you do, you can use AJaX to submit it to a CFC, use the CFC to DeserializeJSON the data, and VOILA!, you have a query object in the CFC from the data you put into a JavaScript string.

                     

                    HTH,

                     

                    ^_^