I have a problem getting an inputed date (yyyyMMdd) from an HTML form to a sql database via a servlet. The date from the form passes to the servlet as a string but then somehow I need to convert it to date for storing in the database. I have tried a number of methods, date formatter etc.. A possible way
Display an array in a readable/hierarchical format
Here is the code for pulling the data for my array
INSERT with SELECT
I have a query that inserts using a SELECT statement: Is it possible to only select “name, location” for the insert, and set gid to something else in the query? Answer Yes, absolutely, but check your syntax. You can put a constant of the same type as gid in its place, not just 1, of course. And, I just made
Case insensitive searching in Oracle
The default behaviour of LIKE and the other comparison operators, = etc is case-sensitive. Is it possible make them case-insensitive? Answer Since 10gR2, Oracle allows to fine-tune the behaviour of string comparisons by setting the NLS_COMP and NLS_SORT session parameters: You can also create case insensitive indexes: This information was taken from Oracle case insensitive searches. The article mentions REGEXP_LIKE
Update statement using with clause
I have a script that uses a stack of with clauses to come up with some result, and then I want to write that result in a table. I just can’t get my head around it, could someone point me in the right direction? Here’s a simplified example that indicates what i want to do: The real thing has quite
How do I find maximum in a column without using MAX function?
I was asked this question by a friend. You are given a table with just one field which is an integer. Can you the highest value in the field without using the MAX function ? I think we can change the …
how to sort order of LEFT JOIN in SQL query?
OK I tried googling for an answer like crazy, but I couldn’t resolve this, so I hope someone will be able to help. Let’s say I have a table of users, very simple table: and I have another table of their cars and their prices. Now what I need to do is something like this (feel free to rewrite): Which
ADD_MONTHS function does not return the correct date in Oracle
See the results of below queries: >> SELECT ADD_MONTHS(TO_DATE(’30-MAR-11′,’DD-MON-RR’),-4) FROM DUAL; 30-NOV-10 >> SELECT ADD_MONTHS(TO_DATE(’30-NOV-10′,’DD-MON-RR’),4) FROM DUAL; 31-…
PostgreSQL: SQL script to get a list of all tables that have a particular column as foreign key
I’m using PostgreSQL and I’m trying to list all the tables that have a particular column from a table as a foreign-key/reference. Can this be done? I’m sure this information is stored somewhere in information_schema but I have no idea how to start querying it. Answer This uses the full catalog/schema/name triplet to identify a db table from all 3
Select 2 columns in one and combine them
Is it possible to select 2 columns in just one and combine them? Example: select something + somethingElse as onlyOneColumn from someTable Answer Yes, just like you did: If you queried the database, you would have gotten the right answer. What happens is you ask for an expression. A very simple expression is just a column name, a more complicated