Oracle PSQL getting reason of error in a with as expression - oracle

I have a more thousand lines "with as" sql. When I try to run it I've got a message:
"Expression must have same datatype as corresponding expression", but I cannot get any info where is it and which field is not the same type. In a normal sql I can get it, but in with as I cannot. Yes I know "with as" is not the best practice, but I have to port an old sql to a new environment.
Is there any trick to get where is it?

Related

Oracle command gives error while inserting - C#

I'm executing a regular Oracle insert query, I don't know why this error happens, any clue?
Insert query is a bit complicated, can't paste it here
is ParamInfo893e67a5-d0ab-4489-b8b3-4f5b05dbdb3d mean that the issue is because of Guide?
System.ArgumentOutOfRangeException: Specified argument was out of the range of valid values.
at Oracle.ManagedDataAccess.Client.OracleParameter.set_Size(Int32 value)
at ParamInfo893e67a5-d0ab-4489-b8b3-4f5b05dbdb3d(IDbCommand , Object )

UCanAccess allows ambigious column names

It appears that UCanAccess does not complain when a column name appearing in the SELECT clause, WHERE clause, etc. is ambiguous. Instead, it seems that the first table in the FROM clause that has a column with that name is used. This is a very dangerous behaviour that most other database engines reject. For example Access will respond with an error message "The Specified field 'something' could refer to more than one table listed in the FROM clause of your SQL statement". Similarly SQL Server would complain with the message "Ambiguous column name 'something'". MySQL complains with the message "Column 'something' in field list is ambiguous". DB2 responds "‪A‬‎ ‪reference‬‎ ‪to‬‎ ‪column‬‎ ‪‬‎"‪something"‬‎ ‪is‬‎ ‪ambiguous‬‎". And Oracle responds "column ambiguously defined".
Is it possible to fix this in UCanAccess? Is there a way to configure this behaviour?

BizTalk WCF-Custom" raised an error ORA-29275: partial multibyte character

I have an interface which is a simple receiveport mapping sendport. The receiveport is the result of an add generated items query. The query just fetches some adres data from the database. This data does contain 'foreign' letters but when i run the query on Oracle SQL Developer, it works fine (gives me 12800 rows).
When BizTalk runs the query, it gives an ORA, which i assumed was an error the db gives to BizTalk am i wrong?
Where do i actually have to fix this problem? and How? Do i need to find out which character set is used on the database and use a convert in the query?
This is an error coming from Oracle - it's very unlikely that it's due to BizTalk or the WCF adapter. It indicates you have some corrupt data in your Oracle DB. You may not be getting the error in SQL Developer because SQL Developer is only returning the first ~50 rows by default (until you actually scroll down past them).
I'd use a strategy like this: http://vibhork.blogspot.com/2011/02/fix-of-ora-29275-partial-multibyte.html to try to find the bad data (e.g. page through the rows using ROWNUM until you find the row that's in error) - you could simulate that in SQL Developer by just scrolling down until you get the error (I think). If you can fix the data, fix it - if the data was put there by another source, you'll either have to get that source to stop putting invalid characters in there or you'll have to convert/concat the column(s) that is (are) causing problems, like:
SELECT problem_column || '' FROM table
or
SELECT CONVERT(COLUMN NAME,'NLS_CHARACTERSET','NLS_CHARACTERSET') FROM table
You might try SELECT CONVERT(COLUMN NAME, 'UTF8', 'US7ASCII') for example.

ORA-01438 Issue while performing dup search

I am a developer with SQL Server experience. We have one legacy application which uses SQR and Oracle to perform a weekly duplicate record search. We got an error while performing this search after 14 years. It says 'ORA-01438: value larger than specified precision allows for this column'. When I googled that error, I found out that it is related to a numeric field and the value passed is larger than it can hold. I can increase the size but don't know for which one. Since no one supports Oracle here, I am trying to trouble shoot this error and found people using
alter system set events='1438 trace name Errorstack forever,level 10';
I would like to know if this is the right way to find out which sql is failing?
Also what does it alter and what is level 10? Anything that I should consider before running this query in production? Is there something I need to roll back after performing this query? I was told that if I do SQL> insert into test values (100000000000000000,'test','test'); where 10000000000000000 is invalid then it will throw generic Oracle message ORA-01438. But in the trace file, it would show ORA-01438: value larger than specified precision allowed for this column. So, where would the trace file be generated?
Current SQL statement for this session:
insert into test values (100000000000000000,'test','test').
Please let me know if I am not in the right path.
Use DBMS_MONITOR to enabling trace for the session affected. This will contain all SQL and errors and bind variables, if you enable it.

How to resolve SQL query parameters mapping issues while using Oracle OLE DB provider?

When trying to enter a SQL query with parameters using the Oracle OLE DB provider I get the following error:
Parameters cannot be extracted from the SQL command. The provider might not help to parse parameter information from the command. In that case, use the "SQL command from variable" access mode, in which the entire SQL command is stored in a variable.
ADDITIONAL INFORMATION:
Provider cannot derive parameter information and SetParameterInfo has not been called. (Microsoft OLE DB Provider for Oracle)
I have tried following the suggestion here but don't quite understand what is required:Parameterized queries against Oracle
Any ideas?
To expand on the link given in the question:
Create a package variable
Double click on the package variable name. (This allows you to access the properties of the variable)
Set the property 'EvaluateAsExpression' to true
Enter the query in the expression builder.
Set the OLE DB source query to SQL Command from Variable
The expression builder can dynamically create expressions using variable to create 'parametised queries'.
So the following 'normal' query:
select * from book where book.BOOK_ID = ?
Can be written in the expression builder as:
"select * from book where book.BOOK_ID = " + #[User::BookID]
You can then do null handling and data conversion using the expression builder.
If You use Data Flow Task and use OLE DB Source, and you need parameterize your Query :
Create Variable to save "Full" of Query statement : Right Click on blank area outside the package - and Click Variables :
Click Add Variables on Variables Window :
Make the name is SQL_DTFLOW_FULL or something that can you understand easily. The variable data type is STRING
Create Variable(s) to save your parameter(s).
i.e, the full of Query stamements is :
SELECT * FROM BOOK WHERE BOOK_ID = #BookID --#BookID is SQL Parameter
at the sample above, I have just one parameter : #BookID, so I need to create one variable to save my parameter. Add more variables depends on your Queries.
Give it name SQL_DTFLOW_BOOKID
The variable data type is STRING
So, you need make your SSIS neat, and the variables is sorted in understandable parts.
Try to make the variable name is SQL_{TASK NAME}_{VariableName}
Make Expression for SQL_DTFLOW_FULL variable, click on number 1, and start fill number 2. Make Your SQL Statements to be a correct SQL Statement using string block. String block usually using "Double Quote" at the beginning and the end. Concat the variables with the string block.
Click evaluate Expression, to showing result, to make sure your query is correct, copy-paste the Query result at SSMS.
Make sure by yourself that the variables is free from SQL Injection using your own logic. (Use your developer instinct)
Open the Data Flow Task, open the OLE DB Source Editor by double click the item.
Select the Data Access Mode : SQL Command From Variable
Select the Variable Name : SQL_DTFLOW_FULL
Click Preview to make sure it works.
That is all, my way to prevent this SSIS failure case. Since I use this way, I never got that problem, you know, SSIS something is weird.
To change the variable value, set it before Data Flow Task, the SQL Result of SQL_DTFLOW_FULL variable will changed every you change your variable value.
In my case the issue was that i had comments within the sql in the normal form of /* */ and i also had column aliases as "Column name" instead of [Column Name].
Once i removed them it works.
Also try to have your parameter ? statement within the WHERE clause and not within the JOINS, that was part of the issue too.

Resources