Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

Announcements

Breathe easy -- you now have more time to plan your next steps with Qlik!
QlikView 11.2 Extended Support is now valid through December 31, 2020. Click here for more information.

Not applicable

QlikView Fields to Sql

Sub Inserta_en_SQL

dim strServer, strConexion, oConn,oRS

strServer="servername"

strConexion="provider=sqloledb;data source=" & strServer & ";initial catalog=dbMain"

Set oConn = CreateObject("ADODB.Connection")

oConn.Open strConexion, "sa", "password"

Set oRS =CreateObject("ADODB.Recordset")

sSQL="insert into tbUsuarios (intEmpresa,intSucursal,strUsuario,strConstrasena)  values (0,0,'Field?','123')"

ors.open sSQL, oconn

end sub

How can I put  a field or variable in an SQL sentence?.

It is possible?

Or read an QVD and store it into an sql database?.

Help and Thanks!!

Tags (1)
5 Replies
Not applicable

Re: QlikView Fields to Sql

Hi the best method is create the txt file or csv file by using STORE command.

Create the shell script to insert the data into DB.

Here are the steps.

1. Create the shell script to insert the data from txt file into database.

2. Create the batch file to execute the shell script.

3. Write your Qlikview script in qvw

4. create the txt file by using STORE command

5. Execute the batch file to insert the data from txt file to DB by using EXECUTE command.

Not applicable

Re: QlikView Fields to Sql

Hello,

Sorry for my english, and my probelm resides in the procces to save the csv into a sql database.

1.I already create an qvw, this one transforms my qvd into a csv.

2.A .bat  reload this qvw to transforms the data into csv

3.Then i need to store this csv into an sql database, but here i dont know how to do it by code.

Im using a .bat to do the all the thigs, but the third one is still wrong.

So many thanks!

bumin
Not applicable

Re: QlikView Fields to Sql

Hi

I mostly do it in script.

So if you read your data in a QVD, you can read your QVD and generate an SQL-Statement for each row

Example

--------------

ListeSQL:

load 

cmpcode, code, text(BIC)    as    BIC, iban,

'update oas_elmbanklist set iban=#'&iban&'#,swift=#'&BIC&'# where cmpcode=#'&cmpcode&'# and elmcode=#'&code&'#'

as sqlstring

resident Liste;

drop table Liste;

Clever_Anjos
Not applicable

Re: QlikView Fields to Sql

All modern databases provides a cmd line util to import data.

SQL Server - bcp

Oracle - sqlplus

Use your qlikview script to generate a csv file, or even better a text flat file with your inserts and then

EXECUTE bcp/sqplpus

vikasmahajan
Not applicable

Re: QlikView Fields to Sql

Hope this help you

Vikas