The following code is from a released version of an application using framework version 1 and Oracle 9i.
strSQL = "SELECT COURSE_CODE AS CODE FROM COURSE_REVISIONS WHERE DOC_REF_CODE = '" & doc_ref_prevcode & "'"
objDataset = stkDataAssistant.getTable(strSQL)
course_code = objDataset.Tables(0).Rows(0)("Course_Code").ToString
Response.Redirect("../Courses/CourseRevisionNew.aspx?flag=add&course_code=" & course_code)
It is throwing an error on the following line:
course_code = objDataset.Tables(0).Rows(0)("Course_Code").ToString
It is known that there is an error in the sql string with the alias CODE. This issue was being ignored in the clients environment and was working until a month ago that is now throwing an error in the stated line above.
Is this error showing up now because of some sort of framework change? Or is it with Oracle?
The client states that there has been updates to the server where the database resides but the application was still working as expected. The error started showing up 3 months later and there has no changes done to either the database or application environment.
Oracle 9i has been out of support for many, many years. However you have to work with what you have, try this:
SELECT "COURSE_REVISIONS"."COURSE_CODE"
FROM "COURSE_REVISIONS"
WHERE "COURSE_REVISIONS"."DOC_REF_CODE" = 'QDMSPROD';
Or you could make a view with the alias that you want and select from that.
Related
I recently added a maven dependency to a Dropwizard project:
<dependency>
<groupId>com.amazon.redshift</groupId>
<artifactId>redshift-jdbc42-no-awssdk</artifactId>
<version>1.2.45.1069</version>
</dependency>
which is replacing the org.postgresql.Driver previously used, and since then some of my queries are returning
! Causing: org.skife.jdbi.v2.exceptions.UnableToCreateStatementException: java.sql.SQLException: [Amazon](500310) Invalid operation: failed to find conversion function from "unknown" to integer;
I suspect I might have dozens of queries that will need adapting to work with the new driver.
Because I don't want to have to restart my server every time I want to test whether a change to a query fixes the problem, I want to run the queries manually against the Redshift DB, so that I can quickly identify the part of the query that needs fixing.
My problem: I cannot reproduce the error when running the query manually from inside an IntelliJ DB Console. I even downloaded the JAR of the Amazon Redshift Driver from https://docs.aws.amazon.com/redshift/latest/mgmt/configure-jdbc-connection.html (I downloaded this one: https://s3.amazonaws.com/redshift-downloads/drivers/jdbc/1.2.45.1069/RedshiftJDBC42-no-awssdk-1.2.45.1069.jar) and used it to set up a new DB connection in IntelliJ. But still, running the exact same query manually from the IntelliJ DB Console won't give me the error.
Can anyone think of what configuration might be causing the query to give an error when run by the server compared to running it manually from the Console ? And how to get it to either stop throwing the exception on the server or start causing the same error when run in a Console ?
I'm assuming the issue lies somewhere between JDBI and the Amazon Redshift Driver. In any case, here's a fix that solved the problem for now:
For a query like this:
//language=PostgreSQL
public static final String MY_QUERY = "" +
"WITH my_table(someid, groupname) AS (\n" +
" SELECT :someId, :groupName\n" +
")\n" +
"SELECT 'something'\n" +
"FROM my_table mt\n" +
"FULL OUTER JOIN another_table at ON at.accountid = mt.someid AND at.groupname = mt.groupname";
Adding \\:\\:int got rid of the error:
//language=PostgreSQL
public static final String MY_QUERY = "" +
"WITH my_table(someid, groupname) AS (\n" +
" SELECT :someId\\:\\:int, :groupName\\:\\:text\n" +
")\n" +
"SELECT 'something'\n" +
"FROM my_table mt\n" +
"FULL OUTER JOIN another_table at ON at.accountid = mt.someid AND at.groupname = mt.groupname";
I'm using the Access Database Engine Redistributable to read an Access database in my .net application and for some reason whenever I use a join to query data from the access database to fill a datatable it causes a fatal communications error with the Windows Process Activation Service. I can populate datatables without issue as long as there is only one table. As soon as I add just one join, I get the system error. There are no errors in my application to trap, the system error occurs and then the application stops processing. This is only happening on one server. My local computer doesn't seem to have this issue. I'm using the exact same redistributable on my local computer and the server. Two things boggle my thinking why does a join cause an issue and why does it cause a system error and doesn't push it up to the app? If I'm using a single table query, it works fine.
Steps to populate datatable:
accessConnection = New
System.Data.OleDb.OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0; Data Source='" &
uploadedFileName & " '; Persist Security Info=False;")
accessDataAdapter = New System.Data.OleDb.OleDbDataAdapter("select * from Table1 INNER JOIN
Table2 ON Table1.PK = Table2.PK", accessConnection)
accessDtSet = New System.Data.DataSet
accessDataAdapter.Fill(accessDtSet) - Application fails here
accessView = accessDtSet.Tables("Locations").DefaultView
This is just a guess but maybe try the following provider in your connection string:
Provider=Microsoft.Jet.OLEDB.4.0
Good day!
I get this error:
SQL STATE 37000 [Microsoft][ODBC Microsoft Access Driver] Syntax Error
or Access Violation, when trying to run an embedded SQL statement on
Powerscript.
I am using MsSQL Server 2008 and PowerBuilder 10.5, the OS is Windows 7. I was able to determine one of the queries that is causing the problem:
SELECT top 1 CONVERT(DATETIME,:ls_datetime)
into :ldtme_datetime
from employee_information
USING SQLCA;
if SQLCA.SQLCODE = -1 then
Messagebox('SQL ERROR',SQLCA.SQLERRTEXT)
return -1
end if
I was able to come up with a solution to this by just using the datetime() function of PowerBuilder. But there are other parts of the program that is causing this and I am having a hard time in identifying which part of the program causes this. I find this very weird because I am running the same scripts here in my dev-pc with no problems at all, but when trying to run the program on my client's workstation I am getting this error. I haven't found any differences in the workstation and my dev-pc. I also tried following the instructions here, but the problem still occurs.
UPDATE: I was able to identify the other script that is causing the problem:
/////////////////////////////////////////////////////////////////////////////
// f_datediff
// Computes the time difference (in number of minutes) between adtme_datefrom and adtme_dateto
////////////////////////////
decimal ld_time_diff
SELECT top 1 DATEDIFF(MINUTE,:adtme_datefrom,:adtme_dateto)
into :ld_time_diff
FROM EMPLOYEE_INFORMATION
USING SQLCA;
if SQLCA.SQLCODE = -1 then
Messagebox('SQL ERROR',SQLCA.SQLERRTEXT)
return -1
end if
return ld_time_diff
Seems like passing datetime variables causes the error above. Other scripts are working fine.
Create a transaction user object inherited trom transaction.
Put logic in the sqlpreview of your object to capture and log the sql statement being sent to the db.
Instantiate it, connect to the db, and use it in your embedded sql.
Assuming the user gets the error you can then check what was being sent to the db and go from there.
The error in your first statement should be the second parameter to CONVERT function.
It's type is not a string, it's type is an valid expression
https://learn.microsoft.com/en-us/sql/t-sql/functions/cast-and-convert-transact-sql
So I would expect that your
CONVERT(DATETIME,:ls_datetime)
would evaluate to
CONVERT(DATETIME, 'ls_datetime')
but it should be
CONVERT(DATETIME, DateTimeColumn)
The error in your second statement could be that you're providing an wrong datetime format.
So please check if your error still occurs when you use this function
https://learn.microsoft.com/en-us/sql/t-sql/statements/set-dateformat-transact-sql
with the correct datetime format you're using
Following code works on my pc but gives error on other pc's. how is it possible to run this successfully on all machines.
QSqlQuery query;
QString queryString = "SELECT * FROM " + parameter3->toAscii() + " WHERE " + parameter1->toAscii() + " = \"" + parameter2->toAscii() + "\"";
bool retX = query.exec(queryString);
What pre requisite should be fulfilled for this to run on any pc
In troubleshooting, if you isolate your query and it returns the result you anticipated ( such as you have done utilizing qt creator to verify the query returns a result of true), the next step would be to take a close look at your code and verify that you are passing the proper parameters into the query for execution.
I have a virgin machine I utilize for this purpose. I am a software engineer by trade and I am fully aware that i have a ton of software installed on my PC which the common user may/will not have installed. So the virgin allows me to test the code in stand-alone form.
I suggest implementing a message box prior to the execution of your query which shows the query to be executed. This will verify the query is correct on the "other machines".
Certain dll's were needed. in my case qtguid4.dll, qtcored4.dll and qtsqld4.dll. There was a size difference. Once matched it worked on a pc. However, on other pc's i still get an error "The application failed to initialize 0xc000007b ....."
How is it possible to make an application run.
Brgds,
kNish
I'm encountering a hang when the program tries to access the fruit database. I've already enabled network access MSDTC on both my development computer and the SQL Server server.
Code:
(pardon the code coloring...SO's misinterpreting my VB .NET)
Using ts As New TransactionScope
Dim fruit As New FruitDataContext
Dim thingies As New ThingiesDataContext
If (From f In fruit.tblApples Where f.Rotten = "Yes" AndAlso f.batch = 1).Count >= 1 Then
'Record today's date as the day that the rotten apples were dumped.
End If
'Other complicated code that uses ThingiesDataContext and FruitDataContext
du.SubmitChanges()
ts.Complete()
End Using
Edit:
I've dug around a bit more and it turns out that the problem lies in the line of LINQ. When I tried to view it with the LINQ to SQL Visualizer, I get the following error:
System.InvalidCastException: Specified cast is not valid.
at LinqToSqlQueryVisualizer.SqlQueryInfo.deserialize(Stream stream)
at LinqToSqlQueryVisualizer.Visualizer.Display(IDialogVisualizerService windowService, Stream rawStream)
at LinqToSqlQueryVisualizer.DialogChooser.Show(IDialogVisualizerService windowService, IVisualizerObjectProvider objectProvider)
at Microsoft.VisualStudio.DebuggerVisualizers.DebugViewerShim.ManagedShim.DelegatedHost.CreateViewer(IntPtr hwnd, HostServicesHelper hsh, SafeProxyWrapper proxy)
I've also edited the LINQ statement to be closer to my real code.
Final edit:
I tried using a normal SqlConnection instead of a "thingies as New ThingiesDataContext" and the problem still occurs.
It appears that TransactionScope cannot handle multiple SQL connections inside the same transaction.
Official Microsoft Note
parallel transactions are not supported by SQL Server.
From MSDN: http://msdn.microsoft.com/en-us/library/bb896149.aspx
This is not an MSDTC issue. If it were, you would get an error saying DTC is not enabled and needs to be. It's also not a deadlock issue, because you would get a specific error about that as well.
If I had to guess, I would say that the 'Other complicated code...' is attempting to perform a database operation and is being blocked by one or the other database context objects.
One way you can determine this is to run SQL Profiler to see what SQL statements are actually being executed on the server, and check for blocks.