5 Replies Latest reply: Apr 9, 2013 9:36 PM by Michael Crowley RSS

    Syntax Error on Load

      I feel silly asking this simple question, but I can't see what I'm doing wrong.  I've looked for commas, semicolons, colons, I think I have them all in the right places.

       

      Excerpt of my script -

       

      ODBC CONNECT TO EM7G2DB;

       

      devicetable:

      LOAD

          'G2' AS Version,

          device as DeviceName,

          id as DeviceID,

          ip as DeviceIP,

          `roa_id` roaid,

          active as Status,

          1 AS DeviceCount;

      SQL SELECT

          IF(active='0', 'Active',

           IF(active='1', 'Disabled',

            IF(active='2', 'Maintenance',

             IF(active='5', 'Pending', 'unknown')))) AS Status,

          device,

          id,

          ip,

          `roa_id`

      FROM master.`legend_device`;

       

      This errors with this error, and yet still loads the data -

      Syntax error, missing/misplaced FROM:

      devicetable:

      LOAD

          'G2' AS Version,

          device as DeviceName,

          id as DeviceID,

          ip as DeviceIP,

          `roa_id` roaid,

          active as Status,

          1 AS DeviceCount

      devicetable:

      LOAD

          'G2' AS Version,

          device as DeviceName,

          id as DeviceID,

          ip as DeviceIP,

          `roa_id` roaid,

          active as Status,

          1 AS DeviceCount

       

      Thoughts?  Thanks in advance.

        • Re: Syntax Error on Load

          Hi,

           

          I couldn't find the field 'active' in the sql part.
          Also you have loaded --  `roa_id` roaid..  I am not sure, if we can load like this. I think it should be 'roa_id` as roaid.

          • Re: Syntax Error on Load
            Amay Patil

            Hi,

             

            You may missing an 'AS' keyword at 'roa_id' field.

             

            Regards,

            Amay

            • Re: Syntax Error on Load
              jagan mohan rao appala

              Hi,

               

              Try this

               

               

              devicetable:

              LOAD

                  'G2' AS Version,

                  device as DeviceName,

                  id as DeviceID,

                  ip as DeviceIP,

                  `roa_id` as roaid,

                  Status,

                  1 AS DeviceCount;

              SQL SELECT

                  IF(active='0', 'Active',

                   IF(active='1', 'Disabled',

                    IF(active='2', 'Maintenance',

                     IF(active='5', 'Pending', 'unknown')))) AS Status,

                  device,

                  id,

                  ip,

                  `roa_id`

              FROM master.`legend_device`;

               

               

              The issue is with this two lines

               

              `roa_id` roaid,

              active as Status,

               

              Hope this helps you.

               

              Regards,

              jagan.

              • Re: Syntax Error on Load
                Mohit Sharma

                Try this

                 

                 

                devicetable:

                LOAD

                    'G2' AS Version,

                    device as DeviceName,

                    id as DeviceID,

                    ip as DeviceIP,

                    [`roa_id`] as roaid,

                         active as    Status,

                    1 AS DeviceCount;

                SQL SELECT

                    IF(active='0', 'Active',

                     IF(active='1', 'Disabled',

                      IF(active='2', 'Maintenance',

                       IF(active='5', 'Pending', 'unknown')))) AS Status,

                    device,

                    id,

                    ip,

                    `roa_id`

                FROM master.`legend_device`;

                 

                 

                The issue is with this two lines

                 

                `roa_id` roaid,

                active as Status,

                `roa_id` in SQL it takes as field but to alias its name then you should be used [] this bracket

                hope it helps

                • Re: Syntax Error on Load

                  Thanks all.  Yes, it was as simple as that, I just needed a new set of eyes looking at it.  Thank you.