Jim Klocksin
asked on
SQL Server query returning -1 with sqldbcode 4104
I've recently added a new query to my PowerBuilder 12.1 application which has existed (in one form or another) for over 15 years now. This is a very simple SELECT query against a very simple database table and is similar to literally hundreds of other query statements in this application. For some reason (and this is something I've never encountered before) this specific query is returning with an SQLCODE value of -1, SQLDBCODE value of 4104 and the following text:
SQLSTATE = 42S22
Microsoft SQL Server Native Client 10.0
The multi-part identifier "struct_key.etss_comp" could not be bound.
I've tried changing the field name a number of times, but the result is still the same. The only thing special about this query is that it's always the FIRST database query in the application, since I'm planning on using the results to potentially "kick-off" another application based on the values in the fields returned by this query -OR- just continue with the application which will be the case 99.9% of the time. Problem is, in order to do what I'm looking to do, I need the results from this query. Note: Running the query in SQL Server Management Studio with hard-coded values in the WHERE clause works fine!? I'm hoping one of you SQL Server gurus have run into this before and there's a simple solution. If you need any additional information, please let me know.
SQLSTATE = 42S22
Microsoft SQL Server Native Client 10.0
The multi-part identifier "struct_key.etss_comp" could not be bound.
I've tried changing the field name a number of times, but the result is still the same. The only thing special about this query is that it's always the FIRST database query in the application, since I'm planning on using the results to potentially "kick-off" another application based on the values in the fields returned by this query -OR- just continue with the application which will be the case 99.9% of the time. Problem is, in order to do what I'm looking to do, I need the results from this query. Note: Running the query in SQL Server Management Studio with hard-coded values in the WHERE clause works fine!? I'm hoping one of you SQL Server gurus have run into this before and there's a simple solution. If you need any additional information, please let me know.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
This turned out to be a "really, really" dumb coding mistake. I want to give you credit, though, for the solution, since your first statement got me thinking and made me realize what the problem was (when you said "The error message indicates that SQL does not know what struct_key is.". My problem (typical to programming I suppose, but I should have picked up on it) was a missing colon (:). It should have been ":struct_key" not "struct_key". Once I added the colon, I knew it was going to work and it did. I do thank you for pointing me in the right direction!!!
Kudos. Well keep that tracing feature in mind too, that has come in very handy when developing PowerBuilder stuff.
If you can extract and show us a DDL SQL table creation script for "struct_key" that gives us column names and datatypes (without exposing any data) we can compare that against the DML SQL to see where the mismatch happens.