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.
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 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
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.
Closed 8 years ago.
This question appears to be off-topic because it lacks sufficient information to diagnose the problem. Describe your problem in more detail or include a minimal example in the question itself.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Improve this question
I'm new to PL/SQL and I think Ive created a procedure inside of my package body, when i run it in SQL commands it says it been successfully created, I am just not sure how to test it?
The procedure is to delete a customer based on their ID
Here is the code
PROCEDURE remove_customer (customer_id VARCHAR2) IS
BEGIN
DELETE FROM customer
WHERE customer.customer_id = remove_customer.customer_id;
END;
any idea on how to test it works?
Thanks
You can run it from an anonymous block:
begin
your_package.remove_customer('CUST_ID');
end;
/
If you're using SQL*Plus or SQL Developer there's a shorthand for this with the execute command:
exec your_package.remove_customer('CUST_ID');
And then check that the customer you tried to delete is no longer in the table...
you would just run it as:
begin
your_package_name.remove_customer('abc');
-- commit; -- optional if you want to commit it.
end;
/