Run time Column Name in the Select Statement
Hi there,
I face problem while writing sql statment for report in the Oracle reports.
The prom is I want to bound the where clause column name with the value stored in a variable e.g.
Select * from emp
where Column_Name = 'XYZ' ;
where the variable Column_Name have different values at different times, e.g.
At a time the value of Column_Name is Dept then
Select * from emp
where Dept = 'XYZ' ;
At other time value of Column_Name is City then
Select * from emp
where City = 'XYZ' ;
Waiting for the response .
Regards,
Hafeez
Hi,
U can use lexical parameters for the solutions.U must be aware of it, but still i describe how to work it out.
1)In your datamodel in object navigator create a parameter under User parameter node.Name the parameter, for eg. p_clause.
set data type of parameter to character.
2)write a select query eg.
select * from emp &p_clause; --(THIS IS THE PARAMETER WE CREATED ABOVE)
3)Now run your report
Now in your parameter form pass the value for p_clause parameter.
eg: where name='JACK';
or
where city='NEWYORK';
or where deptno=10;
But do it in steps as above mentioned.
Do tell me if it works or not via mail on [email protected]
Enjoy.......
navneet jain
[email protected]
Similar Messages
-
Hi,
Is it possible to use column aliases in the select statement for a database adapter to return an xml element name which is different to the column in the queried table?
I have tried using
SELECT EMPLOYEE_ID, FIRST_NAME AS MYNAME, LAST_NAME, SALARY, DEPARTMENT_ID, PHONE_NUMBER, EMAIL, HIRE_DATE FROM HR.EMPLOYEES WHERE (DEPARTMENT_ID = #DEPT_ID)
but I get the following XML fragment returned
<Employees>
<employeeId>100</employeeId>
<firstName xsi:nil="true" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/>
<lastName>King</lastName>
<salary>24000</salary>
Any pointers appreciated.
Joel.That is really interesting.
When I use the "custom sql" option in the DB adapter wizard, it used the aliases just fine in the return schema.
Marc -
Using column number inplace of column name in SQL Select statement
Is there a way to run sql select statements with column numbers in
place of column names?
Current SQL
select AddressId,Name,City from AddressIs this possible
select 1,2,5 from AddressThanks in Advanceuser10962462 wrote:
well, ok, it's not possible with SQL, but how about PL/SQL?As mentioned, using DBMS_SQL you can only really use positional notation... and you can also use those positions to get the other information such as what the column is called, what it's datatype is etc.
CREATE OR REPLACE PROCEDURE run_query(p_sql IN VARCHAR2) IS
v_v_val VARCHAR2(4000);
v_n_val NUMBER;
v_d_val DATE;
v_ret NUMBER;
c NUMBER;
d NUMBER;
col_cnt INTEGER;
f BOOLEAN;
rec_tab DBMS_SQL.DESC_TAB;
col_num NUMBER;
v_rowcount NUMBER := 0;
BEGIN
-- create a cursor
c := DBMS_SQL.OPEN_CURSOR;
-- parse the SQL statement into the cursor
DBMS_SQL.PARSE(c, p_sql, DBMS_SQL.NATIVE);
-- execute the cursor
d := DBMS_SQL.EXECUTE(c);
-- Describe the columns returned by the SQL statement
DBMS_SQL.DESCRIBE_COLUMNS(c, col_cnt, rec_tab);
-- Bind local return variables to the various columns based on their types
FOR j in 1..col_cnt
LOOP
CASE rec_tab(j).col_type
WHEN 1 THEN DBMS_SQL.DEFINE_COLUMN(c,j,v_v_val,2000); -- Varchar2
WHEN 2 THEN DBMS_SQL.DEFINE_COLUMN(c,j,v_n_val); -- Number
WHEN 12 THEN DBMS_SQL.DEFINE_COLUMN(c,j,v_d_val); -- Date
ELSE
DBMS_SQL.DEFINE_COLUMN(c,j,v_v_val,2000); -- Any other type return as varchar2
END CASE;
END LOOP;
-- Display what columns are being returned...
DBMS_OUTPUT.PUT_LINE('-- Columns --');
FOR j in 1..col_cnt
LOOP
DBMS_OUTPUT.PUT_LINE(rec_tab(j).col_name||' - '||case rec_tab(j).col_type when 1 then 'VARCHAR2'
when 2 then 'NUMBER'
when 12 then 'DATE'
else 'Other' end);
END LOOP;
DBMS_OUTPUT.PUT_LINE('-------------');
-- This part outputs the DATA
LOOP
-- Fetch a row of data through the cursor
v_ret := DBMS_SQL.FETCH_ROWS(c);
-- Exit when no more rows
EXIT WHEN v_ret = 0;
v_rowcount := v_rowcount + 1;
DBMS_OUTPUT.PUT_LINE('Row: '||v_rowcount);
DBMS_OUTPUT.PUT_LINE('--------------');
-- Fetch the value of each column from the row
FOR j in 1..col_cnt
LOOP
-- Fetch each column into the correct data type based on the description of the column
CASE rec_tab(j).col_type
WHEN 1 THEN DBMS_SQL.COLUMN_VALUE(c,j,v_v_val);
DBMS_OUTPUT.PUT_LINE(rec_tab(j).col_name||' : '||v_v_val);
WHEN 2 THEN DBMS_SQL.COLUMN_VALUE(c,j,v_n_val);
DBMS_OUTPUT.PUT_LINE(rec_tab(j).col_name||' : '||v_n_val);
WHEN 12 THEN DBMS_SQL.COLUMN_VALUE(c,j,v_d_val);
DBMS_OUTPUT.PUT_LINE(rec_tab(j).col_name||' : '||to_char(v_d_val,'DD/MM/YYYY HH24:MI:SS'));
ELSE
DBMS_SQL.COLUMN_VALUE(c,j,v_v_val);
DBMS_OUTPUT.PUT_LINE(rec_tab(j).col_name||' : '||v_v_val);
END CASE;
END LOOP;
DBMS_OUTPUT.PUT_LINE('--------------');
END LOOP;
-- Close the cursor now we have finished with it
DBMS_SQL.CLOSE_CURSOR(c);
END;
SQL> exec run_query('select empno, ename, deptno, sal from emp where deptno = 10');
-- Columns --
EMPNO - NUMBER
ENAME - VARCHAR2
DEPTNO - NUMBER
SAL - NUMBER
Row: 1
EMPNO : 7782
ENAME : CLARK
DEPTNO : 10
SAL : 2450
Row: 2
EMPNO : 7839
ENAME : KING
DEPTNO : 10
SAL : 5000
Row: 3
EMPNO : 7934
ENAME : MILLER
DEPTNO : 10
SAL : 1300
PL/SQL procedure successfully completed.
SQL> exec run_query('select * from emp where deptno = 10');
-- Columns --
EMPNO - NUMBER
ENAME - VARCHAR2
JOB - VARCHAR2
MGR - NUMBER
HIREDATE - DATE
SAL - NUMBER
COMM - NUMBER
DEPTNO - NUMBER
Row: 1
EMPNO : 7782
ENAME : CLARK
JOB : MANAGER
MGR : 7839
HIREDATE : 09/06/1981 00:00:00
SAL : 2450
COMM :
DEPTNO : 10
Row: 2
EMPNO : 7839
ENAME : KING
JOB : PRESIDENT
MGR :
HIREDATE : 17/11/1981 00:00:00
SAL : 5000
COMM :
DEPTNO : 10
Row: 3
EMPNO : 7934
ENAME : MILLER
JOB : CLERK
MGR : 7782
HIREDATE : 23/01/1982 00:00:00
SAL : 1300
COMM :
DEPTNO : 10
PL/SQL procedure successfully completed.
SQL> exec run_query('select * from dept where deptno = 10');
-- Columns --
DEPTNO - NUMBER
DNAME - VARCHAR2
LOC - VARCHAR2
Row: 1
DEPTNO : 10
DNAME : ACCOUNTING
LOC : NEW YORK
PL/SQL procedure successfully completed.
SQL> -
How can i pass a variable instead of a table name in the Select statement.
Dear all
how can i pass a variable instead of a table name in a select statement ?
Example :-
Begin
P_get_procedure_tname (aap_name,otable_name);--It will take an application name and will return a table name
Select col1 into ocol1
from ---- here i want to pass the variable OTABLE_NAME
End;How can i pass this ?Hi,
You can use dynamic sql.
EXECUTE IMMEDIATE 'SELECT COL1 INTO ' || OCOL1 || ' FROM " || OTABLE_NAME;
{code}
cheers
VT -
Run time column names as parameters
Hi SDN,
I am trying to use a FORM/ENDFORM which can work for many internal tables in my project except that a couple of field (table columns) names differ. In other words, just for two assignment statements I may have to repeat rest of the code, unless there is a way to 'reference' these fields.
Is there a way to pass the field names as a parameter to the FORM? Can someone give me an example if that is possible. I looked at the FIELD SYMBOL but don't know how to use it in a FORM.
Thanks for the help.
Saf.FM DDIF_NAMETAB_GET retruns a table of field names.
Sample code follows (hope it helps!)
call function 'DDIF_NAMETAB_GET'
exporting
tabname = 'Z213'
tables
dfies_tab = lta_dfies
exceptions
not_found = 1
others = 2.
if sy-subrc <> 0.
message e007 with 'syserr bld bkpf fields.'.
endif."subrc
loop at lta_dfies assigning <i>.
append <i>-fieldname to lta_bkpf_fl.
endloop."dfies
select (lta_bkpf_fl)
from bkpf
into table lth_vbkpf
where
bukrs = p_bukrs
and bstat = space " normal documant
and blart = 'WE'
and gjahr = p_gjahr
and monat in so_monat
and budat in so_budat
and waers in so_waers
order by belnr.
if sy-subrc <> 0.
message i008 with 'No BKPF data found for selection'.
stop.
endif."subrc.
Best,
Jim -
How to use a table name in the select statement using a variable?
Hi Everybody,
I got a internal table which has a field or a variable that gets me some tables names. Now I need to retrieve the data from all these tables in that field dynamically at runtime. So could you suggest me a way out to use the select query which uses this variable as a table ?
Regards,
Mallik.Hi all,
Actually i need some more clarification. How to use the same select statement, if i've to use the tabname in the where clause too?
for ex : select * from (tab_name) where....?
Can we do inner join on such select statements? If so how?
Thanks & Regards,
Mallik. -
* table name in the select statements
Hi,
I have come across a select Statement as below.
Select * into *nast from nast where <conditions>.. End select.
what does this *nast represents and when is it used. why do we need to call a Table with *<Table Name>
Kind Regards,
Ushahi,
select statement will always points to a database table so we have to give database table name and it gets data from that table. for storing that data we have to use internal tables must have same structure of database table.
so select statement has the following form as........
select * from [dbtable] into table [internal table]
endselect.
in sap select will act as a loop so that we hav to use end sleect. select has different varities in sap. for some types no need of end select.
for ex:
select single *
select * ..................... into table [internal table name].....
if helpful reward some points.
with regards,
suresh. -
Create Dynamic table name in the select statement.
I use oracle reports 6i to make myrep.rdf , this report created using certain select query Q1, I created a formula column in this report,
in the formula column I write pl/sql block statements to select the data from certain table depends on the output of a column in Q1,
I want to make the pl/sql block dynamically enough to change the user which I select the data from depends on the connected user
Ex: if I connected with user = 'KAM14'
the pl/sql block will be
select x into v_value from kam13.bil_file where .....;
and if I connected with user = 'KAM13'
the pl/sql block will be
select x into v_value from kam12.bil_file where .....;
and so on
how can I do this in the pl/sql block ...
Thanks in Advance.I am not sure I understood properly, but I think you should create bil_file table under a different user and create synonyms under KAM1x users.
Regards -
How to pull only column names from a SELECT query without running it
How to pull only column names from a SELECT statement without executing it? It seems there is getMetaData() in Java to pull the column names while sql is being prepared and before it gets executed. I need to get the columns whether we run the sql or not.
Maybe something like this is what you are looking for or at least will give you some ideas.
public static DataSet MaterializeDataSet(string _connectionString, string _sqlSelect, bool _returnProviderSpecificTypes, bool _includeSchema, bool _fillTable)
DataSet ds = null;
using (OracleConnection _oraconn = new OracleConnection(_connectionString))
try
_oraconn.Open();
using (OracleCommand cmd = new OracleCommand(_sqlSelect, _oraconn))
cmd.CommandType = CommandType.Text;
using (OracleDataAdapter da = new OracleDataAdapter(cmd))
da.ReturnProviderSpecificTypes = _returnProviderSpecificTypes;
//da.MissingSchemaAction = MissingSchemaAction.AddWithKey;
if (_includeSchema == true)
ds = new DataSet("SCHEMASUPPLIED");
da.FillSchema(ds, SchemaType.Source);
if (_fillTable == true)
da.Fill(ds.Tables[0]);
else
ds = new DataSet("SCHEMANOTSUPPLIED");
if (_fillTable == true)
da.Fill(ds);
ds.Tables[0].TableName = "Table";
}//using da
} //using cmd
catch (OracleException _oraEx)
throw (_oraEx); // Actually rethrow
catch (System.Exception _sysEx)
throw (_sysEx); // Actually rethrow
finally
if (_oraconn.State == ConnectionState.Broken || _oraconn.State == ConnectionState.Open)
_oraconn.Close();
}//using oraconn
if (ds != null)
if (ds.Tables != null && ds.Tables[0] != null)
return ds;
else
return null;
else
return null;
}r,
dennis -
COLUMN NAMES IN AN INSERT STATEMENT
Hi,
What are the advantages and disadvantages of giving the column names in an insert statement. My team lead says, that when ever we use insert, even thought we have value for all the columns in the table, it is advantages to add the column names... I want to know what are the pros and cons...
Any help...By giving column names in the insert statement means your data is arranged in that order. Otherwise, we do not know what order the data (columns) will come (which will come from the table definition). If fur some reason, the table has all the columns with integer/number as data type then, if the columns are not named in the insert statement and data in in the insert values stament can be in any order (there will not be any database error). The data inserted can be wrong.
-
Calling an SP takes over 200% more time over the select statement
As part of my POC converting a SQL Server application over to SAP HANA, I'm find that CALL is taking over 200% more time than calling the SELECT statement directly. The result is that the application that uses ODBC against HANA with CALL statements is taking much more time than SQL Server. I'm finding this for all stored procedure calls in the application. Here is an example:
CREATE PROCEDURE dbo.usp_GetOrdersByCustomerID
(IN C_ID bigint)
LANGUAGE SQLSCRIPT DEFAULT SCHEMA "DBO" READS SQL DATA
AS BEGIN
SELECT TOP 20
C_F_NAME,
C_L_NAME,
C_EMAIL,
O_ID,
O_TOTAL,
O_DTS,
O_FM_DTS
FROM dbo.Customer JOIN dbo.Orders ON C_ID = O_C_ID
WHERE C_ID = :C_ID
ORDER BY O_ID DESC;
END;
When using the following CALL statement in SAP HANA Studio
CALL dbo.usp_GetOrdersByCustomerID(3429);
I get execution times that look like this:
Statement 'CALL dbo.usp_GetOrdersByCustomerID(3429)'
successfully executed in 9 ms 663 µs (server processing time: 8 ms 115 µs)
Fetched 5 row(s) in 0 ms 69 µs (server processing time: 0 ms 0 µs)
Statement 'CALL dbo.usp_GetOrdersByCustomerID(3429)'
successfully executed in 11 ms 851 µs (server processing time: 8 ms 238 µs)
Fetched 5 row(s) in 0 ms 62 µs (server processing time: 0 ms 0 µs)
Statement 'CALL dbo.usp_GetOrdersByCustomerID(3429)'
successfully executed in 8 ms 522 µs (server processing time: 6 ms 892 µs)
Fetched 5 row(s) in 0 ms 93 µs (server processing time: 0 ms 0 µs)
When I execute the select statement with the hard coded parameter value, I get much faster results:
Statement 'SELECT TOP 20 C_F_NAME, C_L_NAME, C_EMAIL, O_ID, O_TOTAL, O_DTS, O_FM_DTS FROM dbo.Customer JOIN ...'
successfully executed in 4 ms 430 µs (server processing time: 2 ms 424 µs)
Fetched 5 row(s) in 0 ms 73 µs (server processing time: 0 ms 0 µs)
Statement 'SELECT TOP 20 C_F_NAME, C_L_NAME, C_EMAIL, O_ID, O_TOTAL, O_DTS, O_FM_DTS FROM dbo.Customer JOIN ...'
successfully executed in 4 ms 105 µs (server processing time: 2 ms 210 µs)
Fetched 5 row(s) in 0 ms 69 µs (server processing time: 0 ms 0 µs)
Statement 'SELECT TOP 20 C_F_NAME, C_L_NAME, C_EMAIL, O_ID, O_TOTAL, O_DTS, O_FM_DTS FROM dbo.Customer JOIN ...'
successfully executed in 4 ms 694 µs (server processing time: 2 ms 810 µs)
Fetched 5 row(s) in 0 ms 60 µs (server processing time: 0 ms 0 µs)
I have 500,000 rows in the Customers table and 2,500,000 rows in the Orders table. The tables are COLUMN tables.
Is there an optimization that I'm missing?
Regards,
BillHi Bill,
Can you please try something:
tab_cust =
SELECT
C_F_NAME,
C_L_NAME,
C_EMAIL
FROM dbo.Customer
WHERE C_ID = :C_ID;
tab_orders =
SELECT
O_ID,
O_TOTAL,
O_DTS,
O_FM_DTS
FROM dbo.Orders ON C_ID = O_C_ID
WHERE O_C_ID = :C_ID
SELECT TOP 20
C_F_NAME,
C_L_NAME,
C_EMAIL,
O_ID,
O_TOTAL,
O_DTS,
O_FM_DTS
FROM :tab_cust JOIN :tab_orders ON C_ID = O_C_ID
ORDER BY O_ID DESC;
END;
Expected behavior: The data set for each of the tables is filtered out and then joined. Although the filter is expected to be pushed to each of the joined tables even in your case, but this is worth the try.
Regards,
Ravi -
Dual Case Column names fail in select ORDER BY clause
This one is solved, but I thought someone might be able to explain why it happens.
I'm a newbie, since I just downloaded Oracel XE last night, and am trying it out.
I set up a trivial table with 4 text columns. As it happened, I used dual case for some of my column names, such as 'Nickname'.
When trying out the Query Builder, the Select statement failed whenever I added a sort.
After some head scratching and back-and-forth with the sample data base (HR), I finally renamed all the columns to upper case. (e.g. column 'Nickname' became 'NICKNAME'). Then it works.
Seems like a bug, but maybe it's just a feature. Here's the code generated by the Query Builder. As you can see, there are no quotes around the Table name or column names in the ORDER BY clause (and the dual case version of the column name works if I put the quotes in manually and run it with SQL command.) Seems quirky.
select "TEAMS"."NICKNAME" as "NICKNAME",
"TEAMS"."CITY" as "CITY",
"TEAMS"."DIVISION" as "DIVISION",
"TEAMS"."CONFERENCE" as "CONFERENCE"
from "TEAMS" "TEAMS"
order by TEAMS.NICKNAME ASCWelcome to forum. :)
Now, answering your question - no i don't think this is a bug.
It is your code - which create this bug.
Now, question is - what happen?
Just check your select and from clause. You put all the names are in double quote. When you put anything within double quotes - it become a case sensitive. So, the problem occurs there.
Let's see ->
satyaki>
satyaki>select * from v$version;
BANNER
Oracle Database 10g Enterprise Edition Release 10.2.0.3.0 - Prod
PL/SQL Release 10.2.0.3.0 - Production
CORE 10.2.0.3.0 Production
TNS for 32-bit Windows: Version 10.2.0.3.0 - Production
NLSRTL Version 10.2.0.3.0 - Production
Elapsed: 00:00:01.11
satyaki>
satyaki>create table s_otn
2 (
3 id number(4)
4 );
Table created.
Elapsed: 00:00:02.14
satyaki>
satyaki>set lin 80
satyaki>
satyaki>desc s_otn;
Name Null? Type
ID NUMBER(4)
satyaki>
satyaki>desc S_OTN;
Name Null? Type
ID NUMBER(4)
satyaki>
satyaki>desc s_OtN;
Name Null? Type
ID NUMBER(4)
satyaki>
satyaki>drop table s_otn;
Table dropped.
Elapsed: 00:00:05.22
satyaki>
satyaki>
satyaki>create table "S_otn"
2 (
3 id number(4)
4 );
Table created.
Elapsed: 00:00:00.12
satyaki>
satyaki>
satyaki>desc S_otn;
ERROR:
ORA-04043: object S_otn does not exist
satyaki>
satyaki>desc S_OTN;
ERROR:
ORA-04043: object S_OTN does not exist
satyaki>
satyaki>desc s_otn;
ERROR:
ORA-04043: object s_otn does not exist
satyaki>
satyaki>desc "S_OTN";
ERROR:
ORA-04043: object "S_OTN" does not exist
satyaki>
satyaki>desc "S_otn";
Name Null? Type
ID NUMBER(4)
satyaki>Got me?
Regards.
Satyaki De. -
Variable table name in the select statment ?
data: h_itab like hier_out occurs 0 with header line,
table_name(30) type C.
here i declare h_itab as the variable for the table name
itab_name = input_name
input_name is imported
select * from table_name
into table h_itab
where OBJVERS = 'A'.
it does not allow me to use table_name in the select statement i get the error 'table_name is not defined i the abap dictionary as a table, projection view or database view'.
Any suggestions are highly appreciated.
Thanks in advance,
BWerHi,
You must enclose the name of the table in braces to let the compiler know that the value will be supplied at run time.
For example -
tables mara.
data table_name(30) type c.
table_name = 'MARA'.
SELECT *
FROM (table_name)
endselect.
Regards,
Anand Mandalika. -
If I want to order by dateAdded to I have to include it in the select statement like
If I do this:
<cfquery name="chart" datasource="#datasource#">
select behaviourID,score, dateAdded2 = convert(varchar,
dateAdded , 101)
from staff_charts_data
where userID =
<cfqueryparam value="#arguments.userID#"
cfsqltype="cf_sql_integer"> AND
NOT score = 5
</cfquery>
If I want to order by dateAdded to I have to include it in
the select statement like so:
<cfquery name="chart" datasource="#datasource#">
select behaviourID,score, dateAdded2 = convert(varchar,
dateAdded , 101),dateAdded
from staff_charts_data
where userID =
<cfqueryparam value="#arguments.userID#"
cfsqltype="cf_sql_integer"> AND
NOT score = 5
</cfquery>you should be able to order by dateAdded without it being in
the select clause. The only time the order by field has to be in
the select clause is when your query has an aggregate and group by
clause, like this:
select field1, field2, max(field3) as youralias
from sometables
where whatever
group by field1, field2
order by ???
You can only order field1, field2, max(field3) or youralias.
You can't order by field4. -
Decode in the select Statement
Hi All,
I am using the decode function in the select statement....but as i am using the group by in the select statement....i am not able to run the same query
How to tackle this problem of handling the decode ....while we have group by also.
This is bit urgent
Thanks for your help
RamyaHi,
Thanks for the quick reply.
Here is the code...i have included the decode for the customer carrier code...
SELECT c.trx_number invoice_number,
c.trx_date invoice_date,
ctl.sales_order_date order_date,
c.ship_date_actual ship_date,
c.purchase_order,
ctl.sales_order order_number,
olv.ordered_item item,
msi.description item_description,
olv.ordered_quantity quantity,
olv.unit_selling_price unit_price,
olv.unit_selling_price * olv.ordered_quantity amount,
olv.tax_value,
rc.customer_number,
csta.customer_carrier_code,
(SELECT decode(customer_carrier_code, NULL, 'Shipping & Handling', 'Shipping') sh
FROM xx_cust_ship_to_addresses_v cstaa,
ra_addresses ara
WHERE cstaa.location_id = ad.location_id
AND ara.location_id = ad.location_id) SH,
rc.customer_name invoice_to_name,
rct.name invoice_type,
olv.sold_to,
olv.ship_to_location,
olv.ship_to_address1,
olv.ship_to_address2,
SUBSTR(olv.ship_to_address5, LENGTH(olv.ship_to_address5) -2, LENGTH(olv.ship_to_address5)) ship_to_country,
SUBSTR(olv.ship_to_address5, LENGTH(olv.ship_to_address5) -9, 6) ship_to_postalcode,
SUBSTR(olv.ship_to_address5, LENGTH(olv.ship_to_address5) -12, 2) ship_to_state,
SUBSTR(olv.ship_to_address5, 1, LENGTH(olv.ship_to_address5) -15) ship_to_city,
olv.invoice_to_address1,
olv.invoice_to_address2,
SUBSTR(olv.invoice_to_address5, LENGTH(olv.invoice_to_address5) -2, LENGTH(olv.invoice_to_address5)) invoice_to_country,
SUBSTR(olv.invoice_to_address5, LENGTH(olv.invoice_to_address5) -9, 6) invoice_to_postalcode,
SUBSTR(olv.invoice_to_address5, LENGTH(olv.invoice_to_address5) -12, 2) invoice_to_state,
SUBSTR(olv.invoice_to_address5, 1, LENGTH(olv.invoice_to_address5) -15) invoice_to_city,
olv.flow_status_code,
olv.terms net_terms,
olv.freight_terms_code freight_terms,
olv.fob_point_code fob
FROM ra_customer_trx_all c,
ra_customer_trx_lines_all ctl,
ra_cust_trx_types rct,
jtf_rs_salesreps rs,
ra_customers rc,
ra_addresses ad,
ra_site_uses su,
mtl_system_items msi,
oe_order_headers_v ohv,
oe_order_lines_v olv,
rcv_lot_transactions tl,
rcv_shipment_lines sl,
rcv_shipment_headers rsh,
rcv_transactions rt,
wsh_delivery_details wdd,
xx_cust_ship_to_addresses_v csta
WHERE to_char(ohv.order_number) = ctl.sales_order
AND ctl.customer_trx_id = c.customer_trx_id
AND c.cust_trx_type_id = rct.cust_trx_type_id
AND c.org_id = rs.org_id
AND c.primary_salesrep_id = rs.salesrep_id
AND c.ship_to_site_use_id = su.site_use_id
AND su.address_id = ad.address_id
AND ad.customer_id = rc.customer_id
AND ctl.inventory_item_id = msi.inventory_item_id
AND ohv.header_id = olv.header_id
AND olv.line_id = wdd.source_line_id(+)
AND to_char(olv.line_id) = ctl.interface_line_attribute6
AND tl.shipment_line_id = sl.shipment_line_id
AND sl.shipment_header_id = rsh.shipment_header_id
AND tl.transaction_id = rt.transaction_id
AND csta.location_id = ad.location_id;
GROUP BY c.trx_number,
csta.customer_carrier_code,
c.trx_date,
c.creation_date,
c.ship_date_actual,
c.sold_to_customer_id,
c.bill_to_customer_id,
c.bill_to_site_use_id,
c.ship_to_customer_id,
c.ship_to_site_use_id,
c.purchase_order,
(SELECT decode(customer_carrier_code, NULL, 'Shipping & Handling', 'Shipping') sh
FROM xx_cust_ship_to_addresses_v cstaa,
ra_addresses ara
WHERE cstaa.location_id = ara.location_id
AND ara.location_id = ad.location_id),
ctl.sales_order,
ctl.sales_order_date,
ctl.tax_rate,
ctl.customer_trx_id,
ctl.taxable_amount,
rc.customer_number,
olv.ordered_item,
olv.unit_selling_price,
olv.unit_list_price,
olv.tax_value,
olv.unit_cost,
olv.ordered_quantity,
rs.name,
rc.customer_name,
rc.customer_id,
rc.party_id,
rc.party_number,
ad.address_id,
rct.name,
msi.description,
olv.unit_selling_price * olv.ordered_quantity,
c.org_id,
ohv.header_id,
olv.sold_to,
olv.ship_from,
olv.ship_to_location,
olv.ship_to_address1,
olv.ship_to_address2,
SUBSTR(olv.ship_to_address5, LENGTH(olv.ship_to_address5) -2, LENGTH(olv.ship_to_address5)),
SUBSTR(olv.ship_to_address5, LENGTH(olv.ship_to_address5) -9, 6),
SUBSTR(olv.ship_to_address5, LENGTH(olv.ship_to_address5) -12, 2),
SUBSTR(olv.ship_to_address5, 1, LENGTH(olv.ship_to_address5) -15),
olv.invoice_to_location,
olv.invoice_to_address1,
olv.invoice_to_address2,
SUBSTR(olv.invoice_to_address5, LENGTH(olv.invoice_to_address5) -2, LENGTH(olv.invoice_to_address5)),
SUBSTR(olv.invoice_to_address5, LENGTH(olv.invoice_to_address5) -9, 6),
SUBSTR(olv.invoice_to_address5, LENGTH(olv.invoice_to_address5) -12, 2),
SUBSTR(olv.invoice_to_address5, 1, LENGTH(olv.invoice_to_address5) -15),
olv.flow_status_code,
olv.terms,
olv.freight_terms_code,
olv.shipping_method_code,
olv.fob_point_code,
olv.line_id,
rsh.attribute1,
rsh.attribute2,
su.tax_code,
su.ship_via,
wdd.tracking_number
ORDER BY invoice_number;
Maybe you are looking for
-
Hi there, We want to routhe orders05 from our R3 system to SRM via XI. We tried by using receiver IDOC adapter, but it failed because XI wasn't able to get the metadata from SRM. What is the best way of sending orders05 from xi to SRM? Any help is a
-
this is very odd. I've had minor crashes and lockups in the past that do a full reboot. For the last week the crashes been hapening at odd intervals, sometimes under a load (graphic designing), sometimes just listening to itunes. What makes it odd
-
Hello, Backup/synch is no longer working on my PSE7 catalog. I have been using it for over a year, this just started this month. I have a few new photos to upload, and a bunch that just need to synch again due to a minor change (I renamed the Windo
-
Hi all, i have added the field in address screen in partner tab of sales order header. this is screen independent to the sales order. Now my issue is, this field is always in change mode even the sales order in display mode. can you please guide us r
-
Changing Date in one cell based on text in another cell
Is there a formula to change the date in a cell in one column to the date in another column on the same row based on the text in a third cell on the same row? For example, I want the date in G3 to change to the date in J3 when the text in H3 says Com