Display SQL results in flash
Hi all,
Can anyone tell me how I would go about setting up flash to display results returned by a SQL query one at a time. I can work out the query and PHP, but want I want to know is how to make flash take each one and animate it, including pausing and clearing the screen when full, then continuing on a 'new' screen. It's basically for displaying a list of events in a database.
So, looking at the movie in action, you would see
Blank screen
Event 1 (pause)
Event 2 (pause)
Event 3 (pause)
(pause and fade out)
New screen
Event 4
Event 5
Event 6
...and so on until all the results had been displayed.
Any help much appreciated. In fact, it may be that actually what I need is help as to how to achieve this returning from xml. It's really the actionscript I'm lost on.
Thanks
James
If you don't have a handle on managing dynamic content in Flash, then for the time being you should focus on resolving just that aspect and save integrating the sql/php/xml afterwards. For now just creat an array of stufff that you want to process in the manner you desire and work it from there. Eventually, that's what you end up with when you feed the file the data anyways.
As far as the pausing and animating aspects go, your best bet will be to search Google for a tutorial regarding maybe a slideshow or marquee that runs automatically. Figure out how it works and then figure out how to turn it into something that suits your needs.
The basic tools you'll be after will be the Tween class for animating and the Timer class for triggering pausing/motion, along with their respective event listeners. If you can find simple tutorials just for those two things separately, you might be able to reason out the merger for what you're after.
Similar Messages
-
Dear all,
I need some advice on how to display results of an SQL query in Forms.My scenario is as follows:
The use need to searchs for a First name in Table called Customers.
Users enters User name need and press Search Button.I need to display all names that matches his criteria.
How to do that in Forms?
ThanksThe easiest way to do this would be to create two data blocks. The first is a Control block (not based on a database table) and only has the FIRST_NAME field and the Search button. The second block is a base table block based on the CUSTOMER table. Use the name entered in the FIRST_NAME field to filter the records in a base table block. When your user clicks on the Search Button, the code in the button would simply add the FIRST_NAME value to the WHERE clause of the base table block and then call the EXECUTE_QUERY() built-in to query the block.
When-Button-Pressed Trigger Example:
BEGIN
IF :query_block.first_name IS NOT NULL THEN
SET_BLOCK_PROPERTY('data_block',default_where,'first_name = :query_block.first_name');
go_block('data_block');
execute_query;
ELSE
message('Please enter a name before searching.');
END IF;
END;Default functionality in Oracle Forms will handle the rest.
Hope this helps.
Craig... -
Displaying SQL results in Web Pages from non-native DBs?
How do developers process the results from SQL queries fron non-narive DBs? If Spry Data sets are the best approach do I save the query as a .htnl file with the results formatted as an HTMLDataset or do I save the SQL query as an XML file? What other options do I have?
TIA Ephraim.Hi
You will require a database driver for PHP in order for it to communicate with your chosen database, you can find a list of supported drivers here - http://php.net/manual/en/pdo.drivers.php.
However this will require you to use PHP:PDO for the querys/inserts/updates etc, see - http://php.net/manual/en/book.pdo.php. PDO is supported by the zend framework or you can code your own by following the examples given in the php:pdo manual, (link above).
The good news is that by using pdo it is possible to use prepared statements and transactions if your database supports these. Prepared statements are the recommended method of issuing queries etc.
PZ -
Displaying SQL result in data grid
I'm trying to access a local DB file using an Air app. I can
successfully create the connection and connect; what I'm really
stuck on is displaying the data from my request in a Data Grid.
Using this code I can see my records in the console, but how
do I get it into a data grid? It doesn't seem to want to go into an
ArrayColleciton.
quote:
function selectResult(event:SQLEvent):void
var result:SQLResult = selectStmt.getResult();
resultData = result;
var numRows:int = result.data.length;
for (var i:int = 0; i < numRows; i++)
var output:String = "";
for (var columnName:String in result.data
output += columnName + ": " + result.data[columnName] +
trace("row[" + i.toString() + "]\t", output);"arthurlockman" <[email protected]> wrote in
message
news:g7lfrq$qi$[email protected]..
>I want to have an image component that gets it's source
from the item that
>is
> currently selected selected in a data grid (like a
master detail region).
> I
> also want to do the same with a text box and a text
area. How do i do it?
yourDataGrid.selectedItem will contain the data from the
selected item. -
SQL*plus not displaying the result of XMLELEMENT
HI,
I am using SQL*Plus: Release 10.1.0.4.2
Connected to: Oracle Database 10g Enterprise Edition Release 10.2.0.4.0
When I run the following query in SQL*PLUS, I get nothing displayed. However when I run the same query connecting to the same database using SQL Developer then I get the result
SQL> select XMLELEMENT("form_id",form_id)
2 FROM collections;
XMLELEMENT("FORM_ID",FORM_ID)
In SQL developer
<form_id>101</form_id>
I set long and longchuncksize to 32K , and I change linesize, pages, but nothing helped
Is there any configuration that I have to do, so that SQL*plus display the result of “ select XMLELEMENT("form_id",form_id) query.
Appreciate you help, thanksFrom a fresh start ;) :
SQL*Plus: Release 10.1.0.4.2 - Production on Fri Feb 26 15:29:04 2010
Copyright (c) 1982, 2005, Oracle. All rights reserved.
Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.3.0 - 64bit Production
With the Partitioning, OLAP and Data Mining options
SQL> select xmlelement("value", a.object_name )
2 from all_objects a
3 where rownum <= 5;
XMLELEMENT("VALUE",A.OBJECT_NAME)
SQL> select xmlelement("value", (select b.object_name
2 from all_objects b
3 where b.object_name = a.object_name
4 )
5 )
6 from all_objects a
7 where rownum <= 5;
XMLELEMENT("VALUE",(SELECTB.OBJECT_NAMEFROMALL_OBJECTSBWHEREB.OBJECT_NAME=A.OBJE
<value>ICOL$</value>
<value>I_USER1</value>
<value>CON$</value>
<value>UNDO$</value>
<value>C_COBJ#</value>
SQL> show all
appinfo is OFF and set to "SQL*Plus"
arraysize 15
autocommit OFF
autoprint OFF
autorecovery OFF
autotrace OFF
blockterminator "." (hex 2e)
btitle OFF and is the first few characters of the next SELECT statement
cmdsep OFF
colsep " "
compatibility version NATIVE
concat "." (hex 2e)
copycommit 0
COPYTYPECHECK is ON
define "&" (hex 26)
describe DEPTH 1 LINENUM OFF INDENT ON
echo OFF
editfile "afiedt.buf"
embedded OFF
escape OFF
FEEDBACK ON for 6 or more rows
flagger OFF
flush ON
heading ON
headsep "|" (hex 7c)
instance "local"
linesize 80
lno 9
loboffset 1
logsource ""
long 80
longchunksize 80
markup HTML OFF HEAD "<style type='text/css'> body {font:10pt Arial,Helvetica,sans-serif; color:blac
newpage 1
null ""
numformat ""
numwidth 10
pagesize 14
PAUSE is OFF
pno 1
recsep WRAP
recsepchar " " (hex 20)
release 1002000300
repfooter OFF and is NULL
repheader OFF and is NULL
serveroutput OFF
shiftinout INVISIBLE
showmode OFF
spool OFF
sqlblanklines OFF
sqlcase MIXED
sqlcode 0
sqlcontinue "> "
sqlnumber ON
sqlpluscompatibility 10.1.0
sqlprefix "#" (hex 23)
sqlprompt "SQL> "
sqlterminator ";" (hex 3b)
suffix "sql"
tab ON
termout ON
timing OFF
trimout ON
trimspool OFF
ttitle OFF and is the first few characters of the next SELECT statement
underline "-" (hex 2d)
USER is "HR"
verify ON
wrap : lines will be wrapped
SQL>
{code} -
To_char displays different results on sql client and server
Hi,
I am executing the below query on my database with 8.1.7.4 version:
SQL> select to_char(to_date('20-OCT-07'),'D') from dual;
The following result is displayed:
T
7
When the same query is being run through sqlplus client(9.2.0.3) connecting to the same database, following result is being displayed:
SQL> select to_char(to_date('20-OCT-07'),'D') from dual;
T
6
Could anyone please explain me why is this difference and what parameter setting needs to be made to get the same result.
Thanks in advance,
VishwanathOr from the territory part of NLS_LANG OS variable :
oracle@xxx:/home/oracle# echo $NLS_LANG
AMERICAN_AMERICA.UTF8
oracle@xxx:/home/oracle# sqlplus '/ as sysdba'
SQL*Plus: Release 9.2.0.8.0 - Production on Mon Oct 22 10:44:59 2007
Copyright (c) 1982, 2002, Oracle Corporation. All rights reserved.
Connected to:
Oracle9i Enterprise Edition Release 9.2.0.8.0 - 64bit Production
With the Partitioning, OLAP and Oracle Data Mining options
JServer Release 9.2.0.8.0 - Production
SQL> select to_char(to_date('20-OCT-07'),'D') from dual;
T
7
SQL> quit
Disconnected from Oracle9i Enterprise Edition Release 9.2.0.8.0 - 64bit Production
With the Partitioning, OLAP and Oracle Data Mining options
JServer Release 9.2.0.8.0 - Production
oracle@xxx:/home/oracle# export NLS_LANG=AMERICAN_FRANCE.UTF8
oracle@xxx:/home/oracle# sqlplus '/ as sysdba'
SQL*Plus: Release 9.2.0.8.0 - Production on Mon Oct 22 10:45:38 2007
Copyright (c) 1982, 2002, Oracle Corporation. All rights reserved.
Connected to:
Oracle9i Enterprise Edition Release 9.2.0.8.0 - 64bit Production
With the Partitioning, OLAP and Oracle Data Mining options
JServer Release 9.2.0.8.0 - Production
SQL> select to_char(to_date('20-OCT-07'),'D') from dual;
T
6
SQL>Check it on both sites (client and server).
Nicolas. -
Displaying SQL Query results in rows instead of Columns
Hi,
I'm fairly new to Oracle so forgive me if this is a really stupid question.
I used Mysql for a while and if I wanted to display query results in rows instead of columns I could end the SQL command with '\G' instead of a semicolon.
This would give me output like...
Column_1: AAAA
Column_2: BBBB
Column_3: CCCC
Instead of the normal
Column_1 Column_2 Column_3
AAAAAA BBBBBBB CCCCCCC
Is there an equivalent in SQLPlus to the MySQL \G termination?
Thanks.
John> so forgive me if this is a really stupid question.
It is certainly not a stupid question, but pivoting is a very frequently asked and answered question:
[url http://forums.oracle.com/forums/search.jspa?threadID=&q=pivot&objID=f75&dateRange=all&userID=&numResults=15]http://forums.oracle.com/forums/search.jspa?threadID=&q=pivot&objID=f75&dateRange=all&userID=&numResults=15
In 11g you have special PIVOT and UNPIVOT functions.
Regards,
Rob. -
i have a c++ form that accepts data and saves it on a table in a database via a button click, this is the code for the eventprivate: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e) {
String^ constring=L"datasource=localhost;port=3306;username=root;password=lampard";
MySqlConnection^ conDatabase=gcnew MySqlConnection(constring);
MySqlCommand^ cmdDatabase=gcnew MySqlCommand("insert into test.Data(Full_Name,Matric_No) values('"+this->textBox1->Text+"','"+this->textBox10->Text+"') ;" ,conDatabase);
MySqlDataReader^ myReader;
try{
conDatabase->Open();
myReader=cmdDatabase->ExecuteReader();
MessageBox::Show("Saved");
while(myReader->Read()){
}catch(Exception^ex){
MessageBox::Show(ex->Message);
NOW i want to send a query to give out this information in a new form or in a form exactly like the one used to enter the data, this is how far i have come
private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e) {
this->Hide();
MyForm ^ Form = gcnew MyForm(this);
Form->ShowDialog();
String^ constring=L"datasource=localhost;port=3306;username=root;password=lampard";
MySqlConnection^ conDatabase=gcnew MySqlConnection(constring);
MySqlCommand^ cmdDatabase=gcnew MySqlCommand("Select * from test.Data where Matric_No='"+textBox1->Text +"';",conDatabase);
MySqlDataReader^ myReader;
try{
conDatabase->Open();
myReader=cmdDatabase->ExecuteReader();
while(myReader->Read()){
textBox1->Text ;
}catch(Exception^ex){
MessageBox::Show(ex->Message);
NOte: MyForm is the title of the form used to enter in the data sent to the database please how do i get the program to display the data meeting the query criteria into a form?i made textBox1 a public memeber of MyForm class and i changed
Form->ShowDialog(); to Form->Show() and i entered the code you advised me to and it displayed the result.i am very grateful, thank you -
How to display the results in order by based on search value
Hi All,
how to display the results in the below order.
CREATE TABLE TEST( SONGID NUMBER, TITLE VARCHAR2(200))
INSERT INTO TEST(SONGID,TITLE) VALUES (10,'AHMADZAI, MIRWAIS (CA)/ MADONNA (CA)');
INSERT INTO TEST(SONGID,TITLE) VALUES (11,'CICCONE, MADONNA (CA)');
INSERT INTO TEST(SONGID,TITLE) VALUES (12,'DALLIN, MADONNA LOUISE/STOCK');
INSERT INTO TEST(SONGID,TITLE) VALUES (13,'MADONNA');
INSERT INTO TEST(SONGID,TITLE) VALUES (14,'MADONNA (A)/ AHMADZAI, MIRWAIS (C)');
INSERT INTO TEST(SONGID,TITLE) VALUES (15,'MADONNA (CA)');
INSERT INTO TEST(SONGID,TITLE) VALUES (16,'MIRWAIS AHMADZAI, MADONNA');
INSERT INTO TEST(SONGID,TITLE) VALUES (17,'MIRWAIS (CA)/ MADONNA (CA),AHMADZAI');
INSERT INTO TEST(SONGID,TITLE) VALUES (18,'MADONNA (CA),CICCONE');
SELECT *FROM TEST WHERE INSTR (TITLE, 'MADONNA') > 0
output:
SONGID TITLE
10 AHMADZAI, MIRWAIS (CA)/ MADONNA (CA)
11 CICCONE, MADONNA (CA)
12 DALLIN, MADONNA LOUISE/STOCK
13 MADONNA
14 MADONNA (A)/ AHMADZAI, MIRWAIS (C)
15 MADONNA (CA)
16 MIRWAIS AHMADZAI, MADONNA
17 MIRWAIS (CA)/ MADONNA (CA),AHMADZAI
18 MADONNA (CA),CICCONE
Expected output :
13 MADONNA
14 MADONNA (A)/ AHMADZAI, MIRWAIS (C)
15 MADONNA (CA)
18 MADONNA (CA),CICCONE
...if user searches with 'MADONNA' , I have to display the results like title starts with 'MADONNA' first then rest of the records.
Please let me know is it possible to display the results in that order.
Regards,
RajasekharThis may be a bit more accurate:
SQL> SELECT *
2 FROM TEST
3 WHERE INSTR (TITLE, 'MADONNA') > 0
4 ORDER BY INSTR (TITLE, 'MADONNA')
5 ,TITLE
6 ;
SONGID TITLE
13 MADONNA
14 MADONNA (A)/ AHMADZAI, MIRWAIS (C)
15 MADONNA (CA)
18 MADONNA (CA),CICCONE
12 DALLIN, MADONNA LOUISE/STOCK
11 CICCONE, MADONNA (CA)
17 MIRWAIS (CA)/ MADONNA (CA),AHMADZAI
16 MIRWAIS AHMADZAI, MADONNA
10 AHMADZAI, MIRWAIS (CA)/ MADONNA (CA) -
Search button not displaying search results
I have created a page where you enter a string and click a search button and it will display the file that contains that string. It works on one page but not any of the other pages I have created. I went to dkubiceck page and copied the code for the search button there.
This is the code I used to run the query to bring up the document information:
select score(1) relevance, filename,transcript_id,
dbms_lob.getlength("trans_document") "trans_document"
from transcript_documents
where contains (trans_document, :P20_SEARCH, 1) > 0
order by 1 desc
I can run the script in sql workshop and it returns information but I can't get the page to display anything so I think it has something to do with the search button. Does it have something to do with the button request. I have the request as go which is what the Oracle Text for APEX tutorial indicates. I am at a loss as to why it is working in one place and not in another. HELP!!!!!!!I used the Using Oracle Application Express to Build
Oracle Text Web Applications An Oracle White Paper documentation to create this button. The instructions to create the button is below.
http://www.oracle.com/technology/products/database/application_express/pdf/apex_text_application_v1.6.pdf
To create a button to submit the search:
1. Under Buttons, click the create icon ().
2. For Region, select Search Terms(s).
3. For Task, select Create a button displayed among this region’s items.
4. For Button Name, enter P1_FIND.
5. For Label, enter Find.
6. For Button Style, select HTML Button.
Run your page using the run page icon () and your development username and password. Your page should look similar to the following figure.
This was the instructions to create the query region:
To create a query region:
1. Navigate back to the Page Definition for the Search page. You can do this by using the edit links at the bottom of the running page, Edit Page 1.
2. Under Regions, click the create icon ().
3. For Region Type, select Report.
4. For Report Implementation, select SQL Report.
5. For Title, enter Results.
Using Oracle Application Express to Build Oracle Text Web Applications Page 9
6. Enter the following SQL query:
select score(1) relevance, doc_title, doc_url
from htmldb_documentation
where CONTAINS (doc_url, :P1_SEARCH, 1) > 0
order by 1 desc
7. For Display Conditions, for Condition Type, select Value of Item in Expression 1 is NOT NULL.
8. For Expression 1, enter P1_SEARCH.
This condition specifies to only display the Results region if a term is entered as a search criterion.
Run the page and enter a search criterion for Term(s). Your results should look similar to the following figure.
Figure 2.0
The only thing I added to the query above is a dbms_doc.getlength statement to be able to open a link to the document.
The first 2 times I created this on a page it worked just fine. But now no matter what conputer or schema or application I create this button in it won't display the results. I can admit that I have no experience creating a button with a different request than what comes up in the wizard. And the documentation that I found on creating buttons was of no help.
I have not made any changes to anything in the wizard so can someone guide me as to how to create a button that will allow me to search a document using Oracle Text as described above -
Class not found javax.servlet.jsp.jstl.sql.Result in Richfaces
When I try to run the richfaces application using Weblogic 10.3 AS and Netbean IDE 6.9.1, I found ClassNotFoundException on javax.servlet.jsp.jstl.sql.Result class.
I class path the following libs.
commons-beanutils-core-1.8.0.jar
commons-digester-1.8.jar
commons-fileupload-1.2.1.jar
commons-io-1.2.jar
commons-logging-1.1.1.jar
glassfish.el_2.1.1.jar
glassfish.jsf_1.2.9.0.jar
javassist-3.8.0.GA.jar
jhighlight-1.0.jar
jsf-facelets.jar
jsf-api.jar
log4j-1.2.14.jar
richfaces-api-3.3.0.GA.jar
richfaces-impl-3.3.0.GA.jar
richfaces-ui-3.3.0.GA.jar
glassfish.jstl_1.2.0.1.jar
Also I try to deploy without using some jar files already exists in application server.
My web.xml configuration is-
<context-param>
<param-name>org.richfaces.SKIN</param-name>
<param-value>#{skinSelector.skin}</param-value>
</context-param>
<context-param>
<param-name>org.richfaces.CONTROL_SKINNING</param-name>
<param-value>enable</param-value>
</context-param>
<context-param>
<param-name>org.ajax4jsf.VIEW_HANDLERS</param-name>
<param-value>com.sun.facelets.FaceletViewHandler</param-value>
</context-param>
<context-param>
<param-name>javax.faces.DEFAULT_SUFFIX</param-name>
<param-value>.xhtml</param-value>
</context-param>
<context-param>
<param-name>javax.faces.STATE_SAVING_METHOD</param-name>
<param-value>server</param-value>
</context-param>
<context-param>
<param-name>org.ajax4jsf.SKIN</param-name>
<param-value>skin_name</param-value>
</context-param>
<filter>
<display-name>RichFaces Filter</display-name>
<filter-name>richfaces</filter-name>
<filter-class>org.ajax4jsf.Filter</filter-class>
</filter>
<filter-mapping>
<filter-name>richfaces</filter-name>
<servlet-name>Faces Servlet</servlet-name>
<dispatcher>REQUEST</dispatcher>
<dispatcher>FORWARD</dispatcher>
<dispatcher>INCLUDE</dispatcher>
</filter-mapping>
<servlet>
<servlet-name>Faces Servlet</servlet-name>
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.jsf</url-pattern>
</servlet-mapping>
<login-config>
<auth-method>BASIC</auth-method>
</login-config>
<listener>
<listener-class>com.sun.faces.config.ConfigureListener</listener-class>
</listener>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
I also try to configure <library-ref>....</libray-ref> configuration in weblogic.xml and weblogic-application.xml and I also deploy JSF-2.0.war as library in application.
Please
h5.MUTUSo why didn't you think that the JSP forum here wasn't a good place to ask JSP questions like this one?
You can use <c:for-each> with a List. That's how it's designed. I don't understand why you say you can't. Perhaps you were confused by the SQL tags in JSTL. But anyway, you should just return a List from your EJB and forget about using obscure internal JSP classes. -
2.1 EA2 does not display query results, query works fine in sqlplus
2.1 EA2/Windows XP 32-bit
The following query does not show any results for Total(GB) and Free(GB) columns. The diskgroup name shows correctly.
SELECT
DG.name ,
ROUND(SUM(DSK.TOTAL_MB)/1024,2) "Total (GB)",
round(SUM(DSK.FREE_MB)/1024,2) "Free (GB)"
FROM
V$ASM_DISK DSK,
V$ASM_DISKGROUP DG
WHERE
DSK.GROUP_NUMBER=DG.GROUP_NUMBER
group by DG.name;
The query works fine when run from SQL*Plus:
SQL> SELECT
2 DG.name ,
3 ROUND(SUM(DSK.TOTAL_MB)/1024,2) "Total (GB)",
4 round(SUM(DSK.FREE_MB)/1024,2) "Free (GB)"
5 FROM
6 V$ASM_DISK DSK,
7 V$ASM_DISKGROUP DG
8 WHERE
9 DSK.GROUP_NUMBER=DG.GROUP_NUMBER
10 GROUP BY DG.name;
NAME Total (GB) Free (GB)
DG1 707.98 162.32
DG2 134.84 122.68
SQL>
This must be something unique to SQLDeveloper. I tested in 2.1 EA1 and 1.5.5.59.69 and the query does not show results for the Total (GB) and Free (GB) columns.I would like to update the problem. It seems like when SQLDeveloper is connected to ASM instance, it has trouble using the divide operator (/). For example, the following query works fine:
SELECT
name,
TOTAL_MB
FROM
V$ASM_DISKGROUP;
But if I try to divide the TOTAL_MB by any number, the column shows blank (the column is blank, not NULL). So, if I try to run the following query, the output will just display diskgroup names. The TOTAL_MB/1024 column shows blank.
SELECT
name,
TOTAL_MB/1024
FROM
V$ASM_DISKGROUP;
If I run the same query in SQL*Plus from the same desktop using the same TNS alias, it works just fine which tells me that it is a SQLDeveloper problem.
When I am connected to a regular database, then the problem does not show up and SQLDeveloper is able to display the results even when I am using the divide operator (/). -
How to connect sql database with Flash
Dear Friends,
Iam working on a quessinarie (assesment) for elearning software. i want to connect sql database with flash and save my records in back end like add, delete, modification of student result and details.
Kindly help me to connect the sql database. or dot net server. I know how to connect PHP and mysql. But my client dont want php. only sql database and do the add, del, modificaiton.
Thanks in advance,
Syed Abdul Rahimunfortunately no, i do not know ASP well enough to give any code advice, other than the basic concept: make a request on a server-side script (such as ASP) via URLLoader - the script receives variable values (if required), runs the DB queries you wish to invoke, and 'returns' the results - pick them up in the URLVariables class via the event handler in Flash and assign them to local properties if needed, etc.
there are quite a few threads that you could find more specific information on the ASP side, here and elsewhere around the net. -
How to display sqlplus result in java?
I want to call sqlplus to execute some sql commands in java,but how can i print the result of sqlplus?
In java code ,i call sqlplus like:
Process p;
//execute the command
p = Runtime.getRuntime().exec(commandString);
//print return result of the command
InputStream inputStream = p.getInputStream();
How to display the execution result?
Edited by: Yi on Feb 26, 2012 11:41 PMYou can use ProcessBuilder. This code launches sql*plus and runs the script in the 'filename' variable. It displays the results in NetBeans console.
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.File;
import java.util.Map;
public class test1 {
public static void main (String args []) {
test_script();
public static void test_script () {
String fileName = "@test_table.sql";
String sqlPath = "E:\\";
String sqlCmd = "sqlplus";
String arg1 = "user/password@sid"; -- plug in your user, password and db name
String arg2 = fileName;
try {
String line;
ProcessBuilder pb = new ProcessBuilder(sqlCmd, arg1, arg2);
Map<String, String> env = pb.environment();
env.put("VAR1", arg1);
env.put("VAR2", arg2);
pb.directory(new File(sqlPath));
pb.redirectErrorStream(true);
Process p = pb.start();
BufferedReader bri = new BufferedReader
(new InputStreamReader(p.getInputStream()));
BufferedReader bre = new BufferedReader
(new InputStreamReader(p.getErrorStream()));
while ((line = bri.readLine()) != null) {
System.out.println(line);
bri.close();
while ((line = bre.readLine()) != null) {
System.out.println(line);
bre.close();
System.out.println("Done.");
catch (Exception err) {
err.printStackTrace();
}Here is the contents of the script placed at E:\\test_table.sql
Prompt drop TABLE ANOTHER_TEST;
DROP TABLE ANOTHER_TEST CASCADE CONSTRAINTS
Prompt Table ANOTHER_TEST;
CREATE TABLE ANOTHER_TEST
BATCH_SEQ NUMBER,
BATCH_GROUP_ID NUMBER,
STATUS_FLAG VARCHAR2(30 BYTE),
OBJ_BEING_PROCESSED VARCHAR2(80 BYTE),
BATCH_RUN_START_DTTM DATE,
BATCH_RUN_END_DTTM DATE,
CREATE_DTTM DATE,
CREATE_USER VARCHAR2(30 BYTE),
UPDATE_DTTM DATE,
UPDATE_USER VARCHAR2(30 BYTE)
LOGGING
NOCOMPRESS
NOCACHE
PARALLEL ( DEGREE DEFAULT INSTANCES DEFAULT )
MONITORING
COMMENT ON TABLE ANOTHER_TEST IS 'This is a test table.'
EXIT
/ -
How to Read the one Source Column data and Display the Results
Hi All,
I have one PR_ProjectType Column in my Mastertable,Based on that Column we need to reed the column data and Display the Results
Ex:
Pr_ProjectType
AD,AM
AD
AM
AD,AM,TS,CS.OT,TS
AD,AM
like that data will come now we need 1. Ad,AM then same we need 2. AD also same we need 3. AM also we need
4.AD,AM,TS,CS.OT,TS in this string we need AD,AM only.
this logic we need we have thousand of data in the table.Please help this is urgent issue
vasuHi Vasu,
Based on your description, you want to eliminate the substrings (eliminated by comma) that are not AD or AM in each value of the column. Personally, I don’t think this can be done by just using an expression in the Derived Column. To achieve your goal, here
are two approaches for your reference:
Method 1: On the query level. Replace the target substrings with different integer characters, and create a function to eliminate non-numeric characters, then replace the integer characters with the corresponding substrings. The statements
for the custom function is as follows:
CREATE FUNCTION dbo.udf_GetNumeric
(@strAlphaNumeric VARCHAR(256))
RETURNS VARCHAR(256)
AS
BEGIN
DECLARE @intAlpha INT
SET @intAlpha = PATINDEX('%[^0-9]%', @strAlphaNumeric)
BEGIN
WHILE @intAlpha > 0
BEGIN
SET @strAlphaNumeric = STUFF(@strAlphaNumeric, @intAlpha, 1, '' )
SET @intAlpha = PATINDEX('%[^0-9]%', @strAlphaNumeric )
END
END
RETURN ISNULL(@strAlphaNumeric,0)
END
GO
The SQL commands used in the OLE DB Source is like:
SELECT
ID, REPLACE(REPLACE(REPLACE(REPLACE(dbo.udf_GetNumeric(REPLACE(REPLACE(REPLACE(REPLACE([ProjectType],'AD,',1),'AM,',2),'AD',3),'AM',4)),4,'AM'),3,'AD'),2,'AM,'),1,'AD,')
FROM MyTable
Method 2: Using a Script Component. Add a Derived Column Transform to replace the target substrings as method 1, use Regex in script to remove all non-numeric characters from the string, add another Derived Column to replace the integer
characters to the corresponding substring. The script is as follows:
using System.Text.RegularExpressions;
Row.OutProjectType= Regex.Replace(Row.ProjectType, "[^.0-9]", "");
References:
http://blog.sqlauthority.com/2008/10/14/sql-server-get-numeric-value-from-alpha-numeric-string-udf-for-get-numeric-numbers-only/
http://labs.kaliko.com/2009/09/c-remove-all-non-numeric-characters.html
Regards,
Mike Yin
TechNet Community Support
Maybe you are looking for
-
SD Billing doc was not created
Hi, we have a sales document and the status of order is completed.But the invoice hasn't created.It shows Account determination error.It is not creating the Acc doc. what could be the possibilities?? Krish.
-
Determining number of lines in a File without loading it to memory
hello guys, I'm just wondering if there is a way to know the number of lines in a file without having to load the file entirely into memory and count the lines. in my project i have a restriction that says that i'm not allowed to load into memory mor
-
Using Spanish characters in CF
I need help setting my coldfusion application tu show accents ans othe characters that are used in spanish but when I use them it shows a different character.
-
BDC/BAPI Assign characteristics to material using CL24n
Hi Gurus My requirement is : We have already assigned characteristics to the material class, Now we need to assign characteristics values to materials. Assign characteristics to material using cl24n(Class name & Classtype) > only new assignments > ma
-
Was able to create guest network but when I try to access guest network to test it, I cannot connect. I tried iPad and iPhone.