Problem with a stored procedure (Error(4,1): PLS-00428: an INTO clause..)
Dear Oracle Experts,
I try to use the stored procedure below but get this error :
"Error(4,1): PLS-00428: an INTO clause is expected in this SELECT statement"
I don't have any clue what could be wrong with my syntax. INTO wouldn't make any sense at this task.
Does someone of you know what's wrong with my Procedure ?
Hope someone can help,
best regards,
Daniel Wetzler
create or replace PROCEDURE AnalysisCompatibility (DATEBEGIN timestamp, DATEEND timestamp)
AS
BEGIN
select Fs.*,Vs.Analysispriority,Vs.Compatibility Compatibility from SigFacts Fs
inner Join Variables Vs On
(Fs.Var_Ref=Vs.Var_Ref and Fs.Machines_Ref=Vs.Machines_Ref )
where Fs.DT between DATEBEGIN and DATEEND
and
Vs.AnalysisPriority > 0
or
VS.Compatibility in (6,7,8,9,10,11,13,21,22)
order by Fs.DT,Fs.Machines_Ref desc, Vs.AnalysisPriority;
END AnalysisCompatibility;
I have created a table (ATREPORT.TEST) that has has got the same column name and type of the query output and i still get error message
PLS-00403 -- statement ATreport.TESt cannot be used as an into target, pls help
DECLARE start_date DATE := to_date('01/09/2006' , 'DD-MON-YYYY');
end_date DATE := to_date('30/09/2006' , 'DD-MON-YYYY');
BEGIN
SELECT t.SEC_SHORT_NAME, t.SEC_ISIN, t.SEC_NO,t.SEC_NAME, t.TRADE_DATE,
t.PAYMENT_DATE,t.COUNTERPARTY, t.PRICE , t.NOMINAL ,
t.TRANSACTION_NO,t.CURRENT_VALUE_PC, t.CURRENT_VALUE_SC, t.PAYMENT_AMOUNT_PC,
t.PAYMENT_AMOUNT_SC,
ct.AMOUNT , ct.CURRENCY,
sb.BUSINESS_CLASS_LEVEL_2 ,sb.BUSINESS_CLASS_LEVEL_2_NAME,
sb.BUSINESS_CLASS_LEVEL_3 ,sb.BUSINESS_CLASS_LEVEL_3_NAME,
sb.BUSINESS_CLASS_LEVEL_4 ,sb.BUSINESS_CLASS_LEVEL_4_NAME,
sb.BUSINESS_CLASS_LEVEL_5 ,sb.BUSINESS_CLASS_LEVEL_5_NAME
INTO ATREPORT.TEST
from scdat.A_TRANSACTIONS t
INNER JOIN scdat.A_COSTTAX ct
ON ct.TRANS_REF = t.TRANS_REF
INNER JOIN scdat.A_SECS_BUSINESS_CLASS_TS sb
ON sb.SEC_REF = t.SEC_REF
where t.TRADE_DATE >= to_char(start_date ,'DD-MON-YYYY')
and t.TRADE_DATE < to_char(end_date ,'DD-MON-YYYY')
and ct.COST_NAME = 'Broker commission'
and sb.BUSINESS_CLASS_DEFINITION = 'FTSE';
END;
Similar Messages
-
What is the problem with this Stored Procedure
Hi ,
What is the problem with this Stored Procedure ?Why is it giving errors ??
CREATE or replace PROCEDURE getEmpName
*(EMP_FIRST OUT VARCHAR2(255))*
BEGIN
SELECT ename INTO EMP_FIRST
FROM Emp
WHERE EMPNO = 7369;
END ;
*/*You don't specify precision in procedure arguments.
(EMP_FIRST OUT VARCHAR2(255))should be
(EMP_FIRST OUT VARCHAR2)Since you asked what's wrong with it, I could add that it needs formatting and the inconsistent use of upper and lower case is not helping readability. -
Performance problem with java stored procedure
hi,
i developped a java class, then I stored it in Oracle 8.1.7.
This class contains several import of other classes stored in the database.
It works, but the execution perfomances are disappointing. It's very long. I guess, that's because of the great number of classes to load that are necessary for my class execution.
I tried to increase the size of the java pool (I parameter 70 Mo in the java_pool_size parameter of the init.ora), but the performance is not much better.
Has anyone an idea to increase the performance of this execution of my class ?
In particular, is there a way to keep permanently in memory the java objects used by my class ?
Thanks in advance
bye
[email protected]
nullbefore running Java, the database session needs to be Java enabled; this might be the reason why it is taking so long. If this is the case, you should see an improvement in subsequent calls, once a database session is Java enabled, other users can benefit from it.
Kuassi
I have some performance issue with java stored procedure. Hope some one will be able to help me out. I'm using java stored procedures in my application and basically these procedures are used to do some validation and form the XML message of the database tables. I have noticed that when I call the PL/SQL wrapper function, it is taking time to load the java class and once the class is loaded the execution is faster. Most of the time is spent for loading the class rather than executing the function. if I reduce the class load time, I can improve the performance drastically. Do any one of you know how to reduce the class load time. The following are the platform and oracle version.
O/S: IBM AIX
Oracle: 8.1.7 -
Problems with java stored procedure.
I have a java stored procedure that uses a package called RmiJdbc
which allows calling remote JDBC data sources from any java capable
machine.
I've loaded the RmiJdbc classes into oracle via the loadjava
command and everything seems to come up valid.
The stored procedure does a Class.forName() to get the driver
registered, than attempts to connect to the remote RMI driver.
The particular line it dies on is this (see the error below):
c = DriverManager.getConnection("jdbc:rmi:" + rmiHost + "/" + url);
A mangled version of this (minus the Oracle specific stuff) works
from the command line correctly. Can somebody point me in a
direction to figure out what's going on here?
THanks,
Eric
Oracle9i Enterprise Edition Release 9.0.1.3.0 - 64bit Production
With the Partitioning option
JServer Release 9.0.1.3.0 - Production
ORACLE_HOME = /oracle/v901ee
System name: HP-UX
Node name: athena
Release: B.11.00
Version: A
Machine: 9000/889
Instance name: PASDB2
Redo thread mounted by this instance: 1
Oracle process number: 13
Unix process pid: 7839, image: oracle@athena (TNS V1-V3)
*** SESSION ID:(8.547) 2002-08-15 15:41:27.221
java.rmi.UnmarshalException: Error unmarshaling return; nested exception is:
java.lang.NullPointerException
java.lang.NullPointerException
at sun.rmi.server.LoaderHandler$LoaderKey.<init>(LoaderHandler.java)
at sun.rmi.server.LoaderHandler.lookupLoader(LoaderHandler.java)
at sun.rmi.server.LoaderHandler.loadClass(LoaderHandler.java)
at sun.rmi.server.LoaderHandler.loadClass(LoaderHandler.java)
at sun.rmi.server.MarshalInputStream.resolveClass(MarshalInputStream.java)
at java.io.ObjectInputStream.inputClassDescriptor(ObjectInputStream.java)
at java.io.ObjectInputStream.readObject(ObjectInputStream.java)
at java.io.ObjectInputStream.readObject(ObjectInputStream.java)
at java.io.ObjectInputStream.inputArray(ObjectInputStream.java)
at java.io.ObjectInputStream.readObject(ObjectInputStream.java)
at java.io.ObjectInputStream.inputClassFields(ObjectInputStream.java)
at java.io.ObjectInputStream.defaultReadObject(ObjectInputStream.java)
at java.io.ObjectInputStream.inputObject(ObjectInputStream.java)
at java.io.ObjectInputStream.readObject(ObjectInputStream.java)
at java.io.ObjectInputStream.readObject(ObjectInputStream.java)
at sun.rmi.transport.StreamRemoteCall.executeCall(StreamRemoteCall.java)
at sun.rmi.server.UnicastRef.invoke(UnicastRef.java)
at sun.rmi.registry.RegistryImpl_Stub.lookup
at org.objectweb.rmijdbc.RJConnection.<init>(RJConnection:83)
at org.objectweb.rmijdbc.Driver.connect(Driver:135)
at java.sql.DriverManager.getConnection(DriverManager.java)
at java.sql.DriverManager.getConnection(DriverManager.java)
at TurnoverInfoPlusInterface.insertInterfaceRecords(TurnoverInfoPlusInterface:53)
java.sql.SQLException: Error unmarshaling return; nested exception is:
java.lang.NullPointerException
at org.objectweb.rmijdbc.Driver.connect(Driver:140)
at java.sql.DriverManager.getConnection(DriverManager.java)
at java.sql.DriverManager.getConnection(DriverManager.java)
at TurnoverInfoPlusInterface.insertInterfaceRecords(TurnoverInfoPlusInterface:53)More info...I'm also seeing "ORA-03113: end-of-file on communication channel". I checked the user trace file and didn't get much help...it indicated an "exception signal: 11" and core-dump type stuff that had no meaning to me.
-
Problem with JDBC stored procedure
Hi...
We are implementing an interface from SAP r/3 4.7 to Oracle DB 9.0. On sender side we have used IDOC Adapter and on Receiver side we have used JDBC Adapter.
Here we are using stored procedures in JDBC Adapter. I have 2 stored procedures(one for header and one for items) and SISCSO.SISCSO01 IDOC.
Here we are getting following error in RWB for JDBC Receiver adapter....
<b>Error</b>
" Receiver Adapter v2112 for Party '', Service 'BS_ORADEV':
Configured at 2006-08-16 10:12:14 GMT+05:30
History:
- 2006-08-16 11:02:04 GMT+05:30: Error: TransformException error in xml processor class: Error processing request in sax parser: Error when executing statement for table/stored proc. 'PR_SPARES_VOR_PO_HDR_UPLOAD' (structure 'statement'): java.sql.SQLException: ORA-06550: line 1, column 7:
PLS-00201: identifier 'PR_SPARES_VOR_PO_HDR_UPLOAD' must be declared
ORA-06550: line 1, column 7:
PL/SQL: Statement ignored ".
<b>My mapping file is like this.....</b>
<?xml version="1.0" encoding="UTF-8"?>
<ns0:TVS_MST_SPARES_ORDER xmlns:ns0="urn:tvsmotor:salesorder"><statement><PR_SPARES_VOR_PO_HDR_UPLOAD action="execute"><table>PR_SPARES_VOR_PO_HDR_UPLOAD</table><IN_DEALER_ID isInput="true" type="String">efde</IN_DEALER_ID><IN_SPARE_PO_NO isInput="TRUE" type="STRING">sdfsdf</IN_SPARE_PO_NO><IN_PO_DATE isInput="TRUE" type="STRING">12.12.2555</IN_PO_DATE><IN_ORDER_TYPE isInput="TRUE" type="STRING">23</IN_ORDER_TYPE><IN_REMARKS isInput="TRUE" type="STRING">Remark</IN_REMARKS><IN_SAP_SALE_ORD_NO isInput="TRUE" type="STRING">146546</IN_SAP_SALE_ORD_NO><IN_SAP_SALE_ORD_DT isInput="TRUE" type="STRING">12.12.2555</IN_SAP_SALE_ORD_DT><IN_TOT_VAL isInput="TRUE" type="STRING">2323</IN_TOT_VAL></PR_SPARES_VOR_PO_HDR_UPLOAD><PR_SPARES_VOR_PO_DTL_UPLOAD action="execute"><IN_DEALER_ID isInput="TRUE" type="STRING">efde</IN_DEALER_ID><IN_SPARE_PO_NO isInput="TRUE" type="STRING">sdfsdf</IN_SPARE_PO_NO><IN_PO_DATE isInput="TRUE" type="STRING">12.12.2555</IN_PO_DATE><IN_PART_NO isInput="TRUE" type="STRING">cfgdfw4w</IN_PART_NO><IN_ORDER_QTY isInput="TRUE" type="STRING">2</IN_ORDER_QTY><IN_PENDING_QTY isInput="TRUE" type="STRING">20</IN_PENDING_QTY><IN_RATE isInput="TRUE" type="STRING">2432</IN_RATE><IN_TAX isInput="TRUE" type="STRING">18</IN_TAX></PR_SPARES_VOR_PO_DTL_UPLOAD></statement></ns0:TVS_MST_SPARES_ORDER>
Please help me out with this error... tell me if more information is required.
Thanks,
Audumbar.hi mario,
tell me one thing.... does case metter for stored procedure name? and even for the parameters used in stored procedure?
i have changed the case of stored procedure name... (its small in Oracle) but have not changed the case of parameters....
after changing the case also i m getting the following error....
" Receiver Adapter v2112 for Party '', Service 'BS_ORADEV':
Configured at 2006-08-16 10:12:14 GMT+05:30
History:
- 2006-08-16 14:18:19 GMT+05:30: Error: TransformException error in xml processor class: Error processing request in sax parser: Error when executing statement for table/stored proc. <b>'pr_spares_vor_po_hdr_upload'</b> (structure 'statement'): java.sql.SQLException: ORA-06550: line 1, column 7:
PLS-00201: identifier <b>'PR_SPARES_VOR_PO_HDR_UPLOAD'</b> must be declared
ORA-06550: line 1, column 7:
PL/SQL: Statement ignored "
Reply me as soon as possible.
Thanx,
Regards,
Audumbar
Message was edited by: Audumbar Pikle -
Callable statement with oracle stored procedure error
i'm calling a stored procedure in java with the following code. However i constantly recieve this error
so what is going on please HELP
Parameter Type Conflict: sqlType=2006
my call statement would be this:
call Statement = {call getUserByLogin(?,?,?,?)}
if(storedProcedureName=="getUserByLogin"){
strCStmt = ("{call " + storedProcedureName +"(?,?,?,?) }");
cStmt.setObject(1, "system");
cStmt.setObject(2, "username");
cStmt.setObject(3,"password");
cStmt.registerOutParameter(4, java.sql.Types.REF);
rs = cStmt.executeQuery();
i've also tried it with a setString as the IN parameter:
here's the stored procedure:
CREATE OR REPLACE PROCEDURE getUserByLogin (
arg_subscriptionName IN varchar,
arg_loginName IN varchar,
arg_password IN varchar,
arg_rec_userinfo_valLanguage OUT types.rec_userinfo_valLanguage
) AS
var_userNum int;
BEGIN
select
u.userNum into var_userNum
from
userInfo u,
subscription s
where
s.subscriptionName = arg_subscriptionName AND
s.subscriptionNum = u.subscriptionNum AND
u.loginName = arg_loginName AND
u.password = arg_password;
if (var_userNum is null) then
var_userNum := 0;
end if;
getUser(var_userNum, arg_rec_userinfo_valLanguage);
END;i'm calling a stored procedure in java with the
following code. However i constantly recieve this
error
so what is going on please HELP
Parameter Type Conflict: sqlType=2006
my call statement would be this:
call Statement = {call getUserByLogin(?,?,?,?)}
if(storedProcedureName=="getUserByLogin"){
strCStmt = ("{call " + storedProcedureName +"(?,?,?,?)
cStmt.setObject(1, "system");
cStmt.setObject(2, "username");
cStmt.setObject(3,"password");
cStmt.registerOutParameter(4, java.sql.Types.REF);
rs = cStmt.executeQuery();
i've also tried it with a setString as the IN
parameter:
here's the stored procedure:
CREATE OR REPLACE PROCEDURE getUserByLogin (
arg_subscriptionName IN varchar,
arg_loginName IN varchar,
arg_password IN varchar,
arg_rec_userinfo_valLanguage OUT
types.rec_userinfo_valLanguage
) AS
var_userNum int;
BEGIN
select
u.userNum into var_userNum
from
userInfo u,
subscription s
where
s.subscriptionName = arg_subscriptionName AND
s.subscriptionNum = u.subscriptionNum AND
u.loginName = arg_loginName AND
u.password = arg_password;
if (var_userNum is null) then
var_userNum := 0;
end if;
getUser(var_userNum, arg_rec_userinfo_valLanguage);
END;
/Hai,
Try with this if u are using Oracle.
import oracle.sql.*;
import oracle.jdbc.driver.*;
(inbetween ur code)
cStmt.registerOutParameter(4, OracleTypes.CURSOR);
//in place of "cStmt.registerOutParameter(4, java.sql.Types.REF);"
Hope u reply with joy.
regards,
Siva Kumar Annavaram -
Problem with a stored procedure to search in a table
h5.
Hi,
h5.
As many people on the forum, I'm new on PL/SQL programming.
h5.
I'm trying to program a stored procedure that allow to search on my table fields with different parameters.
h5.
All this parameters doesn't need to be set, at least one.
h5.
I'm looking for the solution from 2 weeks ago.
h5.
I have looked everywhere
h5.
Could someone help me, please??
h5.
Here is my code:
* HERE WE CREATE PACKAGE FOR THE CURSOR
create or replace
PACKAGE HOTEL_DEST_PKG
IS
/* Define the REF CURSOR type. */
TYPE HOTEL_DEST_TYPE IS REF CURSOR;
END HOTEL_DEST_PKG;
* HERE WE CREATE OUR STORE PROCEDURE TO SEARCH
create or replace
PROCEDURE Search_Hotel (
IdDocument IN number,
MyFilter IN VARCHAR2,
IdCountry IN number,
DepartureDateFirst IN DATE,
DepartureDateSecond IN DATE,
HD_Cursor OUT HOTEL_DEST_PKG.HOTEL_DEST_TYPE)
IS
SQL_REQ VARCHAR2(5000);
BEGIN
/* all columns were entered */
IF ((IdDocument > 0) OR
((MyFilter IS NOT NULL) AND (length(MyFilter) > 0)) OR
(IdCountry > 0) OR
(DepartureDateFirst IS NOT NULL) OR
(DepartureDateSecond IS NOT NULL))
THEN
SQL_REQ := 'SELECT HOTEL_DESTINATION.*
FROM HOTEL_DESTINATION
WHERE 1=1';
/* Search on the hotel id*/
IF IdDocument > 0 THEN
SQL_REQ := SQL_REQ || ' AND HOTEL_DESTINATION.HD_ID = :IdDocument';
ELSE
SQL_REQ := SQL_REQ || ' AND :IdDocument IS NULL';
END IF;
/*Search on different indexed fields*/
IF MyFilter IS NOT NULL AND LENGTH(MyFilter)>0 THEN
SQL_REQ := SQL_REQ || ' AND CONTAINS(HOTEL_DESTINATION.HD_FILTER, :MyFilter)';
ELSE
SQL_REQ := SQL_REQ || ' AND :MyFilter IS NULL';
END IF;
/* Search on the hotel country id*/
IF IdCountry > 0 THEN
SQL_REQ := SQL_REQ || ' AND HOTEL_DESTINATION.HD_CN_ID = :IdCountry';
ELSE
SQL_REQ := SQL_REQ || ' AND :IdCountry IS NULL';
END IF;
/* Search on the dates*/
IF DepartureDateFirst IS NOT NULL THEN
SQL_REQ := SQL_REQ || ' AND HOTEL_DESTINATION.HD_DEPARTURE_DATE >= :DepartureDateFirst';
ELSE
SQL_REQ := SQL_REQ || ' AND :DepartureDateFirst IS NULL' ;
END IF;
IF DepartureDateSecond IS NOT NULL THEN
SQL_REQ := SQL_REQ || ' AND HOTEL_DESTINATION.HD_DEPARTURE_DATE <= :DepartureDateSecond';
ELSE
SQL_REQ := SQL_REQ || ' AND :DepartureDateSecond IS NULL';
END IF;
OPEN HD_CURSOR FOR SQL_REQ USING IdDocument,
MyFilter,
IdCountry,
DepartureDateFirst,
DepartureDateSecond;
END IF;
END;
* HERE WE CALL AND EXECUTE OUR STORE PROCEDURE TO SEARCH
* ON WORD
set serveroutput on
DECLARE
IDDOCUMENT NUMBER;
MYFILTER VARCHAR2(200);
IDCOUNTRY NUMBER;
DEPARTUREDATEFIRST IN DATE;
DEPARTUREDATESECOND IN DATE;
HD_CURSOR OUT HOTEL_DEST_PKG.HOTEL_DEST_TYPE);
BEGIN
IDDOCUMENT := 0;
MYFILTER := 'test';
IDCOUNTRY := 0;
DEPARTUREDATEFIRST := NULL;
DEPARTUREDATESECOND := NULL;
SEARCH_HOTEL(
IDDOCUMENT => IDDOCUMENT,
MYFILTER => MYFILTER,
IDCOUNTRY => IDCOUNTRY,
DEPARTUREDATEFIRST => DEPARTUREDATEFIRST,
DEPARTUREDATESECOND => DEPARTUREDATESECOND,
HD_Cursor => HD_Cursor
-- Modify the code to output the variable
--DBMS_OUTPUT.PUT_LINE('HD_Cursor = ' || HD_Cursor);
END;You need to grant right on the table to the owner of the stored procedure directly (not via Role).
When there are only rights via role everything is fine in sql, but it will not work in stored procedures, functions or packages.
So as Table-Owner do:
grant select on <table> to <procedure, package or function-owner>;Edited by: hm on 22.10.2010 08:49 -
Perfomance problem with java stored procedure
hi,
i developped a java class, then I stored it in Oracle 8.1.7.
This class contains several import of other classes stored in the database.
It works, but the execution perfomances are disappointing. It's very long. I guess, that's because of the great number of classes to load that are necessary for my class execution.
I tried to increase the size of the java pool (I parameter 70 Mo in the java_pool_size parameter of the init.ora), but the performance is not much better.
Has anyone an idea to increase the performance of this execution of my class ?
In particular, is there a way to keep permanently in memory the java objects used by my class ?
Thanks in advance
bye
[email protected]
nullHello again,
I read the documentation of 9i and found some hints about different TCP/IP socket handling of 9i and a standard JVM.
There are some parts that give hints but I couldn't find a sample code to show how to handle the differences.
Could anyone tell me how to handle the differences or give some links to sample code?
Thanks
Detlev -
Problem with a Stored Procedure
I created a SP. My SP is:
Create or Replace Procedure sp_atualiza(val_ent in number,id_ent in integer)
as
begin
update venda set valor = val_ent*valor
where id_venda = id_ent;
end sp_atualiza;
Now into SQL*Plus I write:
SQL>execute sp_atualiza(1.5,3)
The message is: Procedure PL/SQL sucessfully(My windows is in Portuguese and I don't known to translate in english this message so well).
If i run into Home XE, this message is: Invalid SQL statement.
How can I do run a SP into Home and SQL*Plus of the XE?Bom Dia!
EXECUTE is a SQL*Plus command - it doesn't work in most other tools (though some like TOAD do recognize it).
In a pure SQL tool, you need to provide a true SQL or PL/SQL statement:
BEGIN
SP_ATUALIZA(1.5, 3);
END;
/I hope that helps
Regards Nigel -
Error PLS-00428: an INTO clause is expected in this SELECT statement
Dear Experts,
I am new PL/SQL Programming
I am trying to run the following query i am getting Error.
Please help me to solve the error.
declare
var_cd number(20);
begin
if :P1_TYP_CAT is not null then
select max(CAT_cd + 1) as var_cd from IM_AST_CAT order by CAT_cd;
insert into IM_AST_CAT (CAT_NM, CAT_CD) values ((upper(:P1_TYP_CAT)),(:var_cd));
else
RAISE_APPLICATION_ERROR (-20001,'Both department and location must be provided');
end if;
end;Others have already explained you the cause of the error. You can simplify your code like this.
begin
if :p1_typ_cat is not null then
insert into im_ast_cat
cat_nm
, cat_cd
select upper(:p1_type_cat)
, max(cat_cd + 1)
from im_ast_cat;
else
raise_application_error (-20001,'Both department and location must be provided');
end if;
end; -
Need Help With a Stored Procedure
Help With a Stored Procedure
Hi everyone.
I am quite new relative to creating stored procedures, so I anticipate that whatever help I could get here would be very much helpful.
Anyway, here is my case:
I have a table where I need to update some fields with values coming from other tables. The other tables, let us just name as tblRef1, tblRef2 and tblRef3. For clarity, let us name tblToUpdate as my table to update. tblToUpdate has the following fields.
PlanID
EmployeeIndicator
UpdatedBy
CreatedBy
tblRef1, tblRef2 and tblRef3 has the following fields:
UserName
EmpIndicator
UserID
In my stored procedure, I need to perform the following:
1. Check each row in the tblToUpdate table. Get the CreatedBy value and compare the same to the UserName and UserID field of tblRef1. If no value exists in tblRef1, I then proceed to check if the value exists in the same fields in tblRef2 and tblRef3.
2. If the value is found, then I would update the EmployeeIndicator field in tblToUpdate with the value found on either tblRef1, tblRef2 or tblRef3.
I am having some trouble writing the stored procedure to accomplish this. So far, I have written is the following:
CREATE OR REPLACE PROCEDURE Proc_Upd IS v_rec NUMBER;
v_plan_no tblToUpdate.PLANID%TYPE;
v_ref_ind tblToUpdate.EMPLOYEEINDICATOR%TYPE;
v_update_user tblToUpdate.UPDATEDBY%TYPE;
v_created_by tblToUpdate.CREATEDBY%TYPE;
v_correct_ref_ind tblToUpdate.EMPLOYEEIDICATOR%TYPE;
CURSOR cur_plan IS SELECT PlanID, EmployeeIndicator, UPPER(UpdatedBy), UPPER(CreatedBy) FROM tblToUpdate;
BEGIN
Open cur_plan;
LOOP
FETCH cur_plan INTO v_plan_no, v_ref_ind, v_update_user, v_created_by;
EXIT WHEN cur_plan%NOTFOUND;
BEGIN
-- Check if v_created_by has value.
IF v_created_by IS NOT NULL THEN
-- Get the EmpIndicator from the tblRef1, tblRef2 or tblRef3 based on CreatedBy
SELECT UPPER(EmpIndicator)
INTO v_correct_ref_ind
FROM tblRef1
WHERE UPPER(USERNAME) = v_created_by
OR UPPER(USERID) = v_created_by;
IF v_correct_ref_ind IS NOT NULL THEN
-- Update the Reference Indicator Field in the table TRP_BUSPLAN_HDR_T.
UPDATE TRP_BUSPLAN_HDR_T SET ref_ind = v_correct_ref_ind WHERE plan_no = v_plan_no;
ELSIF
-- Check the Other tables here????
END IF;
ELSIF v_created_by IS NULL THEN
-- Get the EmpIndicator based on the UpdatedBy
SELECT UPPER(EmpIndicator)
INTO v_correct_ref_ind
FROM tblRef1
WHERE UPPER(USERNAME) = v_update_user
OR UPPER(USERID) = v_created_by;
IF v_correct_ref_ind IS NOT NULL THEN
-- Update the Reference Indicator Field in the table TRP_BUSPLAN_HDR_T.
UPDATE TRP_BUSPLAN_HDR_T SET ref_ind = v_correct_ref_ind WHERE plan_no = v_plan_no;
ELSIF
-- Check the Other tables here????
END IF;
END IF;
END;
END LOOP;
CLOSE cur_plan;
COMMIT;
END
Please take note that the values in the column tblToUpdate.UpdatedBy or tblToUpdate.CreatedBy could match either the UserName or the UserID of the table tblRef1, tblRef2, or tblRef3.
Kindly provide more insight. When I try to execute the procedure above, I get a DATA NOT FOUND ERROR.
Thanks.Ah, ok; I got the updates the wrong way round then.
BluShadow's single update sounds like what you need then.
I also suggest you read this AskTom link to help you see why you should choose to write DML statements before choosing to write cursor + loops.
In general, when you're being asked to update / insert / delete rows into a table or several tables, your first reaction should be: "Can I do this in SQL?" If you can, then putting it into a stored procedure is usually just a case of putting the sql statement inside the procedure header/footers - can't really get much more simple than that! *{;-) -
please help problem with importing a file error output "there was an error decompressing audio or video"
this is related to what adobe program/version?
-
How to verify the user information pass by the form with a stored procedure?
Hi,
I would like to know how to verify user information pass by the form with a stored procedure.
I want make a portal which accepts to new user registration, but I want verify the new user's informations (like the name don't contain a number etc).
Thanks for your help
regards
jlaHi Samson,
You can use the UI API to do this. You can catch the form_ADD event and then validate the input from the users. You can even block the event from completing (and stop the document from being added) if your code finds some incorrect data using the bubbleEvent functionality.
I don't have one specific example to show you, but if you look at some of the SDK samples (for example C:\Program Files\SAP\SAP Business One SDK\Samples\COM UI\VB.NET\02.CatchingEvents) to see how to work with events, you can then create your own validation to ensure the users data is valid.
Regards,
Niall -
How do I merge data from table1 on server 1 to final table on server 2 with a stored procedure to execute every so
many hours.How big is the table on server B? Is that possible to bring the all data into a server A and merge the data locally?
Best Regards,Uri Dimant SQL Server MVP,
http://sqlblog.com/blogs/uri_dimant/
MS SQL optimization: MS SQL Development and Optimization
MS SQL Consulting:
Large scale of database and data cleansing
Remote DBA Services:
Improves MS SQL Database Performance
SQL Server Integration Services:
Business Intelligence -
How do I merge data from table1 on server 1 to final table on server 2 with a stored procedure to execute every so many hours.
Hello,
If you had configure server2 as
linked server on the server1, you can run the following statement inside stored proceduce to copy table data. And then create a job to the run stored proceduce every 4 hours.
Insert Into Server2.Database2.dbo.Table2
(Cols)
Select Cols From Server1.Database1.dbo.Table1
Or you can use the SQL Server Import and Export Wizard to export the data from server1 to server2, save the SSIS package created by the wizard on the SQL Server, create a job to run the SSIS package.
Reference:http://technet.microsoft.com/en-us/library/ms141209.aspx
Regards,
Fanny Liu
Fanny Liu
TechNet Community Support
Maybe you are looking for
-
Ipod nano 7th gen. songs skipping
I bought the 7th generation nano and I have noticed that when I have the ipod on shuffle in the songs sections, some of the songs are skipped. When I go to the specific artist and song, it continues to skip. I figure that it is a corrupt song file, h
-
Storage place for Symbol and Text Substitution
I use Symbol and Text Substitution (Preferences - Language and Text) a lot and like to copy my definitions to another computer. Can anybody tell me where this information is stored?
-
Iweb Photos page not working in Explorer
Created photos page in iweb09 and it works fine in Safari & Firefox. But in Explorer 8 the photos don't show up. I have no shadow or boarders on the photos and there are no graphics behind them. Any solutions for this issue I'm out of ideas!
-
Is there a general purpose output stream class like in java?
Hi, I sometimes create tools (abap OO classes) which output characters, that I would like to store in any media (frontend file, server file, string variable, ftp, clipboard, etc.) This is easily done in java via the output stream classes. Do you know
-
What table rsa7 transaction queue values are stored
I'm working on ECC 5 and BI 7 I created a datasoure in ECC (based on table view) and I created a generic delta source system using rso2. In generic delta I have 'Delta specific field' - calender day. We can view this queue values in RSA7. My question