I have a SQL CE database that has just been created. It has 3 tables in it. One table gets an error when trying to edit data inside Web Developer, but the other two work fine. I have no idea what is wrong.
All works when edited inside WebMatrix.
Error:
Table schema:
I kind of can't believe this, but it looks like a bug in Visual Studio. You're getting the error at character 103 because that's where the 'Cast' column is added to the SQL statement - 'Cast' is a reserved keyword in SQL syntax.
Generally to get around that, you would use the bracket syntax to clarify your intent:
SELECT SKU, Title, Description, OFLC, Collection, Price, Distributor, Format, RunningTime, Discs, [Cast], ImageSmall, ImageMedium, ImageLarge From Titles
But for some reason, VS strips out the brackets! I'll keep looking for an answer to the bug (interesting problem), but in general you want to avoid naming columns reserved keywords :-)
http://msdn.microsoft.com/en-us/library/aa226054(v=SQL.80).aspx
Happy Coding!
Related
data source adapter error: java.sql.SQLSyntaxErrorException: ORA-01795: maximum number of expressions in a list is 1000
I am getting this error in cognos.Basically I am working on report enhancement in cognos.I already have searched for solution on internet but provided solution is for oracle, i want solution to be in cognos as i am unable to access database or framework manager. Please let me know what should be the right approch to resolve that error.
enter image description here
I already have searched for solution on internet but provided solution is for oracle. I want the solution to be in cognos as i am unable to access database or framework manager.
Error you got is indeed raised by Oracle, but the question is whether it should be fixed in Oracle or elsewhere (Cognos?).
Generally speaking, this is what happened:
select whatever from some_table
where id in (1, 2, 3) --> this is the IN clause. In Oracle, it is limited
to 1000 elements
I guess that nobody literally types 1000+ elements into the IN list, but some dynamic piece of code might, concatenating value after value until you reach and pass the limit.
I don't know Cognos, but - if that's what really happens, a simple and effective option is to store values which are being used in IN list into a table, and then either JOIN that table to other table(s), or use it as a subquery.
For example:
select whatever from some_table
where id in (select id from a_new_table)
or
select whatever
from some_table a join a_new_table b on a.id = b.id
Presumably the filter is coming from a prompt and someone is selecting everything in the list in the prompt or close to it.
It might be a good idea to try to figure out why there are so many things being chosen. This would require investigation about the business purpose of the prompt.
It might be that our someone needs to see everything so the prompt should be set as optional, which would not generate the where predicate in the SQL.
It might be that the prompt needs to be generated on an attribute (column) which is at a higher grain of dimensional abstraction (i.e. countries rather than cities).
Simply being told fix it in Cognos is not a very helpful instruction and you need to approach the problem with a better understanding of the purpose of the report.
Basically I have a region (can be classic report, or any other types), which content is sourced from a SQL where column names and table names are page items that can be changed, like below
select :p1_column1, :p1_column2 from :p1_table;
I understand this is not a good practice, but is this doable? Thanks a lot.
Instead of binds, they become substitutions, ie
select &P1_COLUMN1., &P2_COLUMN1., etc
but yeah, in terms of bad practice, you're probably going to get hacked and lose all of your data.
Cest la vie :-)
I have a requirement where 300 columns had to be processed. I am trying to achieve this using IG automatic row processing (DML). When writing the code in the editor I get a error stating 'Value too long by 2015 characters'.
I suppose this is an Oracle Apex limitation. Can someone please share their views on this?
When writing the code in the editor ...
I'd say that your problem isn't related to number of columns, but a large query which can't fit into "SQL Query" item of the Page Designer.
Which Apex version do you use? I can't tell for sure (as I don't know it), but my impression is that Apex up to version 4.2 had that item limited to VARCHAR2(4000) so - if your query is larger than that, it won't fit (such as in your case - query you wrote is 2015 characters longer than the maximum size the item allows). In 5.x version, you can put a whole lot of query into the item (as if it was modified to a CLOB).
Now, as you use Interactive Grid and it appeared in 5.x version, huh ... maybe what I wrote above isn't entirely true. Unfortunately, you can't switch to a query whose source is a function that returns query (such as in Classic Reports), as you could write a (stored) function and simply call it from Apex.
As you said that you used automatic row processing, did you put too much code somewhere in there?
On the other hand, I Googled a little bit, looking for limit of column numbers in the IG - couldn't find anything official, but someone complained (here, on StackOveflow) that they tried to create an IG with over 100 columns, and it didn't work.
So, yes - maybe you hit the limit, but I can't confirm it. Hopefully, someone who knows Apex better will be able to assist. Alternatively, consider asking the same question on OTN forums, as people who designed Apex answer questions there.
We have a database with some fields that are varchar(max) which could contain lots of text however I have a situation where I only want to select the first for example 300 characters from the field for a paginated table of results on a MVC web site for a "preview" of the field.
for a simplified example query where I want to get all locations to display in the table
(this would be paginated, so I don't just get everything - I get maybe 10 results at a time):
return db.locations;
However this gives me a location object with all the fields containing the massive amounts of text which is very time consuming to execute.
So what I resorted to before was using SQL stored procedures with the:
LEFT(field, 300)
to resolve this issue and then in the Linq to SQL .dbml file included the stored procedure to return a "location" object for the result.
However I have many queries and I don't want to have to do this for every query.
This maybe a simple solution, but I am not sure how I can phrase this on a search engine, I would appreciate anyone who can help me with this problem.
You can use functions that directly translate to those functions too, this is useful when you need to translate code that functionally works just fine in SQL at no risk in LINQ.
Have a look at System.Data.Objects.EntityFunctions
Locations.Select(loc=>System.Data.Objects.EntityFunctions.Left(loc.Field,300))
This will get directly translated into a LEFT on the server side.
EDIT: I misread LEFT for LTRIM. Here's all the String functions that can't be used in LINQ to SQL. Have you tried String.Substring()?
Your best option is to map the stored procedure and continue using it. Here is an excellent article with screen shots showing you how to do so.
If you're not using the designer tool you can also call ExecuteCommand against the DataContext. It isn't pretty, but it's what we have for now.
I found something like this worked for me:
return from locationPart in db.locations
select new LocationPart
{
Description = locationPart.description,
Text = locationPart.text.Substring(0,300)
};
Not ideal because I have to use "select new" to return a a different object, but it seems to work.
I currently have an existing database and I am using the LINQtoSQL generator tool to create the classes for me. The tool is working fine for this database and there are no errors with that tool.
When I run a LINQ to SQL query against the data, there is a row that has some invalid data somehow within the table and it is throwing a System.FormatException when it runs across this row. Does anyone know what that stems from? Does anyone know how I can narrow down the effecting column without adding them one by one to the select clause?
Do you have a varchar(1) that stores an empty string?
You need to change the type from char to string in the designer (or somehow prohibit empties). The .net char type cannot hold an empty string.