I have lot of MySQL tables with the same column name. So Im looking for PDO or SQL hack for SELECT * FROM more tables - which will return table names in result sets.
Example:
'SELECT * FROM table0, table1';
Where both tables has 'name' column. But FETCH_ASSOC result returns only one 'name' - the last one.
Result:
echo $result["nam...
I have a stored procedure which selects a single field from a single row (based on a conditional statement) and stores it in a local variable. Based on the value of this field I update the same field in the same row of the table (using the same conditional statement). So the procedure first does a select into a local variable and then ...
Hi everybody.
I have written a tool for database replication in PHP. It's working fine but there's one issue:
I'm using PDO to connect to the different databases to keep it independent of any specific RDBMS, which is crucial to this application.
The tool does some analysis on the tables to decide how to convert certain types and some ...
I want to be able to have an actual list of objects returned when I query, instead of a ResultSet with Hit objects.
Example:
indexer.search(word).prefetch()
this would return a ResultSet object with matching hits, but I would like to have access to the objects themselves. Similar to what:
model.objects.filter(name__icontains=word)
...
I can get NHibernate (v2) to return and process a single SYS_REFCURSOR that contains my single resultset. Is it possible for multiple resultsets/SYS_REFCURSOR's in NHibernate? What would be the syntax of the .hbm.xml file to map multiple resultsets from the SYS_REFCURSOR's?
thanks.
...
I have an application with multiple SqlCeResultSets, and a combobox and a datagrid on one form. I have setup the ResultSets to return subsets of the same SQL CE table, using statements like:
"SELECT * FROM DLH WHERE STATUS = 'A'"
"SELECT * FROM DLH WHERE STATUS = 'D'"
"SELECT * FROM DLH"
Which return ResultSets named DLH_A, DLH_D and ...
I am losing precision in my ResultSet.getDate(x) calls. Basically:
rs = ps.executeQuery();
rs.getDate("MODIFIED");
is returning dates truncated to the day where MODIFIED is an Oracle TIMESTAMP field of default precision. I think there may be some JDBC tweak I'm missing; usually TIMESTAMP is compatible with DATE, but I'm hoping I don...
Or simpler, I have this code (Oracle database)
SELECT TO_NUMBER (tkb.id_kucnog_broja) id, 'Buildings and home numbers' vrsta_pj,
and in Java I have this
for (int j = 0; j < rs.getMetaData().getColumnCount(); j++) {
data = rs.getString(j + 1);
}
and the result it gets is 'Buildings and home number', meaning it 'cuts' the last char (...
Is there a way for an Oracle stored procedure to return paged resultset (as refcursor) back? For example, I would like to pass to the stored procedure the number of records to return and the page number interested. Then I only want to see those number of records back to my client. How is that done on the Oracle side?
i.e.
var v_numreco...
I need to insert multiple records into mysql database at once. What I am doing is SELECT on one table, from my application with Prepared statement. What I must do is to insert those results into one other temporary table.
String sqlquery = "select * from table1 where arg1 = ?";
PreparedStatement statement;
statement = con.prepareStatem...
Assume I have some stored procedure (and I can't change it) which is returning a result set:
create procedure test_procedure
as
begin
select 1
end
I know that I can insert result set into table, so it would be hidden to the calling code:
declare @t table(i int)
insert into @t
exec test_procedure
Are there any other ways to h...
I use mysqli extension and bind the result to an object:
class Item {
public $id, $name;
}
$Item = new Item;
$stmt->bind_result($Item->id, $Item->name);
Every call to $stmt->fetch() will overwrite $Item's properties which became references. If I simply clone the object — these references remain and both instances change simult...
How can I use the paginatation helper in cakePHP to show more than one result set on the same page? They would page independently.
EDIT:
I found out one reason why it can't do that is because the pagination helper would get its URL from the controller/action and then appends its parameters at the end.
If it pulled the url from the add...
First off, here's my SQL query:
SELECT research_cost, tech_name,
(SELECT research_cost
FROM technologies
WHERE research_cost <= USERS_RESEARCH_POINTS_VALUE
ORDER BY research_cost DESC
LIMIT 1) as research_prev,
(SELECT cost
FROM technology_costs
WHERE id = 18
LIMIT 1) as te...
When iterating through a Resultset in the standard way
while (rs.next()){
...
}
To retrieve column data (e.g long) is it quicker to use
rs.getLong(String columnLabel)
or
rs.getLong(int columnIndex)
Presumably columnLabel is better to use in many ways for stronger code, but is there a significant operational loss by matching a co...
Folks,
I have a stored proc as following:
create procedure p1 as
begin
declare @n1 int
select
@n1=count(*)
from
Employee
select top 100
*
from
Employee
return @n1
end
I want to capture @n1 as well as the Employee resultset using Linq To SQL in my C# code.
I would appreciate any...
As the ResultSet contains the data returned from the dynamic SQL, if there are any method to determine if the ResultSet contains a particular column name ? For example , if I run rs.getString("Column_ABC"); but Column_ABC does not really exist, it will throw out the exception . How can I test if the ResultSet can get a data from a colu...
I have a problem in hand and that is to fetch a result set in a numeric pattern / sequence based on a single column's value.
Say I have the following table:
+-------+
| val |
+-------+
| 1 |
| 1 |
| 1 |
| 1 |
| 2 |
| 2 |
| 2 |
| 2 |
| 3 |
| 3 |
| 3 |
| 3 |
+-------+
How can I make...
ResultSet rs;
rs = this.orderedProduct.select(" sum(unitstoproduce) "," soNo = "+ soNo);
int sum = Integer.parseInt(rs.getString(1));
When i try to execute the above query inside the java class i'm getting an exception as below.
Here the orderedProduct(orderedZnAlProduct) is the table
SELECT sum(unitstoproduce) FROM or...
I have a long running query that returns a large data set. This query is called from a web service and the results are converted to a CSV file for the end user. Previous versions would take 10+ minutes to run and would only return results to the end user once the query completes.
I rewrote the query to where it runs in a minute or so i...