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

Announcements
Qlik Connect 2026! Turn data into bold moves, April 13 -15: Learn More!
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Update SQL Table with a QV variable

Dear All,

I´m trying to update a field in a SQL table with the data in a QV variable. The problem is to the macro understand the variable (looks simple but I´m new ...). If I fix a value it works.

Bellow is the macro and the variable used is the v_VARCHAR

sub Rec_Data()

          dim sServer, sConn, oConn,oRS

          sServer="ARPoint-AR\SQL2008"

          sConn="Provider=SQLOLEDB.1;Initial Catalog=QV;Data Source=arpoint-AR\sql2008"

          Set oConn = CreateObject("ADODB.Connection")

          oConn.Open sConn, "sa", "123"

          Set oRS =CreateObject("ADODB.Recordset")

          sSQL="UPDATE Table_1 SET Col1_Varchar = " + $v_VARCHAR

          oRS.Open sSQL, oconn

 

end sub

Thanks in advance.

1 Solution

Accepted Solutions
fosuzuki
Partner - Specialist III
Partner - Specialist III

Hi,

the macro module doesn't understand dollar sign expansion.

You must use:

sSQL="UPDATE Table_1 SET Col1_Varchar = ' " + ActiveDocument.Variables("v_VARCHAR").GetContent.String + " ' "

Hope this helps

Fernando

View solution in original post

4 Replies
Not applicable
Author

try $(v_VARCHAR) or '$(v_VARCHAR)'

Anonymous
Not applicable
Author

Felim,

Both failed. I also tryed it

sSQL="UPDATE Table_1 SET Col1_Varchar = ' " + $(v_VARCHAR) + " ' "

Thanks.

fosuzuki
Partner - Specialist III
Partner - Specialist III

Hi,

the macro module doesn't understand dollar sign expansion.

You must use:

sSQL="UPDATE Table_1 SET Col1_Varchar = ' " + ActiveDocument.Variables("v_VARCHAR").GetContent.String + " ' "

Hope this helps

Fernando

Anonymous
Not applicable
Author

Fernando,

Work fine. Thanks.