Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
sevvalk
Creator
Creator

Microsoft Access Sql transform to qlik sense script

Hi,

This sql written in Microsoft Access. I want to write this sql in qlik sense. The table load method is like this:

fg_salspm:
LOAD spmyil,
spmrfc,
spmref,
spmtrh,
spmony,
spmdrm,
spmckt,
spmchs;
SQL SELECT spmyil,
spmrfc,
spmref,
spmtrh,
spmony,
spmdrm,
spmckt,
spmchs
FROM informix.fg_salspm;

fg_salspd:
LOAD spdyil,
spdrfc,
spdref,
spdmik,
spdbrm,
spdktg,
spdskd,
spdntt,
spditt,
spdkdt;
SQL SELECT spdyil,
spdrfc,
spdref,
spdmik,
spdbrm,
spdktg,
spdskd,
spdntt,
spditt,
spdkdt
FROM informix.fg_salspd;

fg_salflm:
LOAD flmnum,
flmckt,
flmchs,
flmbsl,
flmbts;
SQL SELECT flmnum,
flmckt,
flmchs,
flmbsl,
flmbts
FROM informix.fg_salflm;

 

-------------- SQL --------------------------

Siparis_S:

SELECT fg_salspm.spmyil, fg_salspm.spmrfc, fg_salspm.spmref, fg_salspm.spmtrh, fg_salspd.spdmik, fg_salspd.spdbrm, fg_salspd.spdktg, fg_salspd.spdskd, fg_salspd.spdntt, fg_salspd.spditt, fg_salspd.spdkdt, fg_salspm.spmckt, fg_salspm.spmchs

FROM fg_salspm LEFT JOIN fg_salspd ON (fg_salspm.spmyil = fg_salspd.spdyil) AND (fg_salspm.spmrfc = fg_salspd.spdrfc) AND (fg_salspm.spmref = fg_salspd.spdref)

WHERE (((fg_salspm.spmtrh)>#1/1/2024#));

FiyatListesi:

SELECT Siparis_S.*, fg_salflm.flmnum, Format([flmbsl],"Short Date") AS İfade1, IIf(IsNull([flmbts]),Date(),Format([flmbts],"Short Date")) AS A

FROM Siparis_S LEFT JOIN fg_salflm ON (Siparis_S.spmckt = fg_salflm.flmckt) AND (Siparis_S.spmchs = fg_salflm.flmchs);

Karsilastirma:

SELECT FiyatListesi_S.*

FROM FiyatListesi_S

WHERE ((([Siparis_S].[spmtrh])>=[İfade1] And ([Siparis_S].[spmtrh])<=[A]));

Can you help me about Access sql transform to qlik sense script?

Labels (1)
1 Solution

Accepted Solutions
marksouzacosta

 

There are multiple approaches for this problem.

 

1. You can try to just execute the query as it is, without any modification, and load the results in Qlik. Usually recommend for very complex queries, hard to translate to Qlik Script.

 

2. You can load all the tables from your source database, store as QVDs and try to reproduce the queries. This is close to your case, you just need to save the QVD files. 
 
Anyway, this is how you can translate your first query:
 
Siparis_S:
LOAD 
    // Key fields
    spmyil,     
    spmrfc, 
    spmref, 

    // Regular fields
    spmtrh, 
    spmckt, 
    spmchs
RESIDENT 
    fg_salspm 
WHERE 
    spmtrh > MakeDate(2024,1,1)
;

LEFT JOIN (Siparis_S)
fg_salspd:
LOAD
    // Key fields
    spdyil AS spmyil,
    spdrfc AS spmrfc,
    spdref AS spmref,

    // Regular fields
    spdmik, 
    spdbrm, 
    spdktg, 
    spdskd, 
    spdntt, 
    spditt, 
    spdkdt, 
RESIDENT
    fg_salspd
;

Read more at Data Voyagers - datavoyagers.net
Follow me on my LinkedIn | Know IPC Global at ipc-global.com

View solution in original post

6 Replies
henrikalmen
Specialist II
Specialist II

If you have created a connection (see Connecting to data sources or Connecting to databases) to your database I kind of think those scripts will run in Qlik Sense. Possibly with an error here: WHERE (((fg_salspm.spmtrh)>#1/1/2024#))

What problems do you encounter?

sevvalk
Creator
Creator
Author

The final version of the code is this:

LIB CONNECT TO 'LoginX (Login)';

fg_salspm:
LOAD spmyil,
spmrfc,
spmref,
spmtrh,
spmony,
spmdrm,
spmckt,
spmchs;
SQL SELECT spmyil,
spmrfc,
spmref,
spmtrh,
spmony,
spmdrm,
spmckt,
spmchs
FROM informix.fg_salspm;

fg_salspd:
LOAD spdyil,
spdrfc,
spdref,
spdmik,
spdbrm,
spdktg,
spdskd,
spdntt,
spditt,
spdkdt;
SQL SELECT spdyil,
spdrfc,
spdref,
spdmik,
spdbrm,
spdktg,
spdskd,
spdntt,
spditt,
spdkdt
FROM informix.fg_salspd;

fg_salflm:
LOAD flmnum,
flmckt,
flmchs,
flmbsl,
flmbts;
SQL SELECT flmnum,
flmckt,
flmchs,
flmbsl,
flmbts
FROM informix.fg_salflm;

 

//-------------- SQL --------------------------

Siparis_S:

SELECT
[fg_salspm].[spmyil],
[fg_salspm].[spmrfc],
[fg_salspm].[spmref],
[fg_salspm].[spmtrh],
[fg_salspd].[spdmik],
[fg_salspd].[spdbrm],
[fg_salspd].[spdktg],
[fg_salspd].[spdskd],
[fg_salspd].[spdntt],
[fg_salspd].[spditt],
[fg_salspd].[spdkdt],
[fg_salspm].[spmckt],
[fg_salspm].[spmchs]

FROM
[fg_salspm]
LEFT JOIN
[fg_salspd]
ON
([fg_salspm].[spmyil] = [fg_salspd].[spdyil])
AND ([fg_salspm].[spmrfc] = [fg_salspd].[spdrfc])
AND ([fg_salspm].[spmref] = [fg_salspd].[spdref])

WHERE
[fg_salspm].[spmtrh] > '01.01.2024';


FiyatListesi:
SELECT
[Siparis_S].*,
[fg_salflm].[flmnum],
Format([fg_salflm].[flmbsl], "Short Date") AS [ref_flmbsl],
IIf(IsNull([fg_salflm].[flmbts]), Date(), Format([fg_salflm].[flmbts], "Short Date")) AS [ref_flmbts]

FROM
[Siparis_S]
LEFT JOIN
[fg_salflm]
ON
([Siparis_S].[spmckt] = [fg_salflm].[flmckt])
AND ([Siparis_S].[spmchs] = [fg_salflm].[flmchs]);


Karsilastirma:

SELECT
[FiyatListesi_S].*

FROM
[FiyatListesi_S]

WHERE
([Siparis_S].[spmtrh] >= [ref_flmbsl])
AND ([Siparis_S].[spmtrh] <= [ref_flmbts]);

---------------------------- ERROR -------------------------------

The following error occurred:
Connector reply error: SQL##f - SqlState: 37000, ErrorCode: 4294967095, ErrorMsg: [Informix][Informix ODBC Driver][Informix]A syntax error has occurred.
 
The error occurred here::
Siparis_S: SELECT [fg_salspm].[spmyil], [fg_salspm].[spmrfc], [fg_salspm].[spmref], [fg_salspm].[spmtrh], [fg_salspd].[spdmik], [fg_salspd].[spdbrm], [fg_salspd].[spdktg], [fg_salspd].[spdskd], [fg_salspd].[spdntt], [fg_salspd].[spditt], [fg_salspd].[spdkdt], [fg_salspm].[spmckt], [fg_salspm].[spmchs] FROM [fg_salspm] LEFT JOIN [fg_salspd] ON ([fg_salspm].[spmyil] = [fg_salspd].[spdyil]) AND ([fg_salspm].[spmrfc] = [fg_salspd].[spdrfc]) AND ([fg_salspm].[spmref] = [fg_salspd].[spdref]) WHERE [fg_salspm].[spmtrh] > '01.01.2024'

 

henrikalmen
Specialist II
Specialist II

The error you are getting is not a problem with the qlik script itself, it's the database that responds with an error. And it seems that the query the databse is trying to run, includes your definition of what the table is supposed to be called when loaded by qlik. Try adding one line like this:

Siparis_S:
LOAD *;
SELECT
[fg_salspm].[spmyil],
...

sevvalk
Creator
Creator
Author

It doesn't work. It given the same error.

p_verkooijen
Partner - Specialist II
Partner - Specialist II

Hi @sevvalk 


Does this work?  Load * FROM informix.fg_salspm;

Check your FROM in the SQL statements, you are not including informix.

 

Siparis_S:

SELECT
[fg_salspm].[spmyil],
[fg_salspm].[spmrfc],
[fg_salspm].[spmref],
[fg_salspm].[spmtrh],
[fg_salspd].[spdmik],
[fg_salspd].[spdbrm],
[fg_salspd].[spdktg],
[fg_salspd].[spdskd],
[fg_salspd].[spdntt],
[fg_salspd].[spditt],
[fg_salspd].[spdkdt],
[fg_salspm].[spmckt],
[fg_salspm].[spmchs]

FROM
informix.[fg_salspm]
LEFT JOIN [fg_salspd] ON ([fg_salspm].[spmyil] = [fg_salspd].[spdyil])
AND ([fg_salspm].[spmrfc] = [fg_salspd].[spdrfc])
AND ([fg_salspm].[spmref] = [fg_salspd].[spdref])

marksouzacosta

 

There are multiple approaches for this problem.

 

1. You can try to just execute the query as it is, without any modification, and load the results in Qlik. Usually recommend for very complex queries, hard to translate to Qlik Script.

 

2. You can load all the tables from your source database, store as QVDs and try to reproduce the queries. This is close to your case, you just need to save the QVD files. 
 
Anyway, this is how you can translate your first query:
 
Siparis_S:
LOAD 
    // Key fields
    spmyil,     
    spmrfc, 
    spmref, 

    // Regular fields
    spmtrh, 
    spmckt, 
    spmchs
RESIDENT 
    fg_salspm 
WHERE 
    spmtrh > MakeDate(2024,1,1)
;

LEFT JOIN (Siparis_S)
fg_salspd:
LOAD
    // Key fields
    spdyil AS spmyil,
    spdrfc AS spmrfc,
    spdref AS spmref,

    // Regular fields
    spdmik, 
    spdbrm, 
    spdktg, 
    spdskd, 
    spdntt, 
    spditt, 
    spdkdt, 
RESIDENT
    fg_salspd
;

Read more at Data Voyagers - datavoyagers.net
Follow me on my LinkedIn | Know IPC Global at ipc-global.com