Invalid Month error in stored procedure
Hello, I have a simple stored procedure that I pass a begin and end date into and it is complaining about the date formatting. Below is the table layout and stored procedure in question. How can I format the date for example as MM-DD-YYYY and not have it complain? I have tried using TO_DATE and TO_CHAR and it still complains.
Thank you.
-- Table
CREATE TABLE INV_MOVE_ARCHIVE
*( "RETAILER_ID" NUMBER NOT NULL,*
*"SKU_ID" VARCHAR2(18 BYTE) NOT NULL,*
*"OUTLET_ID" VARCHAR2(20 BYTE) NOT NULL,*
*"QTY_CHANGE" NUMBER NOT NULL,*
*"TRANS_DATE" DATE DEFAULT sysdate*
-- Stored procedure
CREATE OR REPLACE PROCEDURE inv_move_update(beginDate IN DATE, endDate IN DATE, retailerId IN INT)
IS
skuId VARCHAR(18);
outletId VARCHAR(20);
qtyChange INTEGER;
-- Declaring the cursor
CURSOR getInvRecord IS
SELECT
sku_id,
outlet_id,
qty_change
INTO
skuId,
outletId,
qtyChange
FROM
inv_move_archive
WHERE
retailer_id = retailerId AND
trans_date >= beginDate AND
trans_date <= endDate;
BEGIN
FOR rec_getInvRecord IN getInvRecord LOOP
UPDATE OUTLET_SKU_XREF
SET qty = qty + qtyChange
WHERE outlet_id = outletId
AND sku_id = skuId;
COMMIT;
END LOOP;
EXCEPTION
WHEN OTHERS THEN
IF getInvRecord%isopen THEN CLOSE getInvRecord;
END IF;
END inv_move_update;
*/*
Okay, I do not wantto change the table. I believe thatthe Java developers will need to change their code to call this procedure correctly. Another iss I am having is when I call this procedure manually from the database is is NOT doing the update. I put some debug statements in it and they indicate that the update statement is NOT updating any rows. If I run the select statement that is in the sp using the same parameters I pass into the sp it comes back with 1 row. The row to be updated is present in the table being updated.
-- Here is my sp call
DECLARE
BEGINDATE DATE;
ENDDATE DATE;
RETAILERID NUMBER;
BEGIN
BEGINDATE := to_date('01/07/2009 00:00:00', 'MM/DD-YYYY HH24:MI:SS');
ENDDATE := to_date('01/07/2009 11:59:59', 'MM/DD-YYYY HH24:MI:SS');
RETAILERID := 104;
INV_MOVE_UPDATE(
BEGINDATE => BEGINDATE,
ENDDATE => ENDDATE,
RETAILERID => RETAILERID
END;
-- Select statement with same values
SELECT
sku_id,
outlet_id,
qty_change
FROM
inv_move_archive
WHERE
retailer_id = 104 AND
trans_date >= to_date('01/07/2009 00:00:00', 'MM/DD-YYYY HH24:MI:SS') AND
trans_date <= to_date('01/07/2009 11:59:59', 'MM/DD-YYYY HH24:MI:SS')
-- Results from select
036266579804040 9900165 500
-- Here is the procedure with the debug statements in it.
CREATE OR REPLACE PROCEDURE inv_move_update(beginDate IN DATE, endDate IN DATE, retailerId IN INT)
IS
skuId VARCHAR(18);
outletId VARCHAR(20);
qtyChange NUMBER;
errorMessage VARCHAR(2500) := NULL;
-- Declaring the cursor
CURSOR getInvRecord IS
SELECT
sku_id,
outlet_id,
qty_change
INTO
skuId,
outletId,
qtyChange
FROM
inv_move_archive
WHERE
retailer_id = retailerId AND
trans_date >= beginDate AND
trans_date <= endDate;
BEGIN
FOR rec_getInvRecord IN getInvRecord LOOP
DBMS_OUTPUT.PUT_LINE('Rows Updated: ' || SQL%ROWCOUNT);
UPDATE OUTLET_SKU_XREF
SET qty = qty + qtyChange
WHERE outlet_id = outletId
AND sku_id = skuId;
DBMS_OUTPUT.PUT_LINE('SKUID: ' || skuId);
DBMS_OUTPUT.PUT_LINE('Rows Updated: ' || SQL%ROWCOUNT);
COMMIT;
END LOOP;
EXCEPTION
WHEN OTHERS THEN
errorMessage := 'Error updating the OUTLET_SKU_XREF table: ' || SQLCODE || ':' || SQLERRM;
RAISE_APPLICATION_ERROR(-20001,errorMessage);
DBMS_OUTPUT.PUT_LINE(errorMessage);
IF getInvRecord%isopen THEN CLOSE getInvRecord;
END IF;
END inv_move_update;
/I get no errors when running it. The DBMS_OUTPUT shows null for the skuId and 0 for Rows Updated. Like I said I ran the select manually and it returns a row and I see that the row does exist in the target table. Any ideas what is going on here?
Thank you
-- David
Similar Messages
-
Invalid Object error in Stored Procedure
Royal ThomasIt was a bit of a puzzler, but here is a repro that demonstrates Thomas's problem:
CREATE USER svante WITHOUT LOGIN WITH DEFAULT_SCHEMA = guest
ALTER ROLE db_owner ADD MEMBER svante
go
EXECUTE AS USER = 'svante'
go
CREATE PROCEDURE dbo.testis AS
SELECT @@procid AS beata INTO sture
SELECT * FROM sture
go
EXEC testis -- Invalid object name 'sture'.
go
REVERT
go
EXEC testis -- Succede
go
DROP USER svante
DROP TABLE guest.sture
DROP TABLE sture
DROP PROCEDURE testis
What is happening is this: In the statement
SELECT @@procid AS beata INTO sture
the table is created in the default schema of the current user, not in the default schema of the procedure owner (which is dbo, since the procedures was created in dbo). This was certainly unexpected, at least for me.
But in
SELECT * FROM sture
the regular rules, and here sture resolves to dbo.sture, not guest.sture.
Thomas should make sure that he uses dbo.xxxx in all his SELECT INTO statements.
Erland Sommarskog, SQL Server MVP, [email protected] -
Invalid month error sometimes in SQL Developer
Hi
sometimes I get 'Invalid Month error' in SQL developer when I execute the following query
select TRUNC(TO_DATE('01-JUN-2013','DD-MON-YYYY')) from dual;
But when I dosconnect session and reconnect, It works fine
Any suggestions on how to avoid this issue ?
Thanks872202 wrote:
Hi
sometimes I get 'Invalid Month error' in SQL developer when I execute the following query
select TRUNC(TO_DATE('01-JUN-2013','DD-MON-YYYY')) from dual;
But when I dosconnect session and reconnect, It works fine
Any suggestions on how to avoid this issue ?
ThanksThere's absolutely no reason that that should result in that error.
The SQL is sent to the database and it's perfectly valid SQL, taking a string, and converting it to a date with the correct date format mask, and then truncating the date (which, by default is to the day, which in this case is pointless as it's already truncated), returning a DATE datatype, which SQL Developer will then render using it's date display format. -
Strange invalid month error.
Hi all,
I have a function which receives a date and then returns a text string saying what day of the week it is, ie Monday Tuesday etc etc
For example sakes I'll say the function is called dayoftheweek and we use the function like 'select somedate, dayoftheweek(somedate) from dual'
Now, the bit within the function that works out the day is as below
SELECT TO_CHAR(TO_DATE(p_date, 'DD/MM/RRRR') ,'DAY') from dual (p_date is the internal function variable for the date passed in.)
Now, if I do this
select dayoftheweek('25-MAY-09') from dual -- this works.
But...
select dayoftheweek('25/05/09') from dual -- this does not work, I get an ora 01843 invalid month error.
So, I assumed it was something to do with the logic that worked out the day of the week.
However, the below works.
SELECT TO_CHAR(TO_DATE('25/05/09', 'DD/MM/RRRR') ,'DAY') from dual
Does anyone know why when passing a date to the function in format 'select dayoftheweek('25/05/09') from dual' does not work but if I use this format within the function logic as above it does work?
Cheers,
rgHello,
Oracle does not know your date format:
select dayoftheweek('25/05/09')I.e, it does not know that the date you are passing in is in the form of 'DD/MM/MM'. You must tell it (since it isn't your default format):
select dayoftheweek(to_date('25/05/09', 'DD/MM/YY'))If all you wanted, however, was the day of the week from a date, then:
TO_CHAR(to_date('25/05/09', 'DD/MM/YY'), 'DAY')Will give you that.
And by the way, this:
SELECT TO_CHAR(TO_DATE('25/05/09', 'DD/MM/RRRR') ,'DAY') from dualIs correct by chance, even though you're getting no error you may get the wrong result, because you're telling oracle you're passing in 4 digits for the year, yet you're only passing in two.
Edit Beware:
SQL> SELECT TO_CHAR(TO_DATE('25/05/09', 'DD/MM/RRRR'), 'YYYY') from dual;
TO_C
2009
SQL> SELECT TO_CHAR(TO_DATE('25/05/09', 'DD/MM/YYYY'), 'YYYY') from dual;
TO_C
0009 -
Invalid month error in WEBI report level
Hi,
I had a issue with date format.I am using oracle10g as a backend database.I have a date object in universe level i used that object in web intelligence report level.I created prompt for date object after select the date from the list i am getting " invalid month error". In database level object datatype is timestamp.
How to solve this issue.can somebody help me to solve the problem.Hi
Date Objects depends on various formats for different database
Make sure that u format date like MM/dd/yyyy in universe level . and the object should be in date datatype .
In the query level use prompt to select dates.
In report level
create a variable and use a formula like
todate(userresponse("Enter date");"")
Hope this helps U
Sunil -
Invalid Object when Calling Stored Procedure from JDBC Adapter
JDBC Outbound adapter in XI 2.0 connected to SQL Server. I've coded my mapping to format the XSL mapping properly but the Adapter appears to not be able to find the Stored Procedure. Error message returned is "Invalid Object spStoredProcedureName".
Does anybody have any clue as to what I'm missing???I know this is trivial, but did you use the "full" name of the SP as <schema>.<procname>???
HTH -
Error in stored procedure while using dbms_datapump for transportable
Hi,
I'm facing following issue:
SQL> select * from v$version;
BANNER
Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bi
PL/SQL Release 10.2.0.4.0 - Production
CORE 10.2.0.4.0 Production
TNS for Solaris: Version 10.2.0.4.0 - Production
NLSRTL Version 10.2.0.4.0 - Production
====================================================================================
I'm trying to do transportable tablespace through stored procedure with help of DBMS_DATAPUMP, Following is the code :
==================================================================================
create or replace
procedure sp_tts_export(v_tbs_name varchar2) as
idx NUMBER; -- Loop index
JobHandle NUMBER; -- Data Pump job handle
PctComplete NUMBER; -- Percentage of job complete
JobState VARCHAR2(30); -- To keep track of job state
LogEntry ku$_LogEntry; -- For WIP and error messages
JobStatus ku$_JobStatus; -- The job status from get_status
Status ku$_Status; -- The status object returned by get_status
dts varchar2(140):=to_char(sysdate,'YYYYMMDDHH24MISS');
exp_dump_file varchar2(500):=v_tbs_name||'_tts_export_'||dts||'.dmp';
exp_log_file varchar2(500):=v_tbs_name||'_tts_export_'||dts||'.log';
exp_job_name varchar2(500):=v_tbs_name||'_tts_export_'||dts;
dp_dir varchar2(500):='DATA_PUMP_DIR';
log_file UTL_FILE.FILE_TYPE;
log_filename varchar2(500):=exp_job_name||'_main'||'.log';
err_log_file UTL_FILE.FILE_TYPE;
v_db_name varchar2(1000);
v_username varchar2(30);
t_dir_name VARCHAR2(4000);
t_file_name VARCHAR2(4000);
t_sep_pos NUMBER;
t_dir varchar2(30):='temp_0123456789';
v_sqlerrm varchar2(4000);
stmt varchar2(4000);
FUNCTION get_file(filename VARCHAR2, dir VARCHAR2 := 'TEMP')
RETURN VARCHAR2 IS
contents VARCHAR2(32767);
file BFILE := BFILENAME(dir, filename);
BEGIN
DBMS_LOB.FILEOPEN(file, DBMS_LOB.FILE_READONLY);
contents := UTL_RAW.CAST_TO_VARCHAR2(
DBMS_LOB.SUBSTR(file));
DBMS_LOB.CLOSE(file);
RETURN contents;
END;
begin
--execute immediate ('drop tablespace test including contents and datafiles');
--execute immediate ('create tablespace test datafile ''/home/smishr02/test.dbf'' size 10m');
--execute immediate ('create table prestg.test_table (a number) tablespace test');
--execute immediate ('insert into prestg.test_table values (1)');
--commit;
--execute immediate ('alter tablespace test read only');
--dbms_output.put_line('11111111111111111111');
dbms_output.put_line(log_filename||'>>>>>>>>>>>>>>>>>>>>>>>>>>>'|| dp_dir);
log_file:=UTL_FILE.FOPEN (dp_dir, log_filename, 'w');
UTL_FILE.PUT_LINE(log_file,'#####################################################################');
UTL_FILE.PUT_LINE(log_file,'REPORT: GENERATED ON ' || SYSDATE);
UTL_FILE.PUT_LINE(log_file,'#####################################################################');
select global_name,user into v_db_name,v_username from global_name;
UTL_FILE.PUT_LINE(log_file,'Database:'||v_db_name);
UTL_FILE.PUT_LINE(log_file,'user running the job:'||v_username);
UTL_FILE.PUT_LINE(log_file,'for tablespace:'||v_tbs_name);
UTL_FILE.NEW_LINE (log_file);
stmt:='ALTER TABLESPACE '||v_tbs_name || ' read only';
dbms_output.put_line('11111111111111111111'||stmt);
execute immediate (stmt);
UTL_FILE.PUT_LINE(log_file,' '||v_tbs_name || ' altered to read only mode.');
UTL_FILE.NEW_LINE (log_file);
UTL_FILE.PUT_LINE(log_file,'#####################################################################');
UTL_FILE.NEW_LINE (log_file);
UTL_FILE.PUT_LINE(log_file,' Initiating the Datapump engine for TTS export..............');
UTL_FILE.NEW_LINE (log_file);
dbms_output.put_line('11111111111111111111');
JobHandle :=
DBMS_DATAPUMP.OPEN(
operation => 'EXPORT'
*,job_mode => 'TRANSPORTABLE'*
*,remote_link => NULL*
*,job_name => NULL*
--,job_name => exp_job_name
-- ,version => 'LATEST'
UTL_FILE.PUT_LINE(log_file,'Done');
UTL_FILE.NEW_LINE (log_file);
UTL_FILE.PUT_LINE(log_file,' Allocating dumpfile................');
DBMS_DATAPUMP.ADD_FILE(
handle => JobHandle
,filename => exp_dump_file
,directory => dp_dir
,filetype => DBMS_DATAPUMP.KU$_FILE_TYPE_DUMP_FILE
-- ,filesize => '100M'
UTL_FILE.PUT_LINE(log_file,'Done');
UTL_FILE.NEW_LINE (log_file);
UTL_FILE.PUT_LINE(log_file,' Allocating logfile................');
DBMS_DATAPUMP.ADD_FILE(
handle => JobHandle
,filename => exp_log_file
,directory => dp_dir
,filetype => DBMS_DATAPUMP.KU$_FILE_TYPE_LOG_FILE
UTL_FILE.PUT_LINE(log_file,'Done');
UTL_FILE.NEW_LINE (log_file);
UTL_FILE.PUT_LINE(log_file,' Setting attributes................');
DBMS_DATAPUMP.set_parameter(handle => JobHandle,
name=>'TTS_FULL_CHECK',
value=>1);
DBMS_DATAPUMP.METADATA_FILTER(
handle => JobHandle
,NAME => 'TABLESPACE_EXPR'
,VALUE => 'IN ('''||v_tbs_name||''')'
-- ,object_type => 'TABLE'
UTL_FILE.PUT_LINE(log_file,'Done');
UTL_FILE.NEW_LINE (log_file);
UTL_FILE.PUT_LINE(log_file,' Now starting datapump job................');
DBMS_DATAPUMP.START_JOB(JobHandle);
UTL_FILE.PUT_LINE(log_file,'Done');
UTL_FILE.NEW_LINE (log_file);
UTL_FILE.PUT_LINE(log_file,' Monitoring the job................');
--------------Monitor the job
PctComplete := 0;
JobState := 'UNDEFINED';
WHILE(JobState != 'COMPLETED') and (JobState != 'STOPPED')
LOOP
DBMS_DATAPUMP.GET_STATUS(
handle => JobHandle
,mask => 15 -- DBMS_DATAPUMP.ku$_status_job_error + DBMS_DATAPUMP.ku$_status_job_status + DBMS_DATAPUMP.ku$_status_wip
,timeout => NULL
,job_state => JobState
,status => Status
JobStatus := Status.job_status;
-- Whenever the PctComplete value has changed, display it
IF JobStatus.percent_done != PctComplete THEN
DBMS_OUTPUT.PUT_LINE('*** Job percent done = ' || TO_CHAR(JobStatus.percent_done));
PctComplete := JobStatus.percent_done;
END IF;
-- Whenever a work-in progress message or error message arises, display it
IF (BITAND(Status.mask,DBMS_DATAPUMP.ku$_status_wip) != 0) THEN
LogEntry := Status.wip;
ELSE
IF (BITAND(Status.mask,DBMS_DATAPUMP.ku$_status_job_error) != 0) THEN
LogEntry := Status.error;
ELSE
LogEntry := NULL;
END IF;
END IF;
IF LogEntry IS NOT NULL THEN
idx := LogEntry.FIRST;
WHILE idx IS NOT NULL
LOOP
DBMS_OUTPUT.PUT_LINE(LogEntry(idx).LogText);
idx := LogEntry.NEXT(idx);
END LOOP;
END IF;
END LOOP;
--copy the datafiles to data dump dir
UTL_FILE.PUT_LINE(log_file,'Done');
UTL_FILE.NEW_LINE (log_file);
UTL_FILE.PUT_LINE(log_file,' Copying datafiles to dump directory................');
-- grant select on dba_directories to prestg;
declare
cnt number;
begin
select count(*) into cnt from dba_directories
where directory_name=upper(t_dir);
if cnt=1 then
execute immediate('DROP DIRECTORY '||t_dir);
end if;
end;
FOR rec in (select file_name from sys.dba_data_files where tablespace_name=v_tbs_name)
LOOP
t_sep_pos:=instr(rec.file_name,'/',-1);
t_dir_name:=substr(rec.file_name,1,t_sep_pos-1);
t_file_name:=substr(rec.file_name,t_sep_pos+1,length(rec.file_name));
dbms_output.put_line(t_dir_name|| ' ' || t_dir);
dbms_output.put_line(t_file_name);
execute immediate('CREATE DIRECTORY '||t_dir||' AS '''||t_dir_name||'''');
UTL_FILE.PUT_LINE(log_file,' Copying '||rec.file_name||'................');
utl_file.fcopy(t_dir, t_file_name, dp_dir, t_file_name);
UTL_FILE.PUT(log_file,'Done');
execute immediate('DROP DIRECTORY '||t_dir);
END LOOP;
UTL_FILE.NEW_LINE (log_file);
UTL_FILE.PUT_LINE(log_file,' Altering tablespace to read write................');
execute immediate ('ALTER TABLESPACE '||v_tbs_name || ' read write');
UTL_FILE.PUT(log_file,' Done');
err_log_file:=utl_file.fopen(dp_dir, exp_log_file, 'r');
UTL_FILE.NEW_LINE (log_file);
UTL_FILE.PUT_LINE(log_file,' content of export logfile................');
loop
begin
utl_file.get_line(err_log_file,v_sqlerrm);
if v_sqlerrm is null then
exit;
end if;
UTL_FILE.PUT_LINE(log_file,v_sqlerrm);
EXCEPTION
WHEN NO_DATA_FOUND THEN
EXIT;
END;
end loop;
utl_file.fclose(err_log_file);
utl_file.fclose(log_file);
END;
I'm getting following error when DBMS_DATAPUMP.OPEN is called in procedure:
SQL> exec sp_tts_export('TEST');
BEGIN sp_tts_export('TEST'); END;
ERROR at line 1:
ORA-31626: job does not exist
ORA-06512: at "SYS.DBMS_SYS_ERROR", line 79
ORA-06512: at "SYS.DBMS_DATAPUMP", line 938
ORA-06512: at "SYS.DBMS_DATAPUMP", line 4566
ORA-06512: at "PRESTG.SP_TTS_EXPORT", line 78
ORA-06512: at line 1
==============================================================================================
This procedure is part of user ABC. I'm getting the above when I'm running this under ABC schema. However I have tested the same procedure under sys schema. When I'm creating same procedure in SYS schema it is running fine. I am clueless on this. Pls help
Thanks
Shailesh
Edited by: shaileshM on Jul 28, 2010 11:15 AMPrivileges acquired via ROLE do NOT apply within named PL/SQL procedures.
Explicit GRANT is required to resolve this issue. -
Error executing Stored Procedure that returns a recordset in Visual Basic 6
Hello, i tried to use the example in the link posted as a response to my question in a previous thread, and in Visual Basic 6, when i execute the Stored procedure it gives me the following error:
This is the package created as indicated in the example FAQ you posted.
package types
as
type cursorType is ref cursor;
end;
This is the procedure created as indicated in the example FAQ you posted.
PROCEDURE SP_TITUVALO(T_BR IN VARCHAR2,
P_Cursor OUT TYPES.cursorType )
AS
BEGIN
OPEN P_Cursor FOR
SELECT * FROM TASAS WHERE BR=T_BR AND TASA > 0;
END;
This is the code used to execute the Stored Procedure in VB6:
Dim objConn As New ADODB.Connection
Dim connString
Dim cmdStoredProc As New ADODB.Command
Dim param1 As New ADODB.Parameter
Dim RS As ADODB.Recordset
Set param1 = cmdStoredProc.CreateParameter("T_BR", adVarChar, adParamInput, 255, "97")
cmdStoredProc.Parameters.Append param1
objConn.Open strconex
Set cmdStoredProc.ActiveConnection = objConn
cmdStoredProc.CommandText = "SP_TITUVALO"
cmdStoredProc.CommandType = adCmdStoredProc
Set RS = cmdStoredProc.Execute
This is the error returned:
ORA-06550: line 1, column 7:
PLS-00306: wrong number or types of arguments in call to 'SP_TITUVALO'
ORA-06550: line 1, column 7:
PL/SQL: Statement ignored
****************************************************************Juan,
Not sure about FAQ you are referring to, but it seems that you need to set PLSQLRSet property of ADODB.Command to TRUE. Because if you fail to do so - errors with refcursors are likely to happen.
Consider:
Set objConn = CreateObject("ADODB.Connection")
objConn.ConnectionString = "Provider=OraOLEDB.Oracle;Persist Security Info=False;Data Source=test9ora;User ID=max;Password=blabla"
objConn.Open
'Dim cmdStoredProc
Set cmdStoredProc = CreateObject("ADODB.Command")
Dim param1
Set param1 = cmdStoredProc.CreateParameter("T_BR", adVarChar, adParamInput, 255, "97")
param1.Value = "X"
cmdStoredProc.Parameters.Append param1
'Dim RS
Set cmdStoredProc.ActiveConnection = objConn
'The following line was missed out
cmdStoredProc.Properties("PLSQLRSet") = True
cmdStoredProc.CommandText = "SP_TITUVALO"
cmdStoredProc.CommandType = adCmdStoredProc
Set RS = cmdStoredProc.ExecuteThis works fine, at least for me.
Cheers. -
Error calling stored procedure from MFC using odbc
Hello,
I am using MFC to call a stored procedure written in PL/SQL, but when I make the call I get the next error in Spanish:
"No se enlazaron columnas antes de llamar a SQLFetchScroll o SQLExtendedFetch", which more or less in English means:
"No rows were binded before calling SQLFetchScroll or SQLExtendedFetch".
I am using a CRecordset derived class to access the stored procedure. I am unable to find the error.
THE STORED PROCEDURE'S HEADER:
Sp_Int_Ot_Ordendetrabajoalta ( lineatrabajo NUMBER, lv_orden NUMBER, usuario
VARCHAR2, idvehiculo NUMBER, fechamax1 VARCHAR2, resumen VARCHAR2, detalle
VARCHAR2,
coderp VARCHAR2, numtrabrecibidos NUMBER, lv_CODOT VARCHAR2, retorno OUT
INTEGER)
THE .H FOR THE CRECORDSET DERIVED CLASS (Visual Studio 6 comments removed)
class CRecSP : public CRecordset
public:
CRecSP(CDatabase* pDatabase = NULL);
DECLARE_DYNAMIC(CRecSP)
CString m_szSQL;
long m_RETORNO;
virtual CString GetDefaultConnect();
virtual CString GetDefaultSQL();
virtual void DoFieldExchange(CFieldExchange* pFX);
THE .CPP FOR THE CLASS (VS6 comments removed)
IMPLEMENT_DYNAMIC(CRecSP, CRecordset)
CRecSP::CRecSP(CDatabase* pdb) : CRecordset(pdb)
m_RETORNO = 0;
m_nParams = 1;
m_nDefaultType = snapshot;
CString CRecSP::GetDefaultConnect()
return T( DBCONNECTION_STRING );
CString CRecSP::GetDefaultSQL()
return m_szSQL;
void CRecSP::DoFieldExchange(CFieldExchange* pFX)
pFX->SetFieldType(CFieldExchange::outputParam);
RFX_Long(pFX, _T("[retorno]"), m_RETORNO );
USING THE CRECORDSET DERIVED CLASS: (Vars read from EditBoxes as CStrings
and formatted in the SQL)
CRecSP *rec = new CRecSP(&db);
szSQL.Format( "{CALL
FGROT2005.SP_INT_OT_ORDENDETRABAJOALTA(%s,%s,'%s',%s,'%s','%s','%s','%s',%s,'%s',?)}",
szLinea, szOrden, "USER", szIdVeh, szFechaMax, szResumen,
szDetalle, "ERP", "0", szCodOT
rec->m_szSQL = szSQL;
//rec->Open( CRecordset::forwardOnly,szSQL,CRecordset::readOnly );
rec->Open( );
iError = rec->m_RETORNO;
rec->Close();This forum is meant for discussions about OTN content/site and services.
Questions about Oracle products and technologies will NOT be answered in this forum. Please post your product or technology related questions in the appropriate product or technology forums, which are monitored by Oracle product managers.
Product forums:
http://forums.oracle.com/forums/index.jsp?cat=9
Technology forums:
http://forums.oracle.com/forums/index.jsp?cat=10 -
Error Calling Stored Procedure Receiver adapter
Hi Guys,
I am trying to send data to a stored procedure SQL server R2 2008 from SAP PI7.11.
Transport Protocol: JDBC2.0
Message Protocol : XMLSQLFORMAT
I am able to read from same database using sender adapter.
Name of SP: InderTest
Paramters in SP : @Carrier Varchar(20), @Location Varchar(20), @Product Varchar(20), @Zone Varchar(20),
@dteStart date, @dteEnd date, @strType Varchar(1), @intRate Float
<?xml version="1.0" encoding="UTF-8" ?>
- <ns0:MT_FreightPricing xmlns:ns0="http://na.holcim.com/pi/o2c/pricingmaster">
- <StatementName1>
- <InderTest action="EXECUTE">
<table>InderTest</table>
<Carrier isInput="true" type="VARCHAR">4000004</Carrier>
<Location isInput="true" type="VARCHAR">3600</Location>
<Product isInput="true" type="VARCHAR">3553</Product>
<Zone isInput="true" type="VARCHAR">Zone1</Zone>
<dteStart isInput="true" type="DATE">20110704</dteStart>
<dteEnd isInput="true" type="DATE">20120704</dteEnd>
<strType isInput="true" type="VARCHAR">A</strType>
<intRate isInput="true" type="FLOAT">10.00</intRate>
</InderTest>
</StatementName1>
</ns0:MT_FreightPricing>
Error in JDBC Receiver
Message processing failed. Cause: com.sap.engine.interfaces.messaging.api.exception.MessagingException: Error processing request in sax parser: Error when executing statement for table/stored proc. 'InderTest' (structure 'StatementName1'): java.lang.IllegalArgumentException
Any clue...
I was reading this help document. They have mentioned 5 configuration step, i have worked on JDBC earlier but never did anything like that.... Any idea ?
http://help.sap.com/saphelp_nw70/helpdata/en/b0/676b3c255b1475e10000000a114084/content.htm
Regards
Inder<table> element is optional in the structure. In that case you can try:
<?xml version="1.0" encoding="UTF-8" ?>
<ns0:MT_FreightPricing xmlns:ns0="http://na.holcim.com/pi/o2c/pricingmaster">
<StatementName1>
<InderTest action="EXECUTE">
<Carrier isInput="true" type="VARCHAR">4000004</Carrier>
<Location isInput="true" type="VARCHAR">3600</Location>
<Product isInput="true" type="VARCHAR">3553</Product>
<Zone isInput="true" type="VARCHAR">Zone1</Zone>
<dteStart isInput="true" type="DATE">20110704</dteStart>
<dteEnd isInput="true" type="DATE">20120704</dteEnd>
<strType isInput="true" type="VARCHAR">A</strType>
<intRate isInput="true" type="FLOAT">10.00</intRate>
</InderTest>
</StatementName1>
</ns0:MT_FreightPricing>
Regards
Raj -
Error calling stored procedure from MFC.
Hello,
I am using MFC to call a stored procedure written in PL/SQL, but when I make the call I get the next error in Spanish:
"No se enlazaron columnas antes de llamar a SQLFetchScroll o SQLExtendedFetch", which more or less in English means:
"No rows were binded before calling SQLFetchScroll or SQLExtendedFetch".
I am using a CRecordset derived class to access the stored procedure. I am unable to find the error.
THE STORED PROCEDURE'S HEADER:
Sp_Int_Ot_Ordendetrabajoalta ( lineatrabajo NUMBER, lv_orden NUMBER, usuario
VARCHAR2, idvehiculo NUMBER, fechamax1 VARCHAR2, resumen VARCHAR2, detalle
VARCHAR2,
coderp VARCHAR2, numtrabrecibidos NUMBER, lv_CODOT VARCHAR2, retorno OUT
INTEGER)
THE .H FOR THE CRECORDSET DERIVED CLASS (Visual Studio 6 comments removed)
class CRecSP : public CRecordset
public:
CRecSP(CDatabase* pDatabase = NULL);
DECLARE_DYNAMIC(CRecSP)
CString m_szSQL;
long m_RETORNO;
virtual CString GetDefaultConnect();
virtual CString GetDefaultSQL();
virtual void DoFieldExchange(CFieldExchange* pFX);
THE .CPP FOR THE CLASS (VS6 comments removed)
IMPLEMENT_DYNAMIC(CRecSP, CRecordset)
CRecSP::CRecSP(CDatabase* pdb) : CRecordset(pdb)
m_RETORNO = 0;
m_nParams = 1;
m_nDefaultType = snapshot;
CString CRecSP::GetDefaultConnect()
return T( DBCONNECTION_STRING );
CString CRecSP::GetDefaultSQL()
return m_szSQL;
void CRecSP::DoFieldExchange(CFieldExchange* pFX)
pFX->SetFieldType(CFieldExchange::outputParam);
RFX_Long(pFX, _T("[retorno]"), m_RETORNO );
USING THE CRECORDSET DERIVED CLASS: (Vars read from EditBoxes as CStrings
and formatted in the SQL)
CRecSP *rec = new CRecSP(&db);
szSQL.Format( "{CALL
FGROT2005.SP_INT_OT_ORDENDETRABAJOALTA(%s,%s,'%s',%s,'%s','%s','%s','%s',%s,'%s',?)}",
szLinea, szOrden, "USER", szIdVeh, szFechaMax, szResumen,
szDetalle, "ERP", "0", szCodOT
rec->m_szSQL = szSQL;
//rec->Open( CRecordset::forwardOnly,szSQL,CRecordset::readOnly );
rec->Open( );
iError = rec->m_RETORNO;
rec->Close();I am trying to pass parameter to test my procedure but it is giving this error : ORA-06531: Reference to uninitialized collection
ORA-06512: at line 12
Here is example for my test procedure:
declare
v_session_id_tab SESSION_ID_TAB_TYPE;
v_service_type_tab SERVICE_TYPE_TAB_TYPE ;
v_service_location_tab SERVICE_LOCATION_TAB_TYPE ;
v_service_call_name_tab SERVICE_CALL_NAME_TAB_TYPE;
v_service_call_start_time_tab SERVICE_CALL_ST_TAB_TYPE;
v_service_call_end_time_tab SERVICE_CALL_ET_TAB_TYPE;
v_service_call_duration_tab SERVICE_CALL_DUR_TAB_TYPE;
v_status_tab STATUS_TAB_TYPE;
v_notes_tab NOTES_TAB_TYPE;
begin
v_session_id_tab(1) := 1;
v_service_type_tab(1) := 'db';
v_service_location_tab(1) := 'local';
v_service_call_name_tab(1) := 'Name of call';
v_service_call_start_time_tab(1) := SYSDATE;
v_service_call_end_time_tab(1) := SYSDATE;
v_service_call_duration_tab(1) := 100;
v_status_tab(1) := 'Z';
v_notes_tab(1) := 'NOTES';
BULK_INSERTS (v_session_id_tab,v_service_type_tab, v_service_location_tab,v_service_call_name_tab,v_service_call_start_time_tab,v_service_call_end_time_tab,
v_service_call_duration_tab, v_status_tab, v_notes_tab);
end;
I declare all types at schema level.
Please give your comments.
Thank you -
Error creating stored procedure using Apex
Hello,
I have worked with Access, SQL Server, and Firebird before, but am new to Oracle. I am trying to create a stored procedure to return the count of multiple hash values in a table. I want to know the number of rows that contain hash values that are duplicates somewhere else in the table. So if my table has 10 rows containing hash values: a, b, a, b, c, d, e, a, b, a, my return value should be 7. Here is my create procedure statement:
CREATE OR REPLACE PROCEDURE CommonHashValuesCount (dupThreshold in number, totalCount out number)
IS
BEGIN
totalCount := 0;
FOR h IN
(SELECT DISTINCT xf.MD5_HASH, COUNT(xf.MD5_HASH) as "HashCount"
FROM XFILE xf
GROUP BY xf.MD5_HASH)
LOOP
IF h.HashCount > dupThreshold THEN
totalCount := totalCount + h.HashCount;
END IF;
END LOOP;
END;
I get the following error when I try and run it:
ERROR at line 12: PL/SQL: Statement ignored
1. CREATE OR REPLACE PROCEDURE CommonHashValuesCount (dupThreshold in number, totalCount out number)
2. IS
3. BEGIN
Can anyone tell me what is wrong with my create statement? Or if anyone knows how to accomplish what I want in a single sql statement, I'd love to hear it!
TIA,
TheresaWhy not do it in a SQL statement so you can test it in the APEX SQL command window?
SELECT Sum(HashCount)
FROM (SELECT DISTINCT xf.MD5_HASH
, COUNT(xf.MD5_HASH) HashCount
FROM XFILE xf
GROUP BY xf.MD5_HASH
WHERE HashCount > <testvalue>
not tested
and then simply put that into your stored procedure/package:
SELECT Sum(HashCount)
INTO totalCount
FROM (SELECT DISTINCT xf.MD5_HASH
, COUNT(xf.MD5_HASH) HashCount
FROM XFILE xf
GROUP BY xf.MD5_HASH
WHERE HashCount > dubThreshold
also not tested
C. -
Error - remote stored procedure includes in a function
Hi,
I have a stored procedure, it runs properly
ecos.GetCustTier@BSCSDEV in PL/SQL
But after included into function F_GETCUSTTIER, it comes error.
SQL> select f_getcusttier(585510,'20020808') from dual
ORA-06571: Function F_GETCUSTTIER does not guarantee not to update database
[Function F_GETCUSTTIER]
create or replace FUNCTION f_getcusttier(
Begin
ecos.GetCustTier@BSCSDEV(i_customer_id, i_at_date, o_seqno, o_custcode, o_tier_id, o_tier_des, o_join_date, o_join_reason,
o_renewal_date, o_next_review_date, o_last_review_amt_no, o_exit_date, o_exit_reason,
o_input_by, o_input_date, o_update_by, o_update_date, o_expiry_date, o_next_job_review_date,
o_status_id, o_return_code);
RETURN o_tier_id;
I also try to create a package for this function
CREATE OR REPLACE PACKAGE abc AS
FUNCTION f_getcusttier(i_customer_id number, i_at_date varchar2) RETURN NUMBER;
PRAGMA RESTRICT_REFERENCES(f_getcusttier, WNDS);
END abc;
CREATE OR REPLACE PACKAGE BODY bwan AS
FUNCTION f_getcusttier(
i_customer_id in number,
i_at_date in varchar2
Begin
ecos.GetCustTier@BSCSDEV(i_customer_id, i_at_date, o_seqno, o_custcode, o_tier_id, o_tier_des, o_join_date, o_join_reason,
o_renewal_date, o_next_review_date, o_last_review_amt_no, o_exit_date, o_exit_reason,
o_input_by, o_input_date, o_update_by, o_update_date, o_expiry_date, o_next_job_review_date,
o_status_id, o_return_code);
RETURN o_tier_id;
But with Warning: Package Body created with compilation errors.
2/1 PLS-00452: Subprogram 'F_GETCUSTTIER' violates its associated
pragma
How can I fixed it? Can function pack with remote stored procedure?
DB version: 8.0.4.4.0
I know that this problem is resolved in Release 8.1, is it no solution for release 8.0.4.4.0?First of all, please do not post three separate threads for the one problem. It simply clutters up the forum for the rest of us.
Prior to 8i you need to explicitly guarantee that your function does not write to the database. You do this with the RESTRICT_REFERENCES pragma:
CREATE PACKAGE yr_package AS -- package specification
FUNCTION whatever
(pn IN NUMBER) RETURN NUMBER;
PRAGMA RESTRICT_REFERENCES (whatever, WNDS);
END yr_package;The following link goes to a page of helpful stuff assembeled by some of use regulars:Re: How to attach a java bean in forms6i
It includes jumps to the Oracle online documentation. You may find the Application Developer's Guide - Fundamentals an instructive read.
Regards, APC -
SQLJ error in stored procedure
Okay I'm kind of new to this stuff so this is probably an easy
question but I can't fix my current problem. Know I have been
creating and compiling several java stored procedures in my
oracle 8.1.7.0.0 enterprise edition database. So far everything
is create I have created about a dozen and done all of their
call specs and everything works without a hitch.
The problem I have came into being when I tried to create a
stored procedure that uses SQLJ. When I create my stored
procedures I compile my java code straight into the database
using the
CREATE OR REPLACE AND COMPILE JAVA SOURCE named "myClass" AS
source
this has always worked from me except when I place my
#sql ; lines at which point it issues a the following error
SP2-7034 : unknown command beginning
at which point is it ignores the line of code and continues to
compile my java source. Does this mean the SQLJ is not enabled
in my database or what? I have checked out the SQLJ developer’s
hand book and it did not help me with this problem. Oh please
wont some wise oracle god help me!user21354 wrote:
i am creating the collection in my Stored procedure it is giving me this error
declare
type t_number is table of number;
v_numbers t_number;
begin
select VISIT_ID
bulk collect into v_numbers
from visit
where VISITTYPEID = 2;
select VISIT_ID from v_numbers;
end;
error
PL/SQL: ORA-00942: table or view does not exist
please tell me this why this happeningcouple of things...
context switching - Your second 'select visit_id' query is actually parsed outside plsql, in the 'sql engine'. This sql engine has no knowledge of what v_numbers is, it's expecting an actual table name but it can't find anything called v_numbers in it's metadata. So it bombs out with that error. Google 'context switching plsql' for more info. :o)
- as v_numbers is a collection, you could just loop through the results:
for n in 1..v_numbers.count
loop
dbms_output.put_line(v_numbers(n));
end loop;- as stated above, a 'select' without 'into' won't work in plsql anyway.
- there is a way of getting round the context switch, by creating your Type in sql rather than plsql and 'casting' it to a table. Let us know if you want to know the steps to do it, but try reading up on context switch first.
cheers. -
Error when stored procedure returns cursor in pro c
Hi
I was trying to make work the stuff explained at
[m-2537153]
It executes a stored procedure from pro c that returns a cursor.
But when i compllie at pro c I get following error. My procedure name is TEST.
If i change the output parameter to a int value. It compiles ok.
PLS-S-00306, wrong number or types of arguments in call to 'TEST'
Error at line 34, column 5 in file E:\C\Test\tt.pc
TEST(:test_cursor);
+....1+
PLS-S-00000, Statement ignored
Semantic error at line 33, column 1, file E:\C\Test\tt.pc:
BEGIN
+1+
PCC-S-02346, PL/SQL found semantic errors
Can any one point out what could be the error?
I am working from oracle 8i client. which connects to oracle 9.0.1.
OS is win 2000 sp4This is my code
int main(int argc, char** argv)
+{+
EXEC SQL BEGIN DECLARE SECTION;
char user[]="scott";
char pwd[]="tiger";
char server[]="testdb";
char msg_buf[51|http://forums.oracle.com/forums/]+="";+
int intarg1;
int intId;
char strName[]="";
SQL_CURSOR tcr;
EXEC SQL END DECLARE SECTION;
+/* Register sql_error() as the error handler. */+
EXEC SQL WHENEVER SQLERROR DO sql_error("ORACLE error\n");
EXEC SQL CONNECT :user IDENTIFIED BY :pwd USING :server;
Printf("Connected to %s successfully",server);
EXEC SQL ALLOCATE :tcr;
EXEC SQL EXECUTE
BEGIN
TEST(:tcr);
END;
END-EXEC;
Procedure name is TEST and it like
CREATE OR REPLACE PROCEDURE TEST (crsdata out sys_refcursor)
as
BEGIN
open crsdata for select id,name from newtab;
END;
Maybe you are looking for
-
IPod Classic not being recognized by iTunes
Okay, so I've had an iPod Classic (30 gb) for a while now, and it stopped working for some unknown reason. The thing that's happening is that it's not recognized by the computer at all; once I plug it into the USB drive, the computer says that there'
-
I have not been able to make search work via Zimbra. Whenever I type a search criteria I always get the response "Folder does not exist". My search text looks something like this "in:inbox mysearchcriteria" Appreciate the guidance. -Murali
-
Opening Windows Media videos in Safari
When clicking on windows media video file, the video will open, but also goes to a blank browser page -- being new to Safari -- can this be changed for PC (and Macs)? I would like to have just the windows media application open to see the video, whil
-
a message showing licence of connect expired is always appearing on screen. Dont know why. If anyone is aware of it plz sort out...
-
ITunes doesn't detect my iPhone
Hi all, I've got the latest version of iTunes and an iPhone 4 running on iOS 5.1.1. And yes I don't want to update my iOS to 6.0.1 for obvious reasons. Everything was fine until yesterday. But since yesterday my iTunes wouldn't recognise my iPhone