How to execute a string
if a str = "System.out.println()"
how can i execute the str
thanks
There are some libraries which do this, however java is not a scripting lanaguage and should not be used this way unless you have a very good reason.
Try using an anonymous class
Runnable runnable = new Runnable() {
public void run() {
System.out.println("run()");
runnable.run();
Similar Messages
-
How to execute a string formula and assign the result to a number field
How to execute a string formula and assign the result to a number field
Hi,
we have a function that returns a string like this:
'(45+22)*78/23'
After we should calculate this string and assign the value to a numeric block field
Example:
k number(16,3);
k:=fun1('(45+22)*78/23'); where fun1 execute and translate to number the string.
Does exist a function like fun1 ??
How can we do ?
RegardsHello,
this is the code that does the job:
SQL> set serveroutput on
SQL> DECLARE
2 ch VARCHAR2(20) :='22+10' ;
3 i NUMBER ;
4 BEGIN
5 EXECUTE IMMEDIATE 'select ' || ch || ' from dual' INTO i;
6 dbms_output.put_line ('i = ' || TO_CHAR(i));
7 END ;
8 /
i = 32
Procédure PL/SQL terminée avec succès.
SQL>
just you have to do is to create a small stored function that take the string to calculate and return the number result
Francois -
How to execute an SQL query present in a string inside an ABAP program?
hello,
How to execute an SQL query present in a string inside an ABAP programRaut,
You can execute Native SQl statements.
Ex: To use a Native SQL statement, you must precede it with the EXEC SQL statement, and follow it with the ENDEXEC statement as follows:
EXEC SQL [PERFORMING <form>].
<Native SQL statement>
ENDEXEC.
There is no period after Native SQL statements. Furthermore, using inverted commas (") or an asterisk (*) at the beginning of a line in a native SQL statement does not introduce a comment as it would in normal ABAP syntax. You need to know whether table and field names are case-sensitive in your chosen database.
In Native SQL statements, the data is transported between the database table and the ABAP program using host variables. These are declared in the ABAP program, and preceded in the Native SQL statement by a colon (:). You can use elementary structures as host variables. Exceptionally, structures in an INTO clause are treated as though all of their fields were listed individually.
If the selection in a Native SQL SELECT statement is a table, you can pass it to ABAP line by line using the PERFORMING addition. The program calls a subroutine <form> for each line read. You can process the data further within the subroutine.
As in Open SQL, after the ENDEXEC statement, SY-DBCNT contains the number of lines processed. In nearly all cases, SY-SUBRC contains the value 0 after the ENDEXEC statement. Cursor operations form an exception: After FETCH, SY-SUBRC is 4 if no more records could be read. This also applies when you read a result set using EXEC SQL PERFORMING.
EXEC SQL PERFORMING loop_output.
SELECT connid, cityfrom, cityto
INTO :wa
FROM spfli
WHERE carrid = :c1
ENDEXEC.
Pls. Mark If useful -
How to execute an expression which is in a string
hi
i am facing one interesting problem
i want to evaluate an expression like
sin^2 (theta) * cos^2 (phi) which i am getting in string object
something like expression entered by an user
and i want to evaluate it in a program
how do i do that
i mean how to treat this string as a statement
thanx in advance as usualHere's one of probably many.
http://tp.lc.ehu.es/anonym/java/eval.html
Google is your friend.
http://www.google.com/search?hl=en&q=java+eval&btnG=Google+Search -
How to Execute a Remote Procedure in Portal using Database Link
Hi,
I followed the instructions to create a Portal form for a remote procedure. But I am encountering the following error. Can someone advise what may be the cause?
Failed to execute - Missing string(create_package_body) language(us) domain (wwv) sub_domain (wwv_builder) (WWV-04300)
ORA-04020: deadlock detected while trying to lock object PUBLIC.PORTLET_SCHEMA (WWV-11230)
Failed to parse as PORTAL - (WWV-08300)
PURPOSE
How to execute a remote procedure in Portal using Database Link.
DESCRIPTION
This procedure assumes that you have two databases, one of which is remote, and Portal is configured in the other.
Remote Database A:
==================
1) Create a procedure as follows: Create or Replace PROCEDURE SCOTT.ADD_TWO_VALUES ( v_one IN NUMBER, v_two IN NUMBER, v_result OUT NUMBER) as begin v_result :=v_one+v_two; end; 2) Grant execute privileges to PUBLIC on the procedure.
Database B (where Portal is configured): ========================================
1) Create a public database link and choose to connect as a specific user (say SYSTEM). By default, in an Oracle 8i database, the "global_names" parameter in initSID.ora (or init.ora) file is set to "true". This Global Naming parameter enforces that a dblink has the same name as the database it connects to. Therefore, if the remote global database (A) name is "ora8.acme.com" then the database link should also be named as "ora8.acme.com".
2) Create a synonym for the procedure in Database A. Make sure you fully qualify the procedure name in the remote database (like SCOTT.ADD_TWO_VALUES).
3) Create a dynamic page to execute the procedure. The ORACLE tags in the dynamic page will look similar to the following: <ORACLE> DECLARE v_total NUMBER; BEGIN ADD_TWO_VALUES(:v_one,:v_two, v_total); htp.p('The total is => '); htp.p('<input type="TEXT" VALUE='||v_total||'>'); htp.para; htp.anchor('http://<machine.domain:port#>/pls/portal30/SCOTT.DYN_ADD_TWO_VALUES.show_parms', 'Re-Execute Procedure'); END; </ORACLE>
4) Portal does not have an option to create a form based on a synonym. Therefore, if you want to create a form instead of a dynamic page, create a wrapper procedure and then create a form based on this procedure. For example: Create or Replace PROCEDURE PORTAL30.ADD_TWO_VALUES_PR ( v_one IN NUMBER, v_two IN NUMBER, v_total OUT NUMBER) as begin add_two_values(v_one, v_two, v_total); end;
5) Grant execute privileges to PUBLIC on the procedure.hello...
any input will welcomed... Thanks.. -
How to execute this SQL Query in ABAP Program.
Hi,
I have a string which is the SQL Query.
How to execute this sql Query (SQL_STR) in ABAP Program.
Code:-
DATA: SQL_STR type string.
SQL_STR = 'select * from spfli.'.
Thanks in Advance,
VinayHi Vinay
Here is a sample to dynamically generate a subroutine-pool having your SQL and calling it.
REPORT dynamic_sql_example .
DATA: BEGIN OF gt_itab OCCURS 1 ,
line(80) TYPE c ,
END OF gt_itab .
DATA gt_restab TYPE .... .
DATA gv_name(30) TYPE c .
DATA gv_err(120) TYPE c .
START-OF-SELECTION .
gt_itab-line = 'REPORT generated_sql .' .
APPEND gt_itab .
gt_itab-line = 'FORM exec_sql CHANGING et_table . ' .
APPEND gt_itab .
gt_itab-line = SQL_STR .
APPEND gt_itab .
gt_itab-line = 'ENDFORM.' .
APPEND gt_itab .
GENERATE SUBROUTINE POOL gt_itab NAME gv_name MESSAGE gv_err .
PERFORM exec_sql IN PROGRAM (gv_name) CHANGING gt_restab
IF FOUND .
WRITE:/ gv_err .
LOOP AT gt_result .
WRITE:/ .... .
ENDLOOP .
*--Serdar -
How to execute code from a text file?
Hello all!
How to execute some code lines from a text file? For example my file is:
String varname = "somecontents";
JFrame frame = new JFrame();
frame.setVisible(true);How can I get contents of this file and parse them if I want get new JFrame and access to the variable varname?I mean the PHP would generate a readable Java source,
for example some variables with some data, and I just
dont know what to do with file if I want generate the
xls file from my saved data, could You help? :)Some variables, some data, PHP, Java, XLS file??? Al rather vague.
You need to explain in more detail what it is you're trying to do if you want an answer to your question! -
How to execute commands from Java
hi,
i m trying to execute a CVS command from a java environment. i m writing this code to create a user. for this i m executing this cvs command "cmd /c cvs passwd -r <username> -a <new-username>"
after executing this cmd the command prompt will prompt for a pasword and then after entring the password i have to retype the password for confirmation. the existing code execcutes the command but i don t know how to read the prompt for password.
<code>
import java.io.*;
import java.lang.*;
public class first {
public static void main(String[] args) {
try {
Process p = Runtime.getRuntime().exec("cmd /c cvs passwd -r gopalakrishnan_k -a ram");
InputStreamReader reader=new InputStreamReader(System.in);
BufferedReader OptFromCmd = new BufferedReader(new InputStreamReader(
p.getInputStream()));
BufferedReader fromKeyboard = new BufferedReader(reader);
BufferedReader stdError = new BufferedReader(new InputStreamReader(
p.getErrorStream()));
OutputStream stdOut = p.getOutputStream();
String s;
String pswd = "mahesh";
System.out.println("Success");
int i = 0;
while ((s = OptFromCmd.readLine()) != null) {
//s = OptFromCmd.readLine();
i++;
System.out.println(s);
System.out.println(i);
if (i > 1) {
stdOut.write(pswd.getBytes());
stdOut.flush();
System.out.println(
"Here is the standard error of the command (if any):\n");
while ((s = stdError.readLine()) != null) {
System.out.println(s);
/* Your Password Here */
String password="Password Please";
stdOut.write(password.getBytes());
stdOut.flush();
stdOut.write(password.getBytes());
stdOut.flush();
/* Your Password here */
OptFromCmd.close();
stdError.close();
stdOut.close();
} catch (Exception e) {
e.printStackTrace();
</code>
[o/p]
this program gives the output as
adding the user <username>
password:
now i need to enter the password from java envronment and provide it in the command prompt .
then it prompts for the password again for confirmation so i have to retype the password again
how to acheive this.String abc[]={"sh","-c","/dir1/dir2/dir3/scanVirus/uvscan --clean -- delete --exit-on-error ../*.*>abcde.txt"};
Runtime runtime = Runtime.getRuntime();
Process p = runtime.exec(abc);
when it founds any infected file the process is not terminated correctly and it gives the following error :
"java.lang.Exception: Process failed to terminate correctly"
but it deletes the infected file.
and running the program second time (after deletion of infected file), it executed fine.
Wating for help.
Regards,
Sundeep. -
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 -
How to read a string from file & assign the val to a variable in batch file
Hi,
How to read a string from a file and assign the value to a variable then return the value to the screen in windows batch file?
Any suggestions?
thanks.Unless this is a homework question then I don't see the purpose of doing this, but....
You should be looking a the supplied package utl_file to get the string out of the file, dbms_output to display the string and then google windows batch/command files calling sqlplus to execute your program.
Andre -
How to execute an sql function containing a SELECT query as paramete
Hi
I want to execute this sql query using JDBC methods , but could not be able to find any appropriate method to execute this query.
select dbms_xmlgen.getxml(select * from departments) from dual
please some one help with appropriate java code to execute it.
Thank you>
I want to execute this sql query using JDBC methods , but could not be able to find any appropriate method to execute this query.
select dbms_xmlgen.getxml(select * from departments) from dual
please some one help with appropriate java code to execute it.
>
Java code? You can't execute that query at all since it is invalid. The parameter needs to be a query string NOT a query.
select dbms_xmlgen.getxml('select * from departments') from dual See the DBMS_XMLGEN package in the docs
http://docs.oracle.com/cd/B28359_01/appdev.111/b28419/d_xmlgen.htm#i1013206
>
Converts the results from the SQL query string to XML format, and returns the XML as a temporary CLOB, which must be subsequently freed using the DBMS_LOB.FREETEMPORARY call:
DBMS_XMLGEN.GETXML (
sqlQuery IN VARCHAR2,
dtdOrSchema IN number := NONE)
RETURN CLOB;
>
Then you execute that query like any other query that returns a result set. The result set will consist of one row and one column of CLOB datatype.
See the JDBC Developer's Guide - it has examples of how to execute queries that return result sets.
And this section shows how tow read/write CLOBs
http://docs.oracle.com/cd/B28359_01/java.111/b31224/oralob.htm#sthref755 -
How to execute the method of a class loaded
Hi,
I have to execute the method of com.common.helper.EANCRatingHelper" + version
version may be 1,2, etc
if version = 1 the class is com.common.helper.EANCRatingHelper1;
Iam able to load the class using following code.But iam unable to execute the method of the above class
Can anybody help me how to execute the method of the class loaded.
Following is the code
String version = getHelperClassVersion(requestDate);
String helperClass = "com.redroller.common.carriers.eanc.helper.EANCRatingHelper" + version;
Class eancRatingHelper = Class.forName(helperClass);
eancRatingHelper.newInstance();
eancRatingHelper.saveRating(); This is not executing throwing an error no method.
ThankseancRatingHelper.newInstance();Ok, that creates an instance, but you just threw it away. You need to save the return of that.
Object helper = eancRatingHelper.newInstance();
eancRatingHelper.saveRating(); This is not executing throwing an error no method.Of course. eancRatingHelper is a Class object, not an instance of your EANCRatingHelper object. The "helper" object I created above is (though it is only of type "Object" right now) -- you have to cast it to the desired class, and then call the method on that.
Hopefully EANCRatingHelper1 and 2 share a common interface, or you're up the creek. -
How to execute a PL/SQL in JAVA
I know how to execute a store procedure in PL/SQ. But how to execute a PL/SQL in JSP or other JAVA application?
Thank you!<BLOCKQUOTE><font size="1" face="Verdana, Arial, Helvetica">quote:</font><HR>Originally posted by Chin Chia Liang ([email protected]):
I know how to execute a store procedure in PL/SQ. But how to execute a PL/SQL in JSP or other JAVA application?
Thank you!<HR></BLOCKQUOTE>
You should use CallableStatement.
import java.sql.*;
class StoreProc
public static void main (String args [])
throws SQLException {
try {
DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
Connection conn =DriverManager.getConnection ("jdbc:oracle:thin:@testing:1521:test1", "scott", "tiger");
//create procedure and call it in java (testproc)
CallableStatement cstmt = conn.prepareCall("{call testproc(?,?)}");
cstmt.setString(1, "teststore");
(2, "testagain");
cstmt.executeUpdate();
cstmt .close();
conn.close();
catch(SQLException e)
System.out.println("SQLException caught: " + e.getMessage()+" "+e.getErrorCode());
null -
Workspace Error executing query: String index out of range: -39
I am running a Financial Reporting Book.
When running this book, I am receiving the following error.
Error executing query: String index out of range: -39
What does this mean?
And how do I fix this?
Thank you,
DanThis is happening to a single Financial Reporting book.
Oracle suggested changing the Data Query Optimization settings.
I had checked on Essbase Queries Use MDX on all the reports being called into the book.
Oracle suggested that I uncheck this box.
This did not do the trick.
I ran the reports individually, and they all worked.
I am stumped. -
How to Execute different classes using editplus
Consider a program like this
class abc
public static void main(String args[])
System.out.println("abc");
class bbc
public static void main(String args[])
System.out.println("bbc");
In this program there are two classes when i compile this code in editplus i wont get any error but if i want to execute only ABC class how to do that in editplus because in editplus we usually set the file name for JAVA execution
But here it is different SO,how to execute different classes in a program which is saved with arbitary name in EDIT PLUS..Try reading an editplus FAQ or posting to an editplus forum or even searching through help in editplus.
Maybe you are looking for
-
Questions about using FILE adapter to connect to other systems
Hi, in my PI scenario i am facing a problem in usage of the file adapter. Our PI system is installed on a UNIX server. The target system for upload an download files is a WINDOWS system. The software installed on the WINDOWS system is only able to ex
-
I need advise and help with this problem . First , I have been with Mac for many years ( 14 to be exact ) I do have some knowledge and understanding of Apple product . At the present time I'm having lots of problems with the router so I was looking i
-
Simple FD for generating ALV report using purchase order or sales order
Can anybody send me a simple FD for generating ALV as well as interactive report for purchase order and sales order
-
Plain HTTP Adapter vs SOAP Adapter with regards to SSL
Hi, I need to setup communication channles within XI to send and receive secure xml. I am confused after reading the XI documentation and the some of the discussion forums on SDN. Can anyone clarify the following: 1) Does the plain HTTP Adapter suppo
-
CPU not showing up in System Profiler
Hi, I have a 4 year old Dual 2.5 GHz G5 which I think has had a CPU failure (B CPU). The system profiler states that I only have one, not two CPU's. Is it a case of using a repair CD to reset the lost CPU or is it dead? Any ideas anyone? Thanks in ad