Skip to main content
Announcements
See what Drew Clarke has to say about the Qlik Talend Cloud launch! READ THE BLOG
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

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.

1 Solution

Accepted Solutions
Not applicable
Author

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.

View solution in original post

5 Replies
Not applicable
Author

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.

Not applicable
Author

Hi,

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

Regards,

Amay

jagan
Luminary Alumni
Luminary Alumni

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.

er_mohit
Master II
Master II

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

Not applicable
Author

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