Thursday, February 12, 2015

QV21 Check column existence in table

If you need to check the column exists in table ( qlikview table , resident table or any other type of load), use below code to check column existence. 


tab1:
load * inline [
sno, deleted
1,y
2,y
3,n
4,n
];

ErrorMode=0;          // continue running on errors
LOAD
  deleted,
  rowno() as row
  RESIDENT tab1: where row=1;
IF ScritpError=11 THEN
  // field doesnt exist
  TRACE field 'deleted' does not exist ;
ELSE
  // field exists
  TRACE field 'deleted'  exist;
ENDIF
ErrorMode=1;          // restore deafult error mode


or

ErrorMode=0;          // continue running on errors
LOAD
  deleted,
  rowno() as row
  RESIDENT tab1: where row=1;
IF ScriptErrorCount >= 1 THEN
  // field doesnt exist
  TRACE field 'deleted' does not exist ;
ELSE
  // field exists
  TRACE field 'deleted'  exist;
ENDIF
ErrorMode=1;          // restore deafult error mode

No comments:

Post a Comment

web stats