Hello, I have created a simple static function in oracle 10g to get the reference of an object based on his pk.
STATIC FUNCTION getRef(nome IN VARCHAR2)
RETURN REF folder_typ IS
fl_r REF folder_typ := null;
BEGIN
SELECT REF(fl)
INTO fl_r
FROM folder_tab fl
WHERE fl.nome = nome;
RETURN fl_r;
END getRef;
Thi...
I have 3 tables (follows, postings, users)
follows has 2 fields -> profile_id , following_id
postings has 3 fields -> post_id, profile_id, content
users has 3 fields -> profile_id, first_name, last_name
I have a follows.profile_id value of 1 that I want to match against.
When I run the SQL statement below I get the 1st step in obtai...
Hello I've been tasked with doing a few queries on a large SQL Server 2000 database.
The query I'm having trouble with is "find the number of people between ages 20 and 40"
How would I do this? My previous query to get a count of everyone looks like this:
select count(rid) from people where ...
(with the ... being irrelevant cond...
I'm trying to update a database field to the current time, but can't pass "now()". I get the following error:
'now' is not a recognized built-in function name.
The method I'm using to query the database is as follows:
Public Sub main()
Dim cnn As ADODB.Connection
Dim rst As ADODB.Recordset
Set cnn = New ADODB.Connectio...
I'm not quite sure stackoverflow is a place for such a general question, but let's give it a try.
Being exposed to the need of storing application data somewhere, I've always used MySQL or sqlite, just because it's always done like that. As it seems like the whole world is using these databases (most of all software products, frameworks...
Say I have a dataframe df with two or more columns, is there an easy way to use unique() or other R function to create a subset of unique combinations of two or more columns?
I know I can use sqldf() and write an easy "SELECT DISTINCT var1, var2, ... varN" query, but I am looking for an R way of doing this.
It occurred to me to try fta...
How do I translate the following into a named_scope?
def self.commentors(cutoff=0)
return User.find_by_sql("select users.*, count(*) as total_comments from users, comments
where (users.id = comments.user_id) and (comments.public_comment = 1) and (comments.aasm_state = 'posted') and (comments.talkboard_user_id is null)
...
I'm on a fairly new project where we're still modifying the design of our Oracle 11g database tables. As such, we drop and re-create our tables fairly often to make sure that our table creation scripts work as expected whenever we make a change.
Our database consists of 2 schemas. One schema has some tables with INSERT triggers which ...
Hi everybody:
I am writing a C++ application that needs to execute SQL queries in a SQL Server DB and I want to do it using SQL Server Native Client.
The MSDN documentation has no a full reference on it and has a few examples so I am looking for some site having more information on how to connect, execute queries and retrieve results u...
Hi
We are using "Enterprise Library Data Access Application Block" to access SQL Server database. In DataAccess layer, we are calling application block's API. Internally it must be resolving the command and parameters into SQL statement.
How can I know what SQL query goes to database?
Thanks
AJ
...
I have a table that has 5,000(table1) lines in it. Currently, 3,000 of them are filled up with data. The remaining values are currently null. In a separate table(table2), I have the remaining 2,000 rows of data. I am simply trying to take the values in table2 and put them in table1, but this statement isn't working:
Update table1
Set ...
Is there a SQL standard to escape a column name? If not what works for mysql and sqlite? does it also work for sqlserver?
...
I am doing a select * on a postgresql table, and everything looks good. But if I do:
SELECT Name from People
It says:
ERROR: column People.Name does not exist
SQL state: 42703
Character: 8
But the name column shows up during select *. I've tried:
SELECT People.Name from People
as well, with the same result. Am I missing somethi...
I'm entirely new at SQL, but let's say that on the StackExchange Data Explorer, I just want to list the top 15 users by reputation, and I wrote something like this:
SELECT TOP 15
DisplayName, Id, Reputation, Reputation/1000 As RepInK
FROM
Users
WHERE
RepInK > 10
ORDER BY Reputation DESC
Currently this gives an Error: Invalid col...
I have a single table called "Indexes", it contains one nvarchar and three ntext columns (all Full Text Indexes). Index is up to date.
CONTAINSTABLE(Indexes, *), 'test', 5) //5 results
No matter what I change the above keyword too, it only returns the first 3-5 results. It should roughly return 90-120 results, for the above query.
SE...
Assume I have a budget of $10 (any integer) and I want to distribute it over records which have rank field with varying needs. Example:
rank Req. Fulfilled?
1 $3 Y
2 $4 Y
3 $2 Y
4 $3 N
Those ranks from 1 to 3 should be fulfilled because they are within b...
A query (see below) that extracts climate data from weather stations within a given radius of a city using the dates for which those weather stations actually have data. The query uses the table's only index, rather effectively:
CREATE UNIQUE INDEX measurement_001_stc_idx
ON climate.measurement_001
USING btree
(station_id, taken, ...
Don't know if this is possible, I am looking a writing social network-esque code but need a bit of help.
SELECT wall.Wid, wall.uid, wall.wcomment, wall.name, comment.wid, comment.comment,comment.wid
FROM wall
LEFT JOIN comment ON wall.Wid=comment.wid
WHERE wall.uid in (SELECT fid from friends where uid = 3)
Cheers guys
...
I have an SQL function which returns a list of Teams.
I want to join an additional list to that list with a union, but only if first select returns more than one rows.
Something like:
CREATE FUNCTION Teams()
RETURNS TABLE
AS
RETURN
(
SELECT * FROM TABLE1
if @@rowcount>1
UNION
SELECT * FROM TABLE2
end if
)
...
Ok, here's the situation: I need to display the same record in two different sections. stupid i know, but here's why.
The Report I am building is grouped by one Field, called Day. Each record has
date/times, an expected arrival date time, and an expected departure date/time.
so, at this point we have something like this:
Day............