I want to select columns running multiple stored procedure in 'From ' as shown below.
select col1-sp1, col1-sp2, col1-sp3
from sp1, sp2, sp3 (list of stored procedure)
where .....
How can I do this?
I appreciate you reply.
Related
I need to know how to see the result of a query into a stored procedure.
A simple select * from... or any complex query just in the same way I see it after typing it from dbeaver SQL section.
The stored procedure is:
procedure TABLAS(oid in number, rec out stbienes%RowType)
As
Begin
Select * into rec from stbienes where oid_Art= oid;
End;
I'm using DBeaver 3.0.1 and Oracle XE.
Thank you very much.
I've created one of many stored procedures as part of an ETL process and one of the queries within a stored procedure isn't executing.
The environment is SQL Server 2012 SP2.
The bizarre thing is this -
Run the select part of the insert (affected query) - returns rows
Run the insert (affected query) - inserts rows
Run the whole stored procedure via SSMS - inserts rows
Run via SSIS - all other queries run barring the one of concern!
There are no conditions in my stored procedure e.g. if x = True the Return and no debug code is in there either e.g. return. There are also no transactions and the table I am reading from is a staging table populated prveiously by a data flow.
The query:
INSERT INTO Person.CustomerLinks
(PersonID, SystemID, CustomerID_bin, CustomerActive)
SELECT i.PersonID
, s.SystemDefID
, i.CustomerID_bin
, 0
FROM Staging.IdentifyOutput i
JOIN Config.SystemDef s ON s.OutputType = i.OutputType
WHERE i.CustomerID_bin IS NOT NULL
AND i.OutputType IN ('L', 'X')
AND i.PersonID > 0
AND i.FileDuplicate = 1
AND i.PreferredRecord = 1
AND NOT EXISTS ( SELECT 1
FROM Person.CustomerLinks cl
WHERE cl.PersonID = i.PersonID
AND cl.CustomerID_bin = i.CustomerID_bin)
The procedure has a Try Catch block and the Catch will raise an error and no error is raised.
The only other non ETL code in the procedure is -
SET NOCOUNT ON
SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED
But I put this in all of my procedures in this application as I am not concerned about dirty reads as they won't happen.
I placed tsql directly after the insert to write to my audit system and ##RowCount was 0. Yet if I run the select now I get over 1.5 million rows back.
Any suggestions?
If you are using a Execute T-SQL task then please try replacing it with the Execute SQL Task.
I don't know what caused it, but I moved the specific SQL into another stored procedure and it worked. In reality, it warranted being in its own stored procedure by right as it was only semi related to the procedure in question.
I am trying to combine the results of several stored procedures into a single temporary table. The results of the various stored procedures have the same column structure. Essentially, I would like to UNION ALL the results of the various stored procedures. A significant fact: each of the stored procedures creates a temporary table to store its data and the results each returns are based on a select against the temporary table:
create proc SP1
as
.
. <snip>
.
select * from #tmp -- a temporary table
Noting that select * from OPENQUERY(server, 'exec SP1') does not work if the select in SP1 is against a temporary table (see this question for details), is there another way for a different stored proc, SP2, to get the results of executing SP1 into a temporary table?
create proc SP2 as
-- put results of executing SP1 into a temporary table:
.
.
.
NOTE: SP1 cannot be modified (e.g. to store its results in a temporary table with session scope).
Create your temporary table such that it fits the results of your stored procedures.
Assuming your temp. table is called "#MySuperTempTable", you would do something like this...
INSERT INTO #MySuperTempTable (Column1, Column2)
EXEC SP1
That should do the trick.
INSERT INTO #MySuperTempTable
EXEC SP1
Following above code style but sqlserver is not compialing instructions.
I have a stored procedure in SQL server 2008 as follow:
if something
select
x, y
... from table 1
else
select
a, b
... from table 2
The database field in Crytal Reports is not showing me a and b from the second statement but only x, y.
How to proceed in Crystal Report in order to have all these fields ?
What exactly is something? If that is how your procedure is written, your report will only ever return either x and y or a and b depending on what your IF statement returns.
If you want all of them returned, you need to edit your question with your procedure, and show your data strutures. I strongly suspect you'll need some combination of SELECT CASE and/or UNION to join your tables and conditionally return columns.
I have a .NET app that retrieves a SYS_REFCURSOR output from an Oracle 9i stored proc. I would like to take that cursor and pass it into another stored proc to get a different one in return.
Loose psudocode:
CREATE OR REPLACE PROCEDURE get_Addresses(
userList IN SYS_REFCURSOR,
addressList OUT SYS_REFCURSOR)
IS
OPEN addressList FOR (
SELECT * FROM Addresses A
WHERE A.UserID in (SELECT UserID from userList)
This way i can pass a list (dataset) of user info to the stored proc and get a list of addresses that match the user list passed in.
I'm not much of an oracle developer, but I was hoping there was a way to do this rather than loop through the dataset in .NET and open/close an Oracle connection for each line.