MySQL temporary tables or call Stored procedures in CS4
I need to filter the results by username before making a LEFT JOIN and including lines or IS NULL. The SQL works from the mysqli client, either by creating a temporary table using the "create a temporary table temp_appts select * from...» "Or by creating a stored procedure that contains the statement even 'create temporary table' and then running my LEFT JOIN statement against the temporary table.
I've tried both in CS4, it accepts the code 'code' without errors but the page loads in a browser as a white or a 500 error in Internet Explorer. From my experience, this is caused by the exit before arriving to the html header.
Is it possible to do either in CS4? Here is the code I use.
$varU_temp_appts = "-1";
If (isset (<? php $_SESSION ['MM_Username'])) {}
$varU_temp_appts = $_SESSION ['MM_Username"];
}
@mysql_select_db ($database_ess, $ess);
$query_temp_appts = sprintf ("' CREATE TEMPORARY TABLE SELECT temp_appts * of appts WHERE username = %s", /GetSQLValueString($varU_temp_appts,"text") ");
$temp_appts = mysql_query ($query_temp_appts, $ess) or die (mysql_error ());
$row_temp_appts = mysql_fetch_assoc ($temp_appts);
$totalRows_temp_appts = mysql_num_rows ($temp_appts);
@mysql_select_db ($database_ess, $ess);
$query_todays_appts = "SELECT * from appt_tm LEFT JOIN (temp_appts) ON appt_tm.appt_time = temp_appts.appt_hr WHERE (appt_date = CURDATE () OR appt_date IS NULL)";
$todays_appts = mysql_query ($query_todays_appts, $ess) or die (mysql_error ());
$row_todays_appts = mysql_fetch_assoc ($todays_appts);
$totalRows_todays_appts = mysql_num_rows ($todays_appts);
Any help is appreciated!
Why not just use a derived table, rather than creating a temporary table?
Tags: Dreamweaver
Similar Questions
-
NullPointerException when calling stored procedure
I have the stored procedure
create or replace PROCEDURE GREETING_PROC
(
TEXT_PARAM IN VARCHAR2
MSG_TEXT VARCHAR2 OUT
) AS
BEGIN
MSG_TEXT: = "Hello" | TEXT_PARAM;
END;
My stored procedure call method
public class UserBean {}
public UserBean() {}
Super();
}
Public Shared Sub main (String [] args) {}
UserBean userBean = new UserBean();
userBean.callP ();
userBean.callStoreProcedure ();
}
public void callStoreProcedure() {}
CallableStatement st = null;
SysUser SysUserEOImpl = new SysUserEOImpl();
try {}
String sql = "BEGIN GREETING_PROC (: TEXT_PARAM,: MSG_TEXT); END; « ;
St = sysUser.getDBTransaction () .createCallableStatement (sql, sysUser.getDBTransaction (). DEFAULT VALUE);
st.setObject ("TEXT_PARAM", "Scoot");
st.registerOutParameter ("MSG_TEXT", Types.VARCHAR);
St.Execute ();
System.out.println ((String) St.GetObject ("MSG_TEXT"));
} catch (SQLException e) {}
throw new Aexception.getLocalizedMessage (e);
}
}
then I got an exception:
Exception in thread "main" java.lang.NullPointerException
at cic.opsi.model.bean.UserBean.callStoreProcedure(UserBean.java:35)
at cic.opsi.model.bean.UserBean.main(UserBean.java:27)
Hello
What statemet is UserBean.java:35)?
Second, create a new SysUserEOImpl()!
If you want to call stored proc, put the java code calling stored proc in ViewRowImpl/ViewObjectImpl/ApplicationModuleImpl and export this code in the customer interface. Then put this method in the pageDef as
a call him as an OperationBinding Zeeshan Baig blog: the PL/SQL procedure call and function in the Oracle ADF application
Extending the functionality of the components Business
ADF/OFA for Oracle Techies: ADF call stored procedure with Out parameters
Latest Oracle technology: call Store procedures for Oracle ADF Application
-
Calling stored procedure - re-edited NullPointerException
Hi all
I am re-editing that my first attempt was quite low.
I want to create a Java application that communicates with an Oracle XE database edition to:
Class.forName ("oracle.jdbc.driver.OracleDriver");
JOptionPane.showMessageDialog (null, "Driver loaded");
Connection con = DriverManager.getConnection ("jdbc:oracle:thin:@//localhost:1521/xe", "SYSTEM", "root");
JOptionPane.showMessageDialog (null, "database connected");
This all works fine and I can perform queries and transactional instructions within the instance of java.
However, I can't call stored procedures that I will receive a null pointer exception. The stored procedure, I try to call returns values however I know it works as I can run it in SQL Developer. The code below is the statement that calls the stored procedure, alll the sources I looked at it's correct, I also tried, cs.executeUpdate and Resultset rs when you try to call the java statement.
public void thread_actionsperformed (ActionEvent c) //generates son
{
Try
{
CallableStatement cs = con.prepareCall ("{call PROCEDURE2}"); Calls a stored procedure that would generate threaded emails
CS. Execute();
JOptionPane.showMessageDialog (null, "Algorithm Threading successfully Executed");
}
catch (SQLException ex)
{
ex.printStackTrace ();
JOptionPane.showMessageDialog (null, "Threading algorithm Executed without success"); Error response
}
catch (NullPointerException ex)
{
ex.printStackTrace ();
JOptionPane.showMessageDialog (null, "Threading algorithm Executed without success"); Error response
}
}
The Java application cannot 'see' the sp? Or is it something to do with privileges? I was puzzled by this during some time now, any help would be greatly appreciated.
java.lang.NullPointerException
at ETA_Final.thread_actionPerformed (ETA_Final.java:332)
to ETA_Final$ 5.actionPerformed(ETA_Final.java:141)
at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1995)
in javax.swing.AbstractButton$ Handler.actionPerformed (AbstractButton.java:2318)
at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:387)
at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:242)
at javax.swing.AbstractButton.doClick(AbstractButton.java:357)
at javax.swing.plaf.basic.BasicMenuItemUI.doClick(BasicMenuItemUI.java:1223)
in javax.swing.plaf.basic.BasicMenuItemUI$ Handler.mouseReleased (BasicMenuItemUI.java:1264)
at java.awt.Component.processMouseEvent(Component.java:6263)
at javax.swing.JComponent.processMouseEvent(JComponent.java:3255)
at java.awt.Component.processEvent(Component.java:6028)
at java.awt.Container.processEvent(Container.java:2041)
at java.awt.Component.dispatchEventImpl(Component.java:4630)
at java.awt.Container.dispatchEventImpl(Container.java:2099)
at java.awt.Component.dispatchEvent(Component.java:4460)
at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4574)
at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4238)
at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4168)
at java.awt.Container.dispatchEventImpl(Container.java:2085)
at java.awt.Window.dispatchEventImpl(Window.java:2475)
at java.awt.Component.dispatchEvent(Component.java:4460)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:599)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:269)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:184)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:174)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:169)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:161)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)
Thank you and best regards,
K
Published by: Outbound86 on April 28, 2010 13:58Hi Kev,
I expected this - so is it possible that your dumb object is null when you are in the ActionListener who manages the procedures?
How will you spend until you use it (line 332), are you using Threads?Thnaks,
Ivaylo -
Call stored procedures in the object module and application of entity
Hello
I've implemented a helper methods that contains the EntiyImpl base class to call stored procedures.
Now, I need to call procedures stored from the module of the application.
Apart from the creation of a module base class asks and the programme of assistance of duplication of code in the method is possible
to share methods of assistance for calling stored procedures between the entity impl and application module impl?
Concerning
PaulSupport code depends on characteristics of an object instance given entity beyond its database transaction?
If so, I'm not sure I see how it could be used with a class of application module.
Otherwise, here's what you do:
Step 1:
Set up the database transaction - you can even choose to. So instead of
{myHelperMethod (Object someParam) protected
DBTransaction trans = getDBTransaction();
...
}This is for change
protected myHelperMethod (DBTransaction trans, someParam Object) {}
...
}Step 2: make the method public and static - once you set DBTransaction, you should be able to do.
public static myHelperMethod (DBTransaction trans, someParam Object) {}
...
}Step 3: Remove your EntityImpl base class method in a utility class:
Public MustInherit class PlSqlUtils {}
private PlSqlUtils() {}public static myHelperMethod (DBTransaction trans, someParam Object) {}
...
}
}When you call the method of application module, object entity or class of same view object, call
PlSqlUtils.myHelperMethod (getDBTransaction (), paramValue);
Unlike Transaction.executeCommand (), allows you to provide features like the setting procedure of parameter values, recovery of the values of the parameters, etc.
Hope this helps,
Avrom -
How to create a table in a stored procedure
Please help me to answer the following question...
How to create a table inside the stored procedure... I want a detailed explanation... Please help mePlease see this link:
http://tinyurl.com/cmq5vo -
Calling stored procedures with parameters with the database connectivity Toolkit
Hi all
I'm new to the forum and struggling to find a solution to a particular problem I have in this respect, using the LabVIEW Database Connectivity Toolkit on a project, I am currently working on my work. I have a database in which I tables and stored procedures with parameters. Some of these stored procedures have input, output and return parameters.
I tried to follow this example, but to no avail: http://digital.ni.com/public.nsf/allkb/07FD130746083E0686257300006326C4?OpenDocument
Such a stored procedure I am working on the implementation is named "dbo.getAllowablePNs", running "SELECT * from DeviceType" (DeviceType is the table). In this case, it requires no input parameter, it has an output parameter that generates the table [cluster] and has a return parameter that returns an integer value (status code for execution) to show if an error occurred. The DeviceType table has 3 columns; ID (PK, int not null), PN (nvarchar ((15), null) and NumMACAddresses (int, null).) I have surpassed many examples and I talk to the support OR try to implement this and similar procedures stored in LabVIEW but have not been successful. I am able to connect to the database with the VI of open connection without error, but spin in some confusion as a result of this step. I then try to use the VI of parameter query create to call the stored procedure and set the parameters. I guess I would then use the Set parameter value for each parameter that is connected to the entry of parameters on the previous query with parameters VI VI? I am also having some confusion during and after these steps as well. I would greatly appreciate advice or suggestions that anyone could have in this situation because I am not a SQL expert. Also, I would be happy to provide more information that might be useful.
Kind regards
Jon
Here's what I use to do this. I think I had to change him create parameterized query VI for him to work. There is a post on the forum about this somewhere.
-
How do we call stored procedure in owb?
Hello
I have 20 mapping and I stored that I need to call after 20 mapping completed successfully.
I want to run my stored as 21st mapping procedure. I should not call my stored procedure in the 20th mapping as the mapping process.
How to achieve this?
What I did was, I created another dummy mapping and just create simple mapping (copy couple of records from a fictitious table to another table. dummy so I called the post, process mapping procedure. Is there another way, we can achieve this task?
In informatica, we have retained the transformation of the procedure. Is there something equivalent in OWB?
Any help is appreciated!Two options, you can: -.
1. create in OWB.
Under Oracle-> your name of the Module-> Transformation
-> Function
-> Procedure
-> Package
2. right click-> new (it will sail with series of screen)2 2 creer create database, and then import into OWB.
Once you have created and then form be it you can drag directly and drp then to the workflow process as done with mapping.
See you soon
KatiaPublished by: Nawneet_Aswal on July 19, 2010 01:53
-
SELECT the data inserted into a global temporary Table in a stored proc
A stored procedure is run from Oracle SQL Developer to insert data into a global temporary table. A SQL (in Oracle SQL Developer) worksheet is open to run a SELECT query to retrieve the data from the temporary table overall which was populated in the stored procedure. No row is returned. I guess it's because the stored procedure and the SELECT statement executed in different sessions.
Is it possible to run the stored procedure in Oracle SQL Developer and then execute a select statement on the temporary table overall which was filled in the stored procedure by using the same connection so that the data can be extracted?
I use version 1.5.1 build HAND-5440 of Oracle SQL Developer.In a worksheet, do something like
Start
insert_proc;
end;Select * from my_temp_table;
Place the cursor on each statement in turn and Press f9 (where it all began... the end is a single statement.
-
Calling stored procedure with an input of DATE parameter
Hello. A question about the Date input parameters when you call a stored procedure.
I have a procedure that takes a DATE as input parameter. I would DATE this value to include a time element.
My Application Module method takes an input as a java.util.Date (myParamDate) parameter - that will preserve a time element (?).
However when I create the CallableStatement, I am trying to set the parameter using setDate like this (for the param 5):
I understand java.sql.Date does NOT include a time element. But setDate() only accepts a java.sql.Date so my parameter of the procedure ends with a zero time element.st = getDBTransaction().createCallableStatement("begin cs_my_pck.request_values(?,?,?,?,?,?,?,?); end;", 0); Connection myConn = st.getConnection(); ArrayDescriptor myArrDesc = ArrayDescriptor.createDescriptor("CS_FIELD_TABT", myConn); Array sqlParamNameArray = new oracle.sql.ARRAY(myArrDesc, myConn, paramNames.toArray()); Array sqlParamValueArray = new oracle.sql.ARRAY(myArrDesc, myConn, paramValues.toArray()); Array sqlFilterNameArray = new oracle.sql.ARRAY(myArrDesc,myConn,filterNames.toArray()); st.setString(1, repType); st.setObject(2, sqlParamNameArray); st.setObject(3,sqlParamValueArray); st.setObject(4,sqlFilterNameArray); java.sql.Date myRepDate = new java.sql.Date(myParamDate.getTime()); st.setDate(5,myRepDate); System.out.println("Report Date = " + myRepDate.toString()); st.setString(6,repUser); st.setString(7,repAttach); // set out param st.registerOutParameter(8, Types.NUMERIC); st.execute();
How to call this procedure keeping the time element?
Thank you.It includes the time element, if you want more precision with time stamp.
http://docs.Oracle.com/javase/6/docs/API/Java/SQL/date.html
-
Global temporary tables in a stored Proc
Hi all
I am trying to create a procedure that creates tables, and then global temporoay tables. This works well in a scrupt but when I place it in a proc, it fails with the following error
Error (172,10): PLS-00103: encountered the symbol "TABLE" when awaits one of the following values: =. ( @ % ;
I use the code below to create global temporary tables, but I don't think that you can do in a procedure?
TRUNCATE TABLE TMP_table;
DROP TABLE TMP_table;
CREATE GLOBAL TEMPORARY TMP_table
ON THE LINES OF COMMIT PRESERVE
IN SELECT
Thanks for any helpYou cannot use dll phrases in a Begin End; block directly.
Yun can use something like
Begin Execute immediate 'TRUNCATE TABLE TMP_table'; Execute immediate 'DROP TABLE TMP_table'; Execute immediate 'CREATE GLOBAL TEMPORARY TMP_table ON COMMIT PRESERVE ROWS AS SELECT '; End;
-
Call stored procedure in the URL
Hi all
How to call a stored procedure 4 Apex in the URL. The error is less.
The requested URL/apex/EXAMPLE. TESTPROCEDURE was not found on this server.
Thank you.802263 wrote:
Hi allHow to call a stored procedure 4 Apex in the URL. The error is less.
The requested URL/apex/EXAMPLE. TESTPROCEDURE was not found on this server.
Thank you.
Should work on the assumption that:
1. the scheme of analysis can 'see' the object such as defined by synonyms, etc.
2. the schema of analysis has execute privs on the object. -
java.sql.SQLException: ORA-06550 and ORA-00900 call stored procedures
Hi all
I have 2 a stored procedures that I want to call from my Session bean. One of them takes a few settings, but not the other. When I call the procedures, I get the following errors described below. I tested the two stored procedures in sql plus and sqldveleoper and they work well. The funniest, it is, I have another stored procedure that I can call successfully from the same bean in session with no problems, so I'm a bit confused as to why his play now.
I use stand-alone 10.1.3.4 OC4J and Oracle 10 g Db 10.2.0.4 and platform DB that I use is Oracle10gPlatform and Eclipselink as my JPA provider. I have also tried against toplink (not toplink essentials) and still no joy
Here is the error I get when I try and call the procedure which takes the parameters of the session bean
Here are my stored procedure that take parametersInternal Exception: java.sql.SQLException: ORA-06550: line 1, column 7: PLS-00306: wrong number or types of arguments in call to 'HASHDATA' ORA-06550: line 1, column 7: PL/SQL: Statement ignored Error Code: 6550 Call: BEGIN HashData(input=>?, hashedValue=>?, hashed=>?); END; bind => [password1, => hashedValue, => hashed] Query: DataReadQuery()
Here is my code in the session bean to call the procedure that takes as parameters (Hashdata)create or replace procedure hashData(input IN VARCHAR2, hashedValue OUT BLOB, hashed OUT BOOLEAN) as inputRaw RAW(2000); --hashed BOOLEAN := false; begin dbms_output.put_line('the data to be hashed is '||input); dbms_output.put_line('converting input to raw ...'); inputRaw := utl_i18n.string_to_raw(input,'AL32UTF8'); dbms_output.put_line('Hashing Data ...'); hashedValue := DBMS_CRYPTO.Hash (src=>inputRaw,typ=>DBMS_CRYPTO.HASH_SH1); dbms_output.put_line('hash is '||UTL_I18N.raw_to_char(dbms_lob.substr(hashedValue, 4000,1))); if (hashedValue is not null) then hashed :=true; dbms_output.put_line('hashedValue IS NOT null'); else hashed := false; dbms_output.put_line('hashedValue IS null'); end if; end;
When I call the other takes no parameters, I get the following error.public UserBean() { // TODO Auto-generated constructor stub sessMan = SessionManager.getManager(); session = sessMan.getSession("Session", Thread.currentThread() .getContextClassLoader()); } public Serializable hashData(String input){ logger.debug("Hashing Data ... "); hashedValue= null; boolean hashed=false; StoredProcedureCall call = new StoredProcedureCall(); ValueReadQuery query = new ValueReadQuery(); call.setProcedureName("HashData"); call.addNamedArgumentValue("input", input); call.addNamedOutputArgument("hashedValue", "hashedValue", java.sql.Blob.class); call.addNamedOutputArgument("hashed", "hashed", java.lang.Integer.class); query.addArgument("input"); query.setCall(call); session.executeQuery(query); if ((Boolean)hashed){ logger.debug("The data has been hashed and the hash value is: "+hashedValue); } else{ logger.debug("The data has could not be hashed"); hashedValue=null; } return (Serializable)hashedValue; }
Here is the procedure which takes no parametersInternal Exception: java.sql.SQLException: ORA-00900: invalid SQL statement Error Code: 900 Call: BEGIN testJPAProc(); END; Query: DataReadQuery()
Heres is the code to call procedures that take no parameterscreate or replace procedure testJPAProc is begin dbms_output.put_line('testJPAProc called'); end;
You guys can tell me where I'm wrong if I do something wrong. Why make these mistakes? because as far as I can tell the code (java and pl/sql) are both correct unless there is something I missed. It's kinda funny because I have another stored procedure I can call successfully.StoredProcedureCall call = new StoredProcedureCall(); ValueReadQuery query = new ValueReadQuery(); call.setProcedureName("testJPAProc"); query.setCall(call); session.executeQuery(query);
Thank youThe first question is that the Boolean in Oracle is not a supported JDBC type, but a PLSQL type.
Change to an INTEGER is probably the best, you can also use the PLSQLStoredProcedureCall class to access.The second problem is perhaps that the stored procedure is not valid, make sure that it compiled correctly. It can also be the type of your query, you must use a DataModifyQuery, not a read request that it returns nothing.
If still no luck, try to call directly through JDBC, it works?---
James: http://www.eclipselink.org: http://en.wikibooks.org/wiki/Java_Persistence -
Can't access Table inside the stored procedure
Pls Me suggest good way
The problem that I face that I created a user user1 and create a global temporary table under that user. Then I "select" Developer sql query this time under another user (User0) as select * from user1.gtt_table; successfully, it runs and return results. also can also insert data into user1.gtt_table.
But if I try to use Insert or select user1.gtt_table and error
- Error (798,29): PL/SQL: ORA-00942: table or view does not exist
am I something wrong or missing any step?
Connect as user1 for this.
-
Call stored procedures and using its output parameters in a report
Hello
I have a procedure defined in a package on the database. This procedure returns a number of output parameters. How to call this procedure and use the output parameters in my report?
Thank you, MarkDepends on the level at which the procedure should be called. If its at the State level, call the form in the trigger-REPORT-BEFORE (or AFTER-PARAMFORM) and store the off-values space reserved columns. These you can use anywhere in your report.
-
I have a package with the procedures below.
I have 12 instructions insert (named procedures P1 to P12) which insert in the TABLE A and TABLE B, each insert another condition where.
I created P13 procedure in each package so that every month instead of every procedure P1 - P12 I call all the procedures in P13 and P14.
Are there disadvantages to do? Any suggestions?
package A
P1
(
INSERT statement... INSERT into TABLE A
)
P2
(
INSERT statement... INSERT into TABLE A
)
P3
(
INSERT statement... INSERT into TABLE A
)
P4
(
INSERT statement... INSERT into TABLE A
)
P5
(
INSERT statement... INSERT into TABLE A
)
P6
(
INSERT statement... INSERT into TABLE A
)
P7
(
INSERT statement... INSERT into TABLE A
)
P8
(
INSERT statement... INSERT into TABLE A
)
P10
(
INSERT statement... INSERT into TABLE A
)
P11
(
INSERT statement... INSERT into TABLE b.
)
P12
(
INSERT statement... INSERT into TABLE b.
)
P13
(
P1
P2
P3
P4
P5
P6
P7
P8
P9
P10
)
P14
(
P11
P12
)
Published by: user7988 on March 17, 2010 06:49Are queries for table a similar inserts? Is the using the same tables and joins, but the different criteria? If yes then that Frank pointed out you should look combining queries. You can combine the criteria and use instructions BOX when it is required.
You may also be able to combine a and b inserts using a multi-tableau insert.
Not sure what look like queries, but here is a small example of how you might be able to combine the table an inserts;
create table source_data as ( select 'CA' state, 'F' payment from dual union all select 'CT', 'T' from dual union all select 'XX', 'F' from dual); Table created insert into a select my_seq.nextval id, state, case when state = 'CA' and payment = 'F' then 'REPORT1' when state = 'CT' then 'REPORT9' else null end report_num from source_data where state in ('CA', 'CT'); 2 rows inserted select * from a; ID STATE REPORT_NUM ---------- ----- ---------- 1 CA REPORT1 2 CT REPORT9
Maybe you are looking for
-
G7 Pavilion: Pavilion g7 won't boot afyer routinr 8.1 update
I can't start my conputer, I was prompted to restart for the installation of the update and now stuck on a white background screen of purplr. I need to keep my posting attached external display, my screen is broken on my computer laptop andhas Bern
-
Qosmio G25: Qosmioplayer TV button function change
I have a Qosmio G25, but instead of switching to the analog tuner Qosmioplayer key I want to turn on my hdtv usb device. Is this possible?Any help is appreciated.Thank you
-
Re: Satellite A30 - battery starts to unload if the power is connected
Hi all My Toshiba laptop Satellite A30-871 began to discharge the battery while the power is connected (the LED shows that AC is connected but laptop consumes the battery power instead of loading battery and the use of current alternative). When the
-
How to use the scanner Canon of my computer with Windows Vista?
How to use the Canon Scanner of my Toshiba with Windows Vista computer? Need help, tq.
-
Authorization of RADIUS WebVPN ASA
Hi, guys. I'm working on an ASA 5510 and plan to work as a waiter webvpn. Currently I am facing a Raius permission problem. I can't config Raiuds AV pair in ACS server to designate the webvpn different policies for each group of users. Until I have i