sql

Is this a bug with Advantage Database?

I am running into what seems to me to be a bug in the Advantage Database PHP Extension (I know, I know...). I've reported it as a bug, but still haven't heard anything back, so I thought I'd run it by you guys. Working Code: for ($i = 0; $i < 100; $i++) { $connection = ads_connect( 'DataDirectory=\\some\path\;ServerTypes=2;RightsCh...

Character Column Lengths

What are some good rules of thumb for specifying a column length? People will arbitrarily use "VARCHAR(50)" for name fields etc... but most of this is guess work. Does anyone have any resources they use? What are the rules of thumb you follow to designate a character length? For example, for a URL - these can be lengthy especially given ...

multiple joins using activerecord in rails

I'm building a small twitter style microblogging service where users can follow other users and get a feed of their messages I have the following models: class Follow < ActiveRecord::Base belongs_to :follower, :class_name => "User" belongs_to :followee, :class_name => "User" end class User < ActiveRecord::Base has_many :follows,...

How do I select rows that have a column value equal to the value of the known row?

There is a table: create table table1 ( id integer primary key, user_id varchar(36), field1 varchar(100)) How do I select the rows linked to the user, to which the row with a specific id belongs. I'd like to be able to look at the rows, choose a message by id and select all the rows, linked to the same user...

Keeping queries out of JSP - how?

I'm a big fan of keeping application logic in the servlet, and keeping the JSP as simple as possible. One of the reasons for this is that any good web designer should be able to expand upon his HTML knowledge to build in a few JSTL tags to do simple iteration, access beans, etc. We also keep the more complex/ajax/js components behind a t...

What is the best way to collapse the rows of a SELECT into a string?

In a SQL statement ( or procedure ) I want to collapse the rows of this table into a single comma delimited string. simpleTable id value -- ----- 1 "a" 2 "b" 3 "c" Collapse to: "a, b, c" ...

SQL to find duplicate foreign keys in a group

With tables basically like this: Elements id INT PRIMARY KEY ... Observations id INT PRIMARY KEY ... Data id INT PRIMARY KEY observation_id FOREIGN KEY element_id FOREIGN KEY value FLOAT ... I want to find all observation_ids where there are duplicate element_ids in a single observation_id. For example, if I have D...

Combining SQL Insert and Delete

Ok here is the question I have three tables events - id - name questions - id - event_id - name answers - id - question_id - description While generating the add form, i can simply search for all the questions belonging to particular event, and show the questions in single HTML form. But consider the edit scenario. An event manage...

If statement SQL

Hi i want to run an if statement but keep getting syntax errors near all my AS aliases, what am i doing wrong? SELECT IF @Origin = 'ALL' (SELECT COUNT(*) FROM TBL_PARTORDER INNER JOIN TBL_REPAIR_ORDER ON TBL_PARTORDER.ORDERID = TBL_REPAIR_ORDER.ORDERID INNER JOIN TBL_PROPERTY ON TBL_REPAIR_ORDER.PROPREF = TBL_PROPERTY.PROPREF WHERE ...

Output of a query displaying as null

I am trying to trieve a list of files where a field ARTICLE_NO is a certain number. At the moment, I have a files table, with columns ARTICLE_NO, FILENAME and USERNAME. There is one record, with values 1, x.txt and user respectively. $pk is assigned to 1 in my php code. However, the following code only produces NULL, and I am unsure why....

Debugging MS SQL Stored Procedure

I have a problem getting Stored Procedure debugging to work in Visual Studio 2008: When I start debugging, I get these success messages in the output window, however the actual stored procedure windows does not show up. Auto-attach to process '[1640] [SQL] stagsql' on machine 'stagsql' succeeded. The thread 'stagsql [67]' (0xf80) has ex...

Growing a list of links from a query

I have the following code, which will retrieve a filename from a table and make a link to it. What I want to do, is have it so I can refer to $filesList later on, and it will contain a single block of html code with links to as many files as there are files. I thought adding to the previous variable would be the easiest way to do this, ...

Some form of Progress bar when something is loading in ASP.NET?

Is there a easy way to show some form of progress bar on your form in ASP.NET that the code is busy running in the background (meaning thinking)? Like the default I.E have the small little window on the top that moves when its thinking.......... I have done this before with Ajax but its alot of work and my site is not a Ajax enabled sit...

Does 'Select' always order by primary key?

A basic simple question for all of you DBA. When I do a select, is it always guaranteed that my result will be ordered by the primary key, or should I specify it with an 'order by'? I'm using Oracle as my DB. ...

How do you make the Python Msqldb module use ? in stead of %s for query parameters?

MySqlDb is a fantastic Python module -- but one part is incredibly annoying. Query parameters look like this cursor.execute("select * from Books where isbn=%s", (isbn,)) whereas everywhere else in the known universe (oracle, sqlserver, access, sybase...) they look like this cursor.execute("select * from Books where isbn=?", (isbn,)) ...

How to get over "Cannot fetch into text, ntext, and image variables." on SQL Server?

I'm getting this error message: Msg 16927, Level 16, State 1, Procedure GetWfGenProcessParameters, Line 21 Cannot fetch into text, ntext, and image variables. I realy need to make this cursor work with text data. Is there any way to get over this error? ...

Change table cells in sql but how?

i need Sql query Convert Table1 to Table2 select Count(Page) as VisitingCount,CONVERT(VARCHAR(5),Date, 108) as [Time] from scr_SecuristLog where Date between '2009-04-30' and '2009-05-02' and [user] in(select USERNAME from scr_CustomerAuthorities where customerID=Convert(varchar,4) and ID=Convert(varchar,43)...

Is there any library to represent SQL queries as objects in Java code?

I was wondering if there is any library that can be used to represent SQL queries as objects in Java. In the code I have plenty of static variables of type java.lang.String that are hand written SQL queries. I would be looking for library having a nice fluent API that allows me to represent the queries as objects rather than strings. E...

Update Query from a Lookup Query

I have a spreadsheet that I am converting to an Access DB. I have a column of typed out customer names that I want to replace with the appropriate customer number from our accounting system. I have created a table with the customer info, and a query that shows what ID needs to be inserted into the source data. What I'm looking for is:...

Connecting swings with sql

I want to learn sql connectivity with swings(java) can any one suggest a good resource available for my purpose. ...