Parameter based on decode/function field - slow response
Hi,
When one of the parameters of a report is used, the report takes a very long time to run. The parameter has a LOV of statuses in Hebrew.
The folder is a custom folder and the status in Hebrew is a decode field using a function. In other words, it first goes to a function to get the status, and then translates each status (I guess that the Hebrew will be strange but I hope that the general form of the decode is clear):
DECODE( APPS.JAFI_DISCO_UTILS_PKG.JAFI_GET_INVOICE_STATUS(
AI.INVOICE_ID,
AI.INVOICE_AMOUNT,
AI.PAYMENT_STATUS_FLAG,
AI.INVOICE_TYPE_LOOKUP_CODE),
'APPROVED','מאומת',
'NEVER APPROVED','מעולם לא עבר אימות',
'NEEDS REAPPROVAL','דורש אימות מחדש',
'CANCELLED','מבוטל',
'AVAILABLE','זמין',
'UNAPPROVED','לא מאומת',
'SELECTED FOR PAYMENT','נבחר לתשלום',
'FULL','מיוחס במלואו',
'UNPAID','לא שולם',' ')
I am assuming that the reason for the slow response is the constant run of the function in addition to the decode (which I was once told also slows the response a bit).
Is there anyway to change the sql somewhat? Without using the parameter the report takes about 2 1/2 minutes to run. Using the parameter it takes around 25 minutes to run.
Thank you.
Leah
Edited by: user476771 on May 10, 2010 2:09 AM
Hi Michael,
I think your suggestion #3, checking the indexes, is an excellent start.
As to the other suggestions, I believe that everything passed to the function is needed to find the status.
We seem to have serious problems running materialized views. Our dba is actually checking it out now. One group of mv were changed a few months ago so that they are no longer needed (someone worked around it using other tables for the data). Another mv is problematic even though it takes 14 minutes to create in a tst environment (which I happen to do yesterday) and causes no problems afterwards, it is a problem when run in prod as part of a job. As I mentioned, our dba is checking it out.
I hesitate to create a new table that is updated every night with the status of each invoice. It won't be up-to-date during the day, and it means changing the report that has otherwise run smoothly until now. The user avoids using the one parameter as much as possible so it's not THAT bad...
I really appreciate your giving the four suggestions.
Thank you so much.
Leah
Similar Messages
-
Parameter Transaction Code for Function Group based Tcodes
Hi,
I have created a function group for a single screen 1000 having only 2 screen fields with input/output enabled, one of them being a flag field. Have also created a Transaction code to point to the screen 1000.
My requirement is to create another Tcode(Parameter Transaction Code) with the previous created Tcode and pass default values to the screens flag element. I have entered the below :
Name of the screen field
Value
FLAG
X
Still i am not able to get the value of FLAG as X when i debug the program. I am confused what mistake have i done. It will be helpful if someone can guide on this. I know its simple and i believe me i have tried all possible ways to check my mistake. Couldn't find any.
Thanks and Regards,
Vadid ValiullaYes, Basically i am calling TCODE1 from TCODE2.
I am using the same Function Group and yes a global variable is defined for the screen fields.
I actually do not want to go by the Parameter ID method. But still i can use it if that is easier. Currently there is no Parameter ID for the screen field as i wanted the Tcode2 also to be called independently.
Thanks for your time Prakash
Regards,
Vadid -
Decode function involving 2 fields (urgent)
Hi .. I am trying to use the decode function involving 2 fields.
The query runs but does not produce the correct results. If
anyone knows, please reply .. Usually decode function involves
one column only but I have more
than one. The situation is : If ins_code = 2 or special_code =
MMI, put a 'Y', otherwise, it's a 'N'. Does anyone know how to
put this in a decode statement? ThanksThanks, Suresh ... but I have to put this condition using the
decode statement because that's how the rest of the program is
written. It's part of the script that I have to change. The
current statement is this: decode(ins_code, '2', 'Y', 'N'). I
have to change it to ins_code =2 or special_feature = MMI.
Please reply ... thanks a lot.... -
Using collections and experiencing slow response
I am experiencing slow response when using htmldb_collection. I was hoping someone might point me in another direction or point to where the delay may be occurring.
First a synopsis of what I am using these collections for. The main collections are used in order to enable the users to work with multiple rows of data (each agreement may have multiple inbound and outbound tiered rates). These collections, OBTCOLLECTION and IBTCOLLECTION, seem to be fine. The problem arises from the next set of collections.
OBTCOLLECTION and IBTCOLLECTION each contain a field for city, product, dial code group and period. Each of these fields contains a semi-colon delimited string. When the user chooses to view either the outbound tiers (OBTCOLLECTION) or the inbound tiers (IBTCOLLECTION), I generate four collections based on these four fields, parsing the delimited strings, for each tier (record in the OBT or IBT collection). Those collections are used as the bases for multiple select shuttles when the user edits an individual tier.
Here is the collection code for what I am doing.
When the user chooses an agreement to work with, by clicking on an edit link, they are sent to page 17 (as you see referenced in the code). That page has the on-demand process below triggered on load, after footer.
-- This process Loads the collections used
-- for the Inbound and Outbound tier details
-- OBTCOLLECTION
-- IBTCOLLECTION
-- It is an on-demand process called on load (after footer) of page 17 --
-- OUTBOUND TIER COLLECTION --
if htmldb_collection.collection_exists( 'OBTCOLLECTION') = TRUE then
htmldb_collection.delete_collection(p_collection_name => 'OBTCOLLECTION' );
end if;
htmldb_collection.create_collection_from_query(
p_collection_name => 'OBTCOLLECTION',
p_query => 'select ID, AGREEMENT_ID, FIXED_MOBILE_ALL,
OF_TYPE,TIER, START_MIN, END_MIN,
REVERT_TO, RATE,CURRENCY,
PENALTY_RATE, PENALTY_CURR,
PRODUCT,CITY, DIAL_CODE_GROUP, PERIOD,
to_char(START_DATE,''MM/DD/YYYY''),
to_char(END_DATE,''MM/DD/YYYY''),
MONTHLY,EXCLUDED,
''O'' original_flag
from outbound_tiers
where agreement_id = '''||:P17_ID ||'''
order by FIXED_MOBILE_ALL, ID',
p_generate_md5 => 'YES');
-- INBOUND TIER COLLECTION --
if htmldb_collection.collection_exists( 'IBTCOLLECTION') = TRUE then
htmldb_collection.delete_collection(p_collection_name => 'IBTCOLLECTION' );
end if;
htmldb_collection.create_collection_from_query(
p_collection_name => 'IBTCOLLECTION',
p_query => 'select ID, AGREEMENT_ID, FIXED_MOBILE_ALL,
OF_TYPE,TIER, START_MIN, END_MIN,
REVERT_TO, RATE,CURRENCY,
PENALTY_RATE, PENALTY_CURR,
PRODUCT,CITY, DIAL_CODE_GROUP, PERIOD,
to_char(START_DATE,''MM/DD/YYYY''),
to_char(END_DATE,''MM/DD/YYYY''),
MONTHLY,EXCLUDED,
''O'' original_flag
from inbound_tiers
where agreement_id = '''||:P17_ID ||'''
order by FIXED_MOBILE_ALL, ID',
p_generate_md5 => 'YES');
commit;The tables each of these collections is created from are each about 2000 rows.
This part is working well enough.
Next, when the user chooses to view the tier information (either inbound or Outbound) they navigate to either of two pages that have the on-demand process below triggered on load, after header.
-- This process Loads all of the collections used
-- for the multiple select shuttles --
-- DCGCOLLECTION
-- CITYCOLLECTION
-- PRODCOLLECTION
-- PRDCOLLECTION
-- It is an on-demand process called on load (after footer) --
DECLARE
dcg_string long;
dcg varchar2(100);
city_string long;
the_city varchar2(100);
prod_string long;
prod varchar2(100);
prd_string long;
prd varchar2(100);
end_char varchar2(1);
n number;
CURSOR shuttle_cur IS
SELECT seq_id obt_seq_id,
c013 product,
c014 city,
c015 dial_code_group,
c016 period
FROM htmldb_collections
WHERE collection_name = 'OBTCOLLECTION';
shuttle_rec shuttle_cur%ROWTYPE;
BEGIN
-- CREATE OR TRUNCATE DIAL CODE GROUP COLLECTION FOR MULTIPLE SELECT SHUTTLES --
htmldb_collection.create_or_truncate_collection(
p_collection_name => 'DCGCOLLECTION');
-- CREATE OR TRUNCATE CITY COLLECTION FOR MULTIPLE SELECT SHUTTLES --
htmldb_collection.create_or_truncate_collection(
p_collection_name => 'CITYCOLLECTION');
-- CREATE OR TRUNCATE PRODUCT COLLECTION FOR MULTIPLE SELECT SHUTTLES --
htmldb_collection.create_or_truncate_collection(
p_collection_name => 'PRODCOLLECTION');
-- CREATE OR TRUNCATE PERIOD COLLECTION FOR MULTIPLE SELECT SHUTTLES --
htmldb_collection.create_or_truncate_collection(
p_collection_name => 'PRDCOLLECTION');
-- LOAD COLLECTIONS BY LOOPING THROUGH CURSOR.
OPEN shuttle_cur;
LOOP
FETCH shuttle_cur INTO shuttle_rec;
EXIT WHEN shuttle_cur%NOTFOUND;
-- DIAL CODE GROUP --
dcg_string := shuttle_rec.dial_code_group ;
end_char := substr(dcg_string,-1,1);
if end_char != ';' then
dcg_string := dcg_string || ';' ;
end if;
LOOP
EXIT WHEN dcg_string is null;
n := instr(dcg_string,';');
dcg := ltrim( rtrim( substr( dcg_string, 1, n-1 ) ) );
dcg_string := substr( dcg_string, n+1 );
if length(dcg) > 1 then
htmldb_collection.add_member(
p_collection_name => 'DCGCOLLECTION',
p_c001 => shuttle_rec.obt_seq_id,
p_c002 => dcg,
p_generate_md5 => 'NO');
end if;
END LOOP;
-- CITY --
city_string := shuttle_rec.city ;
end_char := substr(city_string,-1,1);
if end_char != ';' then
city_string := city_string || ';' ;
end if;
LOOP
EXIT WHEN city_string is null;
n := instr(city_string,';');
the_city := ltrim( rtrim( substr( city_string, 1, n-1 ) ) );
city_string := substr( city_string, n+1 );
if length(the_city) > 1 then
htmldb_collection.add_member(
p_collection_name => 'CITYCOLLECTION',
p_c001 => shuttle_rec.obt_seq_id,
p_c002 => the_city,
p_generate_md5 => 'NO');
end if;
END LOOP;
-- PRODUCT --
prod_string := shuttle_rec.product ;
end_char := substr(prod_string,-1,1);
if end_char != ';' then
prod_string := prod_string || ';' ;
end if;
LOOP
EXIT WHEN prod_string is null;
n := instr(prod_string,';');
prod := ltrim( rtrim( substr( prod_string, 1, n-1 ) ) );
prod_string := substr( prod_string, n+1 );
if length(prod) > 1 then
htmldb_collection.add_member(
p_collection_name => 'PRODCOLLECTION',
p_c001 => shuttle_rec.obt_seq_id,
p_c002 => prod,
p_generate_md5 => 'NO');
end if;
END LOOP;
-- PERIOD --
prd_string := shuttle_rec.period ;
end_char := substr(prd_string,-1,1);
if end_char != ';' then
prd_string := prd_string || ';' ;
end if;
LOOP
EXIT WHEN prd_string is null;
n := instr(prd_string,';');
prd := ltrim( rtrim( substr( prd_string, 1, n-1 ) ) );
prd_string := substr( prd_string, n+1 );
if length(prd) > 1 then
htmldb_collection.add_member(
p_collection_name => 'PRDCOLLECTION',
p_c001 => shuttle_rec.obt_seq_id,
p_c002 => prd,
p_generate_md5 => 'NO');
end if;
END LOOP;
END LOOP;
CLOSE shuttle_cur;
commit;
END;Creating these collections from the initial collection is taking way too long. The page is rendered after about 22 seconds (when tier collection has 2 rows) and 10 minutes worst case (when the tier collection has 56 rows).
Thank you in advance for any advice you may have.Try to instrument/profile your code by putting timing statements after each operation. This way you can tell which parts are taking the most time and address them.
-
JWS1.2 & Missing version field in response
I must say that the guys with JWS1.2 have done well in getting around the proxy issues with the previous versions. However, its disappointing to see this error still occuring when you perform a version based download which is one of the most useful pieces of functionality in JWS (see quote below) . So when a cleint has proxy issues its goodbye 'Bad MIME type error' and hello 'Missing version field in response from server when accessing resource'. Is this really progress? Surely most people use version based downloads?
Will this be fixed for 1.4.1 final and / or does anybody know of a workaround? I've included a previous quote, our jnlp, errors and stack dump below.
Many thanks
Ian
Quote from dietz Jul9, 2002
"The problem is probably that your proxy server is not passing on the correct mime type. Some proxy servers (I'm sorry I don't remember which ones) will only pass on mime types that they are aware of, and will substitute text/html, for others. This should be no problem when using Java Web Start 1.2, since it itself does not require that jnlp files download come with the proper mime type. You may still have a problem using these proxy servers if you are running a servlet implementing the jardiff (incremental update) protocol, since Java Web Start may use the mime type to differenciate between jar files (application/x-java-archive) and jardiff files (application/x-java-archive-diff) "
An error occurred while launching/running the application.
Title: OS MasterMap Viewer
Vendor: Snowflake Software
Category: Download Error
Missing version field in response from server when accessing resource: (http://www.snowflakesoft.co.uk/app/viewer.jar, 1.1)
Stack dump:
JNLPException[category: Download Error : Exception: null : LaunchDesc: null ] at com.sun.javaws.cache.DownloadProtocol.doDownload(Unknown Source) at com.sun.javaws.cache.DownloadProtocol.getDownloadSize(Unknown Source) at com.sun.javaws.LaunchDownload.downloadJarFiles(Unknown Source) at com.sun.javaws.LaunchDownload.downloadEagerorAll(Unknown Source) at com.sun.javaws.Launcher.downloadResources(Unknown Source) at com.sun.javaws.Launcher.handleApplicationDesc(Unknown Source) at com.sun.javaws.Launcher.handleLaunchFile(Unknown Source) at com.sun.javaws.Launcher.run(Unknown Source) at java.lang.Thread.run(Unknown Source)
JNLP:
<?xml version="1.0" encoding="UTF-8"?>
<jnlp spec="1.0+" codebase="http://www.snowflakesoft.co.uk/app/" href="viewer.jnlp">
<information>
<title>OS MasterMap Viewer</title>
<vendor>Snowflake Software</vendor>
<description kind="one-line">A Java based map viewer for OS MasterMap</description>
<description kind="short">A Java based viewer for OS MasterMap capable of reading both Topology and Independent Polygons in either GZip, WinZip or uncompressed GML</description>
<description kind="tooltip">OS MasterMap Viewer</description>
<homepage href="http://www.snowflakesoft.co.uk"/>
<icon width="64" height="64" href="images/SnowflakeLogo64.gif"/>
<icon width="32" height="32" href="images/SnowflakeLogo32.gif"/>
<icon kind="splash" href="images/SnowflakeSplash.gif"/>
<offline-allowed/>
</information>
<security>
<all-permissions/>
</security>
<resources>
<j2se version="1.3*" href="http://java.sun.com/products/autodl/j2se" initial-heap-size="8m" max-heap-size="1024m"/>
<j2se version="1.4*" href="http://java.sun.com/products/autodl/j2se" initial-heap-size="8m" max-heap-size="1024m"/>
<jar href="viewer.jar" version="1.1"/>
</resources>
<application-desc main class="uk.co.snowflakesoft.jme.application.Viewer"/>
</jnlp>Version based download protocol is not available with vanila web server.
You need to either run some form of script, jsp, or a servlet such as the JNLPDownloadServlet included in the developers pack, to return the requested version, and with the version information.
If you are currently running the servlet you may still be having problem with your proxy having security settings that prohibit sending the additional version information on to the client, although I have never heard of this before.
/Dietz -
Hi all,
i want to know abt decode function in oracle-sql
i..e passing the parameters in decode using decode using ":" bind parameter
select JOB, decode(:j,'CLERK','MANAGER','ANALYST','EXEC',JOB) FROM EMP;
i declared the j variable in sql environment
VARIABLE J VARCHAR2(20);
i exec the query
and passed as the clerk as input parameter
but iam getting the o/p as
JOB DECODE(:J
MANAGER MANAGER
MANAGER MANAGER
MANAGER MANAGER
SALESMAN SALESMAN
SALESMAN SALESMAN
SALESMAN SALESMAN
CLERK CLERK
SALESMAN SALESMAN
ANALYST ANALYST
CLERK CLERK
ANALYST ANALYST
JOB DECODE(:J
CLERK CLERK
12 rows selected.
SQL> PRINT J;
J
im not getting o/p
so please hlelp me only : should be used not &
this is my first thread.
execuse me if any mistakes
tons of thanks in advance to allSORRY DAVE,ROD FOR NOT BEING CLEAR,
IAM WORKING WITH EMP TABLE THE DATA IN IT IS LIKE THIS
EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO
7698 BLAKE MANAGER 7839 01-MAY-81 2850 30
7782 CLARK MANAGER 7839 09-JUN-81 2450 10
7566 JONES MANAGER 7839 02-APR-81 2975 20
7654 MARTIN SALESMAN 7698 28-SEP-81 1250 1400 30
7499 chaitu SALESMAN 7698 20-FEB-81 1600 300 10
7844 TURNER SALESMAN 7698 08-SEP-81 1500 0 30
7900 JAMES CLERK 7698 03-DEC-81 950 30
7521 WARD SALESMAN 7698 22-FEB-81 1250 500 30
7902 FORD ANALYST 7566 03-DEC-81 3000 20
7369 SMITH CLERK 7902 17-DEC-80 800 20
7788 SCOTT ANALYST 7566 09-DEC-82 3000 20
EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO
7876 ADAMS CLERK 7788 12-JAN-83 1100 20
AND I USED DECODE FUNCTION
select JOB BEFOREPROMOTION, decode(job,'CLERK','MANAGER','ANALYST','EXEC') PROMOTION FROM EMP
BEFOREPRO PROMOTI
MANAGER
MANAGER
MANAGER
SALESMAN
SALESMAN
SALESMAN
CLERK MANAGER
SALESMAN
ANALYST EXEC
CLERK MANAGER
ANALYST EXEC
I..E ALL THE CLERKS TO MANAGERS AND SAME THING WITH ANALYST
OK
NOW I WILL SHOW U ANOTHER QUERY
select job,decode(job,'CLERK','MANAGER','ANALYST','EXEC',JOB) FROM EMP where job=&job;
Enter value for job: 'CLERK'
old 1: select job,decode(job,'CLERK','MANAGER','ANALYST','EXEC',JOB) FROM EMP where job=&job
new 1: select job,decode(job,'CLERK','MANAGER','ANALYST','EXEC',JOB) FROM EMP where job='CLERK'
JOB DECODE(JO
CLERK MANAGER
CLERK MANAGER
CLERK MANAGER
HERE OBSERVE THAT I PASSED JOB ='CLERKS AS PARAMETER AFTER EXECUTING THE QUERY
IT ASKED LIKE THIS AND SHOWED THE REPLACED VALUES
Enter value for job: 'CLERK'
AS SHOWN ABOVE
FOR THIS TO PASS VALUE
IN TO THE QUERY BY USING AMPERSAND('&')
TO TAKE INPUT AS CLERK
IT CHECKED AND RETURNED THE VALUE
IN THE SIMILAR WAY CAN I USE ":" COLON
TO PASS PARAMETERS
IN TO THE QUERY
CAN I USE IT
REGARDS,
PHANI
Edited by: user10652894 on Nov 26, 2008 3:24 AM -
Using DECODE Function to change data
I am trying to use the Decode function in a SQL statement to find a field that has a specific type, and when it finds that type, I want to blank out the results in a different field.
For example:
DECODE(ADDR_TYPE,'HOME',PHONE='') HOME_PHONEsomething like:
SQL> with t as
2 (select 219 id,
3 'BUS' addr_type,
4 '505-555-5555' phone
5 from dual
6 union
7 select 219 id,
8 'HOME' addr_type,
9 null phone
10 from dual
11 union
12 select 220 id,
13 'BUS' addr_type,
14 '101-111-1111' phone
15 from dual
16 union
17 select 220 id,
18 'HOME' addr_type,
19 null phone
20 from dual
21 union
22 select 223 id,
23 'BUS' addr_type,
24 '202-222-2222' phone
25 from dual
26 union
27 select 224 id,
28 'HOME' addr_type,
29 '303-333-3333' phone
30 from dual
31 union
32 select 225 id,
33 'BUS' addr_type,
34 null phone
35 from dual
36 union
37 select 226 id,
38 'HOME' addr_type,
39 null phone
40 from dual)
41 select a.id,
42 a.addr_type,
43 decode(a.addr_type,'BUS',phone,null) phone
44 from (select id, addr_type, phone,
45 row_number() over (partition by id order by id, decode(addr_type,'BUS',1,2)) rn
46 from t) a
47 where a.rn = 1;
ID ADDR PHONE
219 BUS 505-555-5555
220 BUS 101-111-1111
223 BUS 202-222-2222
224 HOME
225 BUS
226 HOME
6 rows selected.
SQL> -
Error while replacing IF statements with DECODE function in procedure
Hi All,
I have created a procedure which has nested IF statements. Now I want to replace the IF statements with DECODE functions to improve performance.
Procedure:
IF (var_int_sev = '0')
THEN
var_sev := '2';
ELSE
SELECT sev
INTO var_int_sev
FROM errorconfig
WHERE errorcode = var_errorcode;
var_sev := var_int_sev;
END IF;
I converted the above IF statement into DECODE function as mentioned below:
var_Sev := DECODE(var_int_sev,0,2,SELECT severity FROM errorconfig WHERE errorcode=var_ErrorCode)
But it throws below error at the select statement used inside DECODE.
Error(58,51): PLS-00103: Encountered the symbol "SELECT" when expecting one of the following: ( - + case mod new not null others <an identifier> <a double-quoted delimited-identifier> <a bind variable> avg count current exists max min prior sql stddev sum variance execute forall merge time timestamp interval date <a string literal with character set specification> <a number> <a single-quoted SQL string> pipe <an alternatively-quoted string literal with character set specification> <an alternativ
Can someone help me in converting the IF to DECODE in the above case. Also how can we use a select statement inside decode.instead of trying to rewrite all your code and hoping that the performance will be better, it's a better option to investigate and find out which part of your application is slow
read this:
When your query takes too long ... -
Help on Decode function in Toplink
Hi,
I have a sql statement like this:
select field1, field2 from table1 where upper(field1) like 'ADELPHI%'
order by field1,
DECODE(TO_CHAR(NVL(LENGTH(TRANSLATE(field1,'A1234567890','A')),0)),'0',LPAD(field1 ,50),field1)
How would I converted this to toplink query?
I appreciate any help you guys can extend to me.I just spent about a half hour writing a response here, and the damned forum timed out on me. #$^!@$#!^!@$%.
Here is the summary:
- Using TL Expressions and EJBQL are to allow Java developers who don't necessarily know SQL to write queries and to facilitate portability/maintainability of the apps. For REALLY gnarly queries, using TL Expressions or EJBQL won't buy you this. I.e., SQL is more expressive and easier for this kind of quer, so it's not easier to use, and frankly with the code needed to support it, it won't be easier to maintain or port... Bottom line, maybe SQL is the best option here?
- If you want to experiment, search for TO_CHAR on this forum, and the decode function in the javadoc. You need to build the expressions in pieces and you can treat expressions as arguments to other expressions -- in other words, you can build an expression like builder.leftPad(50, builder.get("field1")) and use it as one of the key/values in the hashtable to the decode function (in theory).
- Don -
SQL*Loader and DECODE function
Hi All,
I am loading data from data files into oracle tables and while loading the data using SQL*Loader, the following requirement needs to be fulfilled.
1) If OQPR < 300, RB = $ 0-299, SC = "SC1"
2) If 300 < OQPR < 1200, RB = $ 300-1199, SC = "SC2"
3) If 1200 < OQPR < 3000, RB = $ 1200-2999, SC = "SC3"
4) If OQPR > 3000 USD, RB = > $3000, SC = "SC4"
Here OPQR is a field in the data file.
Can anyone suggest how do we handle this using DECODE function? Triggers and PL/SQL functions are not to be used.
TIA.
Regards,
Ravi.The following expression gives you different values for your different intervals and boundaries :
SIGN(:OQPR - 300) + SIGN(:OQPR - 1200) + SIGN(:OQPR - 3000) -
Decode function in Update statement
Hello everyone,
I'm trying to write a query where I can update a pastdue_fees column in a book_trans table based on a difference between return_dte and due_dte columns.
I am using Oracle SQL. This is what I have so far for my decode function:
SQL> SELECT
2 DECODE(SIGN((return_dte - due_dte)*2),
3 '-1', '0',
4 '1', '12', 'Null')
5 FROM book_trans;
DECO
Null
12
Null
0
So the logic is that if the sign is -1, the value in return_dte column should be 0; if it's +1 then it's 12 and everything else is Null.
So now, I need to enter my decode function into the update statement to update the columns. However, I get error messages.
The logic should be:
UPDATE book_trans SET PastDue_fees = decode(expression)
I've given it a couple of different tries with the following results:
SQL> UPDATE book_trans
2 SET pastdue_fees = SELECT
3 DECODE(SIGN((return_dte - due_dte)*2),
4 '-1', '0',
5 '1', '12', 'Null')
6 FROM book_trans;
SET pastdue_fees = SELECT
ERROR at line 2:
ORA-00936: missing expression
SQL> UPDATE book_trans
2 SET pastdue_fees =
3 DECODE(SIGN((return_dte - due_dte)*2),
4 '-1', '0',
5 '1', '12', 'Null')
6 FROM book_trans;
FROM book_trans
ERROR at line 6:
ORA-00933: SQL command not properly ended
Any help or tips would be greatly appreciated as I've been taking SQL for about six weeks and not very proficient!
Thanks!882300 wrote:
Hello everyone,
I'm trying to write a query where I can update a pastdue_fees column in a book_trans table based on a difference between return_dte and due_dte columns.
I am using Oracle SQL. This is what I have so far for my decode function:
SQL> SELECT
2 DECODE(SIGN((return_dte - due_dte)*2),
3 '-1', '0',
4 '1', '12', 'Null')
5 FROM book_trans;
DECO
Null
12
Null
0
So the logic is that if the sign is -1, the value in return_dte column should be 0; if it's +1 then it's 12 and everything else is Null.
So now, I need to enter my decode function into the update statement to update the columns. However, I get error messages.
The logic should be:
UPDATE book_trans SET PastDue_fees = decode(expression)
I've given it a couple of different tries with the following results:
SQL> UPDATE book_trans
2 SET pastdue_fees = SELECT
3 DECODE(SIGN((return_dte - due_dte)*2),
4 '-1', '0',
5 '1', '12', 'Null')
6 FROM book_trans;
SET pastdue_fees = SELECT
ERROR at line 2:
ORA-00936: missing expression
SQL> UPDATE book_trans
2 SET pastdue_fees =
3 DECODE(SIGN((return_dte - due_dte)*2),
4 '-1', '0',
5 '1', '12', 'Null')
6 FROM book_trans;
FROM book_trans
ERROR at line 6:
ORA-00933: SQL command not properly ended
Any help or tips would be greatly appreciated as I've been taking SQL for about six weeks and not very proficient!
Thanks!If you really really really want to update the entire table, the syntax would be...
UPDATE book_trans
SET
pastdue_fees = DECODE(SIGN((return_dte - due_dte)*2), -1, 0, 1, 12, Null);I took out all the single quotes. If you actually have a string column and you're storing entirely numbers in it then it should be declared as a NUMBER column and not a character (varchar2) column.
ALWAYS use the proper data type, it'll save you a ton of headaches in the future.
Also, since you're new to the forum, please read the FAQ so you learn the etiquette and what not.
http://wikis.sun.com/display/Forums/Forums+FAQ -
How do I create a dynamic parameter based on a formula?
Hi,
I've developed a report, in CR 11, that is parameterized based on the field "ticket_date". I've created a Min and a Max formula so that I can select a date range. This works wonderfully. However, my date list is growing longer by the day and each day I have to run the report I need to scroll through an even longer list of date values. This will become increasingly impractical with each passing month and year. I would like create a "Year" paramater and a "Month" parameter so that I can first select the Year, then the month(s), then the dates.
When I attempted to create a parameter based on the formula, "Year (), the formula wasn't in the list of available values to create a parameter on.
How can I address this requirement?
thanks in advance!
MarkHi Abhilash,
Looks like I was able to create a Year field in the Command - thanks for the tip!
Before I close this off as answered can you take a look at two sets of SQL I wrote in the Command that I'm getting errors on and offer advice on where the error is occurring.
Example 1
The SQL I attempted to write must be close though:
Select ft.sequence, ft.ticket_date, coff.office_name, comp.subscriptions_id from
field_tickets as ft, company_offices as coff, companies as comp
INNER JOIN jobs ON comp.companies_id=jobs.companies_id
INNER JOIN field_tickets ON jobs.jobs_id=field_tickets.jobs_id
LEFT JOIN company_offices ON jobs.company_offices_id=company_offices.company_offices_id
Where comp.subscriptions_id=7.00
When I attempt to save this I get an error:
"Failed to retrieve data from the database. Details: Exception: Error Message: Java Heap Space"
Example 2
I get the error, "Not unique table/alias: 'custom_jobs_values'" for the following SQL Command
SELECT companies., jobs., field_tickets., regions., customers., custom_jobs_values. FROM
companies, jobs, field_tickets, regions, customers, custom_jobs_values
LEFT JOIN custom_jobs_values ON jobs.jobs_id=custom_jobs_values.jobs_id
INNER JOIN regions ON companies.regions_id=regions.regions_id
INNER JOIN jobs ON companies.companies_id=jobs.companies_id
INNER JOIN field_tickets ON jobs.jobs_id=field_tickets.jobs_id
INNER JOIN customers ON jobs.customers_id=customers.customers_id and
companies.subscriptions_id=4.00
thanks!
Mark -
Limit values shown in Parameter based on current week
We have a requirement wherein a parameter can be chosen depending on the current week number.
For example, today is Feb 3, 2015 (WEEK NUMBER 6), the parameter dropdown should only show
Week 1
Week 2
Week 3
Week 4
Week 5
Upon choosing a specific week, i.e. Week 2, SSRS report will show data where Created By matches the dates in Week 2 which is from January 4, 2015 to January 10, 2015 (SUNDAY is the first day week)
----------------------- Sharepoint NewbieHi 120613,
Because you are using the sharepoint list as the datasource and have some limitation when using query in the dataset, so I recommend you to take reference of the alternative method below which will not effect the filter of the data, you can create an calculated
field which will use to create the week parameter, the values of the Week list are before the week number of the today's date and get based on the date field in the report.
Details information below for your reference:
Create an new dataset(DataSet2) to add the query which have the same structure as in the main dataset but only contain the field "Date".
Right click the DataSet2 to select the "Add Calculated field" and create an new calculatted fields: name : "Week" and using expression below to get the value(The value will be the week number before the current date's week
number):
=IIF(DatePart("ww",Fields!date.Value)<DatePart("ww",Today()),DatePart("ww",Fields!date.Value),Nothing)
Create the parameter week based on the Calculated field "Week", specify both the Available value and default value by "Get Values from a query"
Add the filter in the Dataset as below:
Expression:=DatePart("ww",Fields!Date.Value)
Operator:In
Value: [@Week]
Preview you will got the result as below:
If the parameter is Multiple and you got some duplicate values, please reference to the article
Visakh16 have provided.
If you still have any questions, please feel free to ask.
Regards
Vicky Liu
If you have any feedback on our support, please click
here.
Vicky Liu
TechNet Community Support -
Slow Response Sun ONE 6.1 SP3 Win 2003
My Sun ONE web server is processing my JSP pages very quickly when serving one session at a time. However when there are 4 or more active sessions, it slows right down. Response time goes from 2 seconds (1 active session) to 60 seconds (multiple active sessions) for a single JSP page. I've been running the performance monitor to see if I can notice anything, but nothing seems to stand out. I have tried manipulating the Keep Alive settings and the Performance settings within the Magnus Editor but there hasn't been a noticable improvement.
I've recently upgraded to SP4 to see if this solved my problem, but there was no imporvement.
This server is an HP DL380 with dual 2.8GHz Xeon processors & 2 Gigs of RAM. There is a lot of available disk space. I'm running Windows 2003 and it's up to date with all the latest patches.
Anyone have any ideas or experienced this before?
I've attached the output from my performance monitor:
webservd pid: 4280
Sun ONE Web Server 6.1SP4 B01/20/2005 21:34 (WINNT DOMESTIC)
Server started Thu Mar 03 09:41:06 2005
Process 4280 started Thu Mar 03 09:41:06 2005
ConnectionQueue:
Current/Peak/Limit Queue Length 0/1/4096
Total Connections Queued 126
Average Queue Length (1, 5, 15 minutes) 0.00, 0.00, 0.00
Average Queueing Delay 0.02 milliseconds
ListenSocket ls1:
Address http://10.178.132.7:8080
Acceptor Threads 8
Default Virtual Server https-guruweb01
KeepAliveInfo:
KeepAliveCount 2/64
KeepAliveHits 1083
KeepAliveFlushes 0
KeepAliveRefusals 0
KeepAliveTimeouts 11
KeepAliveTimeout 360 seconds
SessionCreationInfo:
Active Sessions 2
Keep-Alive Sessions 1
Total Sessions Created 48/256
CacheInfo:
enabled yes
CacheEntries 110/1024
Hit Ratio 1912/2164 ( 88.35%)
Maximum Age 30
Native pools:
NativePool:
Idle/Peak/Limit 5/6/128
Work Queue Length/Peak/Limit 0/1/0
Server DNS cache disabled
Async DNS disabled
Performance Counters:
Average Total Percent
Total number of requests: 1213
Request processing time: 1.5520 1882.5520
default-bucket (Default bucket)
Number of Requests: 1213 (100.00%)
Number of Invocations: 15085 (100.00%)
Latency: 0.0002 0.2013 ( 0.01%)
Function Processing Time: 1.5518 1882.3507 ( 99.99%)
Total Response Time: 1.5520 1882.5520 (100.00%)
Sessions:
Process Status Function
4280 keep-alive
response service-dump
response service-j2ee
Thanks...The JSP's are simply Hello World JSP's (however I created these type of JSP's for testing and they do respond slowly as well when these are multiple sessions).
These JSP functioned fine on iPlanet 6.0 SP1 (JDK 1.2.2) without any slow response on Win2K and inferior hardware. -
Question on the parameter type of DLL functions
Question on the parameter type of DLL functions
I am trying to develop an interface to control a laser with LV8.2 I am planing to use the VI “Call Library Function Node” to call the DLL and set the exact same parameters of functions in the DLL.
According to the DLL manual of the laser, there are six functions. One of the prototypes is: function getstatuspointer : pointer. I don't know how to set this parameter for the function. Is there anyone who can give some hints? Thanks!
BTW :The following is a description of the function:
This function returns a 32 bit pointer to the STATUS data structure (Tstatusrec). In the 32 bit DLL, every application is using its own copy of the data structure (local
memory). The data structure is a packed structure. "packed" means that the fields in the structure are not aligned on word or double-word boundaries.
Tstatusrec = packed record
size : word;
initstat : byte;
queuefill : byte;
anzapp16 : word; (not used)
anzapp32 : word;
anzdock16 : word; (not used)
anzdock32 : word;
dll16ver : tchararray; (not used)
dll32ver : tchararray;
excimerver : tchararray;
excimer : TExcimerStatus;
end;Hi Jack,
This is a good starting point when using Call Library Function node. Check out this Help Page
Van L
NI Applications Engineer
Maybe you are looking for
-
3rd week of MacBook ownership.. my observations and questions...
Note: I have 2 main questions below.. if you don't want to read my thoughts, skip below... I bought a Black MacBook about 3 weeks ago from CompUSA.. 18 months no interest and an interested buyer for my windows laptop--I had to go for it. This is my f
-
LOST EVERYTHING AFTER 2.0 UPDATE
Fellow iPhoners Recently I upgraded to the 2.0 update which went through smoothly, it restored my iphone with my up to date contacts and other information. I got the apps. store and downloaded a couple apps. and everthing was fine. Well the next day
-
IPhoto'08 inverted colors after import
I've been having problems with photos imported into iPhoto Camera is Canon IXUS 70. After transfer to the desktop it looks fine in Preview, but once transferred to iPhoto it appears violet, inverted or negative? I tried all the methods but nothing wo
-
Hello Experts, Can any of you help me with a workflow administrator tcode that has the ability to find all the workitem using the user ID. Im aware of the tcodes that can be used to find the workflow status with the task - dates etc... but im not abl
-
Hello, I tried searching on a lot of sites but need a conclusive answer. I am having problems with a highly-loaded servers, and concluded that the connection hangs ALWAYS for the first 80 packets then continues as normal ( eg. ping hangs for first 80