Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

Highlighted
aetingu12
Contributor

Qlikview - SQL and Script Editing

Dear all,

I have managed to load data from our SQL server into Qlikview by:

ODBC CONNECT32................................

SQL

SELECT a,b,c FROM TABLE1

;

Then later on I would like to create a few new fields using:

LOAD *;

IF(MATCH(a,'Apples'),'FRUIT','VEGETABLE') as GROCERY_MARKER;

This last line of code does not give me the newly created GROCERY_MARKER among my field list.

So two questions:

1.Should my SQL be under a LOAD command (I know Qlikview does it by default) and the result to be defined by a Table name?

ie.

ODBC CONNECT32................................

GROCERY_Tbl:

LOAD *;

SQL

SELECT a,b,c FROM TABLE1

;

2. How can I get this new field to appear on my field list?  I believe it might be related to the first question, as I might need to define my table to refer to it on question 2.

Thanks for your help and patience,

Aksel

Tags (2)
1 Solution

Accepted Solutions
olivierrobin
Valued Contributor II

Re: Qlikview - SQL and Script Editing

hello

you should code it in this way

odbc ...

grocery_tbl:

load *,

IF(MATCH(a,'Apples'),'FRUIT','VEGETABLE') as GROCERY_MARKER;

sql

select ....

;

and your new field will appear with the others

View solution in original post

4 Replies
olivierrobin
Valued Contributor II

Re: Qlikview - SQL and Script Editing

hello

you should code it in this way

odbc ...

grocery_tbl:

load *,

IF(MATCH(a,'Apples'),'FRUIT','VEGETABLE') as GROCERY_MARKER;

sql

select ....

;

and your new field will appear with the others

View solution in original post

aetingu12
Contributor

Re: Qlikview - SQL and Script Editing

Does this mean that every time I add a new field after my load line, I need to rerun the whole SQL?  or can I just run that bit on its own?

Thanks for quick come back.

olivierrobin
Valued Contributor II

Re: Qlikview - SQL and Script Editing

you can also run your sql once and store the result in a qvd file

then load your data from this qvd and add additional fields

aetingu12
Contributor

Re: Qlikview - SQL and Script Editing

Thank you.