Drop Procedure
Hi,
I am trying to drop some procedure in my database, its not working.
it says that object was locked, i checked the v$lock and dba_jobs_running, there is no lock.
kindly tell how can i drop the procedure.
These errors from alert log file
Errors in file /opt/oracle/app/oracle/admin/BBMLTEST/bdump/bbmltest1_j000_7981.trc:
ORA-12012: error on auto execute of job 23215244
ORA-06550: line 1, column 102:
PLS-00201: identifier 'FFT.SECT_FFT_ASSET_SCD_POMS_INP_A' must be declared
ORA-06550: line 1, column 102:
PL/SQL: Statement ignored
Fri Apr 11 01:25:56 2008
Errors in file /opt/oracle/app/oracle/admin/BBMLTEST/bdump/bbmltest1_j003_17754.trc:
ORA-12012: error on auto execute of job 23215367
ORA-06550: line 1, column 102:
PLS-00201: identifier 'FFT.SECT_FFT_ASSET_SCD_POMS_INP_A' must be declared
ORA-06550: line 1, column 102:
PL/SQL: Statement ignored
Fri Apr 11 01:25:56 2008
Errors in file /opt/oracle/app/oracle/admin/BBMLTEST/bdump/bbmltest1_j004_17756.trc:
ORA-12012: error on auto execute of job 23218854
ORA-06550: line 1, column 102:
PLS-00201: identifier 'FFT.SECT_FFT_ASSET_SCD_POMS_INP_A' must be declared
ORA-06550: line 1, column 102:
PL/SQL: Statement ignored
Similar Messages
-
Hi Experts,
I had created one procedure before month but i have deleted that procedure yesterday. Now i want to use that procedure. Can i get that procedure? Is there any query for getting drop procedure?
Thanks in advanced..
regards,
Viraj VashiNo. Only tables and their dependent objects go to recycle bin. You have to restore it from backup or export file. I personally always keep local copies of my code in txt files. And of course you should have some verion control software.
-
Dropping procedure of a package
Hi,
Is it possible to drop a procedure or function available inside a package ?
For example....
Suppose there areoceduresProc1, Proc2 inside a package Pack1 and I want to drop only the procedure Proc1
Pls let me know whether is there any possibilities..
Thanks in advanceNope it is impossible.
you must change specification of your package and body of your package. -
How to drop a procedure, if already exists
Hi,
I want to run an sql script in Hana Studio that will drop a procedure if this procedure already exists.
Otherwise nothing will happen.
Thank you in advance.
D.E.You can use the view SYS.PROCEDURES to check if your procedure exists, something similar to this:
declare v_proc_exists integer;
select count(PROCEDURE_NAME) into v_proc_exists from SYS.PROCEDURES
where PROCEDURE_NAME = '<PROC_NAME>';
if :v_proc_exists > 0 then
DROP PROCEDURE "<PROC_NAME>";
end if;
Cheers,
Fernando -
Dear guys
i made a procedure for sending mails in loop and when i executed it...its running continuosly,even i closed session,its keep on sending mail as somewhere the loop is wrong.
Is there anyway to stop running the execution of the procedure. as i am unable to drop it with command
drop procedure procedure name
os-linux
db-10.2.0.4SELECT a.username,serial#,c.os_user_name, a.sid,c.session_id,a.terminal,
b.object_id,substr(b.object_name,1,40) object_name
from v$session a, dba_objects b, v$locked_object c
where a.sid = c.session_id
and b.object_id = c.object_id
ALTER SYSTEM KILL SESSION 'sid,serial#'; -
I want to drop a procedure by writting this script
drop procedure procedure_name;
but it is giving a error messege saying it is unable to lock the specified procedure.
when i am seeing the containts of V$_lock_objects it is showing that this procedure is locked.
i want to unlock that procedure pls
help me to unlock that procedure
thangs
AnujUsing V$access and v$session find the sid, machine that is locking the procedure. Contact the person or kill if u feel that is unimportant.
Hope it helps u.
null -
How to execute commit statement in a procedure optionally?
We have a procedure which has DML operations and at the end there is a commit statement.
I want to execute commit statement optionally.
Like, when procedure runs directly it must execute commit statement, but when this procedure is called from a trigger don't run commit.
As you know commit operation is not allowed in triggers.
How can I understant the code is triggered from a trigger or any other (manuel exec or from another procedure).
I am looking for the reserved word that solve my problem. Like INSERTING, DELETING ....
Serkan
Thanks.Hi oraserkan,
You do of course know it's dangerous to have a commit inside a procedure?
Consider this:
SQL> create table t (text varchar2(25))
Table created.
SQL> create or replace procedure p
as
begin
insert into t(text)
values ('Insert PROCEDURE');
commit;
end p;
Procedure created.
SQL> insert into t(text)
values ('Insert SQL')
1 row created.
SQL> exec p
PL/SQL procedure successfully completed.
SQL> rollback
Rollback complete.
SQL> select * from t
TEXT
Insert SQL
Insert PROCEDURE
2 rows selected.You should instead clearly state the procedure has a commit by making it autonomous, and then have two procedures, one that commits, and one that don't
SQL> drop procedure p
Procedure dropped.
SQL> drop table t purge
Table dropped.
SQL> create table t (text varchar2(25))
Table created.
SQL> create or replace procedure p_transactional
as
begin
insert into t(text)
values ('Insert PROCEDURE');
end p_transactional;
Procedure created.
SQL> create or replace procedure p_autonomous
as
pragma autonomous_transaction;
begin
p_transactional;
commit;
end p_autonomous;
Procedure created.
SQL> insert into t(text)
values ('Insert SQL')
1 row created.
SQL> exec p_autonomous
PL/SQL procedure successfully completed.
SQL> rollback
Rollback complete.
SQL> select * from t
TEXT
Insert PROCEDURE
1 row selected.
SQL> drop procedure p_transactional
Procedure dropped.
SQL> drop procedure p_autonomous
Procedure dropped.
SQL> drop table t purge
Table dropped.Regards
Peter -
Passing variable values to pl/sql procedures
Hi,
I wanted to log the step name and message into a table whenever a particular step/interface failed in the ODI package.
Ex:PKG1
A----OK--->B----OK-->C--OK-->LOG SUCCESS status into table. All steps are sequenced.
when not OK
A----KO--->B----KO-->C--KO-->LOG failed status into table with step and message.
I have created 4 variables in ODI and used these vairables in to pass values in pl/sql procedure scenario.
I have drag and drop procedure scenario and given values to every variable...thing is for i want to get the step name dynamically for the procedure scenario's variable i am directly passing
v_int_step=odiRef.getPrevStepLog("STEP_NAME").
I dont want drag and drop procedure for each KO and then pass values to v_int_step=A or B or C .
My scenario command look like this for KO
OdiStartScen "-SCEN_NAME=PROC_LOGEXE_STATUS" "-SCEN_VERSION=-1" "-LOG_LEVEL=3" "-SYNC_MODE=1" "-SESSION_NAME=PROC_CSA_LOGEXE_STATUS_CS_BRANCHES" "-FLEXCUBE_OFSAA.v_execution_status=E" "-project1.v_scen_int_name=A" "-project1.v_batch_id=PKG_GLOBAL_MNT_HANDOFF" "-project1.v_step_name=odiRef.getPrevStepLog("STEP_NAME")"
I am getting following error
oracle.odi.oditools.OdiToolInvalidParameterException: Error while setting parameters on tool
at com.sunopsis.dwg.function.SnpsFunctionBase.getCoreOdiTool(SnpsFunctionBase.java:607)
at com.sunopsis.dwg.function.SnpsFunctionBase.getSunopsisApi(SnpsFunctionBase.java:480)
at com.sunopsis.dwg.dbobj.SnpSessTaskSql.execIntegratedFunction(SnpSessTaskSql.java:1340)
at com.sunopsis.dwg.dbobj.SnpSessTaskSql.treatTaskTrt(SnpSessTaskSql.java:2785)
at com.sunopsis.dwg.dbobj.SnpSessTaskSql.treatTask(SnpSessTaskSql.java:2515)
at com.sunopsis.dwg.dbobj.SnpSessStep.treatAttachedTasks(SnpSessStep.java:537)
at com.sunopsis.dwg.dbobj.SnpSessStep.treatSessStep(SnpSessStep.java:449)
at com.sunopsis.dwg.dbobj.SnpSession.treatSession(SnpSession.java:1954)
at oracle.odi.runtime.agent.processor.impl.StartSessRequestProcessor$2.doAction(StartSessRequestProcessor.java:322)
at oracle.odi.core.persistence.dwgobject.DwgObjectTemplate.execute(DwgObjectTemplate.java:224)
at oracle.odi.runtime.agent.processor.impl.StartSessRequestProcessor.doProcessStartSessTask(StartSessRequestProcessor.java:246)
at oracle.odi.runtime.agent.processor.impl.StartSessRequestProcessor.access$0(StartSessRequestProcessor.java:237)
at oracle.odi.runtime.agent.processor.impl.StartSessRequestProcessor$StartSessTask.doExecute(StartSessRequestProcessor.java:794)
at oracle.odi.runtime.agent.processor.task.AgentTask.execute(AgentTask.java:114)
at oracle.odi.runtime.agent.support.DefaultAgentTaskExecutor$2.run(DefaultAgentTaskExecutor.java:83)
at java.lang.Thread.run(Thread.java:619)
Caused by: com.sunopsis.tools.core.exception.SnpsSimpleMessageException: Invalid parameter
at com.sunopsis.dwg.function.SnpsFunctionBase.getCoreOdiTool(SnpsFunctionBase.java:599)
... 15 more
Please help me ,
Thanks In AdvanceHi,
Mistakes i found in the script,
1. You need to pass the variables with the "-<YOUR PROJECT CODE>.VARIABLE NAME" which i suppose would be in UPPER CASE.
2. You need to pass OdiPrevStepLog with <%=%> enclosed. So your script will looks like,
OdiStartScen "-SCEN_NAME=PROC_LOGEXE_STATUS" "-SCEN_VERSION=-1" "-LOG_LEVEL=3" "-SYNC_MODE=1" "-SESSION_NAME=PROC_CSA_LOGEXE_STATUS_CS_BRANCHES" "-FLEXCUBE_OFSAA.v_execution_status=E" "-PROJECT1.v_scen_int_name=A" "-PROJECT1.v_batch_id=PKG_GLOBAL_MNT_HANDOFF" "-PROJECT1.v_step_name=<%=odiRef.getPrevStepLog( "STEP_NAME" )%>"
Thanks,
Guru -
How Can I use Mysql's PROCEDURE by Java Can you give me sample???
�������^���������������H�iBEGIN�`END�u���b�N�j�@��TOP
ORACLE�@MSSQL�@SSA�@MySQL�@
���{�I���������������������������B
MySQL�������A ORACLE��MSSSQL��������������BEGIN�`END�u���b�N�����s�������������������������B
���������s�������������K���X�g�A�h�v���O�����������R���p�C�������K�v�����������B
�i�����F�������������������A���w�E�������������K�r�����������j
--drop PROCEDURE sp_hoge;
--�f���~�^�����X��������
delimiter //
CREATE PROCEDURE sp_hoge()
DETERMINISTIC
BEGIN
/* �������� */
DECLARE mystr VARCHAR(20);
DECLARE mycnt INTEGER(2);
/* �l������ */
SET mycnt = 0;
SET mystr = '����';
/* IF�� */
IF mycnt = 0 THEN
SET mystr = '�����Q';
select mystr;
ELSE
select '�����R';
END IF;
/* CASE�� */
CASE extract(month from now())
WHEN 1 THEN SET mystr = '1��';
WHEN 2 THEN SET mystr = '2��';
WHEN 3 THEN SET mystr = '3��';
WHEN 4 THEN SET mystr = '4��';
ELSE SET mystr = '1�`4�����O';
END CASE;
select mystr;
/* WHILE-LOOP */
WHILE mycnt <= 5 DO
SET mycnt = mycnt + 1;
select mycnt;
END WHILE;
/* BEGIN-END�u���b�N������SELECT�������s */
/* PROCEDURE�������\�iFUNCTION���������������j */
select * from help_topic;
END//
delimiter ;
--�X�g�A�h�v���V�[�W�����s
call sp_hoge();
�X�g�A�h�v���V�[�W�����T���v���i�J�[�\�����g�p������LOOP�����j�@��TOP
ORACLE�@MSSQL�@SSA�@MySQL�@
�J�[�\�����g�p����LOOP�������T���v�������B
�����p�����[�^���w�����������������Y�������������������A���E���w�X�^�b�t�x�������������A�����������w�c���X�^�b�t�F�x���\���������B
--drop PROCEDURE sp_hoge;
--�f���~�^�����X��������
delimiter //
CREATE PROCEDURE sp_hoge(inum INTEGER(3))
DETERMINISTIC
BEGIN
/* �������� */
/* �J�[�\���g�p�����f�[�^�L�����f���g�p */
DECLARE done INT DEFAULT 0;
/* �������O������ */
DECLARE v_mystr VARCHAR(20);
/* �J�[�\���g�p�� */
DECLARE v_empnm VARCHAR(40);
DECLARE v_job VARCHAR(20);
/* �J�[�\������ �� �����������������`���� */
DECLARE cur1 CURSOR FOR
select empnm,job from kemp where deptno = inum;
/* �f�[�^��������LOOP�E�o�p���������� */
DECLARE CONTINUE HANDLER FOR SQLSTATE '02000' SET done = 1;
/* �J�[�\���I�[�v�� */
OPEN cur1;
/* LOOP */
LOOPPROC:REPEAT
FETCH cur1 INTO v_empnm,v_job;
IF NOT done THEN
IF v_job = '�X�^�b�t' THEN
SET v_mystr = '�c���X�^�b�t�F';
ELSE
SET v_mystr = '';
END IF;
select CONCAT(v_mystr,v_empnm);
/* ������������LOOP���E�o����������LEAVE�� */
/* LEAVE LOOPPROC; */
END IF;
UNTIL done END REPEAT;
/* �J�[�\���N���[�Y */
CLOSE cur1;
END//
--�f���~�^���Z�~�R�����i�f�t�H���g�j������������
delimiter ;
--�X�g�A�h�v���V�[�W�����s
call sp_hoge(1);
12.2. Control Flow Functions
CASE value WHEN [compare_value] THEN result [WHEN [compare_value] THEN result ...] [ELSE result] END
CASE WHEN [condition] THEN result [WHEN [condition] THEN result ...] [ELSE result] END
The first version returns the result where value=compare_value. The second version returns the result for the first condition that is true. If there was no matching result value, the result after ELSE is returned, or NULL if there is no ELSE part.
mysql> SELECT CASE 1 WHEN 1 THEN 'one'
-> WHEN 2 THEN 'two' ELSE 'more' END;
-> 'one'
mysql> SELECT CASE WHEN 1>0 THEN 'true' ELSE 'false' END;
-> 'true'
mysql> SELECT CASE BINARY 'B'
-> WHEN 'a' THEN 1 WHEN 'b' THEN 2 END;
-> NULL
The default return type of a CASE expression is the compatible aggregated type of all return values, but also depends on the context in which it is used. If used in a string context, the result is returned as a string. If used in a numeric context, then the result is returned as a decimal, real, or integer value.
Note: The syntax of the CASE expression shown here differs slightly from that of the SQL CASE statement described in Section 17.2.10.2, �gCASE Statement�h, for use inside stored routines. The CASE statement cannot have an ELSE NULL clause, and it is terminated with END CASE instead of END.
IF(expr1,expr2,expr3)
If expr1 is TRUE (expr1 <> 0 and expr1 <> NULL) then IF() returns expr2; otherwise it returns expr3. IF() returns a numeric or string value, depending on the context in which it is used.
mysql> SELECT IF(1>2,2,3);
-> 3
mysql> SELECT IF(1<2,'yes','no');
-> 'yes'
mysql> SELECT IF(STRCMP('test','test1'),'no','yes');
-> 'no'
If only one of expr2 or expr3 is explicitly NULL, the result type of the IF() function is the type of the non-NULL expression.
expr1 is evaluated as an integer value, which means that if you are testing floating-point or string values, you should do so using a comparison operation.
mysql> SELECT IF(0.1,1,0);
-> 0
mysql> SELECT IF(0.1<>0,1,0);
-> 1
In the first case shown, IF(0.1) returns 0 because 0.1 is converted to an integer value, resulting in a test of IF(0). This may not be what you expect. In the second case, the comparison tests the original floating-point value to see whether it is non-zero. The result of the comparison is used as an integer.
The default return type of IF() (which may matter when it is stored into a temporary table) is calculated as follows:
Expression Return Value
expr2 or expr3 returns a string string
expr2 or expr3 returns a floating-point value floating-point
expr2 or expr3 returns an integer integer
If expr2 and expr3 are both strings, the result is case sensitive if either string is case sensitive.
Note: There is also an IF statement, which differs from the IF() function described here. See Section 17.2.10.1, �gIF Statement�h.
IFNULL(expr1,expr2)
If expr1 is not NULL, IFNULL() returns expr1; otherwise it returns expr2. IFNULL() returns a numeric or string value, depending on the context in which it is used.
mysql> SELECT IFNULL(1,0);
-> 1
mysql> SELECT IFNULL(NULL,10);
-> 10
mysql> SELECT IFNULL(1/0,10);
-> 10
mysql> SELECT IFNULL(1/0,'yes');
-> 'yes'
The default result value of IFNULL(expr1,expr2) is the more �ggeneral�h of the two expressions, in the order STRING, REAL, or INTEGER. Consider the case of a table based on expressions or where MySQL must internally store a value returned by IFNULL() in a temporary table:
mysql> CREATE TABLE tmp SELECT IFNULL(1,'test') AS test;
mysql> DESCRIBE tmp;
-------------------------------------------+
| Field | Type | Null | Key | Default | Extra |
-------------------------------------------+
| test | char(4) | | | | |
-------------------------------------------+
In this example, the type of the test column is CHAR(4).
NULLIF(expr1,expr2)
Returns NULL if expr1 = expr2 is true, otherwise returns expr1. This is the same as CASE WHEN expr1 = expr2 THEN NULL ELSE expr1 END.
mysql> SELECT NULLIF(1,1);
-> NULL
mysql> SELECT NULLIF(1,2);
-> 1
Note that MySQL evaluates expr1 twice if the arguments are not equal.
Previous / Next / Up / Table of Contents
User Comments
Posted by I W on July 12 2005 5:52pm [Delete] [Edit]
Don't use IFNULL for comparisons (especially not for Joins)
(example:
select aa from a left join b ON IFNULL(a.col,1)=IFNULL(b.col,1)
It's terrible slow (ran for days on two tables with approx 250k rows).
Use <=> (NULL-safe comparison) instead. It did the same job in less than 15 minutes!!
Posted by [name withheld] on November 10 2005 12:12am [Delete] [Edit]
IFNULL is like oracle's NVL function (these should help people searching for NVL() ..)
Posted by Philip Mak on May 26 2006 7:14am [Delete] [Edit]
When using CASE, remember that NULL != NULL, so if you write "WHEN NULL", it will never match. (I guess you have to use IFNULL() instead...)
Posted by Marc Grue on June 24 2006 2:03pm [Delete] [Edit]
You can ORDER BY a dynamic column_name parameter using a CASE expression in the ORDER BY clause of the SELECT statement:
CREATE PROCEDURE `orderby`(IN _orderby VARCHAR(50))
BEGIN
SELECT id, first_name, last_name, birthday
FROM table
ORDER BY
-- numeric columns
CASE _orderby WHEN 'id' THEN id END ASC,
CASE orderby WHEN 'desc id' THEN id END DESC,
-- string columns
CASE orderby WHEN 'firstname' THEN first_name WHEN 'last_name' THEN last_name END ASC,
CASE orderby WHEN 'descfirst_name' THEN first_name WHEN 'desc_last_name' THEN last_name END DESC,
-- datetime columns
CASE _orderby WHEN 'birthday' THEN birthday END ASC,
CASE orderby WHEN 'desc birthday' THEN birthday END DESC;
END
Since the CASE expression returns the "compatible aggregated type of all return values", you need to isolate each column type in a separate CASE expression to get the desired result.
If you mixed the columns like
CASE _orderby
WHEN 'id' THEN id
WHEN 'first_name' THEN first_name
...etc...
END ASC
.. both the id and first_name would be returned as a string value, and ids would be sorted as a string to '1,12,2,24,5' and not as integers to '1,2,5,12,24'.
Note that you don't need a "ELSE null" in the CASE expressions, since the CASE expression automatically returns null if there's no match. In that case, you get a "null ASC" in your ORDER BY clause which doesn't affect the sort order. If for instance orderby is 'descfirst_name', the ORDER BY clause evaluates to:
ORDER BY null ASC, null DESC, null ASC, first_name DESC, null ASC, null DESC
Effectively the same as "ORDER BY first_name DESC". You could even add a new set of CASE expressions for a second order column (or more..) if you like.
Add your own comment.What is that post supposed to be?
-
if @CustNo = '0142' begin insert #custnos (CustNo, ClientNo) values ('0142', '1100') ,('0142', '1200') ,('0142', '1201') ,('0142', '1700') ,('0142', '1602') ,('0142', '1202') ,('0142', '1603') ,('0142', '2002') endstore procUSE ODSSupport
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_NULLS ON
GO
if exists (select * from dbo.sysobjects where id = object_id(N'dbo.pr_Load_PASOArgusClaims_Work') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
BEGIN
drop procedure dbo.pr_Load_PASOArgusClaims_Work
IF OBJECT_ID ('dbo.pr_Load_PASOArgusClaims_Work') IS NOT NULL
PRINT '<<< FAILED DROPPING PROCEDURE dbo.pr_Load_PASOArgusClaims_Work >>>'
ELSE
PRINT '<<< DROP PROCEDURE dbo.pr_Load_PASOArgusClaims_Work >>>'
END
GO
CREATE PROC dbo.pr_Load_PASOArgusClaims_Work
@BatchNo varchar(7) = null,
@CustNo char(4) = null,
@NewBatchNo varchar(7) = null
AS
/* Object dbo.pr_Load_PASOArgusClaims_Work 2006234 */
-- SSR# : 2242
-- Date : 12/23/2005
-- Author : Roxy Newbill
-- Description : Add new PASO BCAT 1602
-- SSR# 1932 - 2/22/2006 SEN - Add logic to include only ArgusCustNo - 0142
-- and change PharmacyClaim.ProcessDate to DateWritten
-- SSR# : 2419
-- Date : 08/22/2006
-- Author : Betty Doran
-- Description : PASO reports project
-- Correct mapping of Dispense fee amt from 'AmtProfFee' to 'DispenseFee' -
-- Mapping changed by Argus - did not inform PHP. Used in calcs for mClaimTotAmtCharge and
-- mClaimAmtAllowed fields.
-- SSR# : 2496
-- Date : 06/27/2007
-- Author : Roxy Newbil
-- Description : PASO Reporting Project
-- Add data load for new columns: Prescription No, Drug Name, NDC
-- SSR# : PEBB PROJECT
-- Date : 10/13/2009
-- Author : Tj Meyer
-- Description : Add BCAT 1201 for new PEBB business--
-- SSR# : 132707
-- Date : 12/17/2009
-- Author : Terry Phillips
-- Description : PASO Reporting Project
-- Fix data length issues for Argus_SubGroupId,Argus_PlanCode,vchParticipantId,
-- vchProviderId
-- SSR# : 3253
-- Date : 03/28/2011
-- Author : Susan Naanes
-- Description : PrescriptionNo increased in size from 7 to 12 characters
-- SSR# : SPOCK project
-- Date : 08/09/2012
-- Author : Raymond Beckett
-- Description : Modifed to bring in RxKey from PharmacyClaim instead of using identity value for iRecId
-- Also, modified to load any new batches since last batch loaded into PASOArgusClaims
-- if @BatchNo not supplied
-- Various 'fixes'
-- - removed grouping from initial query due to unique grouping caused by BatchNo, ClaimNumber, ClaimType
-- SSR# : TFS 5264 - Premera Remediation -(3997)
-- Date : 12/21/2012
-- Author : Satish Pandey
-- Description : Add BCATs 1202 and 1603 to the Where clause selecting pharmclm.ArgusClientNo as BCAT
-- SSR# : TFS 10286
-- Date : 1/15/2014
-- Author : Raymond Beckett
-- Description : Add HRI Customer Number and BCAT's. Also add Customer Number and alternate batchno to parameters
-- Only use '@NewBatchNo' if adding data from missed custno and the batchno already exists in PASOArgusClaims
-- ITSM Ticket : 1800925
-- Date : 4/15/2014
-- Author : Roxy Newbill
-- Description : Silverton Hospital had new BCAT (2002) with start of 2014 business. This was never accomodated for
-- Adding this BCAT in so that we can start capturing these claims (Note, special insert being done to capture
-- all BCAT 2002 claims prior to this fix.)
-- ITSM Ticket : TFS 14587 -Intel BCAT Remediation
-- Date : 08/14/2014
-- Author : Andrew Omofonma
-- Description : Added BCAT's (1604,& 2103) for Intel
SET NOCOUNT ON
DECLARE @iCount int
create table #tmpArgusWork (
iRecId int,
BatchNo varchar (7) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL ,
BatchDateTime datetime NULL ,
BatchStatus varchar (20) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
ReadyDateTime datetime NULL ,
Argus_GroupId varchar (10) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL ,
Argus_SubGroupId varchar (4) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
Argus_ClassId varchar (4) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
Argus_PlanCode varchar (8) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
Argus_BusinessCategory varchar (8) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL ,
FacetsClaimSubType varchar (4) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
PASOClaimType varchar (20) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL ,
vchClaimNumber varchar (14) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL ,
dtPaidDate datetime NULL ,
dtProcessDate datetime NULL ,
dtServiceDate datetime NULL ,
vchParticipantId varchar (14) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL ,
vchProviderId varchar (12) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
vchProviderName varchar (55) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
mClaimTotAmtCharge money NULL ,
mClaimAmtDiscount money NULL ,
mClaimAmtAllowed money NULL ,
mClaimAmtDenied money NULL ,
mClaimAmtDeduct money NULL ,
mClaimAmtCoinsurance money NULL ,
mClaimAmtCopay money NULL ,
mClaimAmtPaid money NULL ,
PASO_GroupId varchar (10) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
PASO_SubGroupId varchar (4) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
PASO_ClassID varchar (4) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
PASO_PlanCode varchar (8) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
PASO_BusinessCategory varchar (8) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
RecordStatus varchar (20) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
ErrorDesc varchar (128) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
PrescriptionNo char(12) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
DrugName varchar(30)COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
NDC char(11) COLLATE SQL_Latin1_General_CP1_CI_AS NULL
create table #batches (
BatchNo char(7) not null
primary key (BatchNo))
create table #custnos (
CustNo char(4),
ClientNo char(5), -- bcats associated with the customer
primary key (CustNo, ClientNo)
DECLARE
@len_Argus_SubGroupId smallint,
@len_Argus_PlanCode smallint,
@len_vchParticipantId smallint,
@len_vchProviderId smallint
--Get field lengths for the following fields
SELECT @len_Argus_SubGroupId = 4, --datalength([@tmpArgusWork].[Argus_SubGroupId]),
@len_Argus_PlanCode = 8, --datalength(@tmpArgusWork.Argus_PlanCode),
@len_vchParticipantId = 14, --datalength(@tmpArgusWork.vchParticipantId),
@len_vchProviderId = 12 --datalength(@tmpArgusWork.vchProviderId)
declare @maxbatch char(7)
IF @BatchNo IS NULL
begin
-- assume normal run. Add ClientNo's and custno's to tables
insert #custnos (CustNo, ClientNo)
values ('0142', '1100')
,('0142', '1200')
,('0142', '1201')
,('0142', '1700')
,('0142', '1602')
,('0142', '1202')
,('0142', '1603')
,('0142', '2002')
,('0142', '1604')
,('0142', '2103')
,('0669', '*')
-- get batches loaded since last batch loaded into PASOArgusClaims
SELECT @maxbatch=Max(BatchNo)
FROM ODSSupport.dbo.PASOArgusClaims
declare @dt datetime
declare @ds datetime
select @dt = MIN(DateTimeStamp)
from ODS.dbo.PharmacyClaim_Common
where BatchNo <= @maxbatch
and DateTimeStamp > DATEADD(dd,-16,getdate())
insert #batches (BatchNo)
select distinct BatchNo
from ODS.dbo.PharmacyClaim_Common pcc
inner join #custnos ct
on ct.CustNo = pcc.ArgusCustNo
and (
ct.ClientNo = '*'
or
ct.ClientNo = pcc.ArgusClientNo
where DateTimeStamp > @dt
; -- batch may have had a claim altered since last load, drop any batches already loaded into PASOArgusClaims
with pba as (
select distinct BatchNo
from ODSSupport.dbo.PASOArgusClaims
delete ba
from #batches ba
inner join pba
on pba.BatchNo = ba.BatchNo
end
else if @NewBatchNo is not null and @CustNo is not null
begin
--make sure we haven't already done this batch number/customer combination
set @maxbatch = @NewBatchNo
SELECT @iCount=count(*)
FROM PASOArgusClaims
WHERE BatchNo=@maxbatch
and Argus_BusinessCategory = @CustNo
IF @iCount > 0
begin
PRINT 'Msg: Batch ' + @maxbatch + ' already exists for CustNo ' + @CustNo + '.'
end
else
begin
if @CustNo = '0142'
begin
insert #custnos (CustNo, ClientNo)
values ('0142', '1100')
,('0142', '1200')
,('0142', '1201')
,('0142', '1700')
,('0142', '1602')
,('0142', '1202')
,('0142', '1603')
,('0142', '2002')
,('0142', '1604')
,('0142', '2103')
end
if @CustNo = '0669'
begin
insert #custnos (CustNo, ClientNo)
values ('0669', '*')
end
insert #batches (BatchNo)
values (@BatchNo)
end
end
else
begin
--make sure we haven't already done this batch number
set @maxbatch = @BatchNo
SELECT @iCount=count(*)
FROM PASOArgusClaims
WHERE BatchNo=@maxbatch
IF @iCount > 0
begin
PRINT 'Msg: Batch ' + @maxbatch + ' already loaded.'
end
else
begin
insert #batches (BatchNo)
values (@maxbatch)
end
end
** Insert Pharmacy Claims to temporary table
INSERT INTO #tmpArgusWork
SELECT
pharmClm.RxKey,
isnull(@NewBatchNo, pharmClm.BatchNo),
pharmclm.OrigDateTimeStamp as BatchDateTime,
'PENDING' as BatchStatus,
NULL as ReadyDateTime,
substring(pharmClm.GrpNumber,1,8)as Argus_GroupID,
left(pharmClm.ArgusSubgroup1,@len_Argus_SubGroupId) as Argus_SubgroupID,
substring(pharmClm.GrpNumber,9,4) as Argus_ClassId,
substring(pharmClm.GrpNumber,13,@len_Argus_PlanCode) as Argus_PlanCode,
pharmClm.ArgusClientNo as Argus_BusinessCategory,
'' as vchFacetsClaimSubtype,
PASOClaimType = CASE WHEN pharmClm.ClaimType='A'
THEN 'PHARMACY-ADJUST'
ELSE 'PHARMACY'
END,
pharmClm.ClaimNo,
pharmClm.DateCutoff as dtPaidDate,
pharmClm.DateWritten as dtProcessDate,
NULL as dtServiceDate,
left(pharmClm.MemberId,@len_vchParticipantId) as vchParticipantId,
left(pharmClm.PharmacyNo,@len_vchProviderId) as vchProviderId,
vchProviderName = CASE WHEN pharmclm.PayMemberInd = 'Y'
THEN 'Member Reimbursement'
ELSE pharm.PharmName
END,
mClaimTotAmtCharge = CASE WHEN pharmclm.PayMemberInd = 'Y' -- When this is a member reimbursement use the amt paid
THEN isnull(pharmClm.IngredientCostPaid,0) + isnull(pharmClm.DispenseFee,0) + isnull(APSFee,0) -- as amt charged.
ELSE isnull(pharmClm.AmtBilled,0)
END,
case when pharmclm.PayMemberInd = 'Y'
then isnull(pharmClm.AmtRejected,0) * -1
else isnull(pharmClm.AmtBilled,0) - isnull(pharmClm.IngredientCostPaid,0) - isnull(pharmClm.DispenseFee,0) - isnull(APSFee,0) -isnull(pharmClm.AmtRejected,0)
end as mClaimAmtDiscount,
isnull(pharmClm.IngredientCostPaid,0) + isnull(pharmClm.DispenseFee,0) + isnull(APSFee,0) as mClaimAmtAllowed,
isnull(pharmClm.AmtRejected,0) as mClaimAmtDenied,
isnull(pharmClm.MemberPaidAmt,0) - isnull(pharmClm.MemberCopayAmt,0) as mClaimAmtDeduct,
0 as mClaimAmtCoinsurance,
isnull(pharmClm.MemberCopayAmt,0) as mClaimAmtCopay,
isnull(pharmClm.AmtPaid,0) + isnull(APSFee,0) as mClaimAmtPaid,
NULL as PASO_GroupID,
NULL as PASO_SubgroupID,
NULL as PASO_ClassID,
NULL as PASO_PlanCode,
NULL as PASO_BusinessCategory,
'OK' as RecordStatus,
NULL as ErrorDesc,
PrescriptionNo = pharmClm.PrescriptionNo,
DrugName = pharmClm.DrugName,
NDC = pharmClm.NDC
FROM ODS..PharmacyClaim as pharmClm
LEFT JOIN ODS..pharmacy as pharm on
pharmClm.PharmacyNo = pharm.PharmacyNo
INNER join #batches ba
on ba.BatchNo = pharmClm.BatchNo
INNER join #custnos ct
on ct.CustNo = pharmClm.ArgusCustNo
and (
ct.ClientNo = '*'
or
ct.ClientNo = pharmClm.ArgusClientNo
WHERE pharmClm.ClaimType in ('P','A') -- Processed or Adjusted
--AND pharmClm.ProcessCode <> 'MC' --code doesn't exist
--GROUP BY
-- pharmClm.BatchNo,
-- substring(pharmClm.GrpNumber,1,8),
-- substring(pharmClm.GrpNumber,9,4) ,
-- substring(pharmClm.GrpNumber,13,@len_Argus_PlanCode),
-- pharmClm.ArgusSubgroup1,
-- pharmClm.ClaimNo,
-- pharmClm.ArgusClientNo,
-- pharmClm.DateCutoff,
-- pharmClm.DateWritten,
-- pharmClm.MemberId,
-- pharmClm.PayMemberInd,
-- pharmClm.PharmacyNo,
-- pharm.PharmName,
-- pharmClm.OrigDateTimeStamp,
-- pharmClm.ClaimType,
-- pharmClm.PrescriptionNo,
-- pharmClm.DrugName,
-- pharmClm.NDC
IF @@RowCount=0
BEGIN
PRINT 'Msg: No records found.'
RETURN
END
--Update the Discount column for these Pharmacy Claims
--UPDATE @tmpArgusWork
--SET mClaimAmtDiscount=mClaimTotAmtCharge-mClaimAmtAllowed-mClaimAmtDenied
** Get the lowest service Date for each claim and update temp table
UPDATE #tmpArgusWork
SET dtServiceDate = (SELECT min(pharmclm.DateSvc)
FROM ODS..pharmacyClaim AS pharmclm
WHERE pharmclm.ClaimNo = tcpr.vchClaimNumber
AND pharmclm.MemberID = tcpr.vchParticipantId)
FROM #tmpArgusWork as tcpr
** Copy over the eligibility fields that Argus provided
UPDATE #tmpArgusWork
SET PASO_GroupId = Argus_GroupID,
PASO_SubGroupId = Argus_SubGroupId,
PASO_ClassID=Argus_classid,
PASO_PlanCode=Argus_PlanCode,
PASO_BusinessCategory=Argus_BusinessCategory
FROM #tmpArgusWork pw
WHERE COALESCE(Argus_GroupID,'') <> ''
OR COALESCE(Argus_SubGroupId,'') <> ''
OR COALESCE(Argus_classid,'') <> ''
OR COALESCE(Argus_PlanCode,'') <> ''
OR COALESCE(Argus_BusinessCategory,'') <> ''
** If Argus did not provide all 5 eligibility fields, get them from faEnrollmentHistory
** based on the group, member, date of service
UPDATE #tmpArgusWork
SET PASO_GroupId = eh.GroupId,
PASO_SubGroupId = eh.SubGroupId,
PASO_ClassID=eh.Class,
PASO_PlanCode=eh.PlanCode,
PASO_BusinessCategory=eh.BusinessCategory
FROM #tmpArgusWork pw
INNER JOIN ODS..FAEnrollmentHistory eh
ON eh.MemberID =pw.vchParticipantID
AND eh.Groupid =pw.Argus_GroupID
AND eh.eligind='Y'
AND eh.ProcessCode<>'ID'
AND pw.dtServiceDate BETWEEN eh.EligEffDate AND eh.EligTermDate
WHERE COALESCE(Argus_GroupID,'') = ''
OR COALESCE(Argus_SubGroupId,'') = ''
OR COALESCE(Argus_classid,'') = ''
OR COALESCE(Argus_PlanCode,'') = ''
OR COALESCE(Argus_BusinessCategory,'') = ''
** If we have eligibility for all records, go ahead and set the ready date to today.
IF NOT EXISTS ( SELECT *
FROM #tmpArgusWork
WHERE COALESCE(PASO_GroupID,'') = ''
OR COALESCE(PASO_SubGroupID,'') = ''
OR COALESCE(PASO_ClassID,'') = ''
OR COALESCE(PASO_PlanCode,'') = ''
OR COALESCE(PASO_BusinessCategory,'') = '')
BEGIN
UPDATE #tmpArgusWork
SET ReadyDateTime=convert(varchar(10),GetDate(),101),
BatchStatus='READY'
END
ELSE
BEGIN
PRINT 'Msg: Exceptions found.'
UPDATE #tmpArgusWork
SET RecordStatus='ERR',
ErrorDesc='No valid Eligible span for this Member/Group/Subgroup at time of Service'
WHERE COALESCE(PASO_GroupID,'') = ''
OR COALESCE(PASO_SubGroupId,'') = ''
OR COALESCE(PASO_ClassID,'') = ''
OR COALESCE(PASO_PlanCode,'') = ''
OR COALESCE(PASO_BusinessCategory,'') = ''
END
** Insert the records into the final table.
INSERT INTO PASOArgusClaims
SELECT * FROM #tmpArgusWork
SET NOCOUNT OFF
END
GO
-- Verify that the stored procedure was created successfully.
IF OBJECT_ID ('dbo.pr_Load_PASOArgusClaims_Work') IS NOT NULL
PRINT '<<< CREATED PROCEDURE dbo.pr_Load_PASOArgusClaims_Work >>>'
ELSE
PRINT '<<< FAILED CREATING PROCEDURE dbo.pr_Load_PASOArgusClaims_Work >>>'
GO
GRANT EXECUTE ON dbo.pr_Load_PASOArgusClaims_Work to role_ODSLoad
GO
SET QUOTED_IDENTIFIER OFF
GO
SET ANSI_NULLS ONthis part of the code below
if@CustNo
= '0142'
begin
insert #custnos(CustNo,
ClientNo)
values ('0142',
'1100')
,('0142',
'1200')
,('0142',
'1201')
,('0142',
'1700')
,('0142',
'1602')
,('0142',
'1202')
,('0142',
'1603')
,('0142',
'2002')
end
store proc
How do I covert it to a common table where the values can be selected from when needed. -
How to create a procedure in oracle to write the data into file
Hi All,
I am just wondered on how to create a procedure which will do following tasks:
1. Concat the field names
2. Union all the particular fields
3. Convert the date field into IST
4. Prepare the statement
5. write the data into a file
Basically what I am trying to achieve is to convert one mysql proc to oracle. MySQL Proc is as follows:
DELIMITER $$
USE `jioworld`$$
DROP PROCEDURE IF EXISTS `usersReport`$$
CREATE DEFINER=`root`@`%` PROCEDURE `usersReport`(IN pathFile VARCHAR(255),IN startDate TIMESTAMP,IN endDate TIMESTAMP )
BEGIN
SET @a= CONCAT("(SELECT 'User ID','Account ID','Gender','Birthdate','Account Registered On') UNION ALL (SELECT IFNULL(a.riluid,''),IFNULL(a.rilaccountid,''),IFNULL(a.gender,''),IFNULL(a.birthdate,''),IFNULL(CONVERT_TZ(a.creationDate,'+0:00','+5:30'),'') INTO OUTFILE '",pathFile,"' FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '' LINES TERMINATED BY '\n' FROM account_ a where a.creationDate>='",startDate,"' and a.creationdate <='",endDate,"')");
PREPARE stmt FROM @a;
EXECUTE stmt;
DEALLOCATE PREPARE stmt ;
END$$
DELIMITER ;
Regards,
Vishal G1. Concat the field names
Double Pipe (||) is the concatenation operator in Oracle. There is also a function CONCAT for this purpose
2. Union all the particular fields
Not sure what do you mean by UNION ALL particular fields? UNION ALL is a set operation applied on two different result sets that have the same projection.
3. Convert the date field into IST
SQL> select systimestamp "Default Time"
2 , systimestamp at time zone 'Asia/Calcutta' "IST Time"
3 from dual;
Default Time IST Time
05-05-15 03:14:52.346099 AM -04:00 05-05-15 12:44:52.346099 PM ASIA/CALCUTTA
4. Prepare the statement
What do you mean by prepare the statement?
5. write the data into a file
You can use the API UTL_FILE to write to a file. -
USE [PHPExtracts]
GO
IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[pr_Extract_wt_569_OPTUM]') AND type in (N'P', N'PC'))
BEGIN
DROP PROCEDURE [dbo].[pr_Extract_wt_569_OPTUM]
PRINT '--- Procedure [dbo].[pr_Extract_wt_569_OPTUM] dropped ---'
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- =============================================
-- Author: <Brian Peterson>
-- Create date: <02/25/2014>
-- Description: <This Stored Procedure populates
-- staging table with Facets Member data
-- for Groups 100108,100115,105519,100398,106528,108601>
-- =============================================
CREATE PROCEDURE [dbo].[pr_Extract_wt_569_OPTUM]
AS
BEGIN
SET NOCOUNT ON;
declare @lastRunDate datetime
declare @currentRunDate datetime
-- RETRIEVE last run date
SET @lastRunDate = (select CONVERT(datetime,CHAR_CFLD1) from Extracts_Common_Table
where EXTRACT_ID=569 and SEQ_NO=1 AND DOMAIN_NAME ='LastRunDate'
AND Active=1)
-- if the @lastRunDate is null, then set the date to the default MEPE_EFF_DT
IF @lastRunDate IS NULL
SET @lastRunDate = '01-01-1920'
-- SET current run date
SET @currentRunDate = GETDATE()
PRINT @lastRunDate
PRINT @currentRunDate
-- CHECK for running on same date and exit if true
IF DATEDIFF(dayofyear, @lastRunDate, @currentRunDate) > 0
BEGIN
PRINT 'Deleting tables...'
TRUNCATE TABLE Extract_wt_569_OPTUM
PRINT 'Inserting new Current data...'
-- INSERT statements for procedure here
Insert into [dbo].[Extract_wt_569_OPTUM]
([DATESORT]
,[MEMBERNUMBER]
,[LASTNAME]
,[FIRSTNAME]
,[MIDDLENAME]
,[GENDER]
,[DOB]
,[DatePolicyEffective]
,[RELATIONTOINSURED]
,[SSN]
,[DateEffective]
,[DateExpiration]
,[SUBSCRIBER_ID]
,[ALTERNATE_ID]
,[ADDRESS1]
,[ADDRESS2]
,[ADDRESS3]
,[CITY]
,[STATE]
,[ZIP CODE]
,[TELEPHONE]
,[GROUP_NO]
,[GROUPNAME]
,[LINEOFBUSINESS]
,[PRODUCT_TYPE])
-- add wt_569 columns
-- add select here
SELECT top 1000 ---- remove top 1000 when loading
null as "DATESORT"
,convert(varchar,rtrim(sbsb.SBSB_ID)) + right('000' + rtrim(convert(varchar,meme.MEME_SFX)), 3) as "MEMBERNUMBER"
,meme.MEME_LAST_NAME as "LASTNAME"
,meme.MEME_FIRST_NAME as "FIRSTNAME"
,meme.MEME_MID_INIT as "MIDDLENAME"
,meme.MEME_SEX as "GENDER"
,replace(CONVERT(varchar(10),meme.MEME_BIRTH_DT,110),'-','') as "DOB"
,replace(CONVERT(varchar(10),meme.MEME_ORIG_EFF_DT,110),'-','') as "DatePolicyEffective"
,case
When meme.MCRL_MEME_CREL_CD = 'M' Then 18 -----Added case statement for RELATIONTOINSURED by Andrew 08/19/2014
When meme.MCRL_MEME_CREL_CD = 'O' Then 34
When meme.MCRL_MEME_CREL_CD = 'W' or meme.MCRL_MEME_CREL_CD = 'H' Then 01
When meme.MCRL_MEME_CREL_CD = 'S' or meme.MCRL_MEME_CREL_CD = 'D' Then 19
END
as "RELATIONTOINSURED"
,case when ltrim(rtrim(meme.MEME_SSN)) = '' THEN '999999999'
else ltrim(rtrim(meme.MEME_SSN)) end as "SSN"
,replace(CONVERT(varchar(10),mepe.MEPE_EFF_DT,110),'-','') as "DateEffective"
,replace(CONVERT(varchar(10),mepe.MEPE_TERM_DT,110),'-','') as "DateExpiration"
,sbsb.SBSB_ID as "SUBSCRIBER_ID"
,null as "ALTERNATE_ID"
,sbad.SBAD_ADDR1 as "ADDRESS1"
,sbad.SBAD_ADDR2 as "ADDRESS2"
,sbad.SBAD_ADDR3 as "ADDRESS3"
,sbad.SBAD_CITY as "CITY"
,sbad.SBAD_STATE as "STATE"
,sbad.SBAD_ZIP as "ZIP CODE"
,sbad.SBAD_PHONE as "TELEPHONE"
,grgr.GRGR_ID as "GROUP_NO"
,grgr.GRGR_NAME as "GROUPNAME"
,pdpd.LOBD_ID as "LINEOFBUSINESS"
,mctr.MCTR_DESC as "PRODUCT_TYPE"
-----,null as "BENEFIT_LEVEL" Dropped Benefit_Level not required
FROM [FacetsReport].[dbo].[CMC_MEME_MEMBER] meme with (NOLOCK)
JOIN [FacetsReport].[dbo].[CMC_SBSB_SUBSC] sbsb with (NOLOCK) on meme.SBSB_CK = sbsb.SBSB_CK
JOIN [FacetsReport].[dbo].[CMC_SBAD_ADDR] sbad with (NOLOCK) on meme.SBSB_CK = sbad.SBSB_CK and meme.SBAD_TYPE_MAIL = sbad.SBAD_TYPE
JOIN [FacetsReport].[dbo].[CMC_MEPE_PRCS_ELIG] mepe with (NOLOCK) on meme.MEME_CK = mepe.MEME_CK
JOIN [FacetsReport].[dbo].[CMC_GRGR_GROUP] grgr with (NOLOCK) on meme.GRGR_CK = grgr.GRGR_CK
JOIN [FacetsReport].[dbo].[CMC_PDPD_PRODUCT] pdpd with (NOLOCK) on mepe.PDPD_ID = pdpd.PDPD_ID
JOIN [FacetsReport].[dbo].[CMC_PDDS_PROD_DESC] pdds with (NOLOCK) on pdds.PDPD_ID = pdpd.PDPD_ID
JOIN [FacetsReport].[dbo].[CMC_MCTR_CD_TRANS] mctr with (NOLOCK) on mctr.MCTR_VALUE = pdds.PDDS_MCTR_BCAT
--JOIN [FacetsReport].[dbo].[CMC_CSCS_CLASS] cscs with (NOLOCK) on cscs.PDPD_ID = pdpd.PDPD_ID
WHERE mepe.MEPE_ELIG_IND = 'Y'
AND DATEDIFF(day, mepe.MEPE_EFF_DT, @StartDate) >= 0
AND DATEDIFF(day, mepe.MEPE_TERM_DT, @RunDate) <= 0
--UPDATE the run date
PRINT 'Updating LastRunDate...'
update Extracts_Common_Table set CHAR_CFLD1= @currentRunDate where EXTRACT_ID=569 and SEQ_NO=1 AND
DOMAIN_NAME ='LastRunDate' AND Active=1
END -- Same Date Run Check
END
GO
PRINT '------- Procedure [dbo].[pr_Extract_wt_569_OPTUM] Created ----------'
GRANT EXECUTE ON [dbo].[pr_Extract_wt_569_OPTUM] TO [public] AS [dbo]
GO
Message error:
Msg 102, Level 15, State 1, Procedure pr_Extract_wt_569_OPTUM, Line 71
Incorrect syntax near ')'.
Msg 137, Level 15, State 2, Procedure pr_Extract_wt_569_OPTUM, Line 118
Must declare the scalar variable "@StartDate".
------- Procedure [dbo].[pr_Extract_wt_569_OPTUM] Created ----------
Msg 15151, Level 16, State 1, Line 4
Cannot find the object 'pr_Extract_wt_569_OPTUM', because it does not exist or you do not have permission.Shouldn't @StartDate be an input parameter to the stored procedure? @RunDate also?
Example for sp with parameters:
http://www.sqlusa.com/bestpractices2008/stored-procedure-parameters/
The last error will go away upon a successful sp compile.
Kalman Toth Database & OLAP Architect
SQL Server 2014 Design & Programming
New Book / Kindle: Exam 70-461 Bootcamp: Querying Microsoft SQL Server 2012 -
Fields in Stored Procedure does not appear in Crystal reports 2008.
hi,
I am now using crystal reports 2008 evaluation copy for 30 days. I am trying to create a stored procedure with parameter, here is my sample Stored Procedure code;
DELIMITER $$
DROP PROCEDURE IF EXISTS `puerto`.`SP_FindEmployees`$$
CREATE DEFINER=`root`@`localhost` PROCEDURE `SP_FindEmployees`(SIDNo VARCHAR(10))
BEGIN
SELECT * FROM employees WHERE IDNo=SIDNo;
END$$
DELIMITER ;
when i try to call the procedure in sqlyog here is my sample code;
CALL sp_findemployees('0000000001')
it is successfull, but when i try to connect it with crystal reports 2008 I got no fields in my stored procedure andi got this error message ;
"Database Connector: 'HY00:[MySQL][ODBC 3.51 Driver][mysqld-5.1.33-community]incorect number of arguments for procedure puerto.sp_findemployees; expected 1, got 0 [Database vendor code: 1318]"
CR2008 was not asking a parameter values.
But when I try using stored procedure that i've made in MSSQL, CR2008 asking parameters and succefully created the reports needed.
My Objective is to make a stored procedure in MySQL by using select statement and filter it with parameter(s) that I will pass and CR2008 will use this stored procedure.
i also try the view with this code below and it was successfull in CR2008.
DELIMITER $$
DROP VIEW IF EXISTS `puerto`.`ep_employees`$$
CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `ep_employees` AS (SELECT `employees`.`IDNo` AS `IDNo`,`employees`.`FullName` AS `FullName` FROM `employees`)$$
DELIMITER ;hi,
Crystal Reports 2008 and MySQL 5 , ODBC driver 3.5 and ODBC driver 5.1.
I use ODBC connector 3.5 because I got errors in ODBC drivers in 5.1.
Do you have step by step procedure for creating add command dialog box?
I try creating the add command dialog box
here's my sample sql statement i don't know if its correct because no data appearing in my crystal report
Select * from employees where idno=@IDNo
in Command Parameter Dialog Box
Parameter Name = @IDNo
Prompting Text = @IDNo
Value Type = String
DefaultValue = 0
thanks! -
Error in calling stored procedure in sender JDBC adapter
Hi Experts,
I am working on MySQl to SAP scenario. I have to use stored procedure in sender JDBC adapter.
I am calling SP as fallows: execute proc_dtdc_booking_interface_sd
But it returned following error,
Database-level error reported by JDBC driver while executing statement 'execute proc_dtdc_booking_interface_sd'. The JDBC driver returned the following error message: 'java.sql.SQLException: Unknown prepared statement handler (proc_dtdc_booking_interface_sd) given to EXECUTE'. For details, contact your database server vendor.
the way i called SP is correct ??
please suggest me how to resolve the issue ??
Regards,
Bhuvan.Hi
Below is the code , when we are using this code directly in the mySQl command promp, it fetches 10 record but when the same code is called through XI adapter its fetching only one record
DELIMITER $$
DROP PROCEDURE IF EXISTS `proc_dtdc_booking_interface_sd` $$
CREATE DEFINER=`root`@`localhost` PROCEDURE `proc_dtdc_booking_interface_sd`()
BEGIN
declare done int(1);
declare v_dsr_booked_by char(1) ;
declare v_dsr_branch_code char(3) ;
declare v_dsr_cust_code varchar(7) ;
declare v_dsr_booking_date date ;
declare v_dsr_cnno char(9) ;
declare v_dsr_cn_type char(3) ;
declare v_dsr_cn_weight decimal(8,3) ;
declare v_dsr_dest char(3) ;
declare v_dsr_mode char(2) ;
declare v_dsr_amt decimal(10,2) ;
declare v_dsr_dox char(1) ;
declare v_office_code char(3) ;
declare v_dsr_status char(1) ;
declare v_dsr_remarks varchar(25) ;
declare v_dsr_refno varchar(20) ;
declare v_dsr_transmf_no varchar(10) ;
declare v_dsr_trans_status_xi char(1) ;
declare v_ndsr_cnno char(9) ;
declare v_ndsr_product char(3) ;
declare v_ndsr_sercharge decimal(8,3) ;
declare v_ndsr_ins_amt decimal(8,3) ;
declare v_ndsr_others decimal(8,3) ;
declare v_dr_amt_type decimal(2,0) ;
declare v_dr_extra_amt decimal(10,2) ;
declare v_sales_document varchar(2) ;
declare bookcur CURSOR for
SELECT *
FROM dtdcdb_rw.dtdc_booking_interface_sd
LIMIT 10;
DECLARE CONTINUE HANDLER FOR NOT FOUND SET DONE=1;
set done=0;
OPEN bookcur;
bookloop: loop
FETCH bookcur
INTO
v_dsr_booked_by ,
v_dsr_branch_code,
v_dsr_cust_code,
v_dsr_booking_date,
v_dsr_cnno,
v_dsr_cn_type,
v_dsr_cn_weight,
v_dsr_dest,
v_dsr_mode,
v_dsr_amt,
v_dsr_dox,
v_office_code,
v_dsr_status,
v_dsr_remarks,
v_dsr_refno,
v_dsr_transmf_no,
v_dsr_trans_status_xi,
v_ndsr_cnno,
v_ndsr_product,
v_ndsr_sercharge,
v_ndsr_ins_amt,
v_ndsr_others,
v_dr_amt_type,
v_dr_extra_amt,
v_sales_document ;
IF DONE=1 THEN
LEAVE bookloop;
END IF;
select
v_dsr_booked_by As dsr_booked_by,
v_dsr_branch_code As dsr_branch_code,
v_dsr_cust_code As dsr_cust_code,
v_dsr_booking_date As dsr_booking_date,
v_dsr_cnno As dsr_cnno,
v_dsr_cn_type As dsr_cn_type,
v_dsr_cn_weight As dsr_cn_weight,
v_dsr_dest As dsr_dest,
v_dsr_mode As dsr_mode,
v_dsr_amt As dsr_amt,
v_dsr_dox As dsr_dox,
v_office_code As office_code,
v_dsr_status As dsr_status,
v_dsr_remarks As dsr_remarks,
v_dsr_refno As dsr_refno,
v_dsr_transmf_no As dsr_transmf_no,
v_dsr_trans_status_xi As dsr_trans_status_xi,
v_ndsr_cnno As ndsr_cnno,
v_ndsr_product As ndsr_product,
v_ndsr_sercharge As ndsr_sercharge,
v_ndsr_ins_amt As ndsr_ins_amt,
v_ndsr_others As ndsr_others,
v_dr_amt_type As dr_amt_type,
v_dr_extra_amt As dr_extra_amt,
v_sales_document As sales_document;
update dtdcdb_rw.dsr_table
set dsr_trans_status_xi='T'
where dsr_cnno=v_dsr_cnno;
end loop;
SELECT *
FROM dtdcdb_rw.dtdc_booking_interface_sd
LIMIT 10;
END $$
DELIMITER ;
Please help
Regards
Bhuvan -
How to Use the Procedures in a Sql Query
Hi Friends,
Can anyone help me out whether can we use the procedure in the sql query..
if yes help me out with an example
my requirement is
i have one sql query .. in which i need to use the procedure which returns multiple values... how can i overcome it,can anyone help me out for this..
for your reference i am pasting the sql query
SELECT paf.person_id
FROM per_all_assignments_f paf START WITH paf.person_id = p_person_id
AND paf.primary_flag = 'Y'
AND paf.assignment_type IN('E', 'C')
AND l_effective_date BETWEEN paf.effective_start_date
AND paf.effective_end_date
CONNECT BY PRIOR paf.supervisor_id = paf.person_id
AND paf.primary_flag = 'Y'
AND paf.assignment_type IN('E', 'C')
AND l_effective_date BETWEEN paf.effective_start_date
AND paf.effective_end_date
and paf.person_id not in (>>>I HAVE TO USE THE PROCEDURE HERE<<<<);
Thanks in advanceWe never saw your procedure, but maybe you could wrap it in a function
SQL> create or replace procedure get_members(in_something IN number, out_members OUT sys_refcursor)
is
begin
open out_members for
'select level member_id from dual connect by level <= :num' using in_something;
end get_members;
Procedure created.
SQL> create or replace type numbers as table of number;
Type created.
SQL> create or replace function members(in_something IN number)
return numbers
as
member_cur sys_refcursor;
members numbers;
begin
get_members(in_something, member_cur);
fetch member_cur bulk collect into members;
close member_cur;
return members;
end;
Function created.
SQL> select * from table(members(4));
COLUMN_VALUE
1
2
3
4
4 rows selected.Variant on same using piplined function
SQL> create or replace function members_piped(in_something IN number)
return numbers pipelined
as
member_cur sys_refcursor;
rec number;
begin
get_members(in_something, member_cur);
loop
fetch member_cur into rec;
exit when member_cur%notfound;
pipe row(rec);
end loop;
close member_cur;
return;
end;
Function created.
SQL> select * from table(members_piped(4));
COLUMN_VALUE
1
2
3
4
4 rows selected.
SQL> drop function members_piped;
Function dropped.
SQL> drop function members;
Function dropped.
SQL> drop type numbers;
Type dropped.
SQL> drop procedure get_members;
Procedure droppedEdit:
Sorry Blu, had not seen you already posted similar thing
Edited by: Peter on Jan 27, 2011 5:38 AM
Maybe you are looking for
-
GL not appearing in Profit Center Report
Hello Gurus, A strange error is coming in SAP. I have created a GL with reference to another GL in Same chart of account and have posted few entries in that GL. But the problem is that all GL are coming except that GL in PC Trial Balance Report S_ALR
-
Invoice Verification for IMPORT PO(ASSET)
Hi All, User has created Purchase order against Import Material for asset with Account Assignment category as A.While invoice verification for basic customs duty,ECS and HSES, system debiting the GL account for Asset instead of CenVat clearing. In ca
-
Recently my Macbook wireless connection has been flaky. Sometimes it will connect to the internet and sometimes it won't. Sometimes restarting my computer would make the wireless connection work. Then yesterday my Macbook stopped connecting to the in
-
Welcome everyone, Would anyone be willing to identify and tell me the difference between these two cards? Cheers and Thank You, Mike
-
Hi, I'm editing a video (FCP 7) in which footage from different cameras with different formats will be sent to me. The first stuff that arrived is AVI (640-480). I don't know what will be coming in later. When transforming this AVI footage into QT