Syntax for delete statement within a procedure
within a procedure i tried to delete the table using
delete table tablename;
but it is showing error that
PL/SQL: SQL Statement ignored
PL/SQL: ORA-00903: invalid table name
whether we have to use execute immediate delete table tablename;
or this syntax is correct
Hi ,
i think if you want to use the delete
then it shld be delete from tablename --> this'll delete all rows
but if u want to use execute immediate then you might as well use TRUNCATE --> provided you need not have these data written to the log file (if you need for recovery later better use DELETE)
i.e EXECUTE IMMEDIATE ('TRUNCATE TABLE tbl_name');
hope this helps
Similar Messages
-
Delay in execution of statements within a procedure!
Dear All,
My Database is Oracle 11gR2 on Linux.
I have to schedule delete in 5 tables. For this i will write a procedure with delete queries and schedule the procedure to run daily in night.
I want to give delay in the execution of delete queries within procedure? How can i add this functionality within a procedure?
I don't want to lock the tables as other queries may be accessing the same table meanwhile.
Looking for your help.
Regards,
ImranOther queries accessing the table meanwhile is a perfectly normal reason to lock the tables, as writers don't block readers.
Implementing 'delays' is definitely an amateurish hack to result into more problems.
Locking and transactions are one of the core functions of any RDBMS, and it is better to understand them, than to implement hack on hack on hack to turn a Ferrari like Oracle in a broken bike with a flat tire.
After several years of asking doc questions you should know better.
BTW can you explain why you end all of your questions with an unnecessary exclamation mark?
If you can't explain this, can you stop doing so?
There is no reason to yell here.
Thank you
Sybrand Bakker
Senior Oracle DBA -
Sp_executesql vs transaction statement within Stored Procedure
Experts,
Any difference between sp_executesql vs Transaction/Commit statement or try/catch block within Stored Procedure?
What is the best practice to use and why?
Thank You
Regards,
Kumar
Please do let us know your feedback. Thank You - KG, MCTSYour question is a bit strange. sp_executesql is used for dynamic SQL. Unless the problem demands dynamic SQL and, therefore, sp_executesql, there is no need to use it.
For a single statement I would not use transaction and try/catch. For multiple statements you do need to use transaction. It's up to you if you want to use try/catch in the SP or not and trap the error in the client application.
For every expert, there is an equal and opposite expert. - Becker's Law
My blog
My TechNet articles -
Syntax for deleting listener config.
Can you delete / recreate a listener ?
I can't seem to find the right syntax for this.
NAME=ora.rac2.LISTENER_RAC2.lsnr
TYPE=application
TARGET=ONLINE
STATE=OFFLINE
------------------------------------------------------------If you don't want to use netca then shutdown the listener you want to get rid off. Make sure it is offline. Clean-up listener.ora (and maybe tnsnames.ora) manually then issue:
crs_unregister ora.rac2.LISTENER_RAC2.lsnr
Hope this helps. -
How to add the delete statement in this procedure.
I got a string from user e.g. 1,2,3 and userid =14 from user;
I wrote a procedure that will insert the record as follows;
Userid newsletterid
14 1
14 2
14 3
The procedure is
CREATE OR REPLACE PROCEDURE usersubscription_procd (vuserid in number, vnewsletterid IN VARCHAR2)
AS
I NUMBER;
J NUMBER;
VAL VARCHAR2(100);
BEGIN
I := 1;
J := 1;
WHILE INSTR(vnewsletterid,',',I) != 0 LOOP
VAL := SUBSTR(vnewsletterid,I,INSTR(vnewsletterid,',',I)-J);
I := INSTR(vnewsletterid,',',I)+1;
J := I;
INSERT INTO usersubscription (usersubcriptionid,userid,newsletterid)
VALUES (usersubscription_seq.nextval,vuserid,VAL);
END LOOP;
VAL := SUBSTR(vnewsletterid,I,LENGTH(vnewsletterid));
INSERT INTO usersubscription (usersubcriptionid,userid,newsletterid)
VALUES (usersubscription_seq.nextval,vuserid,VAL);
END;
Now one requirement is that
When next string comes like 1,4 for same user
Then I want to delete the 2 and 3 and insert the 4 .
Please tell me solution.Hi,
Try to delete all record from ther current user :
CREATE OR REPLACE PROCEDURE usersubscription_procd (vuserid in number, vnewsletterid IN VARCHAR2)
AS
I NUMBER;
J NUMBER;
VAL VARCHAR2(100);
BEGIN
begin
delete usersubscription where userid = vuserid;
exception when others then null;
end;
I := 1;
J := 1;
WHILE INSTR(vnewsletterid,',',I) != 0 LOOP
VAL := SUBSTR(vnewsletterid,I,INSTR(vnewsletterid,',',I)-J);
I := INSTR(vnewsletterid,',',I)+1;
J := I;
INSERT INTO usersubscription (usersubcriptionid,userid,newsletterid)
VALUES (usersubscription_seq.nextval,vuserid,VAL);
END LOOP;
VAL := SUBSTR(vnewsletterid,I,LENGTH(vnewsletterid));
INSERT INTO usersubscription (usersubcriptionid,userid,newsletterid)
VALUES (usersubscription_seq.nextval,vuserid,VAL);
END;
/Nicolas. -
What's the syntax for Insert statement in Servlet?
I'm trying to insert record into table using servlet. Can you please show me the statement and syntax of how to use it?
hi
we can insert in 2 types
1) to all column insert
insert into <tablename> values ( 1,2,3,4...n);
2) particular column insert
insert into <tablename> ( col1,col2,col3...n) values ( value1 for col1, 2 , 3...n);
ex:
PreparedStatement ps = con.prepareStatement ( "insert into billtable (grandtotal,userid,creditno)values( ?,?,? )" );
//bill table
ps.setDouble ( 1, 10.50); //replace this double value with double variable
ps.setString ( 2, "vijay");
ps.setLong ( 3, 1111111111);
ps.executeUpdate ();
ps.clearParameters ();
ps.close ();More Details refer java with Jdbc concepts -
Syntax for Merge statement to insert into target and update source
Hello All,
I want to use Merge statement to insert records when not matched in my target and update records in source when matched. Is it possible to do using Merge statement.
create table a (aa number)
create table b (bb number)
alter table a add flg char(1)
merge b as target
using a as source
on (target.bb = source.aa)
when matched then
update set source.flg = 'Y'
WHEN NOT MATCHED THEN
insert (target.bb)
values
(source.aa)
Thanks.Hi,
I have no idea about the version of DB, else some new features with respect version can be specified - just for informaitve purpose and to post across the verison of DB in future posts.
Coming to your issue and requirement.
if you check the syntax and functionality , then its on Merge on target base only - with respect to Update (matched o columns) and insert (for unmatched columns). Source - as the term is clear. It might not work out on source table.
- Pavan Kumar N
- ORACLE OCP - 9i/10g
https://www.oracleinternals.blogspot.com -
Determining proper hyperlink syntax for TOC destination within PDF using example?
I've dabbled but only able to construct a hyperlink jumping to a specific page rather than jumping to a specific table of Contents (TOC) entry, e.g. "901. Scope of the Training and Education Program" in http://www.nerc.com/files/NERC_ROP_Effective_20130305.pdf
Q1: In general how should one determine and form up a TOC based hyperlink to a destination within a PDF such as this.. likely applying "hxxp://www.domain.com/file.pdf#nameddest=TOC" syntax?
Q2: What would be the specific hypertext brower launch link for this example?
tiaTo make use of the "nameddest" parameter you'll have to actually have those in the PDF. The PDF at the link does not have any.
As the authoring file for the PDF was a Word file you could see if Word can be configured to provide named destinations.
If not then you would have to put them in manually using Acrobat (Pro supports this - maybe Standard also).
If you don't already have it the "Parameters for Opening PDF Files" is the document that discusses parameters for opening a PDF via a URL.
http://wwwimages.adobe.com/www.adobe.com/content/dam/Adobe/en/devnet/acrobat/pdfs/pdf_open _parameters_v9.pdf
Be well... -
Dynamic query for delete statement
Hi friends,
I have a table hierarchy where suppose i have tables with following hierarchy
Level1
level2 (child of level1)
level3 (child of level2)
level4 (child of level3)
Now i want to delete data from lowest level table depending on level one table value which is provided to me.
I have a requirement where i want to create this delete query dynamically.
Any help in this concern...
Thanks,
SachinYon can use on delete cascade as satyaki suggested like
SQL> select * from level1;
ID DESCRIPTION
1 L1_1
2 L1_2
4 L1_3
5 L1_4
4 rows selected.
SQL> select * from level2;
ID DESCRIPTION L1_FK
1 L2_1 1
2 L2_2 1
4 L2_3 2
5 L2_4 2
4 rows selected.
SQL> delete from level1 where id =1;
1 row deleted.
SQL> select * from level1;
ID DESCRIPTION
2 L1_2
4 L1_3
5 L1_4
3 rows selected.
SQL> select * from level2;
ID DESCRIPTION L1_FK
4 L2_3 2
5 L2_4 2
2 rows selected.
SQL> -
DELETE syntax for RDF triplets
Hi,
In the ORACLE RDF documentation only the syntax for inserting an RDF triplet is specified. It is:
INSERT INTO articles_rdf_data VALUES (2,
sdo_rdf_triple_s ( 'articles', '<http://www.nature.com/nature/Article1>',
'<http://purl.org/dc/elements/1.1/creator>',
'"Jane Smith"'));
What is the syntax for deleting a triplet? Can SQL statements be combined such that a deletion of the results of a previous SELECT be performed. Thanks in advance.
Cheers,
MirceaHi,
Alter Table Constraint Add Fk_Dept Foreign key(dept_no) references dept(dept_no) on delete cascade.
Hope this helps
Regards,
Ganesh R -
Regarding passing internal table data to D.B Table&DELETE statement in ABAP
Hi All,
Can anybody tell me what is the exact syntax for following statement.
<b>Get all records from table zppe0169_01 into an internal table-I_PO and delete duplicates for unique EBELN and EBELP</b>
Can any body give syntax for the above.
Thanks in advance.
Thanks & Regards,
Rayeez.Hi All,
Thanks for those replies.
Actually <b>zppe0169_01[Datbase table]</b> and I_PO structures are diffrent.
They are as follows
<b>For I_PO
BEGIN OF i_po OCCURS 0,
ebeln LIKE ekpo-ebeln,
ebelp LIKE ekpo-ebelp,
matnr LIKE ekpo-matnr,
werks LIKE ekko-reswk,
eindt LIKE eket-eindt,
ps_psp_pnr LIKE ekkn-ps_psp_pnr,
ptype(3) TYPE c,
techs LIKE ekpo-techs,
mesg(50) TYPE c,
END OF i_po.</b>
For zppe0169_01 fields are as follows.
<b>EBELN
EBELP
MATNR
WERKS
EINDT
PS_PSP_PNR
PTYPE</b>
as I_PO is having 2 more fields than actual database table will the following SELECT statement fetch the data correctly.
<b> SELECT *
FROM zppe0169_01
INTO TABLE i_po.</b>
If <b>No</b> - can anybody tell me what change i have make to above SELECT to make it work perfectly.
Thanks & Regards,
Rayeez. -
SQL Syntax for Access database
This pertains to LV only due to the fact that LV requires a slightly different syntax for SQL statements for use with Access than what you will see in the Access Queries SQL view. For instance, I discovered that if you use a ? for a character placeholder (can be any single character) in Access, you need to use an _ (underscore) for this feature. I also discoverd that you use a % sign instead of an * (asterisk) for any number of characters.
The lat thing I am having trouble with is specifying a range of characters that could be in a certain position in the text field. For instance, if the first character can be only an alpha between A and Z, and the next two characters can be numbers anywhere from 1 to 12, I would use LIKE "[A-Z][1-12]*" In LV, the double quotes are are replaced with single quotes but I cannot figure out what to replace the brackets with.
The brackets do not return a syntax error but also do not return any results that should fit the pattern.
I have tried parenthesis, double quotes, using a TO in place of the dash, etc.
Any input on this is very much appreciated.
Doug
I guess sometimes writing the problem out helps one deduce the answer by taking a closer look at what has been tried and what has not.
So LIKE "[A-Z][1-12]*" in Access will be LIKE ('[A-Z][01-12]%') in LV. I hadn't tried the pecent sign in place of the asterisk using the brackets. Too bad this stuff isn't spelled out in detail somewhere.
Doug
"My only wish is that I am capable of learning each and every day until my last breath."Thanks Danubio for the links. The one for the SQL utility may be helpful as I go forward.
Mike, yes I am using the connectivity toolkit. It's what I cut my teeth on and up to this point, has not caused me any issues. I rarely make changes after implementation but if I do, the use of typedef's keeps it pretty painless. A brief read on the doc included in your referenced zip file confirms there are alternate methods to talks to the database tables (I am not a one table programmer). When time permits, I will do some trials and if warranted, will try some of your techniques at some point. Simply not enough time currently.
As I posted intially, I actually solved my problem before there were any replies and included my solution in the first post. Why there is a syntax difference going from LV to an mdb is an unknown to me but it exists nonetheless.
Thanks for the input on this
Doug
"My only wish is that I am capable of learning each and every day until my last breath." -
DELETE TABLE STATEMENT WITHIN A LOOP IN A PROCEDURE
i am using delete table tablename statement inside a cursor for loop which is inside a procedure
it is telling error in that delete statement
can't i put it inside the loopyou can only run DDL commands like create, drop etc in pl/sql by using "execute immediate" or dbms_sql package. when you use either of the two mentioned , it will work anywhere in PL/SQL , yes even in a loop. Note that the commit on DDL are implicit , so take care of your transactions if any ..
--Samson -
Missing privilege - DELETE statement in procedure
Hello experts,
I am facing a problem for my procedure. I am not able to active the procedure if I use DELETE statement in the produce. When I use only selects, it is working fine. The SYSTEM user has access to the schema with full rights, including DELETE.
PROCEDURE "SYSTEM"."DEV_COL.procedures::FI" ( )
LANGUAGE SQLSCRIPT
SQL SECURITY INVOKER
DEFAULT SCHEMA UXX790
AS
BEGIN
Write your procedure logic
-- SELECT vbeln
--count(*)
DELETE
from vbapold
where erdat < ADD_days(now(), -1700);
END;
Did anybody had the same issue? I run HANA rev70.
BR
TamasHi Tamas
if this is a repository procedure user _SYS_REPO has to have the DELETE privilege with grant option as well.
- Lars -
Procedure for deleting a role which is already in Production
Hi,
can any one explain me the procedure for deleting a role which is already in production
i want to know procedure for deletion of
1.single role
2.composite role
3.derived role
4.parent role
thanks,
SSSSHi,
Role deletion must be done in development box and the deletion must be transported to quality and productuion
For single and derrived roles create the transport request and delete the role and transport the deletion.
For Deletion of parent role: you cannot delete the parent role unless all the derrived roles within it are deleted.
To avoid the transport of user assignment make sure PRGN_CUST is set to 'NO' value for the parameter USER_REL_IMPORT.
Rakesh
Maybe you are looking for
-
Is there a setting that will automatically stop ITunes from playing the next song? I am working with a woman with a disability who wants to be a DJ. She speakes using a communication device and needs time to talk before the song starts. She moves slo
-
Installing tryout version encore 2 ...problems
I've been trying to install the tryout version of encore DVD 2 on my computer and is telling my the 30 days period has expired. I don't understand way, I have a Core 2 @ 2.4, matrox rtx 100, I have encore DVD 1.5, premiere 1.5, audition and after eff
-
Oracle Portal for LDAP Authentication(Iplanet)
Oracle portal installed on Solaries machine and LDAP (iplanet) installed on windows NT machine.I am able to take ldif file from portal30 user and add to ldap.( under o=oracle tree) Completed all step mentioned in document conf_ldap.pdf as follows 1.
-
Music Player that supports FLAC?
Hi, Have just bought a ZTE Open with Firefox OS, and have been looking forward to it arriving. Got it yesterday and am generally very happy, BUT my entire music collection is in FLAC, and it seems that: a) the default music player doesn't support FLA
-
Disable RSS in Safari 4?
Still looking before I leap: I have RSS disabled in 3.2.3 with the following Terminal command: defaults write com.apple.Safari DebugSyndicationEnabled 0 Does anyone, perhaps, know if this command will work with Safari 4 (Tiger PPC)? I will probably r