Re: the similar decode sql command (in Oracle) in ABAP
Dear ABAP Expert,
Could you let me know where there is a similar decode command in Oracle in ABAP?
Thanks.
Arthur
Hi,
You can specify case statement between SELECT and ENDSELECT. However this may lead to performance problems. Please take care.
Example:-
SELECT FIELD1 into LOC_FIELD FROM TAB.
CASE LOC_FIELD.
WHEN 'ABC'.
WRITE: 'ABC'.
WHEN OTHERS.
WRITE: 'REST'.
ENDCASE.
ENDSELECT.
Thanks and Best Regards,
Dinesh.
Similar Messages
-
How do I write this SQL command in Oracle
Hi all
I wriote this SQ L statement in Ms SQL Server. How do I write this sql command in Oracle?
ALTER VIEW dbo.ConsumptionAS SELECT TOP 100 PERCENT ID,
CONVERT(decimal(10, 2), SUM(CASE WHEN YEAR_MONTH = '200710' AND NbrDaysUsed != 0 THEN (QtyUsed/ Days_Usage) * 748.05 ELSE 0 END)) AS Oct2007,
CONVERT(decimal(10, 2), SUM(CASE WHEN YEAR_MONTH = '200711' AND NbrDaysUsed != 0 THEN (QtyUsed/ Days_Usage) * 748.05 ELSE 0 END)) AS Nov2007,
CONVERT(decimal(10, 2), SUM(CASE WHEN YEAR_MONTH = '200712' AND NbrDaysUsed != 0 THEN (QtyUsed/ Days_Usage) * 748.05 ELSE 0 END)) AS Dec2007,
CONVERT(decimal(10, 2), SUM(CASE WHEN YEAR_MONTH = '200801' AND NbrDaysUsed != 0 THEN (QtyUsed/ Days_Usage) * 748.05 ELSE 0 END)) AS Jan2008,
CONVERT(decimal(10, 2), SUM(CASE WHEN YEAR_MONTH = '200802' AND NbrDaysUsed != 0 THEN (QtyUsed/ Days_Usage) * 748.05 ELSE 0 END)) AS Feb2008,
CONVERT(decimal(10, 2), SUM(CASE WHEN YEAR_MONTH = '200803' AND NbrDaysUsed != 0 THEN (QtyUsed/ Days_Usage) * 748.05 ELSE 0 END)) AS Mar2008,
CONVERT(decimal(10, 2), SUM(CASE WHEN YEAR_MONTH = '200804' AND NbrDaysUsed != 0 THEN (QtyUsed/ Days_Usage) * 748.05 ELSE 0 END)) AS Apr2008,
CONVERT(decimal(10, 2), SUM(CASE WHEN YEAR_MONTH = '200805' AND NbrDaysUsed != 0 THEN (QtyUsed/ Days_Usage) * 748.05 ELSE 0 END)) AS May2008,
CONVERT(decimal(10, 2), SUM(CASE WHEN YEAR_MONTH = '200806' AND NbrDaysUsed != 0 THEN (QtyUsed/ Days_Usage) * 748.05 ELSE 0 END)) AS Jun2008 ,
CONVERT(decimal(10, 2), SUM(CASE WHEN YEAR_MONTH = '200807' AND NbrDaysUsed != 0 THEN (QtyUsed/ Days_Usage) * 748.05 ELSE 0 END)) AS Jul2008 ,
CONVERT(decimal(10, 2), SUM(CASE WHEN YEAR_MONTH = '200808' AND NbrDaysUsed != 0 THEN (QtyUsed/ NbrDaysUsed) * 748.05 ELSE 0 END)) AS Aug2008,
CONVERT(decimal(10, 2), SUM(CASE WHEN YEAR_MONTH = '200809' AND NbrDaysUsed != 0 THEN (QtyUsed NbrDaysUsed) * 748.05 ELSE 0 END)) AS Sep2008
FROM dbo.MasterConsumption WHERE YEAR_MONTH >= '200710' AND YEAR_MONTH <= '200809' GROUP BY ID ORDER BY ID
I am very interested in this part:
SUM(CASE WHEN YEAR_MONTH = '200710' AND NbrDaysUsed != 0 THEN (QtyUsed/ Days_Usage) * 748.05 ELSE 0 END)) AS Oct2007
thanks
Edited by: user631364 on Oct 27, 2008 8:25 AM
Edited by: user631364 on Oct 27, 2008 8:26 AM
Edited by: user631364 on Oct 27, 2008 8:27 AMThank you!!
Now let me aslk the second part of my question.
This sql command:
ALTER VIEW dbo.ConsumptionAS SELECT TOP 100 PERCENT ID,
CONVERT(decimal(10, 2), SUM(CASE WHEN YEAR_MONTH = '200710' AND NbrDaysUsed != 0 THEN (QtyUsed/ Days_Usage) * 748.05 ELSE 0 END)) AS Oct2007,
CONVERT(decimal(10, 2), SUM(CASE WHEN YEAR_MONTH = '200711' AND NbrDaysUsed != 0 THEN (QtyUsed/ Days_Usage) * 748.05 ELSE 0 END)) AS Nov2007,
CONVERT(decimal(10, 2), SUM(CASE WHEN YEAR_MONTH = '200712' AND NbrDaysUsed != 0 THEN (QtyUsed/ Days_Usage) * 748.05 ELSE 0 END)) AS Dec2007,
CONVERT(decimal(10, 2), SUM(CASE WHEN YEAR_MONTH = '200801' AND NbrDaysUsed != 0 THEN (QtyUsed/ Days_Usage) * 748.05 ELSE 0 END)) AS Jan2008,
CONVERT(decimal(10, 2), SUM(CASE WHEN YEAR_MONTH = '200802' AND NbrDaysUsed != 0 THEN (QtyUsed/ Days_Usage) * 748.05 ELSE 0 END)) AS Feb2008,
CONVERT(decimal(10, 2), SUM(CASE WHEN YEAR_MONTH = '200803' AND NbrDaysUsed != 0 THEN (QtyUsed/ Days_Usage) * 748.05 ELSE 0 END)) AS Mar2008,
CONVERT(decimal(10, 2), SUM(CASE WHEN YEAR_MONTH = '200804' AND NbrDaysUsed != 0 THEN (QtyUsed/ Days_Usage) * 748.05 ELSE 0 END)) AS Apr2008,
CONVERT(decimal(10, 2), SUM(CASE WHEN YEAR_MONTH = '200805' AND NbrDaysUsed != 0 THEN (QtyUsed/ Days_Usage) * 748.05 ELSE 0 END)) AS May2008,
CONVERT(decimal(10, 2), SUM(CASE WHEN YEAR_MONTH = '200806' AND NbrDaysUsed != 0 THEN (QtyUsed/ Days_Usage) * 748.05 ELSE 0 END)) AS Jun2008 ,
CONVERT(decimal(10, 2), SUM(CASE WHEN YEAR_MONTH = '200807' AND NbrDaysUsed != 0 THEN (QtyUsed/ Days_Usage) * 748.05 ELSE 0 END)) AS Jul2008 ,
CONVERT(decimal(10, 2), SUM(CASE WHEN YEAR_MONTH = '200808' AND NbrDaysUsed != 0 THEN (QtyUsed/ NbrDaysUsed) * 748.05 ELSE 0 END)) AS Aug2008,
CONVERT(decimal(10, 2), SUM(CASE WHEN YEAR_MONTH = '200809' AND NbrDaysUsed != 0 THEN (QtyUsed NbrDaysUsed) * 748.05 ELSE 0 END)) AS Sep2008
FROM dbo.MasterConsumption WHERE YEAR_MONTH >= '200710' AND YEAR_MONTH <= '200809' GROUP BY ID ORDER BY ID
was created with this query in SQL Server and then I saved it in a store procedure, that I scheduled to run montlhy
SET ANSI_NULLS ON
DECLARE @SQLString NVARCHAR(4000)
/* Build the SQL string once.*/
SET @SQLString = 'ALTER VIEW dbo.Consumption AS SELECT TOP 100 PERCENT ID, CONVERT(decimal(10, 2), SUM(CASE WHEN YEAR_MONTH = ' +
"'" + dbo.CONLastMonth_fn(getdate(), month(getdate()) - 12) +
"'" +
' AND NbrDaysUsed != 0 THEN (QtyUsed/ NbrDaysUsed) * 748.05 ELSE 0 END)) AS ' +
dbo.CONMonthInEnglish(getdate(), month(getdate()) - 12) +
… (GOES FROM current month -12 to current month -1)
, CONVERT(decimal(10, 2), SUM(CASE WHEN YEAR_MONTH = ' +
"'" + dbo.CONLastMonth_fn(getdate(), month(getdate()) - 1) +"'" +
' AND NbrDaysUsed != 0 THEN (QtyUsed/ NbrDaysUsed) * 748.05 ELSE 0 END)) AS ' +
dbo.CONMonthInEnglish(getdate(), month(getdate()) - 1) +
' FROM dbo.MasterConsumption WHERE YEAR_MONTH >= ' +
"'" + dbo.CONLastMonth_fn (getdate(), month(getdate())-12 ) +"'" +
' AND YEAR_MONTH <= ' +
"'" + dbo.CONLastMonth_fn (getdate(), month(getdate())-1 ) +"'" +
' GROUP BY ID ORDER BY ID '
EXEC sp_executesql @SQLString
Is that something that can be done in Oracle in the same way?
Do you use another approach?
please advice
Edited by: user631364 on Oct 27, 2008 10:19 AM
Edited by: user631364 on Oct 27, 2008 10:21 AM
Edited by: user631364 on Oct 27, 2008 10:21 AM
Edited by: user631364 on Oct 27, 2008 10:22 AM
Edited by: user631364 on Oct 27, 2008 10:23 AM
Edited by: user631364 on Oct 27, 2008 10:23 AM
Edited by: user631364 on Oct 27, 2008 10:24 AM -
How execute pl/sql command from Oracle ADF Business Components
can't find examples for how execute pl/sql command from Oracle ADF Business Components and how call pl/sql package procedure from ADF Business Components.
insert,update,delete rows in view object instance cache is good but if i must do some complex operations while insert,update,delete rows..it's more better for me to call
pl/sql procedure from oracle db.Am i wrong ????Roman,
this should be similar to how it worked in JDeveloper 9.0.3. hava a look at <JDev903 Home>\BC4J\samples\StoredProc for a code example.
Frank -
Help needed, guys! Could anyone tell me where to find full list and description of SQL commands of Oracle?
http://download-west.oracle.com/docs/cd/B10501_01/server.920/a96540/toc.htm
-
Howto: multiple sql-commands in oracle-xe
Hi,
just installed the oracle-xe. Now I want to create tables, indexes etc within the sql-command tool.
For example:
CREATE TABLE ZUSTAENDIGKEIT (
INSTITUTION_ID VARCHAR2(30) NOT NULL,
FUNKTION_ID NUMBER(4) NOT NULL,
LIEGENSCHAFT_ID VARCHAR2(30) NOT NULL);
CREATE UNIQUE INDEX UX_ZUSTAENDIGKEIT
ON ZUSTAENDIGKEIT (LIEGENSCHAFT_ID,FUNKTION_ID)
Executing this as one command I receive an error ora-00911.
Executing this in two parts it works?
Thanks for any help.
grassuHere is just a sample that should work as a script in the web interface:
-- BVM
-- Benoetigte Sequence numbers
-- Globale Sequence
DROP SEQUENCE bvm_seq;
CREATE SEQUENCE bvm_seq
MINVALUE 1
MAXVALUE 999999999
INCREMENT BY 1
START WITH 1
CACHE 20
NOORDER
NOCYCLE
-- Log Sequence
CREATE SEQUENCE BVM_LOG_SEQ
MINVALUE 1
MAXVALUE 999999999
INCREMENT BY 1
START WITH 1
CACHE 20
NOORDER
NOCYCLE
;Note: no "/" (you need these only after trigger, procedures, etc.)
You need to execute this in the script section, not in the command section of the web interface.
C. -
How to get the correct sql command in oracle?
Hi sir,
i am using this query in sql that is :
SELECT C.*,ISNULL(P.Comp_Name,'') + ' (' + ISNULL(P.Comp_ID,'') + ')' Parent FROM Comp_Master C LEFT JOIN Comp_Master P ON C.Parent_ID = P.Comp_ID Where C.Comp_ID='004'
so i am getting in parent column value like this: "PARIS GROUP (001)"
but the same command i converted in sql developer that is:
SELECT C.* ,NVL(P.Comp_Name, ' ') || ' (' || NVL(P.Comp_ID, ' ') || ')' as Parent FROM Comp_Master C LEFT JOIN Comp_Master P ON C.Parent_ID = P.Comp_ID WHERE C.Comp_ID ='004'
but not getting in parent column value its coming only ( )
help me.
thanksWelcome to Oracle.
It has manuals.
http://tahiti.oracle.com/
Choose your version, which you continue to keep a mystery
E.g.
http://www.oracle.com/pls/db112/homepage
Including Oracle SQL syntax
http://docs.oracle.com/cd/E11882_01/server.112/e26088/toc.htm
Which you will find useful since Oracle does not run Microsoft SQL as you continue to find over and over again.
And there is a 2 day getting started as a developer guide, which you appear to desperately need,
http://docs.oracle.com/cd/E11882_01/appdev.112/e10766/toc.htm
If you have any specific questions about anything you read in there, come back in a couple of days after you have finished reading them. -
I need to covert the following MS SQL query to Oracle.
The query is as follows..
SELECT B.AL_DESCRIPTION,Count(C.TC_STATUS)
FROM ALL_LISTS A, ALL_LISTS B, TESTCYCL C
Where B.AL_FATHER_ID = A.AL_ITEM_ID
And C.TC_STATUS = B.AL_DESCRIPTION
And A.AL_DESCRIPTION = 'Status'
And (C.TC_EXEC_DATE = @ExecutionDate@
Or C.TC_STATUS = 'No Run')
Group By B.AL_DESCRIPTION
Union
SELECT B.AL_DESCRIPTION,0
FROM ALL_LISTS A, ALL_LISTS B
Where B.AL_FATHER_ID = A.AL_ITEM_ID
And A.AL_DESCRIPTION = 'Status'
And Not Exists (Select 1 From TESTCYCL C Where C.TC_STATUS = B.AL_DESCRIPTION)
Order By 1Is
What does this below mean in MySql
And (C.TC_EXEC_DATE = @ExecutionDate@Is ExecutionDate a variable name?
Then replace it by..
And (C.TC_EXEC_DATE = TO_DATE(ExecutionDate,'DD-MON-YYYY')If ExecutionDate is not a date datatype
I guess you are trying to compare the value of TC_EXEC_DATE with some variable value.
If you are using bind variable then you can substitute as
And (C.TC_EXEC_DATE = TO_DATE(&ExecutionDate,'DD-MON-YYYY')check this,
Here I am taking value at run time.
SQL> select empno,ename,hiredate
2 from emp
3 where hiredate > &dt;
Enter value for dt: '22-MAY-1981'
old 3: where hiredate > &dt
new 3: where hiredate > '22-MAY-1981'
EMPNO ENAME HIREDATE
7654 MARTIN 28-SEP-81
7782 CLARK 09-JUN-81
7788 SCOTT 19-APR-87
7839 KING 17-NOV-81
7844 TURNER 08-SEP-81
7876 ADAMS 23-MAY-87
7900 JAMES 03-DEC-81
7902 FORD 03-DEC-81
7934 MILLER 23-JAN-82
9 rows selected.
Using a variable
SQL> declare
2 eno number;
3 name varchar2(50);
4 edate date;
5 dt date :='23-JAN-1982';
6 begin
7 select empno,ename,hiredate into eno,name,edate
8 from emp where hiredate = dt;
9 dbms_output.put_line(Eno||' '||name||' '||edate);
10 end;
11 /
7934 MILLER 23-JAN-82
PL/SQL procedure successfully completed.Twinkle -
JDBC: send batch of SQL commands as anonymous PL/SQL block
Hi All,
I did a little measurement to see if I can improve jdbc
applications by batching dissimilar SQL commands into one
anonymous PL/SQL block and execute it once. To my surprise, for
a batch of 5 SQL commands, it take 60% more time than execute
each of the 5 SQL commands separately.
The same JDBC code, using similar SQL text batching, running
against Sybase or MSSQL shows 60%-300% improvement.
Is there any other way to batch dynamic dissimilar SQL commands
in Oracle other than using anonymous PL/SQL block? Here is an
example of how the "text-batching" PL/SQL block looks like:
"begin insert into testtab1(col1, col2) values(1, 'row1');
insert into testtab2(col1, col2) values(100, 1);....; end;"
Thanks,
Nam Nguyen
nullIf you do:
declare
l_sql varchar2(32767);
l_value varchar2(32767);
begin
select query_sql into l_sql from lov where lov_id = 100;
dbms_output.put_line(l_sql);
end;
You'll see something like that:
SELECT
l.DESCRIPTION || decode(l2.DESCRIPTION,null,'',l2.description, '-' || l2.description) || decode(a.DT,'Y',' - Distributed Training','N',null,null) as value1
FROM ACTIVITY a
,MOUNTAINEERING m
,LOV l
,LOV l2
WHERE a.JSATFA_ID = 82
AND a.SPECIFIC_ACTIVITY_LOV_ID = l.LOV_ID
AND m.ACTIVITY_ID(+) = a.ACTIVITY_ID
AND m.CLASSIFICATION_LOV_ID = l2.LOV_ID(+);
you need to duplicate the '
you can do many things like:
CTH@> select * from sqls;
C
select first_name || ' ' || last_name as value1 from employees where rownum=1
1 fila seleccionada.
CTH@>
CTH@> ;
1 declare
2 l_sql varchar2(32767);
3 l_value varchar2(32767);
4 type generic_cursor is ref cursor;
5
6 c generic_cursor;
7
8 begin
9 select replace(c, ''', ''''') into l_sql from sqls;
10
11 execute immediate l_sql into l_value;
12 dbms_output.put_line(l_value);
13* end;
CTH@> /
Ellen Abel
Procedimiento PL/SQL terminado correctamente.
CTH@> -
How to come out of the output in sql 11g
In sql 11g release 2 i am not able to come out of the query window..if i use ctrl c it throws me out of the window..
Some times i fire control c it does through me out of the ouptut screen to sqlplus prompt but sometimes it just throws me out of the sql window..
What is the best way to cancel a sql command in oracle 11g release 2.
in sql . In 10 g things were easier.. dont know what do we need to do in 11g release 2
Edited by: zycoz100 on Jan 27, 2013 10:57 PMUse the "exit" or cntrl +c command to terminate your SQL*Plus session.
Read the doc too
Stopping a Command while it is Running
http://docs.oracle.com/cd/B19306_01/server.102/b14357/ch4.htm#i1040012
How to use Sql*plus
http://docs.oracle.com/html/A88829_01/ch3.htm
Edited by: Rahul India on Jan 28, 2013 12:35 PM -
SQL command (with XPath) does not work properly with JSP
Hello everyone,
I try this SQL command on Oracle SQL Developer,
select filename,
extract(xml_col, '/Operation/Records/tabDetail/Vehicle_Level/text()') as Vehicle_Level,
extract(xml_col, '/Operation/Records/tabDetail/Vehicles_Closed/text()') as Vehicles_ID
from ope
where upload_datetime in
(select min(upload_datetime)
from ope
where (TO_DATE(TO_CHAR(upload_datetime, 'DD-MM-YYYY'),'DD-MM-YYYY'))
between TO_DATE('01-01-2008','DD-MM-YYYY') and TO_DATE('01-07-2008','DD-MM-YYYY')
HAVING (filename like '60-1-%')
GROUP BY filename);
It works properly, the result is :
FILENAME --------------------- VEHICLE_LEVEL --------------------- VEHICLES_ID
60-1-OPE-1.xml --------------------- 3 --------------------- 60-1-VEH-43
But when I try this command on JSP, the result is :
FILENAME --------------------- VEHICLE_LEVEL --------------------- VEHICLES_ID
60-1-OPE-1.xml --------------------- null --------------------- null
I don't want "null" value, but I don't know where is wrong. Please help me.
Thank you very much.
Orange JasminIf you know that the videos and music have been working before and that the ID3 tags are correct I suggest that you try to reinstall the phone software using Update Service.
http://www.sonymobile.com/gb/tools/update-service/
Let me know if these problems remains after reinstall.
- Community Manager Sony Xperia Support Forum
If you're new to our forums make sure that you have read our Discussion guidelines.
If you want to get in touch with the local support team for your country please visit our contact page. -
Error in SQl Query - SQl Command not properly ended
Hi All
I have this SQL query that returns the following error when I run it in TOAD:
SELECT
VC.CAMPAIGN_NUMBER,VC.CAMPAIGN_TITLE,VC.CAMPAIGN_DESC,
VCV.START_DATE, VCV.END_DATE,VC.CAMPAIGN_TYPE,VC.APPLICABILITY,
VC.CAMPAIGN_PRIORITY
FROM
VM_CAMPAIGN_VIN VCV ,VM_CAMPAIGN VC
WHERE
VCV.VIN = 'US'
AND
VCV.CAMPAIGN_NUMBER = VC.CAMPAIGN_NUMBER AND VC.COUNTRY_CODE = 'E'
AND VC.LANGUAGE_CODE = 'L' AND VC.CAMPAIGN_TYPE = null
AND SYSDATE BETWEEN VCV.START_DATE AND VCV.END_DATE
AND SYSDATE BETWEEN VC.START_DATE AND VC.END_DATE)
A ORDER BY A.CAMPAIGN_PRIORITY DESC, A.END_DATE
The error is:
SQl Command not properly ended
Any help is highly appreciated. ThanksThanks a lot to everyone. It helped me run the query without any problem. Now I have another issue. This may not be the right place to post this question, I think.My apologies for that. The problem is, Weblogic posts an error as follows:
java.sql.SQLException: ORA-00923: FROM keyword not found where expected
I am wondering if this is an Java related error or an SQL related error.
Well, I am using the SQL Statement which you helped debug, and it is inside something called "XXSQLConstants.java consisting of the following SQL statement:
public static final String XX_ALL_CAMPS_SELECT = "SELECT * FROM" +
"(SELECT vc.campaign_number, vc.campaign_title, vc.campaign_desc, vc.start_date," +
"vc.end_date, vc.campaign_type, vc.applicability, vc.campaign_priority" +
"FROM vm_campaign vc" +
"WHERE vc.applicability = 'Y'" +
"AND vc.country_code = ? " +
"AND vc.language_code = ? " +
"AND vc.campaign_type = ? "+
"AND SYSDATE BETWEEN vc.start_date AND vc.end_date" +
"AND NOT EXISTS (" +
"SELECT 'X'" +
"FROM vm_campaign_vin vcv" +
"WHERE (vcv.vin = ? " +
"AND vcv.campaign_number = vc.campaign_number" +
"))" +
"UNION" +
"SELECT vc.campaign_number, vc.campaign_title, vc.campaign_desc," +
"vcv.start_date, vcv.end_date, vc.campaign_type, vc.applicability," +
"vc.campaign_priority" +
"FROM vm_campaign_vin vcv, vm_campaign vc" +
"WHERE vcv.vin = ? " +
"AND vcv.campaign_number = vc.campaign_number" +
"AND vc.country_code = ? " +
"AND vc.language_code = ? " +
"AND vc.campaign_type IS NULL" +
"AND SYSDATE BETWEEN vcv.start_date AND vcv.end_date" +
"AND SYSDATE BETWEEN vc.start_date AND vc.end_date)";
The SQl runs fine when tested (well, it does not return any data for the rows returned, but there are no errors), but in my application server I get the following error (pointing out the same SQL code pasted above:
java.sql.SQLException: ORA-00923: FROM keyword not found where expected
Any suggestions? Thanks in advance. I appreciate all replies -
Extraction SQL statement from oracle stored procedure stored in file
Hi,
I am newbie to oracle stored procedure. I need to extract the list of sqls present in oracle stored procedure. Besides that I also want to parse these sql statements to get the list of tables and columns used. Is there any tool which can help me in doing thats.
thanks,
govindwhy don't check on user_dependencies table instead?
select referenced_name,referenced_type
from user_dependencies
where name='<your stored procedure name in upper case>'
and referenced_type = 'TABLE'HTH,
Prazy -
SQL Command table linking issues
I have created a simple SQL command in CR 2008 to save the creation of a view on the DB (SQL Server 2005). I then link it to another table from the same DB. Once this was done I began experiencing extremely long run times versus the link with the original view. The SQL command set was copied directly from the view in MS Visual Sudio. The joins in CR are left outers and inner that worked fine with the original view. We ended up running a trace of the SQL Server and found the SQL was producing 21,000 record reads everytime the primary table read a record. It was not following the inner join at all. I did a Show SQL in CR and found that the CR generated SQL looked very strange and not like the typical construction when the view was being used instead of the table What am I doing wrong? Below is a copy of the Show SQL for this particular issue. It seems to be the second command set in italics that causes the issue. That is from the SQL command I created in CR.
Thanks,
Brian
PROD - FIN
SELECT "MAN_JOBS"."JOB_NUMBER", "MAN_JOBS"."ACTUAL_START_DATE", "MAN_JOBS"."ACTUAL_START_DATE_2", "MAN_JOBS"."STD_PROCESS_SPEC", "MAN_JOBS"."COMPANY_CODE"
FROM "fin_prod"."dbo"."MAN_JOBS" "MAN_JOBS"
EXTERNAL JOIN MAN_JOBS.STD_PROCESS_SPEC={?PROD - FIN: C_IC_PRODUCT_CHARACTERISTICS.PART_CODE} AND MAN_JOBS.COMPANY_CODE={?PROD - FIN: C_IC_PRODUCT_CHARACTERISTICS.COMPANY_CODE} AND MAN_JOBS.COMPANY_CODE={?PROD - FIN: KX_IC_MOVEMENTS_PRODCTN_IN_OUTS.COMPANY_CODE} AND MAN_JOBS.JOB_NUMBER={?PROD - FIN: KX_IC_MOVEMENTS_PRODCTN_IN_OUTS.DOCUMENT_NUMBER} AND MAN_JOBS.STD_PROCESS_SPEC={?PROD - FIN: KX_PRODUCT_MASTER_EXT.PART_CODE}
PROD - FIN
SELECT *
FROM dbo.IC_PRODUCT_CHARACTERISTICS
WHERE (CHARACTERISTIC_CODE = 'TEXT')
EXTERNAL JOIN C_IC_PRODUCT_CHARACTERISTICS.PART_CODE={?PROD - FIN: MAN_JOBS.STD_PROCESS_SPEC} AND C_IC_PRODUCT_CHARACTERISTICS.COMPANY_CODE={?PROD - FIN: MAN_JOBS.COMPANY_CODE}
PROD - FIN
SELECT "KX_IC_MOVEMENTS_PRODCTN_IN_OUTS"."IC_MOVE_QUANTITY", "KX_IC_MOVEMENTS_PRODCTN_IN_OUTS"."TRANSACTION_TYPE", "KX_IC_MOVEMENTS_PRODCTN_IN_OUTS"."IC_LOT_NUMBER", "KX_IC_MOVEMENTS_PRODCTN_IN_OUTS"."WAREHOUSE", "KX_IC_MOVEMENTS_PRODCTN_IN_OUTS"."PERIOD_TXT", "KX_IC_MOVEMENTS_PRODCTN_IN_OUTS"."YEAR_TXT", "KX_IC_MOVEMENTS_PRODCTN_IN_OUTS"."DOCUMENT_NUMBER", "KX_IC_MOVEMENTS_PRODCTN_IN_OUTS"."PART_CODE", "KX_IC_MOVEMENTS_PRODCTN_IN_OUTS"."COMPANY_CODE"
FROM "fin_prod"."dbo"."KX_IC_MOVEMENTS_PRODCTN_IN_OUTS" "KX_IC_MOVEMENTS_PRODCTN_IN_OUTS"
WHERE "KX_IC_MOVEMENTS_PRODCTN_IN_OUTS"."COMPANY_CODE"={?PROD - FIN: MAN_JOBS.COMPANY_CODE} AND "KX_IC_MOVEMENTS_PRODCTN_IN_OUTS"."DOCUMENT_NUMBER"={?PROD - FIN: MAN_JOBS.JOB_NUMBER}
EXTERNAL JOIN KX_IC_MOVEMENTS_PRODCTN_IN_OUTS.PART_CODE={?PROD - FIN: PRODUCT_MASTER.PART_CODE} AND KX_IC_MOVEMENTS_PRODCTN_IN_OUTS.COMPANY_CODE={?PROD - FIN: PRODUCT_MASTER.COMPANY_CODE}
PROD - FIN
SELECT "PRODUCT_MASTER"."PRODUCT_CLASS", "PRODUCT_MASTER"."COMPANY_CODE", "PRODUCT_MASTER"."PART_CODE"
FROM "fin_prod"."dbo"."PRODUCT_MASTER" "PRODUCT_MASTER"
WHERE "PRODUCT_MASTER"."PART_CODE"={?PROD - FIN: KX_IC_MOVEMENTS_PRODCTN_IN_OUTS.PART_CODE} AND "PRODUCT_MASTER"."COMPANY_CODE"={?PROD - FIN: KX_IC_MOVEMENTS_PRODCTN_IN_OUTS.COMPANY_CODE}
PROD - FIN
SELECT "KX_PRODUCT_MASTER_EXT"."PRODUCT_CLASS", "KX_PRODUCT_MASTER_EXT"."PART_CODE"
FROM "fin_prod"."dbo"."KX_PRODUCT_MASTER_EXT" "KX_PRODUCT_MASTER_EXT"
WHERE "KX_PRODUCT_MASTER_EXT"."PART_CODE"={?PROD - FIN: MAN_JOBS.STD_PROCESS_SPEC}As an update, I created a view in MS VIsual Studio and copied the SQL command set into a Crystal SQL command and made changes in the report to use the new CR SQL command. It ran in seconds instead of hours. There is something wrong with the way CR is building the SQL command when a CR SQL command is linked to a normal DB table. HELP! I started using the CR SQL command with only another 1 or 2 tables and it was slower but bearable. This one uses more table and more data and dies. Here is what the SQL command set looks like that I built in MS VS and used to create the CR SQL command. This is from the Show SQL in CR.
SELECT dbo.MAN_JOBS.ACTUAL_START_DATE, dbo.MAN_JOBS.ACTUAL_START_DATE_2, dbo.MAN_JOBS.JOB_NUMBER,
dbo.KX_IC_MOVEMENTS_PRODCTN_IN_OUTS.DOCUMENT_NUMBER, dbo.KX_IC_MOVEMENTS_PRODCTN_IN_OUTS.IC_LOT_NUMBER,
dbo.KX_IC_MOVEMENTS_PRODCTN_IN_OUTS.IC_MOVE_QUANTITY, dbo.KX_IC_MOVEMENTS_PRODCTN_IN_OUTS.PART_CODE,
dbo.KX_IC_MOVEMENTS_PRODCTN_IN_OUTS.PERIOD_TXT, dbo.KX_IC_MOVEMENTS_PRODCTN_IN_OUTS.YEAR_TXT,
dbo.KX_IC_MOVEMENTS_PRODCTN_IN_OUTS.TRANSACTION_TYPE, dbo.KX_IC_MOVEMENTS_PRODCTN_IN_OUTS.WAREHOUSE,
dbo.PRODUCT_MASTER.PRODUCT_CLASS, dbo.KX_PRODUCT_MASTER_EXT.PART_CODE AS KX_PART_CODE,
dbo.KX_PRODUCT_MASTER_EXT.PRODUCT_CLASS AS KX_PRODUCT_CLASS, dbo.IC_PRODUCT_CHARACTERISTICS.CHARACTERISTIC_CODE,
dbo.IC_PRODUCT_CHARACTERISTICS.IC_DEF_CHAR_TEXT
FROM dbo.MAN_JOBS INNER JOIN
dbo.IC_PRODUCT_CHARACTERISTICS ON dbo.MAN_JOBS.COMPANY_CODE = dbo.IC_PRODUCT_CHARACTERISTICS.COMPANY_CODE AND
dbo.MAN_JOBS.STD_PROCESS_SPEC = dbo.IC_PRODUCT_CHARACTERISTICS.PART_CODE LEFT OUTER JOIN
dbo.KX_PRODUCT_MASTER_EXT ON dbo.MAN_JOBS.STD_PROCESS_SPEC = dbo.KX_PRODUCT_MASTER_EXT.PART_CODE AND
dbo.MAN_JOBS.COMPANY_CODE = dbo.KX_PRODUCT_MASTER_EXT.COMPANY_CODE LEFT OUTER JOIN
dbo.KX_IC_MOVEMENTS_PRODCTN_IN_OUTS ON dbo.MAN_JOBS.COMPANY_CODE = dbo.KX_IC_MOVEMENTS_PRODCTN_IN_OUTS.COMPANY_CODE AND
dbo.MAN_JOBS.JOB_NUMBER = dbo.KX_IC_MOVEMENTS_PRODCTN_IN_OUTS.DOCUMENT_NUMBER LEFT OUTER JOIN
dbo.PRODUCT_MASTER ON dbo.KX_IC_MOVEMENTS_PRODCTN_IN_OUTS.COMPANY_CODE = dbo.PRODUCT_MASTER.COMPANY_CODE AND
dbo.KX_IC_MOVEMENTS_PRODCTN_IN_OUTS.PART_CODE = dbo.PRODUCT_MASTER.PART_CODE
WHERE (dbo.IC_PRODUCT_CHARACTERISTICS.CHARACTERISTIC_CODE = N'TEXT') -
How to execute stored procedure in the SQL Commands page
i'm oracle express edition newbie :) i have this stored procedure. it not belong to a package.
create or replace procedure "LIST_MEMBERS"
("MEMBER_CUR" OUT SYS_REFCURSOR)
is
begin
OPEN MEMBER_CUR FOR
SELECT * FROM members;
end;
now, in the SQL Commands page, how to run the stored procedure and return the records. i do this:
begin
execute list_members();
end;
but i'm getting some errors. just need some immediate help :) thanks!!!Example of using a ref cursor:
SQL> ed
Wrote file afiedt.buf
1 create or replace procedure open_cur(c IN OUT SYS_REFCURSOR) is
2 begin
3 open c for 'select rownum rn from dual connect by rownum <= 10';
4* end;
SQL> /
Procedure created.
SQL> ed
Wrote file afiedt.buf
1 declare
2 c SYS_REFCURSOR;
3 v_val NUMBER;
4 begin
5 open_cur(c);
6 loop
7 fetch c INTO v_val;
8 exit WHEN c%NOTFOUND;
9 dbms_output.put_line(v_val);
10 end loop;
11 close c;
12* end;
SQL> /
1
2
3
4
5
6
7
8
9
10
PL/SQL procedure successfully completed.
SQL> -
Crystal runs sql command of first sub report in the second sub report ?
Hi,
I have report that contains 3 sub reports.
Each subreport is running his own sql command to retrieve it's data.
When moving from the first subreport to the 2nd subreport, we see on the oracle that the crystal runs the sql command of the 1st subreport, and then the sql command of the 2nd subreport.
The results are fine (he ignores the 1st subreport result in the 2nd subreport), but it delays the showing of the 2nd subreport to show.
Why? The 2nd subreport doesn't need the data of the 1st subreport!
How do I cancel that????
BTW - The 3rd subreport is running only his own sql command (As should be).
Thanks.Hello,
Not without more info about the report and the data. If there is nothing linked from the main report to sub1 then it's going to run and return all data, no filtering. And from the sounds of it to take 5 + minutes per query this is going to affect performance for the whole report.
You may want to re-evaluate why and what the subreports are used for. If they all use the same data the link them in the main report use groups to sort the data.
Having subreports in the Details section is asking for performance problems, every record returned will cause the subreport to run. Not knowing what the subs are doing I can't say for sure....
What you should do also is re-evaluate your Commands for each sub and see if you can do it either in one SQL statement or write a Stored Procedure to do all of the data collection. DB Servers are much more efficient at collecting data than CR will ever be. Pushing just the results to CR makes it simply formatting the results in the Designer and no performance hits....
Talk to your DBA on how to optimize your Command SQL's and how to get them into one SQL or into a SP that dumps the final results into a final SQL * from TEMP Table into Crystal.
Don
Maybe you are looking for
-
Duplicate records in Internal table
Hi All, I want to find out the duplicate entry in the internal table. I have used, Delete Adjacent duplicates from itab. It is straight away deleting the record. I want the user to correct that duplicate record. May be some error message. I have trie
-
Hi all. Somehow I am not able to run my web service...here is the invoke page my code. <cfinvoke webservice=" http://bt2bcm:8500/comp.cfc?wsdl" method="myFunction" returnvariable="aString" > <cfinvokeargument name="url1" value="Hello"/> <cfinvokeargu
-
Web Mash Up how to set up pre-req ENABLE_MU_CONF
on EhP1, activated UI_FRW_1 & UI_FRW_1_DOCU in SFW5 but I don't understand this setup per the help http://help.sap.com/saphelp_crm700_ehp01/helpdata/EN/db/28b183e1e04f8daf5534cf0706bf15/frameset.htm To enable or disable the UI configuration of mash-u
-
I just downloaded Photoshop elements 12 and can not open photo editor
-
Didn't buy an app in my Purchases list - links to another, unrecognized Apple ID
How can I get rid of an app that I didn't purchase and don't want? It's linked to another Apple ID that I don't recognize, which pops up in the dialogue box when I try to update it. Here's what it looks like: