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

Announcements
Join us in Bucharest on Sept 18th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
geogou1973
Creator
Creator

How to read values from an input field and add them into an oracle table?

Hello.

I have a vbscript module that inserts values in an oracle table.

sub oracle

set db = CreateObject("ADODB.Connection")

db.open "DSN=XXX;UID=XXX;PWD=XXX"

set Orderfile = db.execute("INSERT INTO QLIKVIEW (STORE, SALES) VALUES ('101', '42000');")

set Orderfile = db.execute("COMMIT;")

db.Close

end sub

It is working correct and inserts the values into the oracle table.

How can i insert values from an input box with variables into the oracle table ?

Let's say i create a variable $(STORE) and $(SALES)

How can i read the variables and insert the values into the oracle table ?

I attach a file.

8 Replies
Gysbert_Wassenaar
Partner - Champion III
Partner - Champion III

Perhaps something like this:

sub oracle

set db = CreateObject("ADODB.Connection")

db.open "DSN=XXX;UID=XXX;PWD=XXX"

myStore = ActiveDocument.Variables("vStore").GetContent.String

mySales = ActiveDocument.Variables("vSales").GetContent.String

strSQL = "INSERT INTO QLIKVIEW (STORE, SALES) VALUES (' " & myStore &" ', ' " & mySales & " ');"


set Orderfile = db.execute(strSQL)

set Orderfile = db.execute("COMMIT;")

db.Close

end sub


talk is cheap, supply exceeds demand
geogou1973
Creator
Creator
Author

I have problem in this line

myStore = ActiveDocument.Variables("vStore").GetContent.String)


It returns the message because of the )


Expected end of statement

Gysbert_Wassenaar
Partner - Champion III
Partner - Champion III

Yeah, cut&paste error. Remove the last ) from both those lines.


talk is cheap, supply exceeds demand
geogou1973
Creator
Creator
Author

No does not pass when i try to run the module. It is stop in the line

mySales = ActiveDocument.Variables("SALES").GetContent.String

Gysbert_Wassenaar
Partner - Champion III
Partner - Champion III

Try if you can get echo the value of your variable at all:

Sub CheckVariable 

     SET vCheck = ActiveDocument.Variables("STORE") 

     MsgBox(vCheck.GetContent.String) 

End Sub 


talk is cheap, supply exceeds demand
geogou1973
Creator
Creator
Author

It returns the correct value but when i give the following commands does not work


sub oracle

set myStore = ActiveDocument.Variables("STORE")

myStore.GetContent.String

set db = CreateObject("ADODB.Connection")

db.open "DSN=xxx;UID=xxx;PWD=xxx"

set Orderfile = db.execute("INSERT INTO QLIKVIEW3 (STORE) VALUES ('"&myStore&"');")

set Orderfile = db.execute("COMMIT;")

db.Close

end sub


Gysbert_Wassenaar
Partner - Champion III
Partner - Champion III

myStore.GetContent.String  <- doesn't do anything

Perhaps this works:

sub oracle

    set vVar = ActiveDocument.Variables("STORE")

    myStore = vVar.GetContent.String

    set db = CreateObject("ADODB.Connection")

    db.open "DSN=xxx;UID=xxx;PWD=xxx"

    set Orderfile = db.execute("INSERT INTO QLIKVIEW3 (STORE) VALUES ('" & myStore & "');")

    set Orderfile = db.execute("COMMIT;")

    db.Close

end sub


talk is cheap, supply exceeds demand
geogou1973
Creator
Creator
Author

Unfortunately does not pass.

Maybe the problem is in line

set Orderfile = db.execute("INSERT INTO QLIKVIEW3 (STORE) VALUES (' " & myStore &" ');")

and can not recognize the variable.