With PostgreSQL, one of my tables has an 'interval' column, values of which I would like to extract as something I can manipulate (datetime.timedelta?); however I am using PyGreSQL which seems to be returning intervals as strings, which is less than helpful.
Where should I be looking to either parse the interval or make PyGreSQL return ...
I'm trying to change the application schema of a database in Postgres...so I need to copy data from one table to another. In the original table, co-ordinates are specified as numeric values in two separate columns, one for the x value and one for the y value. In the new table, the co-ordinates need to be stored as one value of the point ...
I need to modify a query Views generates so that I can use highly custom filters. I have implemented the add_where() function with some ORs thanks to this question: http://stackoverflow.com/questions/1340423/or-operator-in-drupal-view-filters
However this only solves a part of my problem. There are some fields that I cannot filter on be...
Lets say i have two tables EMPLOYEE and INCHARGE_ROOM , EMPLOYEE.INCHARGE_ROOMS has | delimted data of INCHARGE_ROOM.ID
EMPLOYEE
ID NAME INCHARGE_ROOMS
1 K 1|2|3|4
2 S 2|4|5
INCHARGE_ROOM
INCHARGE_ROOM_ID INCHARGE_ROOM_NAME
1 ...
Hi, i am working on this code that is going to query a database for an entry and return the value of the tracking number and the time to print on a label if the tracking number exist in the databse. it does not right now it only seems to reprint the number that is enetered in a text box and it does not grab the date. any ideas? here is t...
I was just wondering where I could find more information on these optimizations? Google searches tend to emphasize prepared queries and such, and not really at the angle of the abstraction the SQL provides.
Source:
http://www.joelonsoftware.com/articles/LeakyAbstractions.html
The SQL language is meant to abstract
away the procedur...
Using linq (.net 3.5 +) and predicate builder, I did it like so:
var startsWith3Chars = new System.Text.RegularExpressions.Regex(@"^[a-zA-Z]{3}\-", System.Text.RegularExpressions.RegexOptions.Compiled);
wherePredicate = wherePredicate.And(x => startsWith3Chars.Matches(x.MATERIALUID).Count > 0);
But now I have the need to do this filt...
I was wondering if there was anyway to specify returned column names using prepared statements.
I am using MySQL and Java.
When I try it:
String columnNames="d,e,f"; //Actually from the user...
String name = "some_table"; //From user...
String query = "SELECT a,b,c,? FROM " + name + " WHERE d=?";//...
stmt = conn.prepareStatement(que...
Imagine I have the following SELECT statement in a view (SQL Server 2008):
SELECT (SELECT CASE
WHEN HISTORY.OUTOFSERV = 'Y' OR HISTORY.OUTOFSERV = 'y' THEN 1
ELSE 0
END) AS OOS
FROM HISTORY
The column OOS ends up being of type int, but I'd like it to be of type bit. How can I acco...
Hi guys,
I have a table that outputs all my contacts via a while loop from my database.
my syntax is like this:
SELECT * FROM contacts WHERE id = $_SESSION['user_id'] ORDER BY name ASC LIMIT 5
that pulls out all my data and only gives me 5 results.
Now my goal is to have a little button that opens up a model box with jquery (this I...
Hi,
I am sure the title of my question doesn't make much sense. But here is what I'm trying to achieve. I have table with different stories(columns are StoryID, StoryTitle, StoryDesc, StoryCategory), so each story can belong to a category. for example category1, category2,.... category10. I am in the need of a SP, where i specify the ca...
When exporting some data from MS SQL Server using Python, I found out that some of my data looked like computer \xa0systems which is causing encoding errors. Using SQL Management Studio the row simply appears to be double spaced: computer systems. It seems that this is the code for : how can I query MS SQL Server within managemen...
I am in the process of revising code to use TVP to send data from our VB.NET app to the SQL 2008 DB and try to keep all the writes atomic.
Using this page as a general guide:
http://www.sqlteam.com/article/sql-server-2008-table-valued-parameters
I am in the process of creating all the in-code datatables to be sent to the SQL stored pro...
I have an Oracle source, and I'm getting the entire table, and it is being copied to a SQL Server 2008 table that looks the same. Just for testing, I would like to only get a subset of the table.
In the old DTS packages, under Options on the data transform, I could set a first and last record number, and it would only get that many r...
I'm trying to do a many to many query on these fields. I'd like to get:
1) all the posts that are in a category
2) all the categories that are in a post
3) all the posts that are in a category that have a specific id
posts
+-------------+--------------+
| id | int(11) |
| title | varchar(255) |
| body |...
Although Oracle is one of the earliest to create stored procedures (PL/SQL) then Informix with (SPL) which RDBMS products besides DB2 have implemented SQL/PSM or a subset of it after 1998?.. Which RDBMS' can support procs like in the following example?:
CREATE OR REPLACE FUNCTION foo1(a integer)
RETURNS void AS $$
CASE a
WHEN 1, ...
I'm designing an inventory system, it has users, products, buy_leads, orders (authorized buy_leads), inputs and outputs.
class Product < ActiveRecord::Base
has_many :buy_leads
end
class BuyLead < ActiveRecord::Base
belongs_to :product
has_one :order
end
class Order < ActiveRecord::Base
belongs_to :buy_lead
belongs_to :user, ...
Running explain plan on this query I am getting Full table Access.
Two tables used are:
user_role: 803507 rows
cmp_role: 27 rows
Query:
SELECT
r.user_id, r.role_id, r.participant_code, MAX(status_id)
FROM
user_role r,
cmp_role c
WHERE
r.role_id = c.role_id
AND r.participant_code IS NOT NULL
AN...
I need to perform some atomic arithmetic in Rails but the only way I've found to do it for single objects is via the crude update_all class method, e.g.:
Account.update_all(["debits = debits + ?", amount], :id => id)
With collection associations, the update_all class method should be usable as an association method, since the collecti...
I am working in a jsp project. I have several SQLs. Currently I hard code them in the relating .java files. I guess this maynot be the proper way to do. Where should I put them? In a config.xml or sql.xml? Put them into a properties file? or put them in files with .sql extension separately, but them what is the proper and easy way to acc...