Search Results

Search found 4815 results on 193 pages for 'parameterized queries'.

Page 56/193 | < Previous Page | 52 53 54 55 56 57 58 59 60 61 62 63  | Next Page >

  • Store time of the day in SQL

    - by nute
    How would you store a time or time range in SQL? It won't be a datetime because it will just be let's say 4:30PM (not, January 3rd, 4:30pm). Those would be weekly, or daily meetings. The type of queries that I need are of course be for display, but also later will include complex queries such as avoiding conflicts in schedule. I'd rather pick the best datatype for that now. I'm using MS SQL Server Express 2005. Thanks! Nathan

    Read the article

  • Oracle (Old?) Joins - A tool/script for conversion?

    - by Grasper
    I have been porting oracle selects, and I have been running across a lot of queries like so: SELECT e.last_name, d.department_name FROM employees e, departments d WHERE e.department_id(+) = d.department_id; ...and: SELECT last_name, d.department_id FROM employees e, departments d WHERE e.department_id = d.department_id(+); Are there any guides/tutorials for converting all of the variants of the (+) syntax? What is that syntax even called (so I can scour google)? Even better.. Is there a tool/script that will do this conversion for me (Preferred Free)? An optimizer of some sort? I have around 500 of these queries to port.. When was this standard phased out? Any info is appreciated.

    Read the article

  • What does MySqlDataAdapter.Fill return when the results are empty?

    - by Brian
    I have a 'worker' function that will be processing any and all sql queries in my program. I will need to execute queries that return result sets and ones that just execute stored procedures without any results. Is this possible with MySqlDataAdapter.Fill or do I need to use the MySqlCommand.ExecuteNonQuery() method? Here is my 'worker' function for reference: private DataSet RunQuery(string SQL) { MySqlConnection connection; MySqlCommand command; MySqlDataAdapter adapter; DataSet dataset = new DataSet(); lock(locker) { connection = new MySqlConnection(MyConString); command = new MySqlCommand(); command = connection.CreateCommand(); command.CommandText = SQL; adapter = new MySqlDataAdapter(); adapter.Fill(dataset); } return dataset; }

    Read the article

  • does a ruby on rails rack class get access to the entire rails environment?

    - by Andrew Arrow
    that is when the def call(env) method is invoked by hitting any url, can I inside that method make some ActiveRecord queries, use classes defined in lib, etc. etc. Or is it more like an irb console without the rails env loaded? Another way to put it with a rake task example: task :foo => :environment do # with env end task :foo2 do # without env end I would think rack classes would NOT get the environment so they are super fast and don't take all the overhead of a normal rails request. But that doesn't seem to be the case. I CAN make ActiveRecord queries inside my rack class. So what is the advantage of rack then?

    Read the article

  • SQL query: how to translate IN() into a JOIN?

    - by tangens
    I have a lot of SQL queries like this: SELECT o.Id, o.attrib1, o.attrib2 FROM table1 o WHERE o.Id IN ( SELECT DISTINCT Id FROM table1, table2, table3 WHERE ... ) These queries have to run on different database engines (MySql, Oracle, DB2, MS-Sql, Hypersonic), so I can only use common SQL syntax. Here I read, that with MySql the IN statement isn't optimized and it's really slow, so I want to switch this into a JOIN. I tried: SELECT o.Id, o.attrib1, o.attrib2 FROM table1 o, table2, table3 WHERE ... But this does not take into account the DISTINCT keyword. Question: How do I get rid of the duplicate rows using the JOIN approach?

    Read the article

  • How does one SELECT block another?

    - by Krip
    I'm looking at output of SP_WhoIsActive on SQL Server 2005, and it's telling me one session is blocking another - fine. However they both are running a SELECT. How does one SELECT block another? Shouldn't they both be acquiring shared locks (which are compatible with one another)? Some more details: Neither session has an open transaction count - so they are stand-alone. The queries join a view with a table. They are complex queries which join lots of tables and results in 10,000 or so reads. Any insight much appreciated.

    Read the article

  • A linq join combined with a regex

    - by Geert Beckx
    Is it possible to combine these 2 queries or would this make my code too complex? Also I think there should be a performance gain by combining these queries since I think in the near future my source table could be over 11000 records. This is what i came up with so far : Dim lit As LiteralControl ' check characters not in alphabet Dim r As New Regex("^[^a-zA-Z]+") Dim query = From o In source.ToTable _ Where r.IsMatch(o.Field(Of String)("nam")) lit = New LiteralControl(String.Format("letter: {0}, count: {1}<br />", "0-9", query.Count)) plhAlpabetLinks.Controls.Add(lit) Dim q = From l In "ABCDEFGHIJKLMNOPQRSTUVWXYZ".ToLower.ToCharArray _ Group Join o In source.ToTable _ On l Equals o.Field(Of String)("nam").ToLowerInvariant(0) Into g = Group _ Select l, g.Count ' iterate the alphabet to generate all the links. For Each letter In q.AsEnumerable lit = New LiteralControl(String.Format("letter: {0}, count: {1}<br />", letter.l, letter.Count)) plhAlpabetLinks.Controls.Add(lit) Next Kind regards, G.

    Read the article

  • SQL query - choosing 'last updated' record in a group, better db design?

    - by Jimmy
    Hi, Let's say I have a MySQL database with 3 tables: table 1: Persons, with 1 column ID (int) table 2: Newsletters, with 1 column ID (int) table 3: Subscriptions, with columns Person_ID (int), Newsletter_ID (int), Subscribed (bool), Updated (Datetime) Subscriptions.Person_ID points to a Person, and Subscription.Newsletter_ID points to a Newsletter. Thus, each person may have 0 or more subscriptions to 0 or more magazines at once. The table Subscriptions will also store the entire history of each person's subscriptions to each newsletter. If a particular Person_ID-Newsletter_ID pair doesn't have a row in the Subscriptions table, then it's equivalent to that pair having a subscription status of 'false'. Here is a sample dataset Persons ID 1 2 3 Newsletters ID 4 5 6 Subscriptions Person_ID Newsletter_ID Subscribed Updated 2 4 true 2010-05-01 3 4 true 2010-05-01 3 5 true 2010-05-10 3 4 false 2010-05-15 Thus, as of 2010-05-16, Person 1 has no subscription, Person 2 has a subscription to Newsletter 4, and Person 3 has a subscription to Newsletter 5. Person 3 had a subscription to Newsletter 4 for a while, but not anymore. I'm trying to do 2 kinds of query. A query that shows everyone's active subscriptions as of query time (we can assume that updated will never be in the future -- thus, this means returning the record with the latest 'updated' value for each Person_ID-Newsletter_ID pair, as long as Subscribed is true (if the latest record for a Person_ID-Newsletter_ID pair has a Subscribed status of false, then I don't want that record returned)). A query that returns all active subscriptions for a specific newsletter - same qualification as in 1. regarding records with 'false' in the Subscribed column. I don't use SQL/databases often enough to tell if this design is good, or if the SQL queries needed would be slow on a database with, say, 1M records in the Subscriptions table. I was using the Visual query builder tool in Visual Studio 2010 but I can't even get the query to return the latest updated record for each Person_ID-Newsletter_ID pair. Is it possible to come up with SQL queries that don't involve using subqueries (presumably because they would become too slow with a larger data set)? If not, would it be a better design to have a separate Subscriptions_History table, and every time a subscription status for a Person_ID-Newsletter-ID pair is added to Subscriptions, any existing record for that pair is moved to Subscriptions_History (that way the Subscriptions table only ever contains the latest status update for any Person_ID-Newsletter_ID pair)? I'm using .net on Windows, so would it be easier (or the same, or harder) to do this kind of queries using Linq? Entity Framework? Thanks!

    Read the article

  • Do I have to use Stored Procedures to get query level security or can I still do this with Dynamic S

    - by Peter Smith
    I'm developing an application where I'm concerned about locking down access to the database. I know I can develop stored procedures (and with proper parameter checking) limit a database user to an exact set of queries to execute. It's imperative that no other queries other then the ones I created in the stored procedures be allowed to execute under that user. Ideally even if a hacker gained access to the database connection (which only accepts connections from certain computers) they would only be able to execute the predefined stored procedures. Must I choose stored procedures for this or can I use Dynamic Sql with these fine grain permissions?

    Read the article

  • Sql Server performance

    - by Jose
    I know that I can't get a specific answer to my question, but I would like to know if I can find the tools to get to my answer. Ok we have a Sql Server 2008 database that for the last 4 days has had moments where for 5-20 minutes becomes unresponsive for specific queries. e.g. The following queries run in different query windows simultaneously have the following results SELECT * FROM Assignment --hangs indefinitely SELECT * FROM Invoice -- works fine Many of the tables have non-clustered indexes to help speed up SELECTs Here's what I know: 1) The same query will either hang indefinitely or run normally. 2) In Activity Monitor in the processes tab there are normally around 80-100 processes running I think that what's happening is 1) A user updates a table 2) This causes one or more indexes to get updated 3) Another user issues a select while the index is updating Is there a way I can figure out why at a specific moment in time SQL Server is being unresponsive for a specific query?

    Read the article

  • How to do query auto-completion/suggestions in Lucene?

    - by Mat Mannion
    I'm looking for a way to do query auto-completion/suggestions in Lucene. I've Googled around a bit and played around a bit, but all of the examples I've seen seem to be setting up filters in Solr. We don't use Solr and aren't planning to move to using Solr in the near future, and Solr is obviously just wrapping around Lucene anyway, so I imagine there must be a way to do it! I've looked into using EdgeNGramFilter, and I realise that I'd have to run the filter on the index fields and get the tokens out and then compare them against the inputted Query... I'm just struggling to make the connection between the two into a bit of code, so help is much appreciated! To be clear on what I'm looking for (I realised I wasn't being overly clear, sorry) - I'm looking for a solution where when searching for a term, it'd return a list of suggested queries. When typing 'inter' into the search field, it'll come back with a list of suggested queries, such as 'internet', 'international', etc.

    Read the article

  • Mysql query: count and distinct

    - by Azevedo
    I have this hypotetical MySQL table: TABLE cars: (year, color, brand) How do I count # of cars grouped by brand and year? I mean, how can I get to know how many colors are there grouped by brand like: brand "GM": total # of colors: 8. brand "GM": total # of years (grouped together): 14 (meaning there are count of 14 different years). brand "TOYOTA": total # of colors: 3. brand "TOYOTA": total # of years (grouped together): 10 (meaning there are count of 14 different years) I tried playing some queries with COUNT, DISTINCT, GROUP BY but I can't get to it. Actually I'm trying to get the 2 queries... +-------+---------------+ | brand | count(colors) | +-------+---------------+ +-------+--------------+ | brand | count(years) | +-------+--------------+ thanks a lot!

    Read the article

  • MYSQL Inserting rows that reference main rows.

    - by Andrew M
    I'm transferring my access logs into a database. I've got two tables: urlRequests id : int(10) host : varchar(100) path: varchar(300) unique index (host, path) urlAccesses id : int(10) request : int(10) <-- reference to urlRequests row ip : int(4) query : varchar(300) time : timestamp I need to insert a row into urlAccesses for every page load, but first a row in urlRequests has to exist with the requested host and path so that urlAccesses's row can reference it. I know I can do it this way: A. check if a row exists in urlRequests B. insert a row in urlRequests if it needs it C. insert a row into urlAccesses with the urlRequests's row id referenced That's three queries for every page load if the urlRequests row doesn't exist. I'm very new to MySQL, so I'm guessing that there's a way to go about this that would be faster and use less queries.

    Read the article

  • mysql multiple where and inner join query combination

    - by bandhunt
    I'm a little lost as how to run two mysql queries as one(return one result set to be sorted etc). I understand how to do multiple JOINS but need to combine the below which is more than just a multiple join - it would include a multiple where etc. 1st query sql = "SELECT s.id, s.song_name FROM `songs` as s INNER JOIN `artists` as a ON s.artist_id = a.id WHERE ((`a`.id = #{search}))" 2nd query sql = "SELECT s.id, s.song_name FROM `songs` as s INNER JOIN `similarments` as si ON s.artist_id = si.artist_id WHERE ((`si`.similar_id = #{search}))" And then run both queries at once so I can ORDER them etc. Or combine them as one big query (maybe put an OR somewhere)? Thanks!

    Read the article

  • Multiple Scripts With the Same MySQL Query Running At Once => Will There Be Interference?

    - by walden
    I want to have multiple scripts running from cron at the same time. They will all update, say, 500 rows with a unique status ID for that particular script to use. If each script grabs the same type of rows to update, and the scripts run at once, will there be interference between the queries run at the same time? For example, using this query: UPDATE table SET status = <unique script ID> WHERE status = 0 LIMIT 500 Will I get the same rows updating more than once? I'm trying to get each script to get unique rows. I was thinking of using sleep() to make the queries run at different times, but I'm not sure if that's necessary. Thanks.

    Read the article

  • C# Dynamic Query Without A Database Model

    - by hitopp
    I have been searching the web for a solution to dynamic queries. I have found many different solutions (e.g. Linq to Sql, Dynamic Linq Expressions, Dynamic Query), but all of these solutions involve some sort of previous knowledge of the database (like a model in code). Maybe what I am asking is way off the deep end, but is there any possible way to dynamically query a database without a model? For example, a database has a Customers table with the following columns: CustomerID Name FavoriteColor I want to create a query as SELECT Name FROM Customers WHERE @0 = @1, where the two placeholders are populated dynamically. The resulting data does not tie to a model class and I would prefer to use some sort of framework to build the queries, not simple string concatenation. The System.Linq.Dynamic namespace came really close to fulfilling this request, but it uses a database model. I realize this is crazy, but I was just curious.

    Read the article

  • Solution for distributing MANY simple network tasks?

    - by EmpireJones
    I would like to create some sort of a distributed setup for running a ton of small/simple REST web queries in a production environment. For each 5-10 related queries which are executed from a node, I will generate a very small amount of derived data, which will need to be stored in a standard relational database (such as PostgreSQL). What platforms are built for this type of problem set? The nature, data sizes, and quantities seem to contradict the mindset of Hadoop. There are also more grid based architectures such as Condor and Sun Grid Engine, which I have seen mentioned. I'm not sure if these platforms have any recovery from errors though (checking if a job succeeds). What I would really like is a FIFO type queue that I could add jobs to, with the end result of my database getting updated. Any suggestions on the best tool for the job?

    Read the article

  • after running insert or update query, need the last inserted record and compare in vb.net sql server

    - by ereffe
    i have 2 queries in vb.net with an if clause - if x=0 then insert into table1 else update table1 both queries have 5 fields. now what i want to do is after this insert or update takes place, i need to look at this inserted/updated record and compare it with another table (table2). Especially for update, i have 5 fields in both tables. if any of the 5 fields dont match with table2, then i insert a new record in table 2 which is the updated record in table 1. how can i do this?

    Read the article

  • How to order by results from 2 seperate tables in PHP and MySQL.

    - by Vafello
    I am trying to output results of 2 sql queries to one JSON file. The problem is that I would like to order them ascending by distance which is the result of equation that takes homelat and homelon from the users table and lat, lng from locations table.(basically it takes lattitude and longitude of one point and another and computes the distance between these points). Is it possible to take some parameters from both select queries, compute it and output the result in ascending order? $wynik = mysql_query("SELECT homelat, homelon FROM users WHERE guid='2'") or die(mysql_error()); ; $query = "SELECT * FROM locations WHERE timestamp"; $result = map_query($query); $points = array(); while ($aaa = mysql_fetch_assoc($wynik)) { while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) { array_push($points, array('name'=>$row['name'], 'lat'=>$row['lat'], 'lng'=>$row['lng'], 'description'=>$row['description'], 'eventType'=>$row['eventType'], 'date'=>$row['date'], 'isotime'=>date('c', ($row['timestamp'])), 'homelat'=>$aaa['homelat'], 'homelon'=>$aaa['homelon'])); } echo json_encode(array("Locations"=>$points));

    Read the article

  • Multiple resultsets from Oracle in Odp.net,without refcursors

    - by James L
    SQL Server is able to return the results of multiple queries in a single round-trip, e.g: select a, b, c from y; select d, e, f from z; Oracle doesn't like this syntax. It is possible to use reference cursors, like this: begin open :1 for select count(*) from a; open :2 for select count(*) from b; end; However, you incur a penalty in opening/closing cursors and you can hold database locks for an extended period. What I'd like to do is retrieve the results for these two queries in one shot, using Odp.net. Is it possible?

    Read the article

  • Best method of Zend Framework caching

    - by iamthejeff
    I have a blog built using Zend Framework, which I realize might be a bit overkill for a blog alone, but I am planning on adding other features in the future. Nevertheless, I've noticed pages could be a little speedier. I've done a basic caching method that basically captures everything in index.php (Core frontend and File backend), which works great, but unfortunately it also prevents dynamic page contents from updating (messages like "this was posted 5 minutes ago", etc) until the cache period expires. So my question is what would be the best method of caching to improve performance? I am doing fairly basic queries which are mostly simple selects, not many joins or anything fancy (using Zend_Db_Table), and even on a small database page loads are a little sluggish. Is it worth it to cache queries or should I focus my time elsewhere?

    Read the article

  • Oracle - pl sql selecting from SYS_REFCURSOR

    - by Einstein
    I have a function that returns a SYS_REFCURSOR that has a single row but multiple columns. What I'm looking to do is to be able to have a SQL query that has nested sub-queries using the column values returned in the SYS_REFCURSOR. Alternative ideas such as types, etc would be appreciated. Code below is me writing on-the-fly and hasn't been validated for syntax. --Oracle function CREATE DummyFunction(dummyValue AS NUMBER) RETURN SYS_REFCURSOR IS RETURN_DATA SYS_REFCURSOR; BEGIN OPEN RETURN_DATA SELECT TO_CHAR(dummyValue) || 'A' AS ColumnA ,TO_CHAR(dummyValue) || 'B' AS ColumnB FROM DUAL; RETURN RETURN_DATA; END; --sample query with sub-queries; does not work SELECT SELECT ColumnA FROM DummyFunction(1) FROM DUAL AS ColumnA ,SELECT ColumnB FROM DummyFunction(1) FROM DUAL AS ColumnB FROM DUAL;

    Read the article

< Previous Page | 52 53 54 55 56 57 58 59 60 61 62 63  | Next Page >