How to use "where" clause in modify statement
Hi
can any1 telll me is it possible to use a where clause in a modify statemetn. I want to use modify statemetn to insert a new recoed in a database table.
Regards
Sabahuddin Ahmed
MODIFY itab - itab_lines
Syntax :
... itab FROM wa TRANSPORTING comp1 comp2 ... WHERE log_exp.
With these additions the MODIFY statement assigns the content of the comp1 comp2 ... components of the wa work area specified after TRANSPORTING to all lines in the itab table that meet the logical condition log_exp. The wa work area must be compatible with the line type of the internal table.
The TRANSPORTING addition has the same effect as changing individual lines. The WHERE addition can only be specified together with the TRANSPORTING addition. After WHERE, any logical expression can be specified in which the first operand of each individual comparison is a component of the internal table. All logical expressions are therefore possible, with the exception of IS ASSIGNED, , and IS SUPPLIED. It is not possible to dynamically specify a component using bracketed character-type data objects.
While for standard tables and hashed tables all lines in the internal table are checked for the logical expression of the WHERE statement, for sorted tables, optimized access can be achieved by checking at least one opening part of the table key for parity using AND linked queries in the logical expression.
Example
Change the contents of the planetype component for all lines in the sflight_tab internal table in which this component contains the value p_plane1 to the value p_plane2.
PARAMETERS: p_carrid TYPE sflight-carrid,
p_connid TYPE sflight-connid,
p_plane1 TYPE sflight-planetype,
p_plane2 TYPE sflight-planetype.
DATA sflight_tab TYPE SORTED TABLE OF sflight
WITH UNIQUE KEY carrid connid fldate.
DATA sflight_wa TYPE sflight.
SELECT *
FROM sflight
INTO TABLE sflight_tab
WHERE carrid = p_carrid AND
connid = p_connid.
sflight_wa-planetype = p_plane2.
MODIFY sflight_tab FROM sflight_wa
TRANSPORTING planetype WHERE planetype = p_plane1.
reward if useful
Similar Messages
-
How to use where clause with get statement in LDB programs
Hi All,
I am using logical databse in my report program.I am not getting how to use the where clause in the get statement is it possible to use?or if not possible only option is we should filter it after get statment is right?Can you please some body throw some idea on this?
Regards
MaheshHi,
Reffer these links
http://help.sap.com/saphelp_nw04/helpdata/en/9f/db9bfa35c111d1829f0000e829fbfe/content.htm
http://help.sap.com/saphelp_nw04/helpdata/en/9f/db9b5e35c111d1829f0000e829fbfe/frameset.htm
http://help.sap.com/saphelp_nw04/helpdata/en/c6/8a15381b80436ce10000009b38f8cf/frameset.htm
/people/srivijaya.gutala/blog/2007/03/05/why-not-logical-databases
reward if helpful
Thanks,
Suma. -
How to use WHERE Clause in BPEL
Hi ,
i am trying to use where clause in DB adapter but its not working.
my query is "select empname from employee where empid = &a"
can any body tell me what is the reason its npt working?
and how can i retrive data form DB?Hi,
You are thinking perfectly fine. The solution what I suggested was
select ename from emp where empno=?
And the solution provided by you was
SELECT first_name, last_name FROM per_all_people_f WHERE person_id = #p_person_id
There is no problem with the above mentioned select statements.
I just want to say that if you see closely, internal logic changes #parameter name to ?. So both the logics are right.
Cheers,
Abhi... -
Hello,
I am using sapnwrfc for perl to get few information about SAP system. To get the Applications pruning on SAP system i need to use two tables DF14AVD and DF14T to get Application Name and Description. table DF14T contains description of the application.
I want to know using QUERY_TABLE how i can combined it and get desired result.
For ex. FCTR_ID is present in both the table. FCTR_ID which are present in DF14AVD table, i want to retrieve short description from DF14T .
Any idea how i can do this?
AmitHi,
You can refer to the following link.
http://help.sap.com/erp2005_ehp_04/helpdata/EN/4b/38b618068911d295300000e8353423/frameset.htm
Thank You.
Regards,
Dhanalakshmi L -
Can we use where clause in Update on Merge statement?
Hi All,
I tried to execute the following Merge Query:
When this query is executed without ‘Where clause’ in Update statement its working fine. When executed with ‘Where clause’ it throwing the following error:
ORA-00905: missing keyword.
Following is the sample query which I tried to execute:
MERGE INTO TABLE_NAME
USING (SELECT COLUMN FORM TABLES)
ON (CONDITION)
WHEN MATCHED THEN
UPDATE SET
COLUMN UPATES
WHERE CONDITION -- Can we use where clause here?
WHEN NOT MATCHED THEN
INSERT
INSERT VALUES;
Can some one help on this?
Thanks in advance.
DariusYes:
SQL> drop table emp1;
Table dropped.
SQL> create table emp1 as select * from emp where deptno = 30;
Table created.
SQL> update emp1 set sal = sal*2;
6 rows updated.
SQL> commit;
Commit complete.
SQL> select ename,sal from emp1;
ENAME SAL
ALLEN 3200
WARD 2500
MARTIN 2500
BLAKE 5700
TURNER 3000
JAMES 1900
6 rows selected.
SQL> MERGE INTO emp1
2 USING(select * from emp) emp
3 ON (emp1.empno = emp.empno)
4 WHEN MATCHED THEN
5 UPDATE SET sal = emp.sal WHERE ename = 'TURNER'
6 WHEN NOT MATCHED THEN
7 INSERT(ename,sal) VALUES(emp.ename,emp.sal);
9 rows merged.
SQL> select ename,sal from emp1;
ENAME SAL
ALLEN 3200
WARD 2500
MARTIN 2500
BLAKE 5700
TURNER 1500
JAMES 1900
SMITH 800
JONES 2975
CLARK 2450
SCOTT 3000
KING 5000
ENAME SAL
ADAMS 1100
FORD 3000
MILLER 1300
14 rows selected.
SQL> SY. -
How to Get the required List Item values by using Where Clause
I have two tables named "TAX_RULES","BILL"
1. " Tax_Rules" (Sub_Head_Code,Tax_ID,Tax_Percentage)
{ While "Sub_Head_Code" field is unique,
Tax_ID describes that there are two kinds of Tax_IDs based on Tax_percentage which is 6% for some Sub_Head_Codes and 3.5% for the remainng Sub_Head_Codes. I have given Tax_ID 1 for 6% and Tax_ID 2 for Sub_Head_codes having 3.5%. }
2. "BILL" (Bill_ID,Sub_Head_Code,Tax_ID,Bill_Amount)
{While "Bill_ID" describes unique Bill Identification Number,
Sub_Head_Code and Tax_ID are behaving like composite foreign key from Tax_Rules table}
I have design form for both tables.
In BILL form i am trying to get values of Tax_ID from Tax_Rules table at run-time by using WHEN-NEW-FORM-INSTANCE.
For this whenever i select a Sub_Head_Code in Bill Form, all the Tax_IDs that i have recorded against each Sub_Head_Code which is either 1 or 2 against 6% and 3.5% respectively.
But I want that whenever i select a "Sub_Head_Code", Only that Tax_ID which is associated with that Sub_Head_Code ahould come in the LIST ITEM.
I have used WHERE clause but that is useless.
Following is the Code that i have applied in the WHE-NEW-ITEM-INSTANCE Trigger at FORM LEVEL
<CODE>
DECLARE
rg_n1 VARCHAR2(40) :='TAX_ID';
rg_idn1 RecordGroup;
gc_idn1 GroupColumn;
errcode NUMBER;
BEGIN
CLEAR_LIST('BILL.TAX_ID');
rg_idn1 := Find_Group(rg_n1);
IF Id_Null(rg_idn1) then
rg_idn1 := Create_Group(rg_n1);
gc_idn1 := Add_Group_Column(rg_idn1,'EXPLAIN',CHAR_COLUMN,60);
gc_idn1 := Add_Group_Column(rg_idn1,'TAX_ID',CHAR_COLUMN,3);
END IF;
errcode := Populate_Group_With_Query(rg_idn1,'select TAX_ID,TAX_ID from TAX_RULES');
POPULATE_LIST('BILL.TAX_ID',RG_IDn1);
END;
</CODE>In the Tax Rules table, you state:
"Sub_Head_Code" field is unique
In the Bill table, you state:
Sub_Head_Code and Tax_ID are behaving like composite foreign key from Tax_Rules table
If the Sub_Head_Code is unique, then it's acting as a primary key, so Sub_Head_Code and Tax_ID in the Bill table are not behaving like a composite foreign key. The Sub_Head_Code is a foreign key, and the Tax_ID is irrelevant as far as keys are concerned.
It is not clear what it is you want to do.
If you want to display the Tax_IDs from the Bill table when you select a Sub_Head_Code from the Tax_Rules table, then change your query to:
select TAX_ID, TAX_ID from BILL where Sub_Head_Code = :Tax_Rules.Sub_Head_Code
If you want to display the Tax_IDs from the Tax_Rules table when you select a Sub_Head_Code from the Bill table, then change your query to:
select TAX_ID, TAX_ID from TAX_RULES where Sub_Head_Code = :Bill.Sub_Head_Code
If this is not what you want, then clarify what it is you want to do. Don't say:
"I want that whenever i select a "Sub_Head_Code", Only that Tax_ID which is associated with that Sub_Head_Code"
because it is not clear what tables you are referring to. -
Can any one tell me how to use EXISTS clause inplace of IN operator.
Hi All,
Can any one tell me how to use EXISTS clause AND (JC.EMPL_ID, JC.EMPL_RCD) inplace of IN operator.
SELECT COUNT (1)
FROM SYSADM.OHR_PERS_CURR PC
, SYSADM.OHR_JOB_CURR JC
WHERE PC.EMPL_ID = JC.EMPL_ID
AND (JC.EMPL_ID, JC.EMPL_RCD) in (
SELECT HS.EMPL_ID, HS.EMPL_RCD
FROM SYSADM.HU_SCRTY_JOB HS, ODSHR.OHR_SCRTY_USER_CFG OS
WHERE HS.HU_SCRTY_CFG_ID = OS.HU_SCRTY_CFG_ID
AND OS.DB_LOGIN = USER)
Thank you.SELECT COUNT (1)
FROM SYSADM.OHR_PERS_CURR PC
, SYSADM.OHR_JOB_CURR JC
WHERE PC.EMPL_ID = JC.EMPL_ID
AND EXISTS (
SELECT null
FROM SYSADM.HU_SCRTY_JOB HS, ODSHR.OHR_SCRTY_USER_CFG OS
WHERE HS.HU_SCRTY_CFG_ID = OS.HU_SCRTY_CFG_ID
AND OS.DB_LOGIN = USER
AND HS.EMPL_ID = JS.EMPL_ID AND HS.EMPL_RCD = JC.EMPL_RCD)
But why ?
Rgds. -
Using Like Clause in Prepared Statement
Hi,
I want to use LIKE clause in prepared statement. This is not returning any record.
This is the query. Please help me in this.
SELECT EMPLYR_GRP,EMPLYR_GRP_NAME FROM EMPLOYER_GROUP WHERE EMPLYR_GRP_NAME LIKE ? AND EMPLYR_GRP = ?
This is giving Oracle SQL Error.
SELECT EMPLYR_GRP,EMPLYR_GRP_NAME FROM EMPLOYER_GROUP WHERE EMPLYR_GRP_NAME LIKE %?% AND EMPLYR_GRP = ?The first variant should work just fine as long as you use stmt.setString(1, '%' + pattern + '%') to set the parameter. The second query is just plain wrong.
Alin. -
How to put OR clause in SELECT statement
Hi
How to put OR clause in SELECT statement to return number_first/number_last to match records from another table's column.
<pre>
SELECT
a.id ,
flat_number ||' '|| a.number_first||' '||a.street_name||' '||a.suburb address1,
apt_no ||' '|| street_no||' '||b.street_name||' '||b.suburb address2
from
a ,
b
where b.street_name = a.street_name
AND b.SUBURB = a.SUBURB
AND b.STATE = a.STATE
</pre>
Thsi will return this as exact match.
ADDRESS 1
12 TAMAN TENANG A ORCHARD 3142
10 RAMA YISHUN 2095
ADDRESS2
12 TAMAN TENANG A ORCHARD 3142
10 RAMA YISHUN 2095
However this only matches number_first.
How can I get the query work that it will match both number_first and number_last (table b)in address 1 to match street_no in address2 ( table b).My oracle version is 10GR/2.Hi, I have a hard time understanding your request, and below is what I thought you want:
SELECT
a.id ,
flat_number ||' '|| (decode(b.street_no, a.number_first, a.number_first, a.number_last, a.number_last)||' '||a.street_name||' '||a.suburb address1,
apt_no ||' '|| street_no||' '||b.street_name||' '||b.suburb address2
from
a ,
b
where b.street_name = a.street_name
AND b.SUBURB = a.SUBURB
AND b.STATE = a.STATE
AND (B.street_no=a.number_first OR b.street_no=a.number_last);Not tested.
Also, since your B.street_no will be either a.number_first OR a.number_last, you could replace
(decode(b.street_no, a.number_first, a.number_first, a.number_last, a.number_last) with just b.street_no.
Edited by: PhoenixBai on Aug 26, 2010 11:33 AM -
I am not able to run a SQL query using where clause.
the query is as follows:
I extract the text input by the user in a text field say 'a' and
store it in string 'y'.
String y= a.getText();
//running the query
Select A from B where B.x=y;
how do we run a where clause when y is a string variable instead of value?Use the following :
String y = a.getText();
String query ="select A.CODE from Port A where A.NAME=" + "'" + y + "'" ;
ResultSet rs= stmt.executeQuery(query); -
Performance hit using "where" clause in the query
Hi All,
I am facing a huge performance hit in the java code when using "where" clause in queries. Following are the details:
1. SELECT * FROM Employee
2. SELECT * FROM Employee where employeeid in (26,200,330,571,618,945)
There is no difference in Query Execution Time for both queries.
Business Logic Time is huge in second case as compared to first one (ratio - 1:20).
Rows returned are more in first case as compared to second case.(ratio - 1:4)
Business Logic is same for both the cases where I iterate through the ResultSet, get the objects and set them in a data structure.
Does anybody know the reason of unexpected time difference for the business logic in the second case?Since you're mentioning clustering your index, I'll assume you are using Oracle. Knowing what database you are using makes it a lot easier to suggest things.
Since you are using Oracle, you can get the database to tell you what execution plan it is using for each of the 2 SQL statements, and figure out why they have similar times (if they do).
First, you need to be able to run SQL*Plus; that comes as part of a standard database installation and as part of the Oracle client installation - getting it set up and running is outside the scope of this forum.
Second, you may need your DBA to enable autotracing, if it's not already:
http://asktom.oracle.com/~tkyte/article1/autotrace.html
http://www.samoratech.com/tips/swenableautotrace.htm
Once it's all set up, you can log in to your database using sql*plus, issue "SET AUTOTRACE ON", issue queries and get execution plan information back.
For example:
SQL> set autotrace on
SQL> select count(*) from it.ticket where ticket_number between 10 and 20;
COUNT(*)
11
Execution Plan
Plan hash value: 2983758974
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
| 0 | SELECT STATEMENT | | 1 | 4 | 1 (0)| 00:00:01 |
| 1 | SORT AGGREGATE | | 1 | 4 | | |
|* 2 | INDEX RANGE SCAN| TICKET_N10 | 12 | 48 | 1 (0)| 00:00:01 |
Predicate Information (identified by operation id):
2 - access("TICKET_NUMBER">=10 AND "TICKET_NUMBER"<=20)
Statistics
0 recursive calls
0 db block gets
1 consistent gets
0 physical reads
0 redo size
515 bytes sent via SQL*Net to client
469 bytes received via SQL*Net from client
2 SQL*Net roundtrips to/from client
0 sorts (memory)
0 sorts (disk)
1 rows processed
SQL> This tells me that this query used an INDEX RANGE SCAN on index TICKET_N1; the query can't do much better than that logically... In fact, the statistic "1 consistent gets" tells me that Oracle had to examine only one data block to get the answer, also can't do better than that. the statistic, "0 physical reads" tells me that the 1 data block used was already cached in Oracle's memory.
the above is from Oracle 10g; autotrace is available back to at least 8i, but they've been adding information to the output with each release.
If you have questions about sql_plus, check the forums at asktom.oracle.com or http://forums.oracle.com/forums/category.jspa?categoryID=18
since sql*plus is not a JDBC thing...
Oh, and sql*plus can also give you easier access to timing information, with "set timing on". -
WHERE clause in SELECT statement
hi experts..
i want to give 'OR' condition in the 'where' clause of 'SELECT' statement.
is it possible?
for examlpe..
IF EXIDV2 IS NOT INITIAL.
SELECT * FROM YSDT_SHIPLOAD
INTO TABLE IG_SHIPLOAD
WHERE EXIDV2 = EXIDV2 AND
VHILM = PC1 OR PC2 OR PC3.
ENDIF.
i want that VHILM should be one of those three.
how can i do this?
thanks..Hi ,
its possible,
Select * from ysdt_shipload int table ig_shipload where exidv2 = exidv2
AND vhilm = pc1
OR vhilm = pc2
OR vhilm = pc3.
OR
Select * from ysdt_shipload int table ig_shipload where exidv2 = exidv2
AND (vhilm = pc1 or vhilm = pc2 or vhilm = pc3).
Regards
Arani Bhaskar
Edited by: arani bhaskar on Mar 16, 2009 5:14 PM -
How to set Where clause in the View Object of the MessageChoice ?
Hi,
How to set Where clause in the View Object of the
MessageChoice ?
Example:
<bc4j:rootAppModuleDef name="EdEscolaCampusView1AppModule"
definition="ed00050.Ed00050Module"
releaseMode="stateful" >
<bc4j:viewObjectDef name="EdEscolaCampusView1" >
<bc4j:rowDef name="CreateEdEscolaCampusView1" autoCreate="true" >
<bc4j:propertyKey name="key" />
</bc4j:rowDef>
</bc4j:viewObjectDef>
<bc4j:viewObjectDef name="ListaTipLocalView1"
rangeSize="9999">
</bc4j:viewObjectDef>
</bc4j:rootAppModuleDef>
</bc4j:registryDef>
messageChoice declaration:
<bc4j:messageChoice name="SeqTipoLocalCampus"
attrName="SeqTipoLocalCampus"
prompt="Local do Campus">
<contents>
<bc4j:optionList attrName="SeqTipoBasico"
textAttrName="NomTipoBasico"
voName="ListaTipLocalView1"/>
</contents>
</bc4j:messageChoice>
I would like set where clause of ViewObject, with dinamic parameters (using attribute1 = :1), before populate messageChoice.
thanks...
DaniloHi Andy,
I try set a where clause using the message:
Set where Clause parameter using UIX , but my UIX Page have 2 messageChoice's of different ViewObject's, then I need implement this Java Class:
//Nome da Package da Tela Detail
package br.com.siadem.siaed.ed00050;
// Importa as Bibliotecas necessárias
import oracle.jbo.ViewObject;
import oracle.jbo.ApplicationModule;
import oracle.jbo.client.Configuration;
import oracle.cabo.servlet.BajaContext;
import oracle.cabo.servlet.Page;
import oracle.cabo.servlet.event.PageEvent;
import oracle.cabo.servlet.event.EventResult;
import oracle.cabo.data.jbo.servlet.bind.*;
import oracle.cabo.ui.data.BoundValue;
import oracle.cabo.ui.data.DataBoundValue;
import javax.servlet.http.HttpServletRequest;
import br.com.siadem.siaed.util.*;
import javax.servlet.http.Cookie;
import oracle.cabo.data.jbo.def.NestedAppModuleDef;
import oracle.cabo.data.jbo.def.ViewObjectDef;
import oracle.cabo.data.jbo.def.AppModuleDef;
// Classe que configura os parametros para a execução da Query,
// utilizando variáveis de Sessao
public class FunPreQueryLista
public static EventResult FunConfiguraQuery(BajaContext context, Page page, PageEvent event) throws Throwable
// TrataDadosSessao - Classe utilizada para retornar os valores das variáveis de sessão genéricas
// Ex: CodCliente, CodMunicipio etc...
TrataDadosSessao varDadosSessao = new TrataDadosSessao();
// 1o. Parametro Configurado - Através da classe TrataDadosSessao, utilizando um método Get
// <alterar>
String valor1 = varDadosSessao.getCodCliente();
String valor2 = varDadosSessao.getCodMunicipio();
//Cria o objeto que retorna o ApplicationModule
ApplicationModule am = ServletBindingUtils.getApplicationModule(context);
// Início das Configurações da Query da Lista
//Cria o objeto que retorna o view object da lista desejada
//alterar
ViewObject TipoLocal = am.findViewObject("ListaTipoLocalView1");
//Configuração dos parametros definidos na query do view Object
//alterar
TipoLocal.setWhereClauseParam(0,valor1);
TipoLocal.setWhereClauseParam(1,valor2);
// Executa a Query
TipoLocal.executeQuery();
// Fim das Configurações da Query da Lista
// Início das Configurações da Query da Lista
//Cria o objeto que retorna o view object da lista desejada
//alterar
ViewObject TipoDestLixo = am.findViewObject("ListaDestinoLixoView1");
//Configuração dos parametros definidos na query do view Object
//alterar
TipoDestLixo.setWhereClauseParam(0,valor1);
TipoDestLixo.setWhereClauseParam(1,valor2);
// Executa a Query
TipoDestLixo.executeQuery();
// Fim das Configurações da Query da Lista
// Retorna o Resultado para a Página
return new EventResult(page);
The code works very well...
And, I'm sorry for my two repost's in UIX Forum about this in a few time.
Thank very much...
Danilo -
How to use From clause as a block datasources
Hi,
I want to know how to use from clause as a block datasource.
Could anyone give me an example to do that? I couldn't find it
in the help file.
I sincerely ask someone help me.
Many thanks
DianaDiana,
I presume you are getting a "FRM-40505: error unable to perform
query" when you try to execute query. I suggest you select the
"Display Error" item from the "Help" menu to see the query that
Oracle is generating. If the query that Oracle generates as a
result of your "Query data source name" is not formed correctly,
you will get the FRM-40505 error.
Copy and paste the query that is displayed into SQLPLUS and test
to see what happens when you try to execute the query from
SQLPLUS. That will give you a better idea of what the cause of
the problem is.
From your example, a query that works should look like "select
c_no from (select c_no from books)".
Keep in mind that for blocks based on FROM clause, the query that
produces the data is of the form :
SELECT <all columns in the block>
FROM <select statement entered in the "Query Data Source Name"
blockproperty>
The data source for the block is the select statement embedded in
the from clause.
Hope this helps. -
How to use create by and modified by
how to use create by and modified by ?
when some one create row it will stamp who create
and when some one edite row it will stamp who edit row
i ever user create on and modified on
but creay by and modified by i never use it.Howard,
If you are not using JAZN you can still register created by and modified by user and date info in a "backdoor-wise" way:
1. Get the user login string by using System.getProperty("user.name")
2. Get the current datetime using java.util.Date
3. In the backing bean for the page and the action method for your submit button, set the values for the components containing the created by or updated by values to the values obtained in points 1 and 2.
Hope this is somehow useful,
AG
Maybe you are looking for
-
Sales invoice with 100% discount
Hi, Can you tell me if there is a way in SAP where the system allows a ZERO value to reflect in the customer account and the reconciliation account. The scenario is, material A is sold at a price of $100 to customer. A 100% Discount is given and the
-
I cannot get Elements to appear as an external editor when I am using Lightroom.
When I am using LR I can go to NIK as an external editor, but Elements is greyed out and will not let me add it as an external editor.
-
Problem of writing data into a txt. file
How can I write the product1 object into the testing.txt? Product product1 = new Product(); product1.addNewProduct(1234, "coffee", 0.89, 23, 23.4, "12/12/2008", "catCoffee", "20/11/2007"); try FileWriter writer = new FileWriter("C:\\Documents
-
Newbie, Missing Admin tab and Schedules tab is greyed out
Hi, I am totally new to BI Publisher. I just completed the installation of both Oracle DB 10g and OBIEE 10.1.3.4 I am following the example in OBE to get started with BI Publisher. However, when I open the BI publisher, I don't see the Admin tab and
-
I have a 3rd generation 15gb ipod. Ever since I downloaded the new Itunes - both the 5.something and the 6.0 my iPod is no longer recognized and will not update. Also the updater for 9/23 doesn't recognize it either. I have tried many of the solution