Question about sql statement
Hi expert,
I have following sql statement, function 'hiroc_get_delta_amount1' and 'hiroc_get_delta_amount2' are separately used in select and where subclause. these two function are exactly same, except that there is a inserting log statement inside. for function 'hiroc_get_delta_amount1' , logs are supposed to write into log table1, whereas for function 'hiroc_get_delta_amount2' , logs are supposed to write into log table2. after running this sql, I got data loaded into log table2, however, there is no data loaded into log table1.
could you please tell me why there is no data in log table2 for function
1. sql statement;
select
pp.policy_premium_pk,
pp.policy_fk,
pp.policy_term_fk,
pp.risk_fk,
pp.coverage_fk,
pp.transaction_log_fk,
pp.coverage_component_code,
hiroc_rpt_user.hiroc_get_delta_amount1(pp.policy_fk, pp.policy_term_fk, pp.risk_fk, pp.coverage_fk, pp.transaction_log_fk, pp.coverage_component_code),
pp.rate_period_from_date
from PRODBKUPDW_MART.rmv_policy_premium pp
where pp.rate_period_type_code = 'TERM_COVG'
and pp.coverage_component_code 'NETPREM'
and hiroc_rpt_user.hiroc_get_delta_amount2(pp.policy_fk, pp.policy_term_fk, pp.risk_fk, pp.coverage_fk, pp.transaction_log_fk, pp.coverage_component_code) != 0
group by pp.policy_premium_pk,
pp.policy_premium_pk,
pp.policy_fk,
pp.policy_term_fk,
pp.risk_fk,
pp.coverage_fk,
pp.transaction_log_fk,
pp.coverage_component_code,
pp.rate_period_from_date;
2. log inserting statement used for both functions:
(1) function 'hiroc_get_delta_amount1'
insert into HIROC_RPT_USER.LOG_TEST1 values (v_start, sysdate,
p_policy_fk,p_policy_term_history_fk,p_risk_fk,p_coverage_fk,p_transaction_log_fk,p_comp_code);
COMMIT;
(2) function 'HIROC_GET_DELTA_AMOUNT_1'
insert into HIROC_RPT_USER.LOG_ZB_TEST_1 values (v_start, sysdate,
p_policy_fk,p_policy_term_history_fk,p_risk_fk,p_coverage_fk,p_transaction_log_fk,p_comp_code);
COMMIT;
Are your functions using autonomous transactions?
We also need more information about the log tables etc. as we cannot tell what the problem would be from just that query, and no data.
Similar Messages
-
Question about delete statement
I have question about delete statement...
i am performing some simple delete statement against one table..but its taking so long..How can we check whether particular delete statements actually deleting records or not..?Is the associated select-statement returning rows or not?
If yes -> delete is deleting
If no -> delete is just using CPU-cycles
To tune the delete-statement, you have to tune the corresponding select-statement. To tune the select-statement, you want to read the thread When your query takes too long ... -
for example:
select
from testtable
outputs below results:
item_desc
950gapple(z)110ml*40
650gbanana(z)215ml 1x18
make above example outputs below result:
item_desc
a950gapplez110ml40
a650gbananaz215ml1x18
how to write above sql code?
who can help me?
thanksJameel Provided solution to one of your other thread
a question about sql code
Try the below query. You can modify the TRANSLATE function to add the characters you want to remove from the string.
select 'a'||replace(translate(str,'()* ','`'),'`') from testtable -
Question about sql batch process in java app
hi all
i have few questions about using batch process in the java.sql package. the addBatch method can take sql statements like inserts or updates. can we use a mixture of insert and update then? can we use prepared statement for this? it's just for performance consideration. thanks in advance.hi all
i have few questions about using batch process in the
java.sql package. the addBatch method can take sql
statements like inserts or updates. addBatch() is a method that has no parameters. It doesn't 'add' sql statements.
can we use a
mixture of insert and update then? can we use
prepared statement for this? it's just for
performance consideration. thanks in advance.The point of batching is that you take something that is invariant and then 'add' a variant part.
Thus a single insert has an invariant part (the table and specific columns) and a variant part (the data for each row by column.)
You can use anything that is valid SQL (for jdbc, driver, database) and use it presuming your database allows that particular usage in batching. But that does require some regular pattern - it won't work if your usage is random. Nor will it work if some statements need to be executed only some of the time. Finally also note that transaction processing will often require smaller chunks - you can't insert a million rows in one batch. -
Where to find information about SQL States ?
Hello,
I'm trying to find information about X/OPEN SQL States explanation. Can anyone help me. ?SQLStates are part of the SQL standard and so you can read up on them from any vendor's site.Here is an IBM explanation that talks about the SQLStates class (first two chars) and subcode.
http://publib.boulder.ibm.com/pubs/html/as400/v5r1/ic2924/index.htm?info/rzala/rzalaint.html -
Question about 'write' statement
Hi,
A question on write statement.
I have a internal table itab which has field var. I am looping at this itab and writing horizontal heading output like below.
example on the output heading:
(3 spaces) itab-var (20 spaces) itab-var (20 spaces) itab-var.
the coding is:
loop at itab.
write: 3 itab-var.
endloop.
I want to increase the space by 20 for every loop. How to increase this 3 by 20? Can we accomplish this way?
Thank you for your time.hi krishen,
just add 20 inside the loop , so that after every loop its value increases by 20
for example:
data: v type i.
v=3.
do 3 times.
write: at v(20).
v=v+20.
end do.
hope it will help you
regards
Rahul sharma
Edited by: RAHUL SHARMA on Sep 4, 2008 7:47 AM -
Using jdev11.1.1..5.0
select 1 from dual where DUMMY = :pdummy ;@ run time if i give :pdummy as String X means i get an value 1
so same try to do in AM.
public void dummy(String pdummy)
CallableStatement cs = null;
try{
String sql = "select 1 from dual where DUMMY = :pdummy ;" ;
cs = getDBTransaction().createCallableStatement(sql,0);
cs.registerOutParameter(1, Types.VARCHAR);
cs.setString(2,pdummy );
cs.executeUpdate();
catch(SQLException e)
throw new JboException(e);
finally
if (cs!=null)
try
cs.close();
catch (Exception e){System.out.println ("Dummy Exception Thrown "+e);}
}Error throwing such invalid index. can anyone re-correct me.public void dummy(String pdummy)
CallableStatement cs = null;
try{
String sql = "select 1 from dual where DUMMY = ?" ;
cs = getDBTransaction().createCallableStatement(sql,0);
cs.setString(1,pdummy );
System.out.println("ex"+ cs.execute());
catch(SQLException e)
throw new JboException(e);
finally
if (cs!=null)
try
cs.close();
catch (Exception e){System.out.println ("Dummy Exception Thrown "+e);}
}sir,
thank you but..i want to see the value of sql statement. how can i see that?
above code is working but i want to see the value.
so i did like this.
public String dummies(String pdummy)
CallableStatement cs = null;
try{
String sql = "select 1 from dual where DUMMY = ?" ;
cs = getDBTransaction().createCallableStatement(sql,0);
cs.setString(1,pdummy );
cs.execute();
return cs.getString(1);
catch(SQLException e)
throw new JboException(e);
finally
if (cs!=null)
try
cs.close();
catch (Exception e){System.out.println ("Dummy Exception Thrown "+e);}
}some invalid index error.. can show me way to see the value of sql statement.
Edited by: subu123 on Apr 18, 2012 1:59 AM -
Question about .sql.date ^o^..really pissed me off
The following code dosent work~~:(
String d = "2003-02-14";
Date myDate = java.sql.Date.valueOf(d);
sql="UPDATE Plan SET MyValue = '"+v+"' WHERE TraineeID = "+id+
" AND TheDate = "+myDate;
try {
stmt.executeUpdate(sql);
} catch(SQLException ex) {
System.err.println("SQLException: " + ex.getMessage());
I know the reason is the sql statement. Actually I dont know how to compare a Date object in WHERE statement...I think _* "AND TheDate = "+myDate; *_ is not correct, But dont know how to solve it... urgent~:( assignment due on next fridayActually I dont know how to compare a Date object in WHERE statement.If you insist on doing string comparisons to compare two dates, then you will have to find out how your database wants the date formatted. This varies by database, so check your database help. Then use SimpleDateFormat to get the date in that format.
My preference is to use a PreparedStatement, because it knows how the database formats dates:PreparedStatement ps =
conn.prepareStatement(
"UPDATE Plan SET MyValue = ? WHERE TraineeID = ? AND TheDate = ?");
ps.setString(1, v);
ps.setString(2, id);
ps.setDate(3, new java.sql.Date(yourDateObject.getTime()));
ps.executeUpdate(); -
Question about call statement in trigger
I faced a question in written exam.
A CALL statement inside a trigger allow us to call
a)package
b)procedure
c)function
d)another trigger
Can anyone give me answer with reason?
I used CALL statement inside trigger but not allowing to use it. Might be earlier in oracle CALL statement we can use..its only a guess so I am asking in forum..
plz guide me..
rgds,
pcYou can use CALL in a trigger without resorting to EXECUTE IMMEDIATE
SQL> create table t1 (
2 col1 number
3 );
Table created.
SQL> create procedure t1_proc
2 as
3 begin
4 dbms_output.put_line( 'In T1_PROC' );
5 end;
6 /
Procedure created.
SQL> ed
Wrote file afiedt.buf
1 create trigger trg_t1
2 before insert on t1
3 for each row
4* call t1_proc
5 /
Trigger created.
SQL> set serveroutput on;
SQL> insert into t1 values( 1 );
In T1_PROC
1 row created.I can't think of any reason that you'd actually intentionally structure your code this way in this day and age because it would be rather likely to cause confusion for whoever had to support this in the future. But it is valid syntax that probably made sense back in Oracle 5.
Justin -
Question about Merge Statement
Is it possible to use a CASE statement inside the update clause of a merge statement? Also what about a function?
I have a string (In Source) that needs to be split into multiple columns (In Target) depending on values in other columns (In Source).
I am on 11iR1Hi Chris,
You can take a look at the below examples :
SQL>create table t_test
col1,col2,col3
) as
select 1,2,3 from dual union all
select 2,3,4 from dual union all
select 3,4,2 from dual union all
select 9,10,12 from dual union all
select 11,23,43 from dual
create table succeeded.
SQL>select * from t_test;
COL1 COL2 COL3
1 2 3
2 3 4
3 4 2
9 10 12
11 23 43
SQL>merge INTO t_test t_t USING
SELECT
1 AS col1
FROM
dual
) d_d
ON
(d_d.col1 = t_t.col1)
WHEN matched THEN
UPDATE set
col2 = (
CASE
WHEN d_d.col1 = 1
THEN 123
ELSE -1
END );
1 rows merged
SQL>select * from t_test;
COL1 COL2 COL3
1 123 3
2 3 4
3 4 2
9 10 12
11 23 43 -
Beginner question about prepared statements...PLEASE help! :-)
First let me say thanks for the assistance. This is probably really easy to do, but I'm new to JSP and can't seem to figure it out.
I want to dynamically populate a table that shows whether a particular person has an appointment at a given date and time with a user. To do this, I want to query the MySQL database for the lastname of the person with the appointment that occurs with the user at the year, month, date, and time, in question.
THE CODE BELOW DOESN'T WORK (obviously) BUT SOMEWHAT ILLUSTRATES WHAT I'M TRYING TO ACCOMPLISH:
<%
Driver DriverTestRecordSet = (Driver)Class.forName(MM_website_DRIVER).newInstance();
Connection ConnTestRecordSet = DriverManager.getConnection(MM_website_STRING,MM_website_USERNAME,MM_website_PASSWORD);
PreparedStatement StatementTestRecordSet = ConnTestRecordSet.prepareStatement("SELECT lastname FROM appts_pid1 WHERE user_id='<%=(((Recordset1_data = Recordset1.getObject(user_id))==null || Recordset1.wasNull())?"":Recordset1_data)%>' AND year='<%= yy %>' AND month='<%= months[mm] %>' AND date='<%= dates[dd] %>' AND appttime='16:15:00'");
ResultSet TestRecordSet = StatementTestRecordSet.executeQuery();
boolean TestRecordSet_isEmpty = !TestRecordSet.next();
boolean TestRecordSet_hasData = !TestRecordSet_isEmpty;
Object TestRecordSet_data;
int TestRecordSet_numRows = 0;
%>
The real problem comes in the prepared statement portion. If I build the prepared statement with static values like below, EVERYTHING WORKS GREAT:
PreparedStatement StatementTestRecordSet = ConnTestRecordSet.prepareStatement("SELECT lastname FROM appts_pid1 WHERE user_id='1' AND year='2002' AND month='October' AND date='31' AND appttime='16:15:00'");
But when I try to use dynamic values, everything falls apart. It's not that the values aren't defined, I use the user_id, year <%= yy %>, month <%= months[mm] %>, etc. elsewhere on the page with no problems. It's just that I can't figure out how to use these dynamic values within the prepared statement.
Thanks for reading this far and thanks in advance for the help!!!!Hi PhineasGage
You are little bit wrong in your
your preparedStatement.
Expression tag within scriptlet tag is invalid.
Whenever you are appending the statement with
expression tag, append it with "+" and remove
expression tag.
Hopefully it will work
ThanksThanks for the response!
I know that the expression tag within scriptlet tag is invalid. I just need a workaround for what I want to do.
I'm unclear what you mean by "Whenever you are appending the statement with expression tag, append it with a "+" and remove expression tag".
Could you give an example?
In the meantime, I've been trying to digest the docs on prepared statements and have changed the code to look like:
PreparedStatement StatementTestRecordSet = ConnTestRecordSet.prepareStatement("SELECT lastname FROM appts_pid1 WHERE user_id= ? AND year= ? AND month= ? AND date= ? AND appttime='13:15:00'");
StatementTestRecordSet.setInt(1,1);
StatementTestRecordSet.setInt(2,2002);
StatementTestRecordSet.setString(3,"October");
StatementTestRecordSet.setInt(4,31);
Again, WITH THE STATIC VALUES, THIS WORKS FINE...but when I try to use expressions or variables like below, things don't work:
StatementTestRecordSet.setInt(2,<%= yy %>);
Obviously, I'm doing something wrong, but there has to be a way to use variables within the prepared statement.
ALSO, the values are being passed to this page via URL in the form:
samplepage?user_id=1&year=2002&month=October&date=31
Based upon this information, is there another way (outside of stored procedures in the db) to do what I want to do? I'm open to ideas. -
A question About SUBMIT statement
Hi,
By SUBMIT statement, i can trigger another report. If the called report runs into dump, how can i detech/catch the dump in the calling report? I tested. It seems impossible to catch the dump. The calling report will also dump.
My question is, if the called report runs into dump, how to detect the dump and avoid dump in calling report?
Thanks in advance,
Best Regards, Johnney.hi
you can catch this kind of error or exeption from the respective report
then pass this error or exeception to the calling report
go through the example I am giving , ti have done it like this only
SUBMIT zgurep03 AND RETURN WITH SELECTION-TABLE li_seltab .
then in the called reprot
*Check ledger
SELECT SINGLE * FROM t881 WHERE rldnr = p_rldnr.
IF sy-subrc NE 0.
SET CURSOR FIELD 'P_RLDNR'.
MESSAGE e448 WITH p_rldnr
MESSAGE e446 INTO lv_text .
lv_type = 'E'.
Capturing the error messages.
EXPORT lv_text TO MEMORY ID 'TX'(004).
EXPORT lv_type TO MEMORY ID 'TP'(005).
in calling report
IMPORT gv_type1 TO gv_type FROM MEMORY ID 'TP'.
IMPORT gv_text1 TO gv_text FROM MEMORY ID 'TX'.
preparing error message in the callge report for the calling report
PERFORM prepare_message
USING sy-msgid
lv_msgno
lv_msgv1
lv_msgv2
lv_msgv3
lv_msgv4
CHANGING gv_text.
preparing error message
FORM prepare_message USING p_sy_msgid
p_sy_msgno
p_sy_msgv1
p_sy_msgv2
p_sy_msgv3
p_sy_msgv4
CHANGING p_gv_text.
CALL FUNCTION 'FORMAT_MESSAGE'
EXPORTING
id = p_sy_msgid
lang = 'EN'
no = p_sy_msgno
v1 = p_sy_msgv1
v2 = p_sy_msgv2
v3 = p_sy_msgv3
v4 = p_sy_msgv4
IMPORTING
msg = gv_text
EXCEPTIONS
not_found = 1
OTHERS = 2.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
I guess this will solve your problem
Regards
Prashant -
Hello Gurus,
as for a statement "The MBW job BI_BTCH__FX_PAYMENT_DATA=X10M and itu2019s child job ended with completed Abnormally status.", I have some question as follows:
(1) where does they check out this job " BI_BTCH__FX_PAYMENT_DATA=X10M " ? what do that "=" and "X10M" and "BI_BTCH__FX_PAYMENT_DATA" mean ?
(2) how does " MBW job BI_BTCH__FX_PAYMENT_DATA=X10M " match some BW object?
(3) what is itu2019s child job ?
MaIs the associated select-statement returning rows or not?
If yes -> delete is deleting
If no -> delete is just using CPU-cycles
To tune the delete-statement, you have to tune the corresponding select-statement. To tune the select-statement, you want to read the thread When your query takes too long ... -
Hi,
I am trying to create a very simple SQL Expression, but can't seem to get the syntax to be valid. The database connection is to a SQL Server database. If I were to create the query in SQL Server Management Studio, it would be something like
select LastName from People
However, every variant I can think of, based on various examples in books and on-line postings, fails syntax check. These include, among many others:
select "People"."LastName"
from "People"
select "People"."LastName"
from "PiapDB_ss5"."dbo"."People"
I have also tried single quotes instead of double quotes. I keep getting the same error:
Database Connector Error: '42000:[Microsoft][ODBC SQL Server Driver][SQL Server] Invalid syntax near the keyword 'select'. [Database vendor code: 156].
Any suggestions as to the proper syntax?
Thanks.
Danan sql expression field is meant to return one value, not records. therefore using a "select * from ..." statement won't work. if you know the select statement will return one value only (e.g. select name from table where id=123), you can surround the statement with parenthesis, that should work.
-
Question about conversational state of Stateless bean....
Hello all,
I have a simple stateless bean which parses an XML file and stores the xml content as an list of 2-D arrays in member variables. Here is quick look at design...
import javax.ejb.Stateless;
// included other libraries
import java.util.List;
import java.util.ArrayList;
@Stateless
public class XMLParseBean implements XMLParseBeanInterface {
public List<String> strParameters;
public List<String> getStrParameters() {
return strParameters;
private void setStrParameters(List<String> strParameters) {
this.strParameters = strParameters;
public void parseXML(String strFileName) {
/* Open the XML file and do initializations for xml parsing here
setStrParameters(visitNode(doc.getDocumentElement()));
private List<String> visitNode(Element thisNode) {
/* Parse the XML here */
return strNodes; // return the node names and their values
}My question is : if I inject this bean in another bean, call the method for parsing XML and then call the getParameter method to access the value of member variable, will it work.
I mean since I am using stateless bean, does the conversation state end when the parseXML method ends?sir_edward wrote:
Hi vikram8jp,
The session of an stateless bean ends after a method call. If you call a method of your bean, the bean will forget all attributes when the method ends. If you want to save attributes, you have to use a stateful bean.
Regards
Sir EdwardHello Sir Edward,
That answers my query.
Maybe you are looking for
-
When restarting my macbook, it made this long beeping noise. What's wrong with my mac?
-
"You are not connected to the internet" but I am!
solved by using the search function.... https://discussions.apple.com/message/15684542#15684542 Sorry for posting too early.
-
Hi. I was wondering if it is possible to share a pdf file but not have the download button? I want to share a file but I don't want to allow the users to be able to download the file to their computer. Thanks in advance for help. Lesli
-
Help with Cleaning up Empty/White Space
Hi all, I have a site I'm getting ready to complete, but there are a few things bugging me. One of which is the empty space at the bottom of the page. I'm not sure how to address it and wanted to get your opinion on what to do (and how to do it) The
-
After upgrading from the recent version of iTunes, I kept seeing the error message (in the title). I have uninstalled, reinstalled, restarted, and not sure what else to do. All help is appreciated. Thanks, Jacob