sql

SQLPlus removes trailing spaces in clob field on insert

Hi, I'm using SQL Plus 11.1.0.6.0 to run a script that performs batch inserts into an Oracle 10g db. The problem i noticed is when inserting some code string into a clob field that has some lines with trailing spaces such as: ....public void myMethod().... --trailing space here ....{ ........int myVar = 1; ........ -- empty line with t...

Complex Sql Query Help. Forming query in SQL

Hello, I am new to SQL and need to write a complex query. Can you please help? I have two tables. One is called PATIENTS and the other one is called CASES. PATIENTS has a "patient number" and a date entered. CASES has "patient number," "case no." and "date modified." The two tables are connected with the "patient number." There are mul...

Foreign Key constraint

Hi Two table are tied with each other because of FK constraint. I am trying to update these tables by disabling ALL Trigger but still getting the following error :- The UPDATE statement conflicted with the FOREIGN KEY constraint "FK_TEST_REFERRING_REFPHYSI". The conflict occurred in database "ccdb", table "dbo.RefPhysician", column 'R...

Name XML result column of TSQL "for xml explicit"?

I have a query that uses for xml explit to return XML result. select ... from ... order by [BatchType!1!TypeName], [FormType!2!TypeName], Tag, Parent for xml explicit, root('ClientImages') But the name of resultant column name is something as cryptic as Is there a way to change the column name? [ANSWER] I had a several nested ...

How to populate a single-dimension array with result of a query ?

I have to populate the result of a query into an array in my pl/sql proc. For example, I have a employeeId empArr (TYPE empArr IS TABLE OF NUMBER INDEX BY BINARY_INTEGER;) and i want to populate this array with the result of a sql statement : select empId where dept = 'accounts'. Is there a way to do this ? Or would you suggest...

Mysql SELECT help please

Hi. I have a querystring that contains a search string entered by the user. I want to search 2 fields in my table (description and headline) for the querystring.. Simply, I want to check both fields if any of the, OR BOTH, contains the querystring... I am using PHP by the way... SELECT * FROM db WHERE xxxxxxxxxxxxxxxxxxx? Tha...

What is causing "Subquery returned more than 1 value..." error?

Hi I dont have any idea why am i getting this error :- Subquery returned more than 1 value. This is not permitted when the subquery follows =, !=, <, <= , >, >= or when the subquery is used as an expression. The statement has been terminated. I was trying to run this query:- ALTER TABLE Test1 NOCHECK CONSTRAINT ALL ALTER TABLE Test2 ...

Database maintenance with SSIS or T-SQL?

Is there any benefit to using SSIS over T-SQL to check integrity, defrag/rebuild indexes, and backup databases? Doesn't SSIS break down its internal tasks and containers into basic T-SQL statements anyways? ...

mysql - user item ratings, 1 rating per user, updateable - table structure?

I'd like to give my users the ability to rate each item on the site from 1 to 5. They also must be able to go back and revise their rating for each item as they please. Lastly, the item's page will display the average-to-date of all user ratings when viewed. As for the PHP, I think I can handle that. What I'm struggling with is envision...

Introspect postgresql 8.3 to find foreign keys

I'm trying to introspect a postgres 8.3 database to retrieve details of its foreign keys. Imagine I have the following schema: CREATE TABLE "a" ( "id" SERIAL PRIMARY KEY ); CREATE TABLE "b" ( "one" integer, "two" integer, "a_id" integer REFERENCES "a", PRIMARY KEY ("one", "two") ); CREATE TABLE "c" ( "id" SERIAL PRIMARY KEY, "...

got ORA-01843 when I try to insert date & time to Oracle

hi I have A anb B in String format A = 14/01/2007 B = 22:10:39 I try to insert date and time: SQL = "insert into MyTbl(Tdate,Ttime) value ('" + Convert.ToDateTime(A) + "','" + Convert.ToDateTime(B) + "')"; i got ORA-01843 error, what I can do ? thank's in advance ...

Dynamic Aliases in the SQL statement

I want to display Alias name based on the value of some other column name in the query in SQL Server. For e.g. SELECT P.Amount AS (CASE P.Type WHEN 'Individual' THEN 'Salary' ELSE 'Profit' END) FROM Person P I know the above is not right, but something like this will help. ...

T-SQL query on huge table running slow depending on join conditions

Hi, we have a huge table of companies (17 million entries) for which we want to find duplicates according to search critera (based on phone number). The query runs very slow (5 minutes+) Here is a simplified version of the query, but the problem is the same : SELECT C1.* FROM dbo.Company AS C1 WITH(NOLOCK) INNER JOIN dbo.Company AS C2 ...

Can anyone suggest a way to do the permission grouping for me?

hello everyone. Im current implementing the permission like this: Permission UserPermision User ------------------- ---------------------- ----------------- PNAME PID PID UID PVAL UID UNAME This concept work fine, but at somepoint, we will want to add a Permissio...

SQL: how to know if a field has "Allow nulls" checked or not checked by SQL command

Hi, I want to know which table's field are required or not required so I have to get "Allow nulls" state. How to do that? ...

Which MYSQL select method?

Hi, I have 3 tables. 1st -> products 2nd -> labels 3rd -> connectionTable I want to select all products with their labels. I have two methods. I want to ask which one is more efficent. 1st way-> Two queries using while $query = "SELECT * FROM products"; $result = mysql_query($query); while($row = mysql_fetch_array($result, MYSQL_A...

Is there a more efficient way than doing several JOINS (MySQL)?

I have three tables: USER: user_id (pk); username FIELD: field_id (pk); name METADATA: metadata_id (pk); field_id (indx); user_id (indx); value The reasoning for this is that the application allows custom fields to be created for each user. To display all the information for a user I am building a dynamic query (via PHP) which ends u...

MySql: Grouping a grouped statement possible?

Hi, I have a SQL Statement with some joins and grouping applied. I also have a Count() column. This is what the resulting data looks like: +----------------+-----------------+----------------+ | EMPLOYEEID | REQTYPE | SHORT (count) | +----------------+-----------------+----------------+ | 1 | 5 ...

MySQL full text fails on a particular table

I've been tearing my hair as to why this fails I have the following code $query = " SELECT DISTINCT title, caption, message, url, MATCH(title, caption, message, url) AGAINST ('$searchstring' ) AS score FROM news WHERE (valid = 1) AND MATCH(title, caption, message, url) AGAINST ('$searchstring' ) UNION ALL SELECT DISTINCT title, captio...

How to find number of rows inserted/deleted in MySQL

Is there a way to find out the number of rows inserted/deleted in a table in MySQL? Is this kind of statistics kept somewhere in the database? If not, what would be the best way to implement something to keep track of these statistics? When I say how many, I mean within a certain period (last 24 hours, or since server was up, or last ...