PL/SQL :: Passing String Values To Partition Clause In A Merge Statement?

May 24, 2013

I am using the below code to update specific sub-partition data using oracle merge statements.

I am getting the sub-partition name and passing this as a string to the sub-partition clause.

The Merge statement is failing stating that the specified sub-partition does not exist. But the sub-partition do exists for the table.

We are using Oracle 11gr2 database.

Below is the code which I am using to populate the data.

declare
ln_min_batchkey PLS_INTEGER;
ln_max_batchkey PLS_INTEGER;
lv_partition_name VARCHAR2 (32767);
lv_subpartition_name VARCHAR2 (32767);
begin

[code]....

View 2 Replies


ADVERTISEMENT

SQL & PL/SQL :: Select Statement From Schemas In MERGE Statement In USING Clause

Sep 13, 2013

In the following merge statement in the USINg clause...I am using a select stament of one schema WEDB.But that same select statement should take data from 30 schemeas and then check the condition below condition

ON(source.DNO = target.DNO
AND source.BNO=target.BNO);

I thought that using UNIONALL for select statement of the schemas as below.

SELECT
DNO,
BNO,
c2,
c3,
c4,
c5,
c6,
c7
[code]....

View 5 Replies View Related

PL/SQL :: Merge Statement - Delete Clause?

Mar 14, 2013

I was reading about merge statement and tried some variations,

create table MERGE_TEST(
C1 number,
C2 varchar2(10 char),
c3 number);

insert into MERGE_TEST values(1, 'Name 3', 300);
insert into MERGE_TEST values(1, 'Name 2', 200);
insert into MERGE_TEST values(1, 'Name 1', 100);
commit;

[code]...

why is result different in this querys?

View 14 Replies View Related

SQL & PL/SQL :: Passing Multiple Values To IN Clause In Function?

Jun 22, 2010

I have a function that returns the total sum of an account. From reports I call the function passing the account code. The function sums the values for that specific account code and returns the value. In my function I have the following code :

where account_code = P_CODE.

Eg. The value of :P_CODE is 'CS'.

I now want to pass multiple account codes ('CS','TV',LJ') to the function. How do I change the IN clause in the function to accommodate multiple values.

I have tried using the instr function, but it does not work. eg. AND instr(o.ACCOUNT_CODES,','||P_CODE||',') > 0

View 3 Replies View Related

Forms :: Passing Check Box Values To WHERE Clause?

Oct 26, 2013

I have created a Data block - 'CONTACTS' (Database data block) and has database item - 'Code', 'Descr'

The number of records displayed is set to 5.

Value When checked - 'Y'
Value When Unchecked - 'N'
Check box mapping of other values - 'unchecked'

The requirement is when i check one or multiple checkboxes, i should pass the 'Code' item values to the WHERE clause.

Right now whenver i am trying to do so, only the current record value is copied to the WHERE clause.

I have tried using basic loop as well as while loop but things havmt worked. Below is a basic code which will work for one record, request to guide me with muliple checkbox ticked.

IF :contacts.cb = 'Y' THEN

IF p_where is null then

p_where := :contacts.code;
else
p_where := p_where ||','||:contacts.code;
end if;
end if;
p_where:= 'where code in ('||p_where||')';

View 6 Replies View Related

Reports & Discoverer :: Between Clause To Compare Two String Values

Jun 15, 2013

I have a problem with Between clause used in where statement to compare two string variable.

Query is like this,

select item_code, item_deacrption
from itm_master, invoce_det
where im_code = item_code
AND invd_item_number BETWEEN (:startNum) AND (:endNum)

Here invd_item_number is a DB field and is of type varchar2(41), and (:startNum),(:endNum) are of same type.

now invd_item_number has one value '001003002001'
if we give :startNum = '001003001002' and :endNum = '001003004006'

:startNum and :endNum is composed of separate field values (ie, 1st 3 character shows color code, next 3 for catagory, next 3 for size etc). These codes are entered separately and are combined at run time.

it is still fetching the invd_item_number with value '001003002001'. (the last set of character(type code) in the :startNum is greater than invd_item_number's type code value. But it is smaller than the previous code (size code), that's why it is fetching).

But how can i get around this as i don't need that value to be fetched.

View 7 Replies View Related

PL/SQL :: Exclude Duplicate Values On SQL Where Clause Statement?

Jul 15, 2013

Are some posibilities to exclude duplicate values do not using sql aggregate functions in main select statement?  Priview SQL statement

SELECT * FROM
(
select id,hin_id,name,code,valid_date_from,valid_date_to
from diaries
)

[Code]....

 In this case i got duplicate of entry TT2 id 50513  In main select statement cant use agregate functions are even posible to exclude this value from result modifying only the QLRST WHERE clause (TRUNC need to be here)

View 5 Replies View Related

SQL & PL/SQL :: Merge With Returning Clause

Feb 21, 2013

Does the Oracle 11g supports 'RETURNING INTO' clause in MERGE statement? if it was not available is there any alternate to achieve the same ?

View 3 Replies View Related

PL/SQL :: Where Condition - Passing Parameters Using IN Clause?

Jul 23, 2013

,I have a queryIn my query iam passing parameters using IN clause.The parameters contains in two tablesfor ex..select a.deptno, b.deptnofrom dept1 a, dept2 bwhere a.deptno = b.deptnoand NVL (a.deptno, b.deptno) in (10, 20, 30,.....) is this correct way to use NVL like this.i have a deptno consists in both the tables. How can i use this condition.

View 4 Replies View Related

SQL & PL/SQL :: Passing Partition Name In A Cursor

Aug 8, 2012

I am running below cursor but getting error like

ORA-06550: line 10, column 38:
PL/SQL: ORA-00971: missing SET keyword
ORA-06550: line 10, column 1:
PL/SQL: SQL Statement ignored

Seems it's not able to identify R.PARTITION_NAME in update statement. Are you aware whether we can partition name like this if we need to update based on partition names in a cursor.

My cursor code is:

DECLARE
CURSOR C_PARTITION IS
SELECT PARTITION_NAME, PARTITION_POSITION FROM ALL_TAB_PARTITIONS
WHERE OWNER = 'FACTS'
AND TABLE_NAME = 'TABLEA'
[code].....

View 1 Replies View Related

SQL & PL/SQL :: Merge Statement In Oracle

Jun 22, 2012

how to update or insert another (third table ) table with merge statement

View 6 Replies View Related

SQL & PL/SQL :: Executing Merge Statement?

Jul 18, 2011

how to use the MERGE Statement. actually I've used oracle Merge Statement before and it works very well. However today I tried to use and perform a command like that:

Merge into myTable mt using ( select 'data' field1, 'data2' field2, ect from dual
union
select 'data' field1, 'data2' field2, ect from dual
union

[code]...

This has not worked.What am I doing wrong?What could I do to solve this problem and axecute this statement sucessfully?

View 3 Replies View Related

Forms :: Using Merge Statement In 6i?

May 9, 2011

in Toad I am using this Merge statement , working accordingly.I want to use this merge statement in my form where can I use it.

I created a Procedure in Form Named Proc_merge and call it when validate item of :bankcode

PROCEDURE proc_merge IS
BEGIN
declare
v_com varchar2(5000);
BEGIN
V_COM := '

[code]...

when matched then

update set
trg.v_chq = src.cheque_no, trg.v_bankcode = src.bank_code ,trg.v_debit=src.debit, trg.v_credit=src.credit, trg.v_narration=src.narration

when not matched then

insert (trg.v_type, trg.v_no, trg.v_date, trg.v_chq, trg.v_bankcode, trg.v_debit, trg.v_credit, trg.v_narration)
values (src.voucher_type, src.voucher_no, src.voucher_date, src.cheque_no, src.bank_code, src.debit, src.credit, src.narration)
';
FORMS_DDL(V_COM);
end;
END;

no any result.

View 2 Replies View Related

SQL & PL/SQL :: Merge Statement Required With Logic

Jul 10, 2013

Table Name: F_SCENARIO
System : Dataware house
Oracle version : 11g
Record Count : 2 Million records

Correct scenario records

F_Key F_Bridge_key Record_type
1 1 1
2 1 2
3 1 3

Wrong scenario records

F_Key F_Bridge_key Record_type
1 1 1
2 -5 2
3 -6 3

I want to write a Merge statement to update the negative values into 1.

View 6 Replies View Related

SQL & PL/SQL :: Merge Statement - Intermediate Commit?

Dec 12, 2012

I am using Merge statement to copy data from one table to other,

merge into tabA a
using tabB b
on a.id = b.id
when match
update (
)
when not matched
(insert )

This is working all fine, as SQL, but when there is large volume, it blows out as there are intermediate commits for this ?

View 3 Replies View Related

PL/SQL :: Merge Statement - Update Only When There Is Difference?

Feb 7, 2013

I have two tables have almost the same columns, how can I use merge statement to update the target table only when there is difference between source and target table. Is there any easier way not compare each column one by one? I am using Oracle 11.2

Here is the MERGE statement:

Merge into tb_trgt trgt using tb_src src
on (src.id = trgt.id)
when not matched then insert (trgt.id, trgt.nm, trgt.addr) values (src.id, src.nm, src.nm)
when matched then update set trgt.nm = src.nm, trgt.addr = src.addr
where trgt.nm <> src.nm or trgt.addr <> src.addr
;

Is there any easier way to specify the where clause in the NOT MATCHED? I don't want compare each column of the tables. Since I may have many columns in the tables.

View 3 Replies View Related

PL/SQL :: Merge Statement On Single Table

Oct 29, 2012

{code{

i want to apply merge stmt on single table.

CREATE TABLE TEST11(TNO NUMBER(5), TVAL VARCHAR2(100), TID VARCHAR2(10));
INSERT INTO TEST11 VALUES(1,'VIJAYA','TEST');
INSERT INTO TEST11 VALUES(2,'VIJAYA','TEST');
INSERT INTO TEST11 VALUES(3,'VIJAYA','TEST');
INSERT INTO TEST11 VALUES(4,'VIJAYA','');
INSERT INTO TEST11 VALUES(5,'VIJAYA','');

[Code]....

My requiremen is if record is exists then i wan to update some value, if record not existes the i wan to insert new record

View 3 Replies View Related

Performance Tuning :: How To Use Index On (ON In MERGE Statement)

Apr 6, 2011

mbr has 60,000 rows and member has 60,000 rows approx. two tables have indexes on ssn, and citi_no on them.

PK of mbr : mbr_id
PK of member : mbr_id

other columns are not PK, and have no index on it.

I'm wondering why the statment doesn't use index while ssn and citi_no have index.

MERGE INTO mbr t
USING (SELECT mbr_id,citi_no
FROM member) a
ON (t.ssn = a.citi_no)
WHEN MATCHED THEN
UPDATE SET t.asis_mbr_id = a.mbr_id
where t.ssn not in(select ssn from mbr group by ssn having count(*) > 1)

View 19 Replies View Related

SQL & PL/SQL :: Calling Pipelined Function In Merge Statement?

Dec 2, 2010

I am getting a (PL/SQL: ORA-00903: invalid table name) compile error in a procedure using a merge statement. I have seen many examples using this technique and am at a loss as to why I can't compile.

the pipelined function is:

FUNCTION f_crcli_pipe(pi_source_data IN sys_refcursor,
pi_limit_size IN PLS_INTEGER DEFAULT pkg_crcli_variables.c_cursor_limit_def)
RETURN CRCLI_AA
PIPELINED
PARALLEL_ENABLE(PARTITION pi_source_data BY ANY)
IS

[code].....

the error is pointing to the TABLE function in the USING clause of the merge statement.

View 7 Replies View Related

SQL & PL/SQL :: Can Have All Rows In A Table Updated At Once In Merge Statement

Aug 10, 2010

Can I have all the rows in a table updated at once in the merge statement?

MERGE INTO providermaster a
using
(
SELECT * FROM PROVIDERMASTER@INGEST) b
ON (b.MASTERPROVIDERID=a.MASTERPROVIDERID)
WHEN MATCHED THEN

UPDATE ....... I want to update all the other rows at once..

View 24 Replies View Related

Forms :: Getting Error While Using MERGE Statement In Application

May 19, 2010

I am using MERGE statement first time in my application but I am facing error.

begin
merge into store.comm_dept a
using factory_data.comm_dept b
on (a.cd_dcode = b.cd_dcode)
when matched then
[code]........

ERROR IS: encountered the symbol 'INTO' when expecting on of the following:
:=.(@%;

View 7 Replies View Related

SQL & PL/SQL :: Merge And Add Rows Values Into One?

Jun 4, 2012

CREATE TABLE emp
(
code NUMBER(4),
name VARCHAR2(15),
salary NUMBER(5),
ovt NUMBER(4),
sal_mon DATE,
dept number (3)
)

[code]....

9 rows selected.

Required Output is

CODE NAME SALARY OVT SAL_MON DEPTMerge Codes
---------- --------------- ---------- ---------- --------- ---------- -----------
1068 ALI 18500 2385 31-OCT-11 1021068,1793
1908 ASGHAR 17000 1900 31-OCT-11 1021908,1802
1960 ZAHID 16000 775 31-OCT-11 1021960,1952
1188 RAZA 9500 2910 31-OCT-11 1111188
1275 RAHIL 15300 3480 31-OCT-11 1111275,1176

Merge 02 rows of same department having sum(salary) <=20000. select those rows who have lower salary.

View 10 Replies View Related

SQL & PL/SQL :: ORA-30926 Occurs Only With PARALLEL Hint On MERGE Statement

Jun 26, 2013

I am writing below MERGE statement. In this cardinality between table_a and table_b is 1:2. I.e. each record in table_b corresponds to 2 records in table_a based on columns in ON clause.

Well this query throws below error.

----Error---

ORA-12801: error signaled in parallel query server P011

ORA-30926: unable to get a stable set of rows in the source tables

However, the same statement executes successfully when PARALLEL hint is removed altogether. (There are no duplicates in table_b based on unit,group,loc columns.)

-----Query--------

MERGE /*+ PARALLEL(8) */
INTO table_a a
USING table_b b
ON (a.unit = b.unit AND a.group = b.group AND a.loc = b.loc)

[Code]....

View 1 Replies View Related

SQL & PL/SQL :: Merge Statement In Procedure - Internal Error Code

Feb 9, 2011

I have a merge statement in one procedure , this job runs on daily . It is running successfully since Jan-19-2010 and giving the below error now.

ERROR at line 1:
ORA-00600: internal error code, arguments: [kcbgcur_9], [4224596], [1],
[4294967250], [2], [], [], []

It is giving error in the beginning of the MERGE statement.

View 11 Replies View Related

PL/SQL :: How To Implement Exception Handling On MERGE Statement In Oracle10g

Jul 19, 2012

How to handle the exception on below MERGE statement?

MERGE INTO COMM_EXSTS_COMIT_AGGR TARGET

USING
(
select  * from   ABC ) SRC
ON
(
SRC.COMMITMENT_ID = TARGET.COMMITMENT_ID
)
WHEN MATCHED THEN
UPDATE
WHEN NOT MATCHED THEN
INSERT ;

View 4 Replies View Related

PL/SQL :: Where Clause In Partition By Column?

Sep 24, 2013

i have in tb1 data like and i need the latest status changed date : when date on which the status of the task changes.for the data below for taskno :

1 i need to get the o/p : 1/2/2013and for taskno :
2 I need the o/p 1/4/2013 taskno :

upd_dateold_status new_status11/1/2013openWIP11/2/2013WIPClosed11/3/2013closed closed21/1/2013openWIP21/2/2013WIPmore_info_needed21/3/2013more_info_neededWIP21/4/2013WIPclosed  im writing the query as below select taskno, max(upd_date) MAX_UPD_DATE from (select taskno, upd_date, old_status, new_status, rank from (select taskno, upd_date, old_status, new_status, rank() over (partition by taskno, old_status, new_status order by upd_date asc) as rankfrom tb1)where rank = 1and old_status <> new_status)group by taskno;

IS there any more efficient way to write this query as the clause "old_status <> new_status" is taking a toll on the performance

View 2 Replies View Related

PL/SQL :: Passing Json String Into Varchar2 Variable

Jan 11, 2013

I'm trying to pass a JSON string into a stored procedure that has a single VARCHAR2 variable.

begin
SAVE_JSON('{"app_id":"800414","merch_id":"84657156","user_id":"6985","P25_DBA_NAME":"TEST"}');
end;
/

I'm getting the ORA-20001: ORA-06502: PL/SQL: numeric or value error

View 3 Replies View Related

Passing Parameter To In Statement?

Oct 9, 2008

I have a scenario where I have to pass a paramter to "in statement". When I run the query from SQL plus its working fine.......but when I run the query at run time it doesnot come back with the results. I am sure its formating issue.

This is how I create a paramter

_sbInStatement.Append("(");
foreach (ListItem item in _listBox.Items)
{

[Code]....

oCmd.Parameters.Add(":InStatement", OracleDbType.Varchar2).Value = InStatement;

View 2 Replies View Related

SQL & PL/SQL :: Merge Statement - Unable To Get Stable Set Of Rows In Source Tables

Sep 15, 2013

When I am executing merge statement I am getting the below error.

ORA-30926: unable to get a stable set of rows in the source tables

MERGE INTO TAN_LIST t
USING (SELECT * FROM (SELECT row_number () over (partition by TANNO order by null) rn,
dno,
TANNO,
SOL,

[Code]....

The query is fectching below data.

SELECT dno,TANNO,SOL,DESC,class,ct_dt,tcost
FROM MAT_LIST;
DNOTANNOSOLDESC CLASS CT_DT TCOST
63007565ADclass A A12345 08/28/131

[Code]...

Intially thers is no records in the TAN_LIST table. When I run the merge statemnt I am able to insert all 15 records into that table.

When I run the same merge statemment second time I am getting the below error.

ORA-30926: unable to get a stable set of rows in the source tables

So that I have used partition by cluase in the slect statement and I am able to resolve the error.

But it's inserting only 14 records not all 15. How to process all 15 records without the error..

View 16 Replies View Related

PL/SQL :: Multiple Partition Names In From Clause Of SQL?

Sep 23, 2013

 I want to use multiple partitions in from clause of SQL statement. select c1 from tab1 partition (part1,part2); However getting below error message. 

ORA-00933: SQL command not properly ended00933. 00000 -  "SQL command not properly ended"
*Cause:   
*Action:Error at Line: 3 Column: 43 Above query is sample query.

Real query is big and hence i cant write using UNION ALL to access multiple partitions.

View 12 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved