|
Hi All,
There is a requirement to create a procedure with passing Table/View name, column names in a dynamic manner with a return of resultset, It is require both in SqlServer and Sybase.
For example I am creating here one procedure:
alter procedure dba.TestProc(in viewname varchar(30),in orderbycol varchar(30),in orderbytype integer)
/* RESULT ( column-name,... ) */
begin
if orderbytype = '1' then
execute immediate 'select '+orderbycol+' from '+viewname+' order by cast('+orderbycol+' as numeric)'
else
execute immediate 'select '+orderbycol+' from '+viewname+' order by '+orderbycol
end if
end
From above procedure I am getting the error when I am using in my .NET application that it is not returning Resultset.
Suppose I want to make a procedure for:
Select dynamicCol1, dynamicCol2 from dynamicTable
How I will create the procedure for above with passing dynamicCol1,dynamicCol2 and dynamicTable variable and how I will call in .NET application.
With regards
|
|
|
|
|
Hi
Try this in Northwind database. Assume you are passing two parameters @OrderBycol and @viewname from the front end.
use northwind<br />
go<br />
<br />
DECLARE @sql nvarchar(4000)<br />
DECLARE @OrderByCol nvarchar(4000)<br />
DECLARE @viewname nvarchar(100) <br />
<br />
set @viewname = 'Invoices' -- passed from front end <br />
set @OrderByCol = 'ShipName, ShipAddress' -- passed from front end <br />
<br />
SET @sql = 'SELECT ' + @OrderByCol + ' FROM ' + @viewname<br />
<br />
print @sql<br />
<br />
EXECUTE (@sql)
and make sure that you have given one space after SELECT in 'SELECT ' and also before & after the keyword FROM clause.
Harini
|
|
|
|
|
Thanks a lot.
I will try it. Have you any idea how I will create it in Sybase.
Is there any problem that to call the Procedure in front-end as it returns a result set not a single value?
|
|
|
|
|
Hi
I have not worked on Sybase.
I dont get you the last line ...
Harini
|
|
|
|
|
Hi
Everyone
Two Tables r there.
Emp-ENO->1,2,3
Ename->A,B,C
Score-ENO->1,2,3
S1->70,96,80
S2->75,65,75
S3->90,,100
In Score Table fields ENO,Subject1,S2,S3 r there shown above.
Please help.I want to display those employee names who got same marks in Subject 2 like 75 in S2.
Please help for this query.
Thanks
CARECAREER
|
|
|
|
|
check whether this solvs
select * from score where s2 in (
select s.s2
from emp e inner join score s on e.id = s.id
group by s.s2 having count(*) > 1
)
Regards
KP
|
|
|
|
|
My web hotel has upgraded from MySQL 4.1.21 to MySQL 5.0.37. The only problem I have had with this is that a query doesn't return anything in the result any more:
select sum(i.FileSize) as TotalSize<br />
from Photos p<br />
inner join Images i on i.PhotoId=p.PhotoId and i.IsPublic=1<br />
where p.IsPublicArt=1 or p.IsPublicCommon=1
If I change "sum" to "max" or "count" the query return one row, with "sum" or "avg" it returns zero rows.
FileSize is int and can not be null.
If I test the query directly in the database (using phpmyadmin) it returns one row with all the aggregates.
My connection string looks like this (with a different uid and pwd of course): "driver={MySQL};server=mysql.loopia.se;uid=asdfasdf;pwd=asdfasdf;database=voidstation_com"
I have tried to add ";option=3" to the connection string, but that didn't make any difference.
The list of changes that the web hotel linked to:
http://dev.mysql.com/doc/refman/5.0/en/upgrading-from-4-1.html[^]
I don't see anything there that should affect this.
Anybody got any ideas?
---
single minded; short sighted; long gone;
|
|
|
|
|
Guffa wrote: If I change "sum" to "max" or "count" the query return one row, with "sum" or "avg" it returns zero rows.
I do not know about MySql.
But see what you can do with this hint:
sum will return a large value than count or max
Regards,
Arun Kumar.A
|
|
|
|
|
Thanks for your reply.
When I use sum and run the query in phpmyadmin, the exact value that it returns is 609538140. It's larger than what count and max returns, but it's still way within the bounds of an int.
Anyway, it's not a problem with reading the value from the row, as the query doesn't even return a row. The result is empty. It doesn't contain any row to read from.
---
single minded; short sighted; long gone;
|
|
|
|
|
When I changed the driver used for the connection from version 2.50 to 3.51, it started working again.
---
single minded; short sighted; long gone;
|
|
|
|
|
I am using
Reporting Services 2005 Express
SQl Express
Visual Studio 2005
The project is in asp.net.
I have .jpg signature images that are stored in an directory image folder that I need to dynamically add to my reports based on the parameter of the person's username that is stored in a User's Table. What do I need to do to add these images dynamically? If possible.
|
|
|
|
|
hello to al,
i am using the SUM(),
but
for eg if i give SUM(PENCOST) means it gives then sum of cost of the pens
but the table name also displays as SUM of PENCOST instead of PENCOST,,
so what should and how should i give the code.......????
self confidence+hard work=SUCCESS
|
|
|
|
|
give Sum(PenCost) as PenCost
|
|
|
|
|
HEY UU ITS WORKING YAAR,
THANK U VERY MUCH REVATHI,,
THANKS A LOT
self confidence+hard work=SUCCESS
|
|
|
|
|
some times we hv to give Sum(COST) COST (we hv to give spae instead of 'as')
self confidence+hard work=SUCCESS
|
|
|
|
|
hi guys ,,,
actually i am very much new to oracle, i just want to
ask that cam we use sql joins in oracle
if not than how can we get data from different tables
based on a particular chriteria,,,
thanks in advance
hello
|
|
|
|
|
Yes.
for fetching data from more than one table, Joins can be used in Oracle.
Regards
KP
|
|
|
|
|
Hi All,
I need a URL from where I can download sample stored procedures, with which I can learn different techniques to write stored procedures. We have 101 Sample C# codes available to download in MSDN site, I am looking for similar kind of with respect to stored procedures.
Can any body help me….
Thanks in advance
Regards,
Krishnaraj
|
|
|
|
|
|
hello krishna, can u tell how to get that 101 sample c# codes from MSDN site, can u give me the link?
self confidence+hard work=SUCCESS
|
|
|
|
|
Please make me clear that
will INT(4) and VARCHAR(4) will consume same storage space in SQL Server 2000 ?
|
|
|
|
|
Navaneeth. wrote: will INT(4) and VARCHAR(4) will consume same storage space in SQL Server 2000 ?
No.
For More Details Here[^]
Regards,
Satips.
|
|
|
|
|
How to Customized SQL Report Viewer Control ? e.g The Export Combo Should only convert the Report to PDF and User Cannot Convert it to another Format
Plz Help me!
Ali
|
|
|
|
|
Hi there,
anyone using Pervasive SQL 8.0??
I have an issue with transactions using C# on Pervasive SQL 8.0. The transaction does not wait when there is a lock (another transaction operating) on the table.
It just throws an exception.
Thanks for helping
|
|
|
|
|
What Exception it throws?
Regards,
Satips.
|
|
|
|