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: 
FrankC
Creator
Creator

Load Inline Quesstion

I would like to create a simple audit table and store it as a qvd after each running of the application.  I would like to store all the table names and a count of rows.  I saw $Tables and $Rows.   They work great when displaying in the application, but how can I use them with Inline?

thanks for your suggestions and help!

 

 

 

Labels (1)
1 Solution

Accepted Solutions
petter
Partner - Champion III
Partner - Champion III

 

You can use a script like this:

 

DATAMODEL:
LOAD * INLINE [TABLE#];  // CREATE EMPTY TABLE

FOR t#=1 TO NoOfTables()
  tn = TableName(t#-1)

  IF tn <> 'DATAMODEL' THEN
    nrows = NoOfRows(tn)
    fns = ''
    FOR f#=1 TO NoOfFields(tn)
      fn = FieldName(f#,tn)
      fns = fns & '|' & fn
    NEXT
    fns = Mid(fns,2,Len(fns));
    DATAMODEL:
    CONCATENATE LOAD  // ADD ONE ROW FOR EACH TABLE
      $(t#) AS TABLE#,
      '$(tn)' AS TABLENAME,
      $(nrows) AS ROWS,
      '$(fns)' AS FIELDS
    AUTOGENERATE 1;
  ENDIF
NEXT

DATE = Date(Now(),'YYYY-MM-DD-hh-mm');

STORE DATAMODEL INTO [D:\DATAMODEL_METADATA\DATAMODEL-$(DATE).QVD] (QVD);
DROP TABLE [DATAMODEL];

View solution in original post

2 Replies
petter
Partner - Champion III
Partner - Champion III

 

You can use a script like this:

 

DATAMODEL:
LOAD * INLINE [TABLE#];  // CREATE EMPTY TABLE

FOR t#=1 TO NoOfTables()
  tn = TableName(t#-1)

  IF tn <> 'DATAMODEL' THEN
    nrows = NoOfRows(tn)
    fns = ''
    FOR f#=1 TO NoOfFields(tn)
      fn = FieldName(f#,tn)
      fns = fns & '|' & fn
    NEXT
    fns = Mid(fns,2,Len(fns));
    DATAMODEL:
    CONCATENATE LOAD  // ADD ONE ROW FOR EACH TABLE
      $(t#) AS TABLE#,
      '$(tn)' AS TABLENAME,
      $(nrows) AS ROWS,
      '$(fns)' AS FIELDS
    AUTOGENERATE 1;
  ENDIF
NEXT

DATE = Date(Now(),'YYYY-MM-DD-hh-mm');

STORE DATAMODEL INTO [D:\DATAMODEL_METADATA\DATAMODEL-$(DATE).QVD] (QVD);
DROP TABLE [DATAMODEL];

FrankC
Creator
Creator
Author

Peter

 

thanks.  This gave me what I needed!