Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 6 years ago.
Improve this question
HI I want to take a passed parameters of a stored procedure, and then use that to update or add rows to a table. is that possible?
Here's a basic example of how to do it.
-- Create the stored procedure
CREATE PROCEDURE usp_TestSp
#Param1 INT
AS
INSERT INTO Table1 VALUES (#Param1)
GO
-- Execute the stored procedure
EXEC dbo.usp_TestSp #Param1 = 2 -- int
Related
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 2 years ago.
Improve this question
We need to add a parameterised select in a pl/sql function. But I don't know what is a parameterised select. :(
You are probably talking about using bind variables in SQL statement in a PL/SQL code, like this:
declare
anumb number:=1;
.....
begin
select ....
into ....
from your_table
where a_column=anumb .....;
....
end;
In this sample code, the select can be called 'parameterised', as is uses a variable set before in the SQL. 'anumb' can also be a parameter passed to a function or procedure.
Finally, why do you tag your quest with sql-server when you have PL/SQL in the subject?
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 4 years ago.
Improve this question
I have a stored procedure where I like to display each Name in the table below
on a separate line with a PRINT so the user can see what has been retreived:
Select Name from Persons;
What is the best way to do this as I can use a cursor and then through each iteration display the Name with the PRINT. Is there a better way to do this?
I think the best way would be to select the output you want to show the user at the end of the procedure:
CREATE PROC dbo.test
AS
BEGIN
--do stuff
INSERT INTO foo (bar)
SELECT name
FROM persons
--select what to show user
SELECT name
FROM persons
END
PRINT doesn't work inside a stored procedure.
If you run the code without being wrapped in a SP, it will display what you want.
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 7 years ago.
Improve this question
Below queries in sql giving weird results. Please help me to understand why it is happening.
exec sp_executesql N'SP_MNP_DownLoadFiles #FileTypeId,#UserId',N'#FileTypeId smallint,#UserId bigint',#FileTypeId=2,#UserId=18 -- This query returns nothing
Exec SP_MNP_DownLoadFiles #FileTypeId=2,#UserId=18 -- This query returns some result
Select Type as FileTypeId ,FileStream as Attachment FROM MNPFiles
where CustomerId = 18
AND
Type = 2 -- This is the query inside SP.
Please consider the data types are same everywhere.
What I am doing wrong here?
Your dynamic SQL string doesn't match your non-dynamic statement.
exec sp_executesql N'EXEC SP_MNP_DownLoadFiles ...',...
^^^^
Other things to check:
Other SELECTs in your stored procedure prior to your main one. You may need to SET NOCOUNT ON.
That you're not RETURNing something before your main query
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about programming within the scope defined in the help center.
Closed 8 years ago.
Improve this question
this is the procedure name :
procedure misowner.proc_kr_text_niki(valdate in varchar2 default '20040101'
, v_table varchar2 default 'KR_TEMP')
and i what to EXEC it. What kind of variables i have to put?
Given that you have default values for the parameters you should be able to surround it with a block like this, and execute it as a script if you are using a GUI tool like SQL developer or Toad
DECLARE
valdate VARCHAR2(10);
v_table VARCHAR2(30);
BEGIN
misowner.proc_kr_text_niki;
END;
This works for testing, then, as suggested by BazzPsychoNut, initialize the variables, pass them in and test some more.
You call it by providing two parameters. The first parameter (= variable) "valdate" is in varchar2. It is apparently a date inputted as text in the form YYYYMMDD. The second parameter "v_table" is a varchar2, probably the name of the table to query on.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I have read this post about USING clause in EXECUTE IMMEDIATE statements:
Then I just wanted to test it for non-null values:
declare mydate date;
begin
mydate := to_date('01.01.2001','dd.mm.yyyy');
execute immediate 'insert into test_testik(DATEZ)
values :x' using mydate;
end;
The result is following error
03001. 00000 - "unimplemented feature"
*Cause: This feature is not implemented.
Any ideas why does this happen?
Thank you in advance!
You should surround :x with parentheses according to Oracle syntax.