sql

How can I provide users with the functionality of the DBUnit DatabaseOperation methods from a web interface?

I am currently updating a java-based web application which allows database developers to create stored procedure regression test suites for database testing. Currently, for test setup, execution and clean-up stages, the user is provided with text boxes where they are able to enter SQL code which is executed by the isql command. I would...

mysql null to 0

SELECT * from book; how to convert NULL result to 0 from the sql ? ...

Simple PHP Crud Generator

I am looking for a simple PHP crud object generator to use with SQL database tables. I've used POG and was wondering if there were any alternatives. ...

Why does NVL always evaluate 2nd parameter

Does anyone know, why Oracle's NVL (and NVL2) function always evaluate the second parameter, even if the first parameter is not NULL? Simple test: CREATE FUNCTION nvl_test RETURN NUMBER AS BEGIN dbms_output.put_line('Called'); RETURN 1; END nvl_test; SELECT NVL( 0, nvl_test ) FROM dual returns 0, but also prints Called. nvl_tes...

SQL Server Query - Insert problem

I'm having a problem with an insert query in SQL Server. The full text of the query is insert into franchise (fran_id, name, address1, address2, city, state, zip, email, phone, text) values(0, "DevFranchise1", "101 Main St.", "-", "Brighton", "Mi", "48116", "[email protected]", 8105551234, "asdflkjsadf"); Now "state" and "text...

get list of products in stock at any given date

I have two tables: one holding products and one holding related inventory moves. Product table: Seq | Name | Barcode Move table: Seq | ProductFK | Direction | Date Each product can have multiple IN and/or OUT move records. How can I get a list of all product that are in stock at any given date? I tried the following but t...

Better for SQL Query performance to use an actual denormalized table with indexes rather than an indexed view?

In order to improve the performance of a query I have created a denormalized indexed view that contains some of the information I need to report on. When I didn't get the performance gains that I had hoped for I created a table version of my view with indexes and got significantly better performance. I should note that when I create ...

Messy sql problem

Table A stores data in rows like id, value1, value2 where id is always an even number. Table B stores this data in the form id, value1 id-1, value2 or else id, value1+value2 I need to do a once-off update of table B with the values taken from table A. Are there any elegant ways of doing this? Clarification : To answer N...

Using derived expressions in MySQL views

The examples here show a very simplified version of a VIEW that I am constructing in MySQL. The goal here is to create a view from which I can select a single set of results to be populated into a HTML table. The purpose of me using a view is, in part, to show calculations over this data as columns in the view. I can do this easily by g...

Postgresql - Using subqueries with alter sequence expressions

My question is kind of simple. Is it possible to use subqueries within alter expressions in PostgreSQL? I want to alter a sequence value based on a primary key column value. I tried using the following expression, but it wouldn't execute. alter sequence public.sequenceX restart with (select max(table_id)+1 from table) Thanks in ...

Drop User from SQL Server Database?

How can I drop user from a database without dropping it's logging? The script should check if the user exists in database, if does then drop the user. ...

SQL Indexed Views : what happens if data has changed

Hi. I undestand what indexed view are but i wonder what exactly happens when the data in underlaying table(s) has been changed? Is entire view cache discarded od just changed rows? I have very complex query on several tables(+5) which is used for searching hotels availability(+100k records) and IMHO indexed view could improves performan...

Update table column with the columns default value

System.Data.SqlClient.SqlConnection dataConnection = new SqlConnection(); dataConnection.ConnectionString = ConfigurationManager.ConnectionStrings["DBConnectionString"].ConnectionString; System.Data.SqlClient.SqlCommand dataCommand = new SqlCommand(); dataCommand.Connection = dataConnection; long MachineGroupID = Convert.ToInt64(Reques...

Database model for semi-structured Data

I'm looking for a little advice on how to setup a database to hold numeric data for a modeling application. My users have a spreadsheet that holds data for use in a modeling application. The data is structured as such: Each tab is a line of business, columns are years and rows are elements. The cells are standard decimal numbers xx.xx...

How to implement the greater than or equal SQL statement in iBatis?

Let's say in my sql statement I want to do: WHERE numberOfCookies >= 10 How do I do this in iBatis? ...

SQL Query Solution - Day By Day Balance

Hello, Every one. first of all, let me explain the table structure. It is as follows. Main Table - CategoryGroup Fields - CatGroupID, GroupName, GroupType Sample Data CatGroupID | GroupName | GroupType 1 | Utility | Expense 2 | Auto | Expense 3 | Misc. | Expense 4 ...

SQL Replacement via table

Mysql question: I've got a table A with a column full of sentences. I've got another table B with two columns: words and abbreviations. I want to look through table A's column sentences and if a word from table B's word column matches then replace it with abbreviation. Hope that is clear. Case doesn't matter, I can deal with that. ...

Get column name of property mapped with Hibernate

How can I access the Hibernate mapping of my model to find out the column name of a property? The column name is not specified in the mapping so Hibernate generates it automatically - I would like to create a native SQL statement including this column name. ...

MySQL: ORDER BY stat / age?

I have an int field in my product table called product_stat which is incremented everytime a product is looked at. I also have a date field called product_date_added. In order to figure out the average visits per day a product gets, you need to calculate how many days the product has existed by using the current date and the date the p...

Rotate table DB2 SQL

I have a small table, one row, three columns. I need it to be one column three rows. Thanks, Buzkie ...