Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
kunkumnaveen
Specialist
Specialist

how to write if statement

Hello All,

I really have no clue whether the thing i am looking is possible  in qlikview or not

the thing is ,currently i moved my application from quality server to production and the issuse is a table which is existing in quality server will be exist in production server after a while i mean in a two months,

so what i am looking is i need to write a code in a way so that it should check if the table is existing in server then load the table in to qvd if not skip that without throwing error and without  halting the script run......is it possible

coal:

SELECT * from ZCOAL_FINAL_DASH;

  STORE coal into $(vPath)Coal.qvd(qvd);

DROP Table coal;

6 Replies
Anonymous
Not applicable

Hi Naveen,

You can use NoOfRows, if there isn't any row you will not load this table:

coal:

LOAD *;

SELECT * from ZCOAL_FINAL_DASH;

IF NoOfWors('coal')>0 THEN

  STORE coal into $(vPath)Coal.qvd(qvd);

  DROP Table coal;

END IF;

kunkumnaveen
Specialist
Specialist
Author

still getting same error

screen.png

Aurelien_Martinez
Partner - Specialist II
Partner - Specialist II

Hi,

For check if table exists :

For SQL Server

SELECT 1
  
FROM INFORMATION_SCHEMA.TABLES
  
WHERE TABLE_TYPE='BASE TABLE'
  
AND TABLE_NAME='mytablename'


For oracle

select count(*) into c from user_tables where table_name = upper('table_name');


and after use the Manuel solution.


Aurélien

Help users find answers! Don't forget to mark a solution that worked for you!
sasiparupudi1
Master III
Master III

It looks like an sql error rather than a qlikview error..

May be you are missing the scehma prefix in you select statement in qlik

SELECT * from [dbo].ZCOAL_FINAL_DASH;

hth

Sasi

sasiparupudi1
Master III
Master III

Hi

Sorry, I misunderstood your question. Please ignore my above comment

set ErrorMode=0;  //to suppress the message box

if (ScriptError=2) or (ScriptError=10) then   ///2 general error 10 table not found

STORE coal into $(vPath)Coal.qvd(qvd);

DROP Table coal;

end if;

hth

Sasi

Anonymous
Not applicable

Hi Naveen:

TableExists:

//Here search on Objects of data base if your table exists on server

IF NoOfWors('TableExists')>0 THEN

     coal:

     LOAD *;

     SELECT * from ZCOAL_FINAL_DASH;

  STORE coal into $(vPath)Coal.qvd(qvd);

  DROP Table coal;

END IF;