MS Excel SQL.REQUEST syntax to connect to Oracle [message #67195] |
Mon, 02 February 2004 05:06 |
Ciarano
Messages: 1 Registered: February 2004
|
Junior Member |
|
|
<PRE class=OTbl style="WORD-WRAP: break-word">Hi guys
I'm trying to get my syntax correct for using sql.request. In the Excel help the syntax is
SQL.REQUEST(connection_string,output_ref,driver_prompt,query_text,col_names_logical)
The connection string for Oracle is DNS=My Oracle Data Source;DBQ=MYSER VER;UID=JohnS;PWD=Sesame
My sql.request is
=SQL.REQUEST("DNS=dw92;DBQ=dw92;UID=sh1;PWD=sh1",C15,2,"select cost from cost_base_view",TRUE)
My database is dw92, I've declared my data source as dw92.dsn but I keep getting N/A
Can anyone help?</PRE><PRE class=OTbl style="WORD-WRAP: break-word">What about ExecuteSQL? Can anyone elaborate on using this function?</PRE><PRE class=OTbl style="WORD-WRAP: break-word">
Thanks
Ciaran</PRE>
|
|
|
|
Re: MS Excel SQL.REQUEST syntax to connect to Oracle [message #67473 is a reply to message #67426] |
Sun, 15 August 2004 18:06 |
Geoff Merkel
Messages: 1 Registered: August 2004
|
Junior Member |
|
|
=SQL.REQUEST("DSN=CLASP;UID=sa;PWD=;Database=CLASP",,,"Select Kkey from dbo.VA where VAF1 = ' "&$A$1&" ' ",FALSE)
This code is entered in cell A2 with the value of a product type (ie Poison) entered into cel A1.
... Note that I have added 3 extra spaces between the quotes that i used to define the cell to make it a bit easier to read. You will need to take these out before it will work.
Also the following works
=SQL.REQUEST("DSN=CLASP;UID=sa;PWD=;Database=CLASP",,,"Select Kkey from dbo.VA where VAF1 = ' "&A1&" ' or VAF1 = ' "&B1&" ' ",FALSE)
Cells A1 and B1 contain different product types
(I found that the cells definition do not need the $ signs)
It only returns a single field of a single record into the cell that contains the formula.
What I want is the code to return all product records (going down the worksheet) within the same product type (VAF1) and multiple fields as selected of each product record (ie. KKey, VAF2, VAF3, VAF4, etc.) starting in cell A2 to "Whatever".
|
|
|
|
|