sql

Best efficient data structure to store object in Android application

I want to build a data structure in my application to store many entries indexed by keys. Each entry has several parameters to retrieve and update. Could you suggest me which structure is most efficient among these following ones: hashmap SQL Lite hashtable others Thanks in advance. ...

PHP and MySQL: Store and print hex char

I'm trying to store an hexadecimal value (\xC1) in MySql Database. When I print that with PHP, i get: xC1lcool instead of the right word. INSERT INTO veiculos VALUES (1, 'Ford', 'Ka RoCam Flex', 25850.00, 1998, 1999, 'Vermelho', 15000, '\xC1lcool;Gasolina;GNV', 'Ar-Condicionado;4 portas;Câmbio automático', 'imagem1.jpg;imagem2.jpg;im...

Executing MySQL Query from PHP error

This part of my code creates a multiple query by this: $sql = ""; $sql .= "INSERT INTO projects (project_id, project_name, project_description, project_deadline, project_status, project_priority) VALUES ('" . $project_id . "', '" . $name . "', '" . $description . "', '" . $final_deadline . "', '" . $status . "', '" . $p...

How can i fetch recursive data from Bill of materials tables

Hi, This is in SQL Server 2008. I plan to create two tables to represent a Bill of material. The Item Master will have data as follows :- [ID] [Item Code] [Item Description] 1---- A001 ---- Assembly 1 2---- B001 ---- Sub Assembly 1 (Child of Assembly 1) 3---- B002 ---- Sub Assembly 2...

How to identify the caller of a Stored Procedure from within the Sproc

I have a depricated stored procedure which should no longer be called from code, but there is some system which is still calling it. This is a production server so I have very limited indirect access to it for performing diagnostics. Is there any way to determine the machine which is calling a particular stored procedure from within th...

Sorting results in sphinx?

Is there an easy way to sort sphinx results? Recently posted (by dates) Highest paid (highest value) ...

Is it possible to set mySQL to have a saturday as the start of the week?

Is it possible to set mySQL to have a saturday as the start of the week? I'm trying to run a query like: SELECT DISTINCT(week(`date`)) FROM `table` WHERE `date` BETWEEN '2010-08-14' AND '2010-08-27' But the week starts on a Saturday, not Sunday or Monday. (It's for a pay period week, not a regular week) It seems that the modes ...

No rows in MSDB.dbo.sysmail_faileditems

Initially I was getting a "no SELECT privilege" error when attempting to query contents for a report I need to create. So we granted DatabaseMailUserRole in MSDB to my account - I see columns, but none of the data we know to exist. What am I missing that needs to be done for my account to see the data? ...

Oracle Check Constraint Issue with to_date

So I'm new to Oracle, trying to create a table as follows: create table Movies ( Title varchar2 primary key, Rating NUMBER CONSTRAINT Rating_CHK CHECK (Rating BETWEEN 0 AND 10), Length NUMBER CONSTRAINT Length_CHK CHECK (Length > 0), ReleaseDate DATE CONSTRAINT RDATE_CHK CHECK (ReleaseDate > to_date('1/1/190...

How do I find the count of columns before the first occurrence of LIKE?

Sorted on column Y X Y Z ------------------------ | | A1 | | ------------------------ | | B2 | | ------------------------ | | C3 | | ------------------------ -----Page 1 | | D3 | | ------------------------ | | E4 | | ------------------------ | | ...

Delete all data in SQL Server database

How I can delete all records from all tables of my database? Can I do it with one SQL command or I need for one SQL command per one table? ...

select/display last inserted serial id in posgres

in sql server I do like this: insert into foo(name) values('bob') select @@identity; so I get a query/scalar result displayed how to this with postgres ? ...

Get column default values with ADO.NET

I want to get the default values of all columns of a table so I can display them in the data-entry form, is there a way to do this using ADO.NET ? I know I can query the information_schema database for this info, I'm just wondering if there's a built-in way to do this in ADO.NET ...

MySQL Sum one field based on a second 'common' field

Not a SQL guy, so i'm in a bind, so I'll keep this simple +--------------+------------------------+ | RepaymentDay | MonthlyRepaymentAmount | +--------------+------------------------+ | 3 | 0.214847 | | 26 | 0.219357 | | 24 | 0.224337 | | 5 | ...

iSeries JDBC Sql statement with "é" in column name throws java.sql.SQLException: [SQL0104]

I am having trouble using the character "é" in a returned column name from an SQL query. Running this query SELECT PRCAT as Categorie, PRYEA as Année, PRDSC as Designation from DEMO.PRODUCT using the IBM Toolbox JDBC driver connecting to an iSeries produces this exception: java.sql.SQLException: [SQL0104] Token é was not valid. Va...

Variable value assignment using RETURNING clause

I try to do this, but it's a syntax error, what am I doing wrong? declare myid := insert into oameni values(default,'lol') returning id; my table: create table oameni ( id serial primary key, name varhcar(10) ); ...

sp_executesql causing my query to be very slow

I am having some issues when running sp_executesql on a database table. I am using an ORM (NHibernate) that generates a SQL query that queries one table in this case. This table has about 7 million records in it and is highly indexed. When I run the query that the ORM spits out without the sp_executesql, it runs very quickly and pro...

insert script with serials in postgres

This is how I do this in sql server. insert into users(name) values('jhon'); set @id = @@identity; -- last serial insert into usersroles(@id, 1) insert into usersroles(@id, 2) insert into usersroles(@id, 3) How can I do the same in postgres (withouth creating a function)? ...

can connection string in SQL Server 2005 be taken from a file??

I have created a web enabled DB for a company as a part of my internship and it's up and ready. However the connection string of the server is already coded by me. But the IT guy said that he wanted me to read the connection string from a file containing various connection strings and choosing whichever it wanted to at that time. My que...

create a table from another and a literal

I'm working with sqlite and trying to create a table from another. This works: create table sources_tmp as select "literal" system,name,user from sources; but it doesn't allow me to specify the type for the "literal". I've tried this but doesn't work that way apparently: create table sources_tmp as select "literal" system as $TYPE,...