sql

SQL Statement Not failing, but not inserting.

ASP.NET 2.0, SQL 2005. I have a very basic insert statement. I enter all the data into the app and step through. No errors are rasied in the app or the stored proc. Yet, when I go to check out the table, no record was inserted. Is there some sort of quirk or bug in SQL server I am unaware of? I have tried ExecuteScalar & ExecuteNonQuery....

How to call a PL/SQL procedure that takes a custom type as a parameter?

I have the following (I can't change it, it is provided for me to use): TYPE Person_Rec IS RECORD( ID NUMBER(10), Name VARCHAR2(30), Age Number(10)); PROCEDURE Modify_Person(rec IN Person_rec, option IN NUMBER) IS BEGIN ... END; How would I call Modify_Person externally, using some SQL statement - from an SQL console or C++, etc? How...

Zend_Db order by field Value

I'm outputting the contents of a select menu from a model using this: $select = $this->select(); $select->order('name'); return $this->fetchAll($select); However, what i want to do is order by a specific value, and then by the name column. The SQL would look like this: SELECT * FROM `names` ORDER BY `name` = 'SomeValue' DESC,`name` ...

Why sql-script isn't executed?

CREATE TABLE PERMISSIONS( ID BIGINT NOT NULL PRIMARY KEY, NAME VARCHAR(255) NOT NULL, UNIQUE(ID) ) CREATE TABLE ROLES( ID BIGINT NOT NULL PRIMARY KEY, NAME VARCHAR(255) ) I want to run this in MySql. When I try to execute separately each create-query everything works fine but they don't work together. I thought that separ...

Sql Query With GroupBys - Impossible Query

I have the following: Name Age When Paul 21 01-Jan-10 Paul 54 01-Jan-11 Paul 65 01-Jan-12 I want to pull out all names and that age wherer the date is >= 01-Jan-11 I ve tried SELECT NAME, AGE, MIN(When) FROM ATABLE WHERE When >= '01-Jan-11' GROUP BY NAME, AGE That did not work - I get the 01 Jan 2011 AND 01 Jan 201...

SQL To_Date table operations

Basically I have the following query that works but doesn't give the right data: SELECT a.* FROM ( SELECT a.*, rownum rnum FROM ( SELECT edate.expiration_date FROM ... ( SELECT To_Date(c.Value, 'MM/DD/YYYY HH24:MI:SS') expiration_date FROM ... ) edate ) a WHERE rownum <= 20) a WHERE rn...

How to find recursively self-joined records from a table.

I've got a simple problem that really has me stumped. I have a master table Table X Table X ID _________ 1 2 3 4 5 I have a join table for Table X that allows records to be self joined. Let's call this JoinTableX JoinTableX RecordAID RecordBID --------- -------- 1 2 (So Record 1 from Table X has a link to Record 2 fr...

Tips for a programmer with Dyslexia

Does anybody have tips for a programmer who recently found they have a form of dyslexia? Currently any of the following would help... A suggested color scheme for Intellij (or any Java ide). SQL is the most brutal language for me to to read, everything blends in together due to a lack of sane automated formatting/coloring. ( I cur...

partial results from a long-running SELECT query?

We are issuing some long running queries on a mysql database. (The context is offline data analysis, not an application.) How we will proceed in research terms depends on the results we obtain along the way. It would be useful for us to be able to view (partial) results as they are generated by a SELECT statement -- before the query comp...

Regular expression for finding non-breaking string names in code and then breaking them up for SQL query

I am trying to devlop a regex for finding camel case strings in several code files I am working with so I can break them up into separate words for use in a SQL query. I have strings of the form... EmailAddress FirstName MyNameIs And I want them like this... Email Address First Name My Name Is An example SQL query which I currentl...

Compare words and get exact match

Now this is tricky... I hope i can explain it well.. I have a a table which names in it and i need to compare it with the word i provide and get the exact match out.. Now i say it is tricky because i tried this query and it gave me a set of names. It contained the word which was an exact match and also words which were similar... this...

read-access to a MyISAM table during a long INSERT?

On mysql and using only myisam tables, I need to access the contents of a table during the course of a long-running INSERT. Is there a way to prevent the INSERT from locking the table in a way that keeps a concurrent SELECT from running? This is what I am driving at: to inspect how many records have been inserted up to now. Unfortuna...

Has anyone converted an existing .NET application with SQL Server backend to work with Oracle

I am looking to modify a .NET application that has a SQL Server backend to make it work with Oracle. Has anyone done this? Any pitfalls that I can avoid? ...

How do copy a modify field of a table to a new field in the same table?

I have a MySQL database table C with a field called Phone. I've already created a new field in the C table called PhoneFixed and I want to update that field with a modified version of the Phone field. The PhoneFixed field will use the following statement to get its value: Concat('(',Left(C.Phone,3),') ',Right(C.Phone,8)) As `PhoneFixed...

IF UPDATE() in SQL server trigger

If there's: IF UPDATE (col1) ...in the SQL server trigger on a table, does it return true only if col1 has been changed or been updated? I have a regular update query like UPDATE table-name SET col1 = 'x', col2 = 'y' WHERE id = 999 Now what my concern is if the "col1" was 'x' previously then again we updated it to '...

Is there a way to publish SQL Server database diagrams to html format?

Currently, we model our databases in Rational Rose. And, it provides the capability to export the database relationship diagrams to a html tree. Does SQL Server or any other tool allow a similar output? We'd like the ability to document our design and deliver it to our customer in an easy way. ...

Joining table with conditional sql

I have tables as below table A emp_code | emp_name table B emp_code | id table C emp_code | id I want to get emp_name so I do: SELECT a.emp_name FROM A a, B a WHERE a.emp_code = b.emp_code Now I want to capture a case when id in table B is not null and greater than 0 then it should compare a.emp_code with emp_code from ta...

oracle help missing comma

I am creating this table in oracle CREATE TABLE COURSE ( COURSE NUMBER(8,0) PRIMARY KEY, DESCRIPTION VARCHAR2(50) NULL, COST NUMBER(9,2) NULL, PEREQUISITE NUMBER(8,0) NULL, CREATED_BY VARCHAR2(30) NOT NULL, CREATED_DATE DATE NOT NULL, MODIFIED_BY VARCHAR2(30) NOT NULL, MODIFIED_DATE DATE NOT N...

SQL Server 2005 Stored procedure problem contatenating string with wildcard

I have a lengthy stored procedure that builds a query string. It works fine until I add in a 'LIKE' description field (text) which has a wildcard in it, see below: IF @AdDescription IS NOT NULL IF @AdSection IS NOT NULL BEGIN SET @SQL = @SQL + @Wand + 'na.Section = '' + @AdDescription + ''' SET @W...

can I use DESC oracle function to display just the column name?

I know how to do this using SELECT but how can I do this using DESC? ...