Truncate table use in the procedure...
Dear,I created the test table.
Now, I have written a procedure like this.
create or replace procedure trunc_test
(ov_v_output OUT VARCHAR2) IS
Start
truncate table stable.
end;
I got error message like
PLS-00103: encountered the symbol "TABLE" when the expected in the following way:
:= . ( @ % ;
Someone help with this...
Thank you and best regards,
Raja.
TRUNCATE is a DDL statement, so you cannot use it directly in PL/SQL. You must run dynimically using EXECUTE IMMEDIATE.
So, your code should be
create or replace procedure trunc_test (ov_v_output OUT VARCHAR2)
is
begin
execute immediate 'truncate table testing';
ov_v_output := 'Success';
end;
Tags: Database
Similar Questions
-
How do I know a table used in the packeges or procedures
Dear all
How can I know that a table uses in any packege or procedure or function?
I mean, let's say I have 10 packages, procedures of 10 and 5 functions.
I need to know where the packages, procedures or functions using the EMP table.
How can I search? Is there any command or I need to open all proceedings and then pick up one by one?Hello
You can use the following sql query. USER_DEPENDENCIES / all_dependencies / dba_dependencies, these can also be used.
Select * from all_dependencies where referenced_name = 'your_table_name '.
Thank you
PAL -
Table table changes to the procedure
I have defined an object Type and an array Type, use it in the package as a parameter and use it in a FORALL statement. It compiles, but I can't really pass the data to the procedure.
I tried to call the procedure as follows:CREATE OR REPLACE TYPE TYPE_RD AS OBJECT (rd_id INTEGER, child_id INTEGER, start_date DATE, end_date DATE); / CREATE OR REPLACE TYPE TABLE_RD AS TABLE OF TYPE_RD; / PROCEDURE save_rd_test ( p_rec_data TABLE_RD ) IS BEGIN forall i in 1 .. p_rec_data.count -- the insert statement here EXCEPTION WHEN OTHERS THEN -- log the error END; /
What I'm trying to actually possible, and if so what am I doing wrong?exec save_rd_test(p_rec_data=>TABLE_RD((1000,100,to_date('01/01/2010','mm/dd/yyyy'),to_date('12/31/2010','mm/dd/yyyy')) ) ) PLS-00306: wrong number or types of arguments in call to 'TABLE_RD'
Maybe this?
exec save_rd_test(p_rec_data=>TABLE_RD(TYPE_RD(1000,100,to_date('01/01/2010','mm/dd/yyyy'),to_date('12/31/2010','mm/dd/yyyy')) ) )
-
Module for knowledge loop can be used in the procedure of the ODI
Hello
I have a unique requirement where I need to use the procedure for ForLoop ODI.
Y at - it an option that we can use to create several instructions based on loop For and execute these instructions in particular technologies.
Below is the code I have tried to create for the MS SQL Server technology in ODI procedure. It gives the select statement several times to condition. But somehow the value of i is not passed to select statement
< % for (int i = 10001; i < = 10005; i ++)
{% >}
Select * from [DB_SERVER]. [dbo]. [DB_TABLE] where col_1 = i
Union
< %}; % >
Select * from [DB_SERVER]. [dbo]. [DB_TABLE] where col_1 = 000000
It generates code below:
Select * from [DB_SERVER]. [dbo]. [DB_TABLE] where col_1 = i
Union
Select * from [DB_SERVER]. [dbo]. [DB_TABLE] where col_1 = i
Union
Select * from [DB_SERVER]. [dbo]. [DB_TABLE] where col_1 = i
Union
Select * from [DB_SERVER]. [dbo]. [DB_TABLE] where col_1 = i
Union
Select * from [DB_SERVER]. [dbo]. [DB_TABLE] where col_1 = i
Union
Select * from [DB_SERVER]. [dbo]. [DB_TABLE] where col_1 = 000000
Can you please help me to know how the value of i will impact inside.
Try this...
< %="" pour="" (int="" i="10001 ;" j’ai="">< =="" 10005 ;="" i="">
{% >
Select * from [DB_SERVER]. [dbo]. [DB_TABLE] where col_1 = <%=i%>
Union
<% }; %>
Select * from [DB_SERVER]. [dbo]. [DB_TABLE] where col_1 = 000000
-
Creating a table using a stored procedure, error
MY querry is as follows:
create or replace
PROCEDURE New_Account_Activations)
MYDATE_DD OUT VARCHAR2,
MYDATE_MM OUT VARCHAR2,
MYDATE_YYYY OUT VARCHAR2,
MYDATE OUT VARCHAR2,
VAR1 OUT VARCHAR2,
VAR2 OUT VARCHAR2,
VAR3 OUT VARCHAR2,
TABLE_NAME OUT VARCHAR2) ISBEGIN
SELECT TO_CHAR (SYSDATE-2, 'YYYY') INTO MYDATE_YYYY FROM DUAL;
SELECT TO_CHAR (SYSDATE-2, "MM") INTO MYDATE_MM FROM DUAL;
SELECT TO_CHAR (SYSDATE-2, 'DD') INTO MYDATE_DD FROM DUAL;
MYDATE: = MYDATE_YYYY | MYDATE_MM | MYDATE_DD | '000000.000Z';
-TABLE_NAME: = "NEWACCOUNTACTI_TEST";
VAR1: = 'B ';.
VAR2: = 'A ';
VAR3: = 'Y ';
Table_name: = "NewAccountActi" | '_' || MYDATE_YYYY | '_'|| MYDATE_MM | '_'|| MYDATE_DD;
run immediately "CREATE TABLE tbl_name AS SELECT * FROM NEWACCOUNTACTI_TEST WHERE 1 = 0';"END;
ERRORS
ORA-01031: insufficient privileges
ORA-06512: at "JACK. NEW_ACCOUNT_ACTIVATIONS', line 21
ORA-06512: at the level of line 12
Process is complete.
WRONG FORUM!
This forum is for Sql Developer issues only. Please mark the thread ANSWERED and repost it in SQL and PL/SQL forum.
https://forums.Oracle.com/community/Developer/English/oracle_database/sql_and_pl_sql
As says the Exception, your user JACK does NOT CREATE TABLE privileges granted DIRECTLY to them (not through a role) on the NEWACCOUNTACTI_TEST table. Grant privileges directly to the user.
If that does not meet your question repost your question in the forum; do NOT here.
-
MISP track changes made to a digitized table used during the conversion?
I need to convert several databases in AL32UTF8, which is 2 TB or so of size. I want to reduce the outage window. Most of the data is ASCII, but the character set is WE8ISO8859P15, so it is possible to get the non-ascii character in there. My plan was to analyze the database while it is live, then run MISP during the blackout without a full re-analysis. But I fear that a non-ascii character could go in there from scanning the failure. The MISP track changes since the last scan, so just check the lines that have been added or changed since the scan? In my tests limited until now, so it seems that complete analysis would take longer than the window of failure, a progressive solution would be wonderful. However, I don't see how to make this happen.
Thank you
Mike has
No, the CDS is not currently able to track incremental changes. However, you could try to categorize paintings like those who can get new non-ASCII characters and those who cannot. The fact that a given table has at least one non-ASCII character is a pretty good approximation of this classification. In this way, you could just rescan the tables which are likely to get new non-ASCII characters. Depending on the size of the problem tables this may shorten the time to restart the analysis considerably.
Note that all need conversion CLOB columns, even if they contain ASCII only.
To minimize the window of downtime, we recommend a solution with GoldenGate. GoldenGate is, however, not a free product.
Thank you
Sergiusz
-
How to get two of the parameter that is used in the procedure
Hi experts,
Am on the thought, but not yet answer keep me... so am here
With the help of Jdev11.1.1.5.0 - adfbc.
I got in db procedure like this
I wrote it in my AM, procedure is executing and printing of the param values perfectPROCEDURE proc_find_x_cal_year_period ( p_bu VARCHAR2, p_date DATE, p_year OUT NUMBER, p_period OUT NUMBER ).................
what I've done / my need:public void ProcFindxCalYearPeriod(String pbu, oracle.jbo.domain.Date pdate) { CallableStatement st = null; try{ String sql = "begin proc_find_x_cal_year_period" + "(:pbu," + ":pdate," + ":pyear," + ":pperiod)" + ";" + "end;"; st=getDBTransaction().createCallableStatement(sql,this.getDBTransaction().DEFAULT); st.setObject("p_bu",pbu); st.setObject("pdate",pdate); st.registerOutParameter("pyear",Types.VARCHAR); st.registerOutParameter("pperiod",Types.VARCHAR); st.execute(); System.out.println("pyear" +(String)st.getObject("pyear")); System.out.println("pperiod" +(String)st.getObject("pperiod")); } catch(SQLException e) { throw new JboException(e); } finally { if(st!=null) try{ st.close(); } catch(SQLException e){} } }
I paste this ProcFindxCalYearPeriod in my EO, and so am validating one of the field, this procedure should call at the time of the call, two parameters in two corresponding setter methods.
(String) st.getObject ("pyear")
value is here, I want to set setAttributeInternal ('x', (String) st.getObject ("pyear"));
(String) st.getObject ("pperiod")
setAttributeInternal ("x 1", (String) st.getObject ("pperiod"));
I hope that you all understand.In your procedure, you must create an object to hold out and return this object
public ProcResult ProcFindxCalYearPeriod(String pbu, oracle.jbo.domain.Date pdate) { CallableStatement st = null; try{ String sql = "begin proc_find_x_cal_year_period" + "(:pbu," + ":pdate," + ":pyear," + ":pperiod)" + ";" + "end;"; st=getDBTransaction().createCallableStatement(sql,this.getDBTransaction().DEFAULT); st.setObject("p_bu",pbu); st.setObject("pdate",pdate); st.registerOutParameter("pyear",Types.VARCHAR); st.registerOutParameter("pperiod",Types.VARCHAR); st.execute(); System.out.println("pyear" +(String)st.getObject("pyear")); System.out.println("pperiod" +(String)st.getObject("pperiod")); //assuming that you are getting the desired outputs *ProcResult outputs=new ProcResult();* *outputs.setOutParam1((String)st.getObject("pyear"));* *outputs.setOutParam2((String)st.getObject("pperiod"));* *return outputs;* } catch(SQLException e) { throw new JboException(e); } finally { if(st!=null) try{ st.close(); } catch(SQLException e){} } }
Now, you call this procedure like this
ProcResult execProc= ProcFindxCalYearPeriod(paramValue1, paramValue2); //you can get the proc outputs by calling String firstOutput = execProc.getOutParam1(); String second = execProc.getOutParam2();
But the question is why you call setAttributeInternal() while you are trying to validate an attribute?
I think that is not correct. -
Display lines without values in a table (using only the answers, 10g)
Hi gurus, I tried bumping the blank in a PivotTable , but since it s beating Pavilion 'responded' it probably won´t get any attention :) That solution seems good, but I get the error message "[nQSError: 10058] a general error has occurred." [nQSError: 22027] Union of incompatible types. (HY000) "when practice columns
My problem is that when a line in a dimension has no value it does not show. Often, it's good, but my requirement is that, even if she hasn´t got the values it should show:
For example
Total sales:
Sweden, 1234
Norway, 4321
Denmark, 1111
Sales - ice hockey clubs
Sweden, 1234
Norway, -.
Denmark--
OBIEE normally removes the Norway and the Denmark in this case, but I want that all the regions to show all the time.
Thanks in advanceOkay, now that you have validated your code, I would have been able to help, but you figured out where is the incompatibility. So now that you know the method works, you can mark this 'proper' and others who seek the same solution can benefit as well.
Thanks and good luck!
-
How to return rows by using the procedure?
Example: There are 3 areas: A, B, C and each region has some people.
create table person (name varchar2 (2), area varchar2 (2));
insert into values('A1','A') of the person; -1st rank
insert into values('A2','A') of the person; -line 2
insert into values('A3','A') of the person; -tier 3
insert into values('A4','A') of the person; -tier 4
insert into values('B1','B') of the person; -tier 5
insert into values('C1','C') of the person; -tier 6
insert into values('C2','C') of the person; -line 7
result as follows:
A, B AND C
--------------
A1 B1 C1
A2 C2
A3
A4
If we ' select * from person ", then we had all the lines.
I want to now choose volunteers in all areas, the rule is to pick one person from each region ordered, until that N people are selected. If N = 6, the sequence is
A1, A3, A2, B1, C1, C2
and want to return lines 1,5,6,2,7,3 (order of lines is not important) of the person.
How to create a procedure for this? And I want to return as rows returned by a select phrase. (can be easily filled in a DataTable object and then be used in a program).
Thank you!!
Hello
2985493 wrote:
Thank you. Could you write a procedure to do the job? This is just an example, real choice rule is complicated enough to be used by the procedure and the cursor. I wonder how do to write a procedure returns the result as a select phrase.
Here's one way:
VARIABLE c REFCURSOR
CREATE OR REPLACE PROCEDURE top_by_area
(csr ON SYS_REFCURSOR
, n_to_return IN PLS_INTEGER: = 6
)
IS
BEGIN
OPEN FOR CSR
WITH got_area_num AS
(
SELECT name, area
OF the person
ORDER BY ROW_NUMBER () (PARTITION BY AREA
ORDER BY name
)
area
)
SELECT name, area
ROWNUM AS r_num
OF got_area_num
WHERE ROWNUM<=>=>
ORDER BY r_num
;
END top_by_area;
/
DISPLAY ERRORS
EXEC top_by_area (: c);
PRINTING: c
PRINT the output of the command, given your sample data is:
R_NUM DOMAIN NAME
---- ---- --------
A1 1
B1 B 2
C1, C 3
A2 4
C2 C 5
A3 A 6
It's just a way to create and test the procedure. I don't know how you plan to use it.
-
How to get data in the procedure after CREATE TABLE table1 AS SELECT * from table2
Hello
can any body tell me how to get the data in the new table created in the procedure. because it gives following error.
- Error (47,21): PL/SQL: ORA-00942: table or view does not exist
tableName: = "BCKUP_" | TO_CHAR (sysdate, 'ddmmrrrr');
tableDDL: = 'CREATE TABLE' | tableName. "AS SELECT * FROM Table1 where to_char(MSG_IN_TIME,''dd-mon-rrrr'') < sysdate - ' | daysNumber;
EXECUTE IMMEDIATE backUpDDL;
COMMIT;
DELETE FROM Table1;
How to select the data in the newly created table. as...
Select * from ". tableName;
Do not choose anything to get the number...
Just after backupDDL EXECUTE IMMEDIATE, simply refers to SQL % ROWCOUNT - who will be the number of lines.
Oh and DDL engages automatically, your commitment is redundant.
-
Tables used in views, relaxation
Hello
Please let me know the query to find the tables used for the creation of a database and view trigger.
Thank you and best regards.select TABLE_NAME from user_triggers where TRIGGER_NAME=&Trigger_Name
-
How to change a table referenced in the form
Hello
I have a "form1" page based on the table "tab1"; "tab2" table is very similar to 'tab1' so I would save time copy "form1" to "form2", then changing the elements. I made the copy, but now I'm not able to modify the table referenced in 'form2' from 'tab1' to 'tab2'... is possible to do?
Thank you.
Eugenio
Request Express 2.1.0.00.39
Published by: user1342238 on April 13, 2009 02:22Hello
You should check the process "go get the line...". "and"process line... ". "on your page, like these identify the table used for the form
Andy
-
Using the procedure to display the table of multiple data
Hi, I need help for the procedure in oracle
I want to create the procedure to display the table of multiples with sample plan
with a parameter imployee_id to display an employee_id, name, function, start_date, end_date
IAM using this query to select more than one table
SELECT e.employee_id, e.first_name, j.job_title, h.start_date, h.end_date
E EMPLOYEES
JOIN j jobs
ON j.job_id = e.job_id
JOIN the job_history:
ON h.employee_id = e.employee_id
WHERE e.employee_id = 200;
Thanks for the help
Blu and Billy showed you the 'real' solution. You can display the data returned by a cursor ref in SQL Developer, too:
http://www.thatjeffsmith.com/archive/2011/12/SQL-Developer-tip-viewing-refcursor-output/
Yet as a duty for a beginner is generally do not have the expected solution. Usually, teachers want to see you using a LOOP and dbms_output. something like
DECLARE
Xy CURSOR IS
SELECT whatever
As much as;
BEGIN
FOR r IN xy LOOP
dbms_output.put_line (r.col1 |' # ' | r.col2);
END LOOP;
END;
Of course this suggestion will inaugurate a discussion abusing DBMS output but I keep my position that it is authorized to use it for learning the basics.
-
Using 'STORAGE of REUSE' with the command 'TRUNCATE TABLE '.
Because ' truncate table... reuse storage "speed up the tronquantes process?
Sometimes statements truncation takes about 30 minutes and other times just a few minutes.
What are the backs of uinsg print 'reuse storage?The RE-USE of STORAGE clause is used to prevent the allocated storage of back to the pool.
Consider this scenario for a typical daily load of an intermediate table1. Empty the table of yesterday's data - TRUNCATE it 2. Load the table with today's data - INSERT
If you load a large number of records it takes time for Oracle to allocate storage for records
When you use Oracle TRUNCATED must return the storage allocated to the pool.
Then when you INSERT new records, that oracle has to allocate the space that he could have used, but returned to the pool.If you use TRUNCATE... RE-USE of STORAGE Oracle truncates the table but keep the storage and it will reuse the same storage
When you do the INSERT instead of having to take the time to allocate new storage.So, there are two options to speed up ETL processes like that.
1. use TRUNCATED... RE-USE of STORAGE and a standard INSERT query2. use TRUNCATE and INSERT / * + APPEND * / and make the table NOLOGGING to INSERT it. This will make a big
load. Oracle must allocate space, but the load mass will make them more effective than a standard INSERT.-editing to update after reading the reference asktom
Storage of back to the pool takes time, so REUSE STORAGE of coding may be faster. The real advantage comes with the next load of data, however if you use a standard INSERT (and not in BULK or direct load) because Oracle failed to reallocate storage.If RE-USE eliminates the return of storage to the pool, as well as the allocation of the new storage for the next INSERTION.
Published by: rp0428 on February 20, 2012 11:16
-
Create the procedure, truncate table
When I run the following, I get the following error:
on the 'truncate table BASE;' line in the following text:PLS-00103: Encountered the symbol "TABLE" when expecting one of the following: := . ( @ % ;
Can someone tell me what I am doing wrong?CREATE OR REPLACE PROCEDURE TransferData IS BEGIN --clear current tables to allow for clean data truncate table BASELINE; truncate table TREATMENT; truncate table FOLLOWUP; truncate table WITHDRAW; END;
Thank you!TRUNCATE is not DML, DDL, but you will need the dynamic SQL statements here:
CREATE OR REPLACE PROCEDURE TransferData IS BEGIN --clear current tables to allow for clean data execute immediate 'truncate table BASELINE'; execute immediate 'truncate table TREATMENT'; execute immediate 'truncate table FOLLOWUP'; execute immediate 'truncate table WITHDRAW'; END;
Maybe you are looking for
-
some characters on the keyboard does not not after installation of macos sierra
keys on one side does not not after installing sierra on my mac pro book
-
No support for npapi plugin?
Hi, we use software that is based on JAVA for our clients to access our services. As I read in some news, support for NPAPI plugins will end in the 64-bit version of firefox 41 (so java no longer be supported). This is only version 64-bit windows or
-
HP Pavilion Elite HPE-575 has: the graphics card upgrade
Hi I want to know if a GTX 950 oc 2gbddr5 graphic card is compatible with my HP Pavilion Elite HPE - 575 a pc, if someone can shed some light on this would be very appreciated
-
HP pavilion 2003ax blutooth g4 does not connect
After you install new window 7 ultimate 64 bit everything is perfect, but when I connect my cell phone to the his research blutooth device and search unanswered and with all the drivers of the peripheral nootbook blutooth blutooth under its weight I
-
Increase the speed to setting 5672/PXI-5671?
Hello I was wondering if it would be possible for materials OR to include an option on NOR-RFSG drivers later to increase the speed at which the lock 5672/5671 on a frequency? Will you please correct me if I'm wrong but I think that the reason why it