Documentation writing stored procedures
Hi,
I wanna write some stored procedures but I cannot find any documentation. Usually I develop stored procedures in oracle (pl/sql) but now in MaxDB I'm really missing good documentation/books about programming MaxDB.
Any links to docu's ?
Thanx a lot!
regards
Wolfgang
Hello Wolfgang,
Please have a look at the SAP MaxDB Documentation Library:
[http://maxdb.sap.com/doc/7_8/1f/b930565f304113bb249b2de677fd69/frameset.htm|http://maxdb.sap.com/doc/7_8/1f/b930565f304113bb249b2de677fd69/frameset.htm]
Best regards
Marina
Similar Messages
-
Writing stored procedures.--PLSQL
Hello,
Need help in learning and writing stored procedures.
Scenario is :-
Tabes:-
Employee -->
* Fields are (empl_id,fname,lname,employee_status)*
* values ( 1,P,M,A)*
* (2,JK,KK,A)*
* (3,lk,kj,a)*
Project->
*(Project_id,Projname,duration)*
* 1 CLEANING*
* 2 driving*
Project and Employee---RELATIONSHIP ---> proj_id and employee_id
Employee_project_reltn
*(project_id,employee_id,created_dt,duration,status)*
1 1
1 3
2 3
{color:#0000ff}_An employee can work in multiple projects(1-MANY) at a time. _{color}
Question:- Please help me with the PROCEDURE for getting all EMPLOYEE details of a PROJECT.
That means, ---->Input is PROJECT_ID as 1 ----RESULT is employee details of employee no 1 and 3 + Project details fully
{color:#0000ff}*(1)I don know how to return the entire result set filled with data.Please help me writing the correct full procedure.*{color}
{color:#0000ff}*(2)Also, a Procedure to add an employee to a project.Inputs are employee_id,project_id*{color}Hi,
If the table Employee_project_reltn has correct foreign keys defined you can attemp to do the insert and if a integrity constrain is violated (ORA-02291) then the exception invalid_employee_or_project is raised.
As a starting point:
CREATE OR REPLACE PROCEDURE proc_add_employee_to_project(p_employee_id IN Employee_project_reltn.employee_id%TYPE,
p_project_id IN Employee_project_reltn.project_id%TYPE,
p_message OUT VARCHAR2) IS
invalid_employee_or_project EXCEPTION;
PRAGMA EXCEPTION_INIT(invalid_employee_or_project,
-2291);
BEGIN
p_message := 'Succesful';
-- Your insert
-- commit;
EXCEPTION
WHEN invalid_employee_or_project THEN
p_message := 'invalid_employee_or_project';
ROLLBACK;
WHEN OTHERS THEN
p_message := SQLERRM;
ROLLBACK;
END proc_add_employee_to_project;
/Regards, -
Confusion when writing Stored Procedure...
Iam having confusion when writing Stored Procedure.Plz solve my confusion.
Can we write Stored Procedure using JDBC like the Code I have given.If So,what is the wrong i had made in the Code?.Iam using MySQL 5.0.27.
If it can't be done with the code that i had written, Iam telling Some steps that I have learned,suggest, whether it is correct or not?
Step 1:
Create Stored Procedure in database separately.We can't create stored procedure in JDBC(Am I Right?).
Step 2:
After writing Stored procedure call the procedure inside JDBC using preparecall method of callable statement.
Code:
try
Class.forName(dbDriver).newInstance();
out.println("<b>MySQL Driver Loaded Sucessfully </b>"+"<br>");
connection=DriverManager.getConnection ("jdbc:mysql://localhost:3306/exportproc? user=root&password=sachin");
statement = connection.createStatement();
out.println("<b>Statement Created</b>");
sql="create procedure exportproc(in name varchar(15),in password varchar(12))"
+"begin"
+"insert into exportproc values(name,password)"
+"end";
out.println("<b>Query assigned to sql</b>"+"<br>");
statement.executeUpdate("create database exportproc");
statement.executeUpdate("use exportproc");
statement.executeUpdate(sql);
out.println("Table Created");
}Message was edited by:
sachindevhi,
create a stored procedure in mysql , i dont know mysql , any way we take your code
create procedure exportproc(in name varchar(15),in password varchar(12))
begin
insert into exportproc values(name,password)
endprocedure created ....
now just call in java by using CallableStatement
ex:
CallableStatement cs = con.prepareCall("{call exportproc(?,?)}");
cs.setString (1, "vijay");
cs.setString (2, "123");
cs.executeUpdate (); -
Documentation about Stored Procedure in SBO
Hi experts,
I need some documentation about the how to use of Stored Procedured in SBO, what is valid and what is not valid for SAP. I want to know If only Execute SP from SBO, but no INSERT, DELETE or UPDATE in any SBO database table is valid for Support SAP??
Thanks.Hi,
You can refer to Note No. [ 896891|https://websmp130.sap-ag.de/sap(bD1odSZjPTAwMQ==)/bc/bsp/spn/sapnotes/index2.htm?numm=896891] regarding the Support Scope.
You can check the link mentioned in the following thread
Re: Tracking Opportunity
Regards,
Jitin
SAP Business One Forum Team -
Help in writing stored procedure!!!
Hi,
I m working step by step ....its very unclear to me ...because, my boss gave me SAS code and asking me to convert it into PL/SQL code ...without businees requiremnet.....thats sounds really wired .....And i dont know the SAS......So please help me in this regard ..How do i write a stored procedure for the following requirement...
Create a table master as select from*
*( select * from acct_master*
where join_dt < NVL( close_dt,sysdate)
oder by acct_nbr, join_dt, nvl (close_dt,sysdate));
here its creating a master table and inserting the acct_master(prod table) result. Now the next step is i have to query the data which i got in master which is a another step, and that resulted query has to be inserted into another table called 'TEST'.
so how do i write a proc for this above process......Pleaseee....Help!!!! Thank you so much ...i really appriciate it.Raj,
Here is the SAS code ....for What i described Before... I m absolutely new to SAS ...first time im looking at SAS code....I m Posting what they gave me and told me ....
There are basicallY two parts ......First part creates table i guess and second part queries the data i guess...
First part*.........
proc sq1;
&con_str;
create table master (sortedby= acct_nbr join_dt ) as
select *
from connection to ora (
select *
from acct_master
where join_dt < nvl ( close_dt, SYSDATE)
order by acct_nbr, join_dt, NVL
(alian_close_dt, sysdate) )
& dis_str;
quit;
Second Part*
%let EOT = '31MAY3000'd;
data test ;
set master (keep= acct_nbr id join_dt close_dt cu_type cu_stat csd_resn );
format init_join_dt join_dt close_dt effective_dt expire_dt lag1_expire_dt date9.
fy_join 4.
init_cu_type $3. ;
retain init_join_dt fy_join n dlk_pend lag1_expire_dt lag1_id 0
init_cu_type ;
by acct_nbr join_dt ;
join_dt = datepart(join_dt);
close_dt = datepart(close_dt)-1;
if first.acct_nbr then do
dlk_pend = 0;
lag1_id = .;
lag1_expire_dt = .;
init_join_dt = join_dt ;
fy_join = year(intnx('month',join_dt,7));
init_cu_type = cu_type;
n = 1;
end;
expire_dt = close_dt ;
lag1_id = lag1(id);
lag1_expire_dt = lag1(expire_dt) ;
if dlk_pend then do ;
cu_class = 'DLK';
effective_dt = lag1_expire_dt + 1;
expire_dt = join_dt - 1;
curr_id = id ;
id = lag1_id;
dlk_pend=2;
output;
id = curr_id ;
dlk_pend=0;
end;
effective_dt = join_dt ;
/* If the join date is in the initial fiscal year (01 june is fiscal year) */
if join_dt < MDY( 6, 1, fy_join ) then do
cu_class = init_cu_type;
/* If it's open or closed after the end of the initial fiscal year */
if close_dt = . or close_dt >= MDY( 6, 1, fy_join ) then do ;
* Create one record through the end of the fiscal year;
expire_dt = MDY( 6, 1, fy_join ) -1 ;
output;
* Create another record through the close date or leave open;
effective_dt = expire_dt + 1 ;
cu_class = 'EXISTING';
expire_dt = coalesce(close_dt,&EOT) ;
output;
end;
else do;
* it it closed in the initial fiscal year, then output just one record ;
expire_dt = close_dt ;
output ;
end;
end;
* if the record starts after the initial fiscal year ;
else do;
* Create a record through the close date or leave open;
cu_class = 'EXISTING';
expire_dt = coalesce(close_dt,&EOT) ;
output;
end;
* if record is delink, output a DLK record ;
if cu_stat = 'CLOSED' and csd_resn = 'DLK' then do
effective_dt = close_dt + 1;
expire_dt = &EOT ;
cu_class = 'DLK';
if last.acct_nbr then output;
else dlk_pend = 1 ;
end;
n+1;
run;
So here is the SAS code ....Thank you so much guys ...i really appriciate it!!!! -
Error while compiling a stored procedure
Hi Expertise,
I want to have all table names with their column name and tried using below stored procedure and it is throwing some compiler error at "fetch TestCurr into temp2;"
I am very new to Data base and writing stored procedure and not able to understand how to resolve it. Please anyone help me out to correct it and provide some better idea to achieve my requirement. This is very urgent. One more thing, I want all these data into a log file.
create or replace
procedure temp as
begin
DECLARE
cursor C1 IS SELECT COLUMN_NAME FROM user_tab_columns;
file_id UTL_FILE.FILE_TYPE;
Temp1 all_tables.table_name%TYPE;
temp2 user_tab_columns.COLUMN_NAME%TYPE;
cursor TempCur is Select table_name from all_tables where owner='XSS_ADMIN' order by TABLE_NAME;
begin
open TempCur;
loop
fetch TempCur into Temp1;
exit when TempCur%NOTFOUND;
DBMS_OUTPUT.PUT_LINE(Temp1);
declare cursor TestCurr is select COLUMN_NAME from user_tab_columns where table_name= Temp1;
open TestCurr;
loop
fetch TestCurr into temp2;
exit when TestCurr%NOTFOUND;
DBMS_OUTPUT.PUT_LINE(Temp2);
end loop ;
close TestCurr;
end loop;
Thanks in advance
R e h a nHi,
declare cursor TestCurr is select COLUMN_NAME from user_tab_columns where table_name= Temp1;
open TestCurr;
loop The Cursor Declarations Should be done in the declaration Section of the PLSQL Block.
The General Structure of Cursor Declaration is:
DECLARE
CURSOR curr IS
SELECT FROM WHERE;
rec curr%ROWTYPE;
BEGIN
OPEN curr;
LOOP
FETCH curr INTO rec;
EXIT WHEN curr%NOTFOUND;
END LOOP;
CLOSE curr;
END;
If Use Multiple Cursor Declaration, then Use the below Structure ,
DECLARE
CURSOR curr IS
SELECT FROM WHERE;
CURSOR curr_1 IS
SELECT FROM WHERE;
rec curr%ROWTYPE;
rec_1 curr_1%ROWTYPE;
BEGIN
OPEN curr;
LOOP
FETCH curr INTO rec;
EXIT WHEN curr%NOTFOUND;
END LOOP;
CLOSE curr;
END;
So, You can Fetch the value for the Second Cursor in the LOOP of the First Cursor Statement.
Or Just Declare a Single Cursor and User FOR-CURSOR LOOP as
DECLARE
CURSOR curr IS
SELECT FROM WHERE;
rec curr%ROWTYPE;
BEGIN
OPEN curr;
LOOP
FETCH curr INTO rec;
EXIT WHEN curr%NOTFOUND;
for rec_curr in(select *from where col_name =rec.col_value)loop
.............Processing
end loop;
END LOOP;
CLOSE curr;
END;
You have ample example available for ,Please have a look at it and Try.. All the Best !!!!!
Thanks,
Shankar -
Stored Procedure Parameters - Setting a default value
Using SQL 2005, 2008, 2012
This should be easy, but think that I am making it hard. Below is the stored procedure that I want to call. If I want to pass a 'N' to @SearchDBsFlag how can I retain the default values for @DBName and @PreviewTextSize? I do not want to explicitly pass the
NULL, 100. I want it to pick up the default values that are defined in the stored procedure.
Create Procedure [dbo].[ifs_util_Find]
@SearchText varchar(8000)
, @DBName sysname = Null
, @PreviewTextSize int = 100
, @SearchDBsFlag char(1) = 'Y'
, @SearchJobsFlag char(1) = 'Y'
, @SearchSSISFlag char(1) = 'Y'I did look up "flag coupling" and all I found was posts from you.
Start with http://en.wikipedia.org/wiki/Coupling_(computer_programming). The terminology varies; what I call "flag coupling" is one version of Content
coupling.
Cohesion:
This is how well a module does one and only one thing; that it is logically coherent. The modules should have strong cohesion. You ought to name the module in the format "<verb><object>", where the "<object>" is a specific logical unit in
the data model. There are several types of cohesion. We rank them going from the worst form of cohesion to the best
1) Coincidental
2) Logical
3) Temporal
4) Procedural
5) Communicational
6) Informational
7) Functional
Coupling:
If modules have to be used in a certain order, then they are strongly coupled. If they can be executed independently of each other and put together like Lego blocks, then they are loosely or weakly coupled. There are several kinds of coupling, which are ranked
from worse to best:
1) Content
2) Common
3) Control
4) Stamp
5) Data
This is covered briefly in a chapter on writing stored procedures in my book on SQL PROGRAMMING STYLE. In the meantime, you can read DeMarco, Yourdon, Constantine, Myers or several other of the pioneers.
This is FAR more basic than SQL programming. This is what you are supposed to know before you write any code in any language.
--CELKO-- Books in Celko Series for Morgan-Kaufmann Publishing: Analytics and OLAP in SQL / Data and Databases: Concepts in Practice Data / Measurements and Standards in SQL SQL for Smarties / SQL Programming Style / SQL Puzzles and Answers / Thinking
in Sets / Trees and Hierarchies in SQL -
Deploy stored procedures manually
Is it possible to deploy .NET stored procedures in 10g manually, without using Oracle Developer Tools and/or Visual Studio 2005?
I am especially interested in writing stored procedures in Microsoft Visual Studio Express Edition. I always get PLS-00378 error.
Sample C#:
using System;
using Oracle.DataAccess.Client;
using Oracle.DataAccess.Types;
namespace SP1 {
public class Class1 {
public static int myfunc() {
int m = 0;
OracleConnection conn = new OracleConnection();
conn.ConnectionString = "context connection=true";
conn.Open();
OracleCommand cmd = new OracleCommand();
cmd.CommandText = "select count(*) from tab";
OracleDataReader rdr = cmd.ExecuteReader();
if (rdr.Read()) {
m = rdr.GetInt32(0);
rdr.Close();
cmd.Dispose();
conn.Close();
return m;
Table creation:
create or replace function myfunc() return number; -
Writing a stored procedure to import SQL Server table data into a Oracle table
Hello,
As a new DBA I have been tasked with writing a stored procedure to import SQL Server table data into an Oracle table. I have been given many suggestions on how to do it from SQL Server but I I just need to write a stored procedure to run it from the Oracle side. Suggestions/guidance on where to start would be greatly appreciated! Thank you!
I started to write it based on what I have but I know this is not correct :/
# Here is the select statement for the data source in SQL Server...
SELECT COMPANY
,CUSTOMER
,TRANS_TYPE
,INVOICE
,TRANS_DATE
,STATUS
,TRAN_AMT
,CREDIT_AMT
,APPLD_AMT
,ADJ_AMT
,TRANS_USER1
,PROCESS_LEVEL
,DESCRIPTION
,DUE_DATE
,OUR_DATE
,OUR_TIME
,PROCESS_FLAG
,ERROR_DESCRIPTION
FROM data_source_table_name
#It loads data into the table in Oracle....
Insert into oracle_destination_table_name (
COMPANY,
CUSTOMER,
TRANS_TYPE,
INVOICE,
TRANS_DATE,
STATUS,
TRANS_AMT,
CREDIT_AMT,
APPLD_AMT,
ADJ_AMT,
TRANS_USER1,
PROCESS_LEVEL,
DESCRIPTION,
DUE_DATE,
OUR_DATE,
OUR_TIME,
PROCESS_FLAG,
ERROR_DESCRIPTION)
END;CREATE TABLE statements would have been better as MS-SQL and Oracle don't have the same data types.
OUR_DATE, OUR_TIME will (most likely) be ONE column in Oracle.
DATABASE LINK
Personally, I'd just load the data over a database link:
insert into oracle_destination_table_name ( <column list> )
select ... <transform data here>
from data_source_table@mssql_db_link
As far as creating the database link from Oracle to MS-SQL ... that is for somebody else to answer.
(most likely you'll need to use an ODBC driver)
EXTERNAL TABLE
If the data from MS-SQL is in a CSV file, just use and external table.
same concept:
insert into oracle_destination_table_name ( <column list> )
select ... <transform data here>
from data_source_external_table
MK -
Help writing a simple stored procedure
Hello, all:
I have normally done fine writing functional anonymous procedures, but I want to tighten up my trade a little. I have been looking through my PL/SQL book and the examples are too simple for the creation of a stored procedure along these lines:
create or replace procedure convertPIDM( iv_PIDM number)
is
v_PIDM number;
v_Banner_ID varchar2;
v_first_name varchar2;
v_first_name varchar2;
begin
/* select spriden_id, spriden_first_name, spriden_last_name from spriden */
select spriden_id into v_Banner_ID from spriden
where spriden_pidm = iv_PIDM
and spriden_change_ind is null;
DBMS_OUTPUT.put_line('Banner ID: ' || v_Banner_ID );
end;
I am getting a "Warning: compiled but with compilation errors." I don't understand why. Could someone point the issue out to me, please.
Thank you.Okay, the answer almost bit me. I forget to add the size (ranges) to the varchar2.
create or replace procedure convertPIDM( iv_PIDM number)
is
v_PIDM number;
v_Banner_ID varchar2(8);
v_first_name varchar2(30);
v_first_name varchar2(30);
begin
--select spriden_id, spriden_first_name, spriden_last_name from spriden
select spriden_id into v_Banner_ID from spriden
where spriden_pidm = iv_PIDM
and spriden_change_ind is null;
DBMS_OUTPUT.put_line('Banner ID: ' || v_Banner_ID );
end;
show errors -
Help on writing pl/sql stored procedure to accept input in xml format
Hi All,
I need to write a pl.sql stored procedure which would be getting the input as an xml.
The requirement is that xml data recieved in below fashion needs to be inserted to 3 different tables.
The tags under the root node directly needs to be inserted into Table1
The tags under the first element of the root node needs to be inserted into Table2
Can anybody help me on how to write a stored procedure which could take up the below xml as input and insert the data received into 3 different tables.
Any sample code.pointers to achieve this could be of great help.
The structure of the xml would be as follows:
<AssemblyProduct>
<AssemblyHeader>
<Name></Name>
<AssemblyId></AssemblyId>
<ListOfHCSIFFs><HCSIFFHeader><Id></Id> </HCSIFFHeader> </ListOfHCSIFFs>
<ListOfHCSIFFs><HCSIFFHeader><Id></Id> </HCSIFFHeader> </ListOfHCSIFFs>
<ListOfHCSIFFs><HCSIFFHeader><Id></Id> </HCSIFFHeader> </ListOfHCSIFFs>
</AssemblyHeader>
<AssemblyHeader>
<Name></Name>
<AssemblyId></AssemblyId>
</AssemblyHeader>
<AssemblyHeader></AssemblyHeader>
<ApplicationId></ApplicationId>
<ApplicationName></ApplicationName>
<ApplicationValidFrom></ApplicationValidFrom>
<ApplicationValidTo></ApplicationValidTo>
</AssemblyProduct>Well you could write your procedure to accept a parameter of XMLTYPE datatype and then use that value in a query inside the procedure to break the data up as required using something like XMLTABLE e.g.
-- Nested repeating groups example:
WITH t as (select XMLTYPE('
<RECSET>
<REC>
<COUNTRY>1</COUNTRY>
<POINT>1800</POINT>
<USER_INFO>
<USER_ID>1</USER_ID>
<TARGET>28</TARGET>
<STATE>6</STATE>
<TASK>12</TASK>
</USER_INFO>
<USER_INFO>
<USER_ID>5</USER_ID>
<TARGET>19</TARGET>
<STATE>1</STATE>
<TASK>90</TASK>
</USER_INFO>
</REC>
<REC>
<COUNTRY>2</COUNTRY>
<POINT>2400</POINT>
<USER_INFO>
<USER_ID>3</USER_ID>
<TARGET>14</TARGET>
<STATE>7</STATE>
<TASK>5</TASK>
</USER_INFO>
</REC>
</RECSET>') as xml from dual)
-- END OF TEST DATA
select x.country, x.point, y.user_id, y.target, y.state, y.task
from t
,XMLTABLE('/RECSET/REC'
PASSING t.xml
COLUMNS country NUMBER PATH '/REC/COUNTRY'
,point NUMBER PATH '/REC/POINT'
,user_info XMLTYPE PATH '/REC/*'
) x
,XMLTABLE('/USER_INFO'
PASSING x.user_info
COLUMNS user_id NUMBER PATH '/USER_INFO/USER_ID'
,target NUMBER PATH '/USER_INFO/TARGET'
,state NUMBER PATH '/USER_INFO/STATE'
,task NUMBER PATH '/USER_INFO/TASK'
) y
COUNTRY POINT USER_ID TARGET STATE TASK
1 1800 1 28 6 12
1 1800 5 19 1 90
2 2400 3 14 7 5And then you can extract and insert whatever parts you want into whatever tables as part of the procedure. -
Writing mulitple sql statements in 1 stored procedure
Hi all, can i know how to create mulitple sql statements in 1 stored procedure??
Eg the first sql statement will generate few results and my second sql statement will based on the first statement result to execute its second results and my third sql statements will on the second results to generate the final results which will be passed back to jsp pages as a resultset??
For the time being, i only know how to create a single sql statement in one stored procedure..i had surf through the oracle website but cant find any solution. Can anyone help me?? Samples or links to any website will do.. Thanks alot...Hi Irene,
If I understand your question correctly, then I have already written
a similar (PL/SQL) stored procedure without any problems.
However, I do think your question is more suited to the following
forum:
http://forums.oracle.com/forums/forum.jsp?id=478021
I also think it will help others to answer your question if you
include the following information:
1. Version of Oracle you are using.
2. The error message you are getting.
3. The part of your code that is causing the problem.
Also, have you looked at the following web sites?
http://asktom.oracle.com
http://metalink.oracle.com
Good Luck,
Avi. -
Writing from Stored Procedure directly into a file...
Hi guys,
I would like to write the results of a stored procedure into a file. Indeed, I am calling a Stored Procedure from a script and I would like to write the result of that procedure to a file and not a table.
Thanks guys,
PipocaHi,
The UTL would be nice, but since I am calling the procedure from a unix script and *I wanted to keep the file in the unix machine* I don't believe this is the solution.UTL_FILE - will refers to a directory - which resides on Server - I Hope your DB is placed on Unix and you script is exeucted from their only. Then obviously your resulted file and source exits on unix machine only.
HTH
- Pavan Kumar N
OCP- Oracle 9i/10g
http://oracleinternals.blogspot.com -
Writing data to a foreign database-SQLServer using a stored procedure
Does anyone know if I can Insert data into a SQLServer table which resides out on the WAN using a stored procedure which resides in my Oracle database?
Is it possible? Sure. How easy it is really depends...
Oracle has a feature called Heterogeneous Connectivity which allows you to create database links to non-Oracle databases. You can then treat the remote SQL Server objects just like you would use remote Oracle tables across a database link, i.e.
INSERT INTO table_name@sql_server_dblink( <<list of columns>> )
VALUES( <<list of values>> )Heterogeneous Connectivity requires some configuration on the Oracle database side. If you want to use Generic Connectivity, which is part of the base license, you'll need a SQL Server ODBC driver on the machine where Oracle is running. If you run Oracle on Windows, this is relatively easy. If you run Oracle on Unix, this gets a bit more challenging.
Justin
Distributed Database Consulting, Inc.
http://www.ddbcinc.com/askDDBC -
Okay - I am new to PLSQL & stored procedures. This will be something that I shall be learning. I am not new to SQL, however.
And so: as a sql command I am able to execute a command to get data from our production database and 'migrate' the data to a different database (using db links):
let's say the table in production is table1. Let's say this table already exists in this DB as well.
In the second db, I am executing the following:
DROP table db2.table1;
CREATE TABLE db2.table1 (table1_id, table1_code, table1_field3, table1_field4)
AS
SELECT "TABLE1_ID", "TABLE1_CODE", "TABLE1_FIELD3", "TABLE1_FIELD4"
FROM table1@productionDB;
The above command executes successfully. However, now I would like to create a stored procedure that I can create a job for - so as to execute the procedure weekly.
I am also new to toad. However, see that toad provides the ability to create & schedule jobs.
I decided to take the above SQL and 'write' a stored procedure:
CREATE OR REPLACE PROCEDURE p_table1_to_db2 IS
BEGIN
DROP table db2.table1;
CREATE TABLE db2.table1 (table1_id, table1_code, table1_field3, table1_field4)
AS
SELECT "TABLE1_ID", "TABLE1_CODE", "TABLE1_FIELD3", "TABLE1_FIELD4"
FROM table1@productionDB;
END p_table1_to_db2;
When running the above stored procedure, I get errors (what seem to be syntactical errors).
I.e.: Oracle Error PLS-00103 -- Encountered the symbol "DROP" when expecting something else... etc.
Since I'm new to this, can someone please assist me in correctly 'formatting' the above stored procedure? What am I doing wrong?DROP is not a valid command for PL/SQL. Inside a procedure you must use PL/SQL. There is a way around this by using the EXECUTE IMMEDIATE command.
I would however prefere NOT to drop the table. If you just need to copy the data then
DELETE FROM db2.table1;
INSERT INTO db2.table1 (table1_id, table1_code, table1_field3, table1_field4)
SELECT "TABLE1_ID", "TABLE1_CODE", "TABLE1_FIELD3", "TABLE1_FIELD4"
FROM table1@productionDB;should be enough.
Instead of "DELETE FROM db2.table1;" "TRUNCATE db2.table1;" is possible and faster, but does commit everything before this statement.
Message was edited by:
Sven Weller
Maybe you are looking for
-
How to get the Creative Cloud to show in the Finder window
I have Creative Cloud Photoshop downloaded to my Mac and Mac Air. On my Mac, Creative Cloud shows up in the Finder Window which makes it easy to open/save files but it doesn't show in the Finder window on my Mac Air. Anyone know how I can get it to
-
since installing iOS 8, my ipad air has started crashing repeatedly. gestures like zoom, causes crash, game playing causes crashes, trying to open a magazine makes it crash. rebooting doesnt help closing open apps doesnt help
-
[svs@mugen media]$ ls -l total 104 drwxr-xr-x 2 root root 4096 2008-03-10 15:20 cd drwxr-xr-x 2 root root 4096 2008-06-17 19:44 d1 drwxr-xr-x 7 svs root 8192 1969-12-31 16:00 disk drwxrwxrwx 1 root root 32768 2008-06-19 18:56 disk-1 drwxrwxrwx 1 root
-
No way to bring keyboard up in Notes
I use this program sometimes to keep a log of my dreams as soon as I wake up, and it's very frustrating trying to go back and change a typo. If you hold too long and use the magnifying glass it goes straight to select or select all, no keyboard pops
-
Changing Role created with Customizing Auth. Utility
I created a role in PFCG using the Customizing Auth. option under Utilities by referencing a project view that I created in the IMG. My intent was to create a security role with access to all of the SPRO tcodes and related security objects. I then