SQL Progress column not found - sql

I have this query:
SELECT spechist.item,image."image-path",image."image-item",image."image-source"
FROM PUB.spechist left outer join PUB.image on (image."image-item"=spechist.item)
WHERE (spechist."photocard-display"=yes) AND (spechist."rec-type"='I') and (spechist.item='111')
For some reason I get this error when i run the query:
error message
[MERANT][ODBC PROGRESS driver][PROGRESS]Column not found/specified (7520)
When I remove the following from the query it runs fine:
WHERE (spechist."photocard-display"=yes) AND (spechist."rec-type"='I') and (spechist.item='111')
I know for a fact those columns are in the table. What am I doing wrong?
Thanks

With out seeing your schema I can't tell for sure but here are some things to try.
Is the capitalization correct?
Do you need to use the full table name PUB.spechist
Does it work with any of those three restrictions in the where clause? Try adding them one at a time and see which one stops execution.

Related

Cannot view the SQL portion of a query in ACCESS?

I am currently working on a project of replacing our old access database queries, but on one of them I am not able to view the actual SQL View.
Does anyone know a way to force the view or to export it somehow?
Error causing problem:
The SQL statement could not be executed because it contains ambiguous outer joins.
Note that I can view the Design View without issue but when I right click on the tab and select SQL View is when I get the error.
I did attempt what #LeeMac mentioned below but same error occurs:
EDIT:
This question is not like Ambiguous Outer Joins?
The OP on that question can actually see and edit their SQL.
My issues is that I cannot see or edit the SQL as the SQL View wont open.
Try executing the following VBA code from the Immediate Window (accessible using Ctrl+G) in the VBA IDE (open the IDE using Alt+F11):
?CurrentDb.QueryDefs("YourQuery").SQL
Replace YourQuery with the name of your query.
This should print the SQL code which comprises your query - you can then analyse the SQL to determine the cause of the error.
It's odd this error would arise when merely viewing the SQL content of the query definition.
It makes me think that the query is perhaps referencing a crosstab subquery which is actually the cause of the error, but which needs to be evaluated in order for MS Access to determine the columns available when viewing the design of the query in question.
Try this:
hit ctrl-g, and from immediate window type in this:
saveastext acQuery,"Name of query","c:\test\mysql.txt"
Access ordinarily doesn't allow you to save invalid queries, so it's strange you somehow got into this situation in the first place.
If you can copy the query, you can easily get to the SQL by changing the query to a passthrough query, either through the GUI or through VBA:
Dim q As DAO.QueryDef
Set q = CurrentDb.QueryDefs!Query1
q.Connect = "ODBC;"
Debug.Print q.SQL
Passthrough queries are not validated, so you can freely read and write anything you want as SQL in it.
Note that this is irreversible when done through VBA. You can only change it back to a normal query once you made the SQL valid again. If you do it through the GUI, you can just not save it, though.
I had this problem and the issue was that i had a subquery that calculated fields but did not actually have a table in it. for example it would calculate first and last day of last month which is 2 calculated fields, then it was the first query in a series of queries that were built off it and the last one wouldnt resolve sql as original poster indicated also gave the ambiguous join message as well as query needs input table (which was that first subquery). i put a table with 1 record in it but didnt use the record and it worked.... so it just a needs a table in it.

how to debug "sql subquery returns more than 1 row" error

We have a huge SQL script involving tens of tables, subqueries, hundreds of attributes. It works perfectly in the test database but returns sql subquery returns more than 1 row error when running in the production database. The script was working perfectly up until now. The problem is, all I get is a one-line error specified above with no clues whatsoever which exact subquery causes the error which makes it near to impossible to debug. The question is, how am I supposed to know which line of the SQL causes the error? Is there any way to "debug" it line by line like you would do it in a programming language?
I am using TOAD with Oracle 11g.
Add print or DBMS_OUTPUT.PUT_LINE commands to your script to print messages. And/or use exception handlers in the script. Possibly add some variables that count or label which statement you are at, and output that in the exception handler.
http://docs.oracle.com/cd/E11882_01/appdev.112/e25519/errors.htm
Once you have found the query that causes the problem, convert it to a similar query with an appropriate group by and having count(*) > 1 so that you can see what data caused the problem. For instance if you have a correlated subquery that looks like:
(select name from names where id=foo.id)
then write a similar query
select id from names group by id having count(*) > 1
to identify the offending data.
If you have multiple subqueries in the query that produces the error, you could temporarily convert the subqueries to use temporary tables and search them all for duplicates.

Does using regular expressions in a SQL Select statement change real data?

select orderid from orders where REGEXP_REPLACE(orderid,'/^0+(.)/')
I have searched the documentation and am missing it. If I run this query will it change any real data or just my set returned for output (the "virtual" data)? The word replace scares me. I am using oracle 11g.
Thank you.
Because you are performing a SELECT, you end up getting a read only view of the data, nothing has changed.
So you don't need to worry about running this select statement. The only way to update it would be to follow this up with an UPDATE command.
No, it doesn't. (even though this answer is too short for SO).

SQL Query in Hibernate

I'm carrying out a SQL query which looks like:
SELECT thi.*
FROM track_history_items thi
JOIN artists art
ON thi.artist_id = art.id
WHERE thi.type = TrackBroadcast
Group By art.name
ORDER thi.created_at DESC
This works fine when I run it directly on my database from MySql Workbench, but when I run in through Hibernate, I get a No Dialect mapping for JDBC type: -1 error.
Anyone have any ideas what could be causing it?
Probably one or more of the columns in the query is not supported by the mysql dialect... try expanding the * and add one column at a time until you find the offending one.
Then it is just a matter of deciding whether you need that column or not.

Ms-Access Query is getting deleted automatically. What can be the reason?

Some of the queries I have written inside MS-Access are getting deleted automatically. And while I run the queries through code, I get this error:
Query should have one destination field
What can be the possible reason?
Explanation: I created a query in MS-access. Ran it from the code. Closed the database. Started it again, and now for that particular query, it is showing 'SELECT ;'only.
Strange. I am in panic mode now
Check if your query actually has any fields in the query design grid. When you open the query in design view, you will most likely notice it doesn't.
Does the query stick around when you don't run the code (but still close and reopen the database)?
If so, I would suspect that something in your code is overwriting the query.