SQL prepare error

I'm trying to learn how To use SQL in CACHE, so I hope I don't bore you with "Dumb" questions.... 

I'm getting "ERROR #6022: Gateway failed" message following this line of code. 

s sc=gc.Prepare(hstmt,pQuery) 

This line of code comes from an example I found in the documentation.  pQuery is the "Select" statement setting up the variables and tables I'm trying to pull information from. 

What does that error indicate? 

Thank you. 

  • 0
  • 140
  • 4
  • 1

Answers

I'd bet my breakfast that your first line of code connects to a remote database, and that is failing.  Therefore, when you go to prepare your query, it is failing due to no connection.  Check the status code from your Connect() call and let us know what that says.

Comments

What's hstmt? You can call like this. SET sc= gc.%Prepare(pQuery)

changed group from "Community Feedback" to "Caché"

That looks like you are trying to connect using a %SQLGatewayConnection. Can you post the preceeding lines of code? 

If so, make sure the DSN exists and can connect. The statement is correct for the desired database and the odbc drivers are correct for your system. 

For reference, you can get a list of error codes from General Error Codes and SQL Error Codes .  From the error description, it seems to be complaining about the 1st parameter.

If the 'gc' object is a %SQL.Statement then the %Prepare method only takes one parameter. What happens when you pass in pQuery to the %Prepare method?

Have you tried executing the SQL in the SQL Shell or System Management Portal?

do $System.SQL.Shell()