Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Just tested a similar string using PostgreSQL and had no problem so it appears it's the construction of your SELECT string. It should be:

sSQL="Select ""strSupplier"", ""serItemId"" FROM ""tblStockItems"" WHERE ""strSupplier"" = 'Penn State' ORDER BY ""strSupplierPartNumber"""

Since you're creating a string and field and table names need to be quoted when using lowercase or spaces, you need extra set around each. If you had used all uppercase for these, you wouldn't need any quotes around them making things easier.

Then run your query using "sSQL" (or whatever variable you are using).

Just tested a similar string using PostgreSQL and had no problem so it appears it's the construction of your SELECT string. It should be:

sSQL="Select ""strSupplier"", ""serItemId"" FROM ""tblStockItems"" WHERE ""strSupplier"" = 'Penn State' ORDER BY ""strSupplierPartNumber"""

Since you're creating a string and field and table names need to be quoted when using lowercase or spaces, you need extra set around each. If you had used all uppercase for these, you wouldn't need any quotes around them making things easier.

Then run your query using "sSQL" (or whatever variable you are using).

Edit: Sample code used:

Sub MainSQL
    oForm1 = ThisComponent.Drawpage.Forms.getByName("Form") 'Get Form
  oStatement = oForm1.ActiveConnection.createStatement() 'Create an SQL statement object
    sSQL = "Select ""type"" FROM ""playground"" WHERE ""color"" = 'yellow blue'"
    result = oStatement.executeQuery(sSQL)
    result.next
    myAnswer = result.getString(1)
    MsgBox myAnswer
    sSQL = "Select ""type"" FROM ""playground"" WHERE ""color"" = 'blue Yellow'"
    result = oStatement.executeQuery(sSQL)
    result.next
    myAnswer = result.getString(1)
    MsgBox myAnswer
End Sub