How Can I Execute Sql Query in Managed bean?
Hi,
I want to execute sql query in managedbean and get the query result. How can I do?
Best wishes!
You can do this by having current Database connection your application is using like this
public static synchronized DBTransaction getDBTransaction(){
FacesContext ctx = FacesContext.getCurrentInstance();
ValueBinding vb = ctx.getApplication().createValueBinding("#{data}");
BindingContext bc = (BindingContext)vb.getValue(ctx.getCurrentInstance());
DataControl dc = bc.findDataControl("AppModuleDataControl");
ApplicationModuleImpl am = ((ApplicationModuleImpl)(ApplicationModule)dc.getDataProvider());
return am.getDBTransaction();
and then user DBTransaction object to create Statement and PreparedStatement you can find those in java doc.
Similar Messages
-
How Can I find SQL Query in Database
Dear Experts,
How Can I find SQL Query in Database.Hi,
U mena what query got executed in db? u can try V$SQL for it.
Regards
Bharath -
How can I execute a query from a BSP application?
How can I execute a query from a BSP application?
I´m trying to execute a Query from intranet. I´ve been looking for examples, but the templates I´ve found doesn´t help me.
does anybody has an example?
Thanks.Hi
Have you designed the BSP application ?
design it first with one page
page will have layout and Event handlers
Design the layout with the fields
in the event handler there are events
in the event On Initiailization or ON inputprocessing write the select query similar to what we write in routine ABAp and fetch the data into ITAB and that has to be passed to the Layout
see the doc
BSP
To learn how to create Web applications with Business Server Pages, you can work through the simple tutorials that build on each other. You should be able to run through all of the steps described here in your own system.
If you want to develop Web applications with BSPs, your system must meet the following requirements: Prerequisites for Creating Web Applications.
The following tutorials are available:
· First Tutorial: First Steps with Business Server Pages
· Second tutorial: A Small BSP Application and A Small BSP Application with HTMLB
· Third tutorial: Our First Online Bookshop
· Fourth tutorial: Further Developing the Bookshop
· A small Tutorial is also available for your first steps with the Model View Controller design pattern.
· For a more complex MVC tutorial based on the third tutorial, see: Our Little Online Bookshop Using MVC and HTMLB
When creating BSP applications, note the browser dependencies described in Note 598860.
steps:
1) start the transaction RZ10.
2) now u u have to select Profile name, so select the INSTANCE Profile from the list of options given with the Profile parameter list.U may find multiple instance profile in the list, so select the profile in which ur server name is given.
3) u will also find three options in the same window.
Administrator data, Basic Maintenance, and Extended Maintenance. So select the last one from that.
4) Now click on change button.
5) here u will find parameter icm/host_name_full, so now set it as FQDN.
6) Now copy ur settings with new version number.
7) Activate that version.
8) And now please restart ur WAS.
So this will set ur FQDN, and also don't forget to login using Admin User.
Now u also check for following service are active in your ICF setting or not,( just start transaction code SICF)
/default_host/sap/bc/bsp/sap
/default_host/sap/bc/bsp/sap/system
/default_host/sap/bc/bsp/sap/public/bc
/def ault_host/sap/public/bc
/default_host/sap/public/bc/ur
/default_host/sap/public/bsp/sap/public
/default_host/sap/public/bsp/sap/public/bc
/defaul t_host/sap/public/bsp/sap/system
/default_host/sap/public/bsp/sap/htmlb
if not then activate all.
check this link
Read this weblog...
/people/brian.mckellar/blog/2003/09/25/bsp-in-depth-fully-qualified-domain-names
http://www.thespot4sap.com/articles/SAP_WAS_Creating_BSP_Apps.asp
it consists of screen shots also
Check it.
http://help.sap.com/saphelp_nw04/helpdata/en/c8/101c3a1cf1c54be10000000a114084/frameset.htm
http://help.sap.com/saphelp_nw04/helpdata/en/e9/bb153aab4a0c0ee10000000a114084/frameset.htm
Regards
Anji -
hi
i have some idea about setwhereClause() method ..... but in my case i want to use one SQL query (select * from tab )...i dont know how to use ....
(without view object we cant use setwhereclause() method thatsy i have to use sql statement in managed bean ........)
thanks in advanceFirst of all, you don't want to have any SQL in a managed bean. Managed beans are part of the View layer, and the query should be part of the Model. So what you want to do is add some code to your Model project. So you are trying to do "SELECT * FROM tab". Why not just create a read-only View Object (VO) for the query in the Model (assuming that you are using ADF BC).
Now as for setWhereClause - what do you need in your where clause? You can add where clauses to the query that defines your VO, without needing to resort to using this method. You can even add bind variables for the where clauses, and just drag the ExecuteWithParams method onto your pages, which will give you a place to set the bind variables before executing the query.
You can create your own method in the VO's implementation class, in which you may call setWhereClauseParam to gain more control over how the bind variables are set. Then you make the method available as an operation in the data controls by making it an exposed method to the client interface. You can use setWhereClause in such a method if you need to do so, but there are good performance reasons not to do so if a bind variable will do the job. setWhereClause can also set you up for SQL Injection attacks on your application's security. -
How can I get SQL query excution time
Hi ,
When I run a query , How can i get total execution time for that query.
Thanks,
Regards,
Basha.There are several ways:
1. In SQL, issue SET TIMING ON
2. Trace your query:
- ALTER SESSION SQL_TRACE=TRUE;
- Execute your query
- ALTER SESSION SET SQL_TRACE=FALSE
- Decode the tracefile left at USER_DUMP_DEST using TKPROF. -
How can I execute a query using RSCRMBW_REPORT?
Hi everybody,
I have read the document:
https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/3ba5e590-0201-0010-59b1-cab51fd245b7
and found it is very intersting for my requirement.
I copied the report,and modified it regarding our case.But during the second call,I get runtime error.
I debugged the code, and found the error results from method GET_CUBETYPE() of class CL_RSCRMBW_BAPI.In this method,it tries to create a object which is TYPE REF TO cl_rsd_dta.
CREATE OBJECT lr_dta
EXPORTING
i_infoprov = g_s_status-infocube
But g_s_status-infcube is null.
I am not able to find where this 'infocube' component in this g_s_status struction is filled,even I found,I don't know how I can give this infocube parameter from report which 2 FM are called.
My code is following:
parameters: p_repuid TYPE RSCRMSTATUS-REPORTUID
DEFAULT 'Z_IC_01/Z_COMP_Q003'.
parameters: p_split type BAPI6110DIM-DIM_NAM.
data:name_query TYPE CHAR50,
result_table LIKE RSCRMSTATUS-TABNAME,
it_return LIKE BAPIRET2 OCCURS 2 WITH HEADER LINE,
infocube TYPE CHAR30,
compid TYPE CHAR30.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_repuid.
CALL FUNCTION 'RSZ_COMPONENT_TREE_GET'
EXPORTING
i_title = 'Query auswählen'(031)
IMPORTING
E_INFOCUBE = infocube
E_COMPID = compid
EXCEPTIONS
OTHERS = 1.
IF sy-subrc GT 0.
ENDIF.
concatenate infocube '/' compid into p_repuid.
START-OF-SELECTION.
CALL FUNCTION 'RSCRMBW_REPORT'
EXPORTING
i_mode = 'OPEN'
i_reportuid = p_repuid
I_PACKSIZE = 10000
I_EXECMODE = 'TABLE'
I_EXTRACT = 'ZBWTEST'
I_SPLIT = p_split
I_CLEAREXTRACT = 'X'
TABLES
E_T_RETURN = it_return.
CALL FUNCTION 'RSCRMBW_REPORT'
EXPORTING
i_mode = 'START'
i_reportuid = p_repuid
I_PACKSIZE = 10000
I_EXECMODE = 'TABLE'
I_CLEAREXTRACT = 'X'
TABLES
E_T_RETURN = it_return.
So far this creation of report is only the 2nd step.But I am not sure how step 3 to step 6 should be done so that the report can be execute exactly.
What should I do? Pleas help me!
Thanks in advance
Regards,
Liying
Message was edited by: Liying Wang
Message was edited by: Liying Wang
Message was edited by: Liying WangLiying
Were you able to get a solution to this problem? I am facing the same issue too. The g_s_status-infocube is showing blank.
Regards
Dilip -
ADF how can i execute a query with parameters when the page renders
hi
i am using ADF web 11g
i need to execute a query with parameters when the page renders
thankshello,
I'm a fan of Java code, I really am.
But when you use ADF, you decided to move to a more declarative environment.
So why not do it declarative, the adf way?
In your pagedef insert a action binding.
This can be anything, a call to the application module, a call on the iterator(Like executeWithparams, etc.)
Create an invokeAction in your pagedef and set the condition.
This example refreshes(Action 2 is execute query) the data.
First the method binding:
<action IterBinding="PersoonIterator" id="Execute" InstanceName="LSAppModuleDataControl.Persoon"
DataControl="LSAppModuleDataControl" RequiresUpdateModel="true" Action="2"/>And the invoke action
<invokeAction Binds="Execute" id="refreshData"/>This always refreshes the data on page entry, but anything is possible, you can set condictions for the invokeAction.
-Anton
PS Yes I know that pagedefs become backing beans in the end and yes that is Java code, but if you wanna play the ADF way, the goal is the reduction of Java code and the increased performance of declarative programming. -
How can I load the data of Manager Beans into an Array?
Hi all!
I have a problem when use the ADF model layer (JDeveloper 10g). I want to load the data of a Manager Bean into Array(such as: Array in JavaScript).But I don't know any ways to do.
Are there any ways to do that?
Please, help me!
Thanks so much!Hi,
there is a fundamental difference between an array in Java and an array in JavaScript as the latter is added to the output page while the first sits in a Java class on the server.
Populating a Java array from a managed bean is straight froward: Just create the Array, loop through the source of the data - ADF binding or the ADF Faces table component - and fill it.
For a JavaScript Array I would suggest to write the array into a js file and reference it from the web page (which might cause concurrency issues).
Frank -
FRM-40737 How can I execute a query in a post block ?
Hi,
I have two blocks based on the same table. Then it is not a 'real' master detail case. The first block contains two fields who are the values in the where clause of the second block. In which trigger or where do I place the EXECUTE-QUERY ? I can't place it in the post-block because post-block don't accept EXECUTE-QUERY and I dont want to use a timer because it bring me some troubles.
Than'k you !I have two blocks based on the same table. Then it is not a 'real' master detail case. You can easily create a master-detail here, if your data model allows it. A table can have a foreign key relation to itself. E.g. emp.manager_id if the fk to emp.empno.
-
How can i write sql query for this result ?
Hello Dear,
Here is the script first.
CREATE TABLE ACC_TEST(
AD_ID NUMBER,
AD_NAME VARCHAR2(50),
AD_SPM_ID NUMBER);
/data are
Insert into ACC_TEST (AD_ID,AD_NAME,AD_SPM_ID) values (136,'Saleh Ahmed',129);
Insert into ACC_TEST (AD_ID,AD_NAME,AD_SPM_ID) values (142,'Hamidur Rahman',136);
Insert into ACC_TEST (AD_ID,AD_NAME,AD_SPM_ID) values (124,'Jasim Uddin',null);
INSERT INTO ACC_TEST (AD_ID,AD_NAME,AD_SPM_ID) VALUES (129,'Sazib',124);I Need The Following Result When I Pass A Value Of Ad_Id. For Example I Pass 142 Then Result Should Be
Select Ad_Id,Ad_Name
From..
where ad_id=142
Ad_Id Ad_Name
136 Saleh Ahmed
129 Sazib
124 Jasim Uddin
If I Pass Ad_Id=136 Then Result Should Be
Ad_Id Ad_Name
129 Sazib
124 Jasim Uddin
If I Pass Ad_Id=129 Then Result Should Be
Ad_Id Ad_Name
124 Jasim Uddin Database 10G XE
Any help will be helpfulHi,
HamidHelal wrote:
WoW ! you acutely got my point. How did you understand that ? lLuck guess. Guessing is usually not the best way to solve problems. It's usually faster and more reliable to say exactly what you want, as well as give an example.
ittle bit more i want to know, if i want to restrict the output not more then 2, what would be sql ?Now you're not even giviing an example!
Maybe you want something like this:
SELECT ad_id
, ad_name
FROM acc_test
WHERE LEVEL BETWEEN 2 AND 3 -- Changed
START WITH ad_id = :target_ad_id
CONNECT BY ad_id = PRIOR ad_spm_id
;which will show jsut the parent and the grandparent of the given row.
I do work with forms developer very much. Sql knowledge is as oracle sql book(cerfitication 9i). But this type of sql isn't available there.
where can i learn this type of sql ? Different sql then ordinary ?Certification is a different topic entirely.
There are books and web sites dealing with more advanced techniques. Sorry, I don't know any well enough to recommend them. Some authors (such as Tom Kyte) are consistently good.
Here are a couple of sites that explain CONNECT BY queries:
http://www.adp-gmbh.ch/ora/sql/connect_by.html
http://www.oradev.com/connect_by.jsp -
Hello.
How can I execute a Query and to store the result in a variable?
Thanks for your help.
Regards,
JoseHi Jose,
i made a c# sample for you
SAPbobsCOM.Recordset oRecordSet = null;
oRecordSet = ((SAPbobsCOM.Recordset)(oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset)));
oRecordSet.DoQuery("SELECT CardCode FROM OCRD");
string tmpResult = null;
tmpResult = oRecordSet.Fields.Item(0).Value.ToString();
lg David -
How to fetch the executed sql query in publisher
hi.. like in obiee from manage session we can fetch the sql query similarly how can we fetch the query in BI publisher
This may help you:
http://gerardnico.com/wiki/bip/log
Cheers
Nico -
How can I execute a Procedure with OUT variable is %ROWTYPE on SQL Prompt
Hi,
I have a procedure with OUT variable is %ROWTYPE
How can I execute the following procedure on SQL prompt.
(without creating anonymous block)
CREATE OR REPLACE PROCEDURE zz_sp_EMP(VEMPNO IN EMP.EMPNO%TYPE,
V_REC IN OUT EMP%ROWTYPE)
AS
BEGIN
SELECT * INTO V_REC FROM EMP WHERE EMPNO = VEMPNO;
END;
Thanks & Regards,
Nareshas previous posters said: it's not possible to do this without declaring a variable in the anonymous block.
With anonymous block it would look like this (had to change it a bit, since i'm using hr-schema on oracle XE):
declare
l_rec EMPLOYEES%ROWTYPE;
begin
zz_sp_EMP(VEMPNO => 100, V_REC => l_rec);
DBMS_OUTPUT.PUT_LINE ( 'first_name = ' || l_rec.first_name );
DBMS_OUTPUT.PUT_LINE ( 'last_name = ' || l_rec.last_name );
end;
first_name = Steven
last_name = King -
In ST03 , how can i see the Query name, user id,how many times executed the
HI Experts,
In ST03 , how can i see the Query name, user id,how many times executed the query.
these details how do i get from the above transaction.
EX:-if there is one report name X,I want to know how many users had executed X report today,weekly,monthly.
ex:-query userid total number of execution
sales order 0000555 5 times
custmer 05855 2 times
fast reply will be appreciated,Hi,
Look here:
http://help.sap.com/saphelp_nw04/helpdata/en/3b/54df4204892a78e10000000a155106/frameset.htm
Also check these:
http://help.sap.com/saphelp_nw2004s/helpdata/en/2d/b8be3befaefc75e10000000a114084/content.htm
http://help.sap.com/saphelp_nw2004s/helpdata/en/25/ece73a39e74d27e10000000a114084/frameset.htm
Hope this helps..
Bye
Dinesh -
How to execute SQL Query in Code behind Using infopath 2010?
Hi,
I've repeatable on infopath form, and want bind it throuth code behind from SQL table. My question is that how to execute SQL Query in code behind from infopath as well as how would get Query result to bind repeatable control?
Thanks In Advance
Shoeb AhmadHello,
You first need to add new SQL DB connection then you need execute connection from code behind.
See below link to create new connection
http://office.microsoft.com/en-in/infopath-help/add-a-data-connection-to-a-microsoft-sql-server-database-HP010092823.aspx:
http://www.bizsupportonline.net/infopath2010/connect-infopath-2010-sql-server-2008-table.htm
Then use below code to execute this connection:
AdoQueryConnection conn = (AdoQueryConnection)(this.DataConnections["Data connection name"]);
string origCommand = Select * from tablename;
conn.Command = origCommand;
conn.Execute();
Finally bind your table:
http://www.bizsupportonline.net/infopath2007/4-way-programmatically-add-row-repeating-table.htm
http://stevemannspath.blogspot.in/2010/09/infopath-20072010-populate-repeating.html
Hope it could help
Hemendra:Yesterday is just a memory,Tomorrow we may never see
Please remember to mark the replies as answers if they help and unmark them if they provide no help
Maybe you are looking for
-
Apple Store offers French or German versions only.
-
How do you import music onto ITUNES if you have two IPODS
Question: I have two IPODS. I can't seem to figure out how to import all the music on my old IPOD onto ITUNES so I can put new music in my library as well as m new IPOD. Can you please help! Also, when I plug in my old IPOD it says it is in WIndows f
-
Oracel Database 11g Release 2 Connection with Forms Builder 10g
I installed Oracle Database 11g at Microsoft window 32-bit , Now I want to connect it with my forms buider 10g developersuit. Please tell me ho do I connect it.
-
hi, getting demands from APO. I need to create planned orders. b4 creating planned order i need to check stock availability and open production orders. how to check this. I think, AUFBAUEN_MDPSX_ANZEIGEN can be used. But I dont know how...plz suggest
-
Use Sys Prefs or WorkGrp Mgr to manage Groups?
I'm new to server 10.6, having run 10.3 for years. Now setting up 10.6 I see that I can manage users and groups somewhat via System Preferences. Having discovered that after creating a Group via WorkGroup Manager, I went to manage Groups in System Pr