Native SQL from ABAP - ORA 02396 max idle time exceeded
Hello,
I am trying to read a table outside of the R/3 environment using native SQL statements. I'm getting the data just fine. But every other time (depending on elapsed time), I get the ORA-02396 exceeded maximum idle time, connect again. Here's the SQL code I'm using and I'm obviously not getting disconnected but I'm not sure why. Any help?
Open a native SQL connection.
EXEC SQL.
connect to 'ONECD'
ENDEXEC.
Retrieve information from the BVER tables.
EXEC SQL PERFORMING read_dental.
select emp_ssn_num, emp_fname, emp_lname,
to_char(start_date, 'YYYYMMDD') as start_date,
rec_type,
to_char(eff_date, 'YYYYMMDD') as eff_date,
vendor_plan_id
into :dental
from opr$8oc.BVER_CURR_DENTAL_MASTER
ENDEXEC.
EXEC SQL PERFORMING read_medical.
select emp_ssn_num, emp_fname, emp_lname, rec_type,
to_char(start_date, 'YYYYMMDD') as start_date,
to_char(eff_date, 'YYYYMMDD') as eff_date,
network_code, pcp_number, patient_flag,
vendor_plan_id,
to_char(network_eff_date, 'YYYYMMDD') as
network_eff_date,
to_char(pha_eff_date, 'YYYYMMDD') as
pha_eff_date
into :medical
from opr$8oc.BVER_CURR_MEDICAL_MASTER
ENDEXEC.
Disconnect from the native SQL connection.
EXEC SQL.
DISCONNECT 'ONECD'
ENDEXEC.
The system log has messages like 'Work process is in reconnect status' and 'Work process has left reconnect status' after the ORA-02396 message. And I specifically do a disconnect at the end and a connect at the beginning, but it looks like it is trying to do a reconnect?
Thanks,
Diane
Hi Daine,
Oracle Parameter IDLE_TIME set by the administrator.
1. Since you are using Secondary database
connection, the connection must
have been made with the help of BASIS Team.
2. This secondary database ORACLE
has some settings/parameters
which have been set to say 10 minutes, 60 minutes etc.
, so what happens,
if there is NO ACTIVITY / NO SQL / NO INTERACTION
with the database ,
the connection is IDLE
and hence ORACLE then disconnects by itself.
3. Contact your basis team / oracle administarotr
team to INCREASE this setting.
(they do it for some security purpose, firewall etc)
I hope it helps.
Regards,
Amit M.
Message was edited by: Amit Mittal
Similar Messages
-
Reading BLOB in Native SQL from ABAP program
Hello,
I'm trying to read content of a BLOB field from a table with Native SQL in ABAP like this:
DATA: l_bytes type xstring.
EXEC SQL.
SELECT bytes INTO :l_bytes FROM tablename
ENDEXEC.
But when I'm using xstring it returns only 32768 bytes. When using type x length 65000 for l_bytes it returns 65000 bytes, but x is limited to 65535 bytes only. So why it returns only 32768 bytes in direct sql? For DB2 I found note 610342 where you need to add \lob to the statement, I tried with Oracle but doesn't work.
DATA: CLOB_VAR TYPE STRING.
DATA: BLOB_VAR TYPE XSTRING.
EXEC SQL.
SELECT FCLOB, FBLOB FROM ZZTAB INTO :CLOB_VAR\lob, :BLOB_VAR\lob
ENDEXEC.
Regards
MarkusHi Markus,
you have to read it in chunks (remember a blob could be up to 4 Gbyte!).
I assume you store the byte stream in the field (no bfile pointer to a file ).
Give you a pseudocode that you get the picture.
Would recommend that you read the Oracle manual (db Version?)
9i
http://download.oracle.com/docs/cd/B10501_01/appdev.920/a96612/d_lob2.htm#1008611
10g
http://download.oracle.com/docs/cd/B19306_01/appdev.102/b14258/d_lob.htm#ARPLS600
chunksize = 32768 . " or use 65000 . This is the amount of the blob part you want to read
offset = 1.
*get the row of interest and retrieve blob's length
Exec sql.
select dbms_lob.getlength(your_blob) :blob_length from blob_table where my_primary_key = 1
end exec.
*calculate times to read from blob until the end (well, leave the adjustment to you
* in case of an uneven fraction)
ntimes = blob_length / chunksize .
Do ntimes
*loop and get the chunks into your variable:
* start reading from offset chunksize of bytes
exec sql.
select dbms_lob.substr(your_blob, :chunksize,:offset) into :xblobvar from blob_table
where my_primary_key = 1
endexec.
*don't know what you want to do with the blob chunk...
*process :xblobvar
offset = chunksize * ntimes .
enddo.
bye
yk -
Are there any risks to use native sql in ABAP to access external DB
here is a requirement to use native sql in abap program to access external DB to load some data into sap. Are there any risks and effects which SAP not recommend ?
Can anybody show some official document to me because I want to know some risks and dangerous to report to my manager..thanks very much.hi Anversha s
thank you for your reply
I means what's the risk when to use native sql to access external DB..
can you show me some examples about open sql which is used to access external DB...
Now I am investigating the technique about the connection
between SAP (by abap program) and external DB...the supporter suggestion is to use native sql to access external DBs.but my manager is afraid of the risks when to use native sql,So I have to report the effective document (example: SAP official document) to explain to my manager.
thanks very much -
How can i change to native sql from "IN" in abap
How can i use native sql where condition in this case?
for example..
SELECT-OPTIONS ; s_vbeln for vbak-vbeln.
EXEC SQL.
SELECT AA, BB, CC
INTO :ITAB-AA, ITAB-BB, ITAB-CC
FROM LEGACY@DBLINK
WHERE VBELN !!!!!!!!! <----
This Line...
ENDEXEC.
I want to see the same effect below sentence..
SELECT AA BB CC
FROM VBAK
WHERE VBELN IN S_VBELN.
Plz~This [link|http://help.sap.com/saphelp_nw04/helpdata/EN/fc/eb3b8b358411d1829f0000e829fbfe/content.htm] may useful for you.
-
Cant run Native SQL from the New BADI enhancements
I m trying to execute a Native SQL statement from the new BADI enhancement in ECC 6.0. Its very simple piece of code
data: v_count type i.
EXEC SQL.
SELECT zvbeln
INTO :v_count
FROM zvi2d
WHERE zvbeln = :'0000010476'.
ENDEXEC.
It compiles and runs perfectly fine in a regular program but in the BADI it keeps giving compile error "Field specification missing" on the SELECT zvbeln line.
In general things dont seem to work right at all in this BADI I dont understand what the problem is. This BADI is being used to populate the EDI Segments and gets called asynchronously
Thanks for readingwhy would you want to use Native SQL for this, why not just do this:
SELECT zvbeln
INTO v_count
FROM zvi2d
WHERE zvbeln = '0000010476'.
result will be the same. -
Using Native SQL in ABAP for DB2 database
Dear Friends,
I have 500K records in ITAB(Internal table) which needs to insert in 'Z' transparent table. Currently it is taking hours of time for insertion and commit.
Does using Native SQL helps in performance or any suggestions? If so please send the code. Our database is DB2.
Your immediate reply is appreciated. Thanks in advance.Hi Rama,
Using array inserts and commit after each Insert, set up your array size as a parameter and try different array sizes.
I would start with 2000 and increment by 1000 or 2000 and see what the optimal array size is.
I would think more commits are desirable, as the array gets bigger it takes longer for the system to prepare in the event of a rollback.
Just remember to commit after each insert. And are you enqueueing the table first?
Hope this helps.
Filler -
Accessinng Table using Native SQL in ABAP Program
Hi Experts,
I need to access a table that is created in Oracle.
But while writing a select query as below:
EXEC sql.
SELECT MAX(ID_EVENTO)
INTO :LV_ID_EVENTO
FROM ZTAB.
ENDEXEC.
I am getting a dump saying "ZTAB doesnot exist" or IF I use ZTAB@ifsap then it dumps saying "Database name is missing a component".
Do I need to add some suffix to the table name like @ifsap to ZTAB?
Also, can I use SY-SUBRC to check to the success and failure for SELECTION OR INSERTION Operation?
Thanks
DepeshHello,
Try using SAP<SID>.ZTAB in your query.
For example SAPC05.ZTAB
Regards,
Yoganand.V -
I need a query or stored procedure to get data from a table name specified by a variable (here 'TableName').
The stored procedure would be called everytime with a parameter that specifies the tablename to be queried.
The following piece of code works in Oracle, but when I use it in ABAP it gives a 'Table Access Error'.
DECLARE @Query varchar(300), @TableName varchar(30)
SET @TableName = 'Tab1'
SET @Query = 'SELECT * FROM ' + @TableName
EXEC (@Query)
Please help me out.Hello again,
Sorry for the misunderstanding!!
Have you tried to concatenate the table??
I mean to concatenate the values as a string??
I have never done it before, but it could work. Try to write it like a dynamic select:
column_syntax = `car name plate`.
dbtab_syntax = `zcars_names`.
SELECT (column_syntax)
FROM (dbtab_syntax)
INTO CORRESPONDING FIELDS OF TABLE itab.
try to concatenate or assign a value on a string variable.
myvar = 'tab1'
SET @TableName = myvar
Will it work, i dont know?? Try it!!...
Be careful with the quotation marks...you know how SQL make us crazy with it!!
Gabriel
Message was edited by: Gabriel Fernando Pulido V. -
TIME_OUT when accessing Oracle table from SAP using native SQL
Hi,
I have a problem in one of my native SQL statement. It takes a long time accessing the table considering that the number of records to be retrieved is only small.
Something happened on the Oracle system. But, stilll to be confirmed. Looking further at the issue, it seems that when the value in the where clause equated is a literal (meaning the value is not declared in DATA or CONSTANTS in the ABAP Program)
Example
1.
EXEC.
WHERE FIELD = '1'
ENDEXEC.
instead of
2.
CONSTANTS: c_1 value '1'.
EXEC.
WHERE FIELD = c_1
ENDEXEC.
i found that when the way of coding is same as Example 1, a time-out error occurs. But when in Example 2, no issue.
Can someone explain this?
Thanks!Repetitively asking the same question again and again is against the forum rules.
Please post an explain of the SQL statement on the remote machine.
Markus -
Possible to do "grant" sql statement in Native SQL?
We have a need to do a grant of access from one of our systems out for various applications. In order for this to work we need to run a grant access command on the table and are trying to put a wrapper around this so we can use an abap. Below is the code I am unit testing. Two questions. First, can a grant be done via native SQL in abap? Second, if it can be done, what is the error with the logic where I am trying to put in the table name via a parameter.
REPORT ZLJTEST2.
tables dd02l.
DATA scarr_carrid TYPE dd02l-tabname.
SELECT-OPTIONS s_carrid for dd02l-tabname no intervals.
DATA s_carrid_wa LIKE LINE OF s_carrid.
DATA name TYPE c LENGTH 20.
TRY.
EXEC SQL.
CREATE FUNCTION selfunc( input CHAR(20) )
RETURNING char(20);
DEFINE output char(20);
set schema sapr3;
grant select on table input to group infouser;
RETURN output;
END FUNCTION;
ENDEXEC.
LOOP AT s_carrid INTO s_carrid_wa
WHERE sign = 'I' AND option = 'EQ'.
TRY.
EXEC SQL.
EXECUTE PROCEDURE selfunc( IN :s_carrid_wa-low,
OUT :name )
ENDEXEC.
WRITE: / s_carrid_wa-low, name.
CATCH cx_sy_native_sql_error.
MESSAGE `Error in procedure execution` TYPE 'I'.
ENDTRY.
ENDLOOP.
EXEC SQL.
DROP FUNCTION selfunc;
ENDEXEC.
CATCH cx_sy_native_sql_error.
MESSAGE `Error in procedure handling` TYPE 'I'.
ENDTRY.Hi,
Yes it is posible.
I made one program like you want. But it need very long code.
Here I explain the idea:
1. Create Screen with input TEXT EDIT CONTROL.
This is for input SQL Statement.
2. Get SQL Statement from Text Edit Control using method <b>get_text_as_r3table</b>.
3. Now we need to separate SQL Statement into different table.
We Separate SELECT, FROM, WHERE, GROUP, HAVING, ORDER, etc.
4. We need dynamic internal table to store the data.
5. Select the data according SQL statement.
SELECT (IT_SELECT)
into corresponding fields of table <dyn_table>
FROM (IT_FROM)
WHERE (IT_WHERE)
GROUP BY (IT_GROUP)
HAVING (IT_HAVING)
ORDER BY (IT_ORDER).
6. Display our data using ALV GRID
Hopefully it will help you.
Regards, -
How to connect to DB2 from ABAP program
Hi,
In my ABAP program I need to retrieve 3 fields from one table of DB2 database. I have tried creating an RFC connection in SM59 and then using native SQL in abap code but could not succeed.
I have also maintained an entry in DBCON table but am unable to connect through program.
Pls suggest.
Thanx in advance.Preeti-
DBCON may not work for you because your target is DB2. You SAP system should have the suitable driver files for connecting to DB2 and I don't think currently this is supported.
However, there are other ways of doing it. One ofcourse is to use a middleware tool, which I guess you don't have in your landscape.
If investing on a middleware tool is out of scope, here are other options
1) If you are a microsoft shop, use .NET connector (freely downlaodable from SAP service market place). You can develop a .NET component which will use .NET connector for connecting to SAP and OBDC to connect to your AS400 system. The OBDC drivers can be obtained from IBM.
2) If you are a java shop, you can develop a java code which can run on your AS400 system or a separte server (windows,unix..).
This java code will use JRFC/JCO (again downloadable for free from SAP service market place) to connect to SAP while it will use Client access ODBC drivers or JT400 drivers (google JT400) to connect to your DB2 database.
Though developing this is not a great deal, could be bit challenging if done for the first time. Let me know which way you wanna go and I can guide with more information/code samples.
KK -
Performance issue using Native SQL
Hi
I am getting the data from Oracle database using Native SQL in ABAP. I am facing performance problem when i am using Native SQL to get data from Oracle database.Its been very slow and getting timed out.
This is the code i am using for this.
EXEC SQL PERFORMING BUILD_TAB.
Get the territory id
SELECT TERR_ID
FROM DWPROD.VW_ARDETAIL_PRD1@DWP
INTO :IT_TERR-TERR_ID
:DG_TERR_ID
WHERE COMPANY = :dt_output-bukrs
AND PAY_ADDR_ID = :dt_output-kunnr
AND DOC_NO = :dt_output-belnr
AND DOC_ITEM_NO = :dt_output-buzei
ENDEXEC.
IF sy-dbcnt >= 1.
READ TABLE it_terr INDEX 1.
dg_terr_id = it_terr-terr_id.
EXEC SQL.
Get the Saled rep id, name
SELECT MR_USER_ID,
MR_NAME
FROM DWPROD.VW_TERR@DWP
INTO :dt_output-srep_id,
:dt_output-srep_name
WHERE TERR_ID = :DG_TERR_ID
ENDEXEC.
*Get sales manager id and sales manager name
EXEC SQL.
SELECT SALES_GRP_ID
FROM DWPROD.VW_TERRRPT@DWP
INTO :DG_SGRPID
WHERE TERR_ID = :DG_TERR_ID
ENDEXEC.
IF sy-dbcnt >= 1.
EXEC SQL.
SELECT MGR_USER_ID,
MGR_NAME
FROM DWPROD.VW_SGRP@DWP
INTO :dt_output-sman_id,
:dt_output-sman_name
WHERE SALES_GRP_ID = :DG_SGRPID
ENDEXEC.
ENDIF.
ENDIF.
Can any one suggest a solution to improve the performance.
Thnaks
VianneyHi John!
Looks like you need just one entry out of the tables, but you select 'into table'.
Try to add a 'up to 1 rows' restriction, then Oracle will be much faster with the execution.
To get an idea, who this parameter looks like in native SQL for Oracle, write a simple test program with an open SQL statement (including this parameter / select single) and run a SQL-trace (ST05). Here you can see in 'explain' how native translation looks like, can also maintain some small tests with 'enter SQL statement'.
Regards,
Christian -
TIME_OUT in SAP when accessing external Oracle table thru native SQL
Hi,
I have a problem in one of my native SQL statement. It takes a long time accessing the table considering that the number of records to be retrieved is only small.
Something happened on the Oracle system. But, stilll to be confirmed. Before, there wasn't any issue. Looking further, I found that when the value in the where clause equated is a literal (meaning the value is not declared in DATA or CONSTANTS in the ABAP Program)
Example
1.
EXEC.
WHERE FIELD = '1'
ENDEXEC.
instead of
2.
CONSTANTS: c_1 value '1'.
EXEC.
WHERE FIELD = c_1
ENDEXEC.
i found that when the way of coding is same as Example 1, a time-out error occurs. But when in Example 2, no issue.
Can someone explain this? is their something that could affect SAP with respect to Oracle configuration?
Thanks!I wonder if you could share the outline of your code to access an external oracle database. I've just been given the assignment to do just that, but don't know where to start.
thx,
Mike DeGuire -
Report Server does not respond after certain idle time
We have an oracle 10g application server on solaris 10.
The report server has the defaul settings for time out , callback etc..
After the report server stays idle for 2 or 3 hours and the first report that comes after that takes around 8 to 10 minutes to generate. The report server engine does not seem to be getting active immediately.
Is there any parameter I can change so that the reports do not get effected.
ThanksI have put the idle time out at 300 minutes and the max idle time as 350 minutes. But that does not seem to have helped.And also I have min engine as 1 , max as 10.
Even with the above settings , When the report engine is idle after 30 minutes the 1st report to generate after 30 minutes takes 9 minutes.
please let me know if there are any other parameters I need to change.
thanks -
ORA-01000: maximum open cursors exceeded ORA-06512
Hi,
An exception error ccurred as below while trying to map a column.
Exception oracle.apps.bne.exception.BneSQLException: SQL Exception in BneFlex.validateSegs: java.sql.SQLException: ORA-01000: maximum open cursors exceeded ORA-06512: at "APPS.FND_MESSAGE", line 525 ORA-06512: at "APPS.FND_MESSAGE", line 565 ORA-06512: at "APPS.FND_MESSAGE", line 654 ORA-06512: at "APPS.FND_MESSAGE", line 766 ORA-06512: at "APPS.FND_MESSAGE", line 741 ORA-06512: at "APPS.FND_FLEX_KEYVAL", line 324 ORA-06512: at line 1 occurred trying to map column: Expense Account.
In alert log file:
Errors in file /vol01/oracle/SIT/db/tech_st/10.2.0/admin/SIT_sit/udump/sit_ora_7
04744.trc:
ORA-07445: exception encountered: core dump [] [] [] [] [] []
ORA-00604: error occurred at recursive SQL level 1
ORA-01000: maximum open cursors exceeded
ORA-01000: maximum open cursors exceeded
Thanks
Edited by: userpat on Aug 15, 2010 5:32 AMHi,
The issue is different this time after restarting application and database find below.
An exception occured trying to map a column
Exception java.lang.ArrayIndexOutOfBoundsException:Array index out of range:1
occured trying to map column:Category
in bne.log
8/18/10 12:08 PM AJPRequestHandler-ApplicationServerThread-2 ERROR BneP
arentMenuResolver.getMenuItem() MENU 101:BUDGET_NOTE - Menu item excluded becaus
e IntegratorAppId and Code does not match that of the Top-Most Menu Item or curr
ent Integrator: 140:FA_MASS_ADDITIONSThe same error is reported in Note: 954462.1 (which is referenced above).
And also let me clear one doubt. v$open_cursors view is used for what?. The total number of count v$open_cursors is 60,000 whereas the parameter is defined only 2000 in the Instance.Cursors Remain Open (in V$OPEN_CURSOR View) after being Closed [ID 1020427.102]
Monitoring Open Cursors & Troubleshooting ORA-1000 Errors [ID 76684.1]
V$OPEN_CURSOR
http://download.oracle.com/docs/cd/B19306_01/server.102/b14237/dynviews_2008.htm#REFRN30166
Thanks,
Hussein
Maybe you are looking for
-
Using thunderbolt to firewire adapter for target disc mode
I need to transfer several GB of data from a 2011 iMac running OS 10.6 to a new Mac Mini running OS 10.9. Can I connect the older iMac to the newer Mini with a Thunderbolt to Firewire adapter and boot the iMac into Target Disc Mode and transfer the d
-
One day the phone just got stuck on ios6 screen then once unlocked it said plug into iTunes. Once I did the phone will not allow me to complete a restore. At the last stages the phone will cut off. I have asked a friend to have a look and he thinks i
-
UPGRADE FROM SAP R/3 4.7 TO ECC 6.0 SR3
Hi Gurus , We are now using SAP R/3 4.7 . Now we are upgrading 4.7 to ECC 6.0 . Kindly advice me what are the steps for doing this upgrade . Regards Selvan .SP
-
Getting error calling a package/procedure from DB
I'm on 11.1.1.6 and I'm trying to execute a procedure in a package in the DB my ADF application is connected to. I get the following error "Could not find saved view state for token". If I comment out the execution of the method that is calling th
-
Multiple Login in ATG on multiple server instances.
Hi, I'm facing a issue with multiple logins in my web application. The scenario is explained below: 1. I login from one browser (IE) and add an item to cart. Then I navigate to cart page. I logout. 2. I login from another browser (Chrome) and add ano