Wrapped in a function and/or stored procedure, recursive CTE stops working
This query builds an hierarchical tree from a single table with the typical
value/reports_to_value columns.
When running in SQL manager returns like 7 records (note i'm avoiding infinite
loop by blocking top level value)
WITH c
AS
SELECT deptid, reports_to_dept
FROM glo_tree
WHERE deptid = '18538'
UNION ALL
SELECT t.deptid, t.reports_to_dept
FROM glo_tree T
INNER JOIN c
ON t.deptid = c.reports_to_dept
where t.deptid <> '00001'
SELECT deptid
FROM c
However, the exact same query, if wrapped in a function and/or stored procedure,
returns 0 records (no error message whatsoever)
CREATE FUNCTION [dbo].[checkDept] (@deptid varchar(16))
RETURNS TABLE
AS
RETURN
WITH c
AS
SELECT deptid, reports_to_dept
FROM glo_tree
WHERE deptid = @deptid
UNION ALL
SELECT t.deptid, t.reports_to_dept
FROM glo_tree T
INNER JOIN c
ON t.deptid = c.reports_to_dept
SELECT deptid
FROM c
GO
CREATE PROCEDURE [dbo].[getDept] (@deptid varchar(16))
AS
SELECT deptid
FROM dbo.checkDept(@deptid)
Then call them like:
select * FROM checkDept('18538')exec getDept @deptid='18538'
Both return nothing
Thanks Patrick, i don't think it can do that, i call it like:
select * FROM checkDept('18538')exec getDept @deptid='18538'Just to make sure, i've changed the function like:WHERE ltrim(rtrim(deptid)) = @deptidStill the same thing
Similar Messages
-
How to execute a procedure or function from Java Stored procedure
Hi,
I am new to Java Stored Procedures. I am working on Oracle 8i and JVM 1.3.1. I want to call a PL/SQL procedure from within Java. I have tried looking at severa; cources but they are quite high level for me. Can someone provide a simple example including the Source Code for .java file and also the calling function's code?
Heres a sample of what I have been working on: I an including Java code, and Function code and how I call the function. Instead of doing "select sysdate from dual" I want to do like "create table temp1(var1 varchar2(10))" or similar... like "exec procname(var1)" etc.
Thanks in advance.
PS. The variable passed in function is just a dummy variable.
-----Begin Java code-------
import java.sql.SQLException;
import java.sql.PreparedStatement;
import java.sql.Statement;
import java.sql.Connection;
import java.sql.ResultSet;
//Oracle Extensions to JDBC
import oracle.jdbc.driver.OracleDriver;
public class Test2{
public static String Testing(String d) {
Connection connection = null; // Database connection object
try {
// Get a Default Database Connection using Server Side JDBC Driver.
// Note : This class will be loaded on the Database Server and hence use a
// Se[i]Long postings are being truncated to ~1 kB at this time.what your after is
Connection conn = DriverManager.getConnection
("jdbc:oracle:oci:@<hoststring>", "scott", "tiger");
CallableStatement cs = conn.prepareCall ("begin ? := foo(?); end;");
cs.registerOutParameter(1,Types.CHAR);
cs.setString(2, "aa");
cs.executeUpdate();
String result = cs.getString(1);
a more complete description can be found in the documentation at
http://download-west.oracle.com/docs/cd/B10501_01/java.920/a96654/basic.htm#1001934
Dom -
Calling a function in a stored procedure
How to call a function in a stored procedure
Oracle 11gDeclare
varname DATATYPE ;
BEGIN
varname:= <Function Name> ;
END;
You have to understand the other bits by yourself.
Read more details at http://download.oracle.com/docs/cd/B19306_01/appdev.102/b14261/overview.htm#sthref192 -
Please help - Can not use stored procedure with CTE and temp table in OLEDB source
Hi,
I am going to create a simple package. It has OLEDB source , a Derived transformation and a OLEDB Target database.
Now, for the OLEDB Source, I have a stored procedure with CTE and there are many temp tables inside it. When I give like EXEC <Procedure name> then I am getting the error like ''The metadata could not be determined because statement with CTE.......uses
temp table.
Please help me how to resolve this ?you write to the temp tables that get created at the time the procedure runs I guess
Instead do it a staged approach, run Execute SQL to populate them, then pull the data using the source.
You must set retainsameconnection to TRUE to be able to use the temp tables
Arthur My Blog -
How to convert REFCursor functions to REFCursor Stored Procedure
Is it possible or not.How to want convert REFCursor functions to REFCursor Stored Procedure.For Example
function QR_1RefCurDS return pkg_sa_reprts_ref_cursr.pa_mis_sa_disp_cursr is
data_cursr pkg_sa_reprts_ref_cursr.pa_mis_sa_disp_cursr;
begin
data_cursr:= sf_sa_dispatch_reprt(:P_USER,:P_USER_TYPE,:P_AREA_CD,:P_RPT_LEVEL,:P_PARNT_GROP,:P_LOCTN_CD,:P_DATE);
return data_cursr;
end;
how to convert it.Its possible. But you need to analyse the requirement well. Post conevrsion, you need to take care of places in the code where the function call is made to invoke the new procedure.
create procedure QR_1RefCurDS_pr (out pkg_sa_reprts_ref_cursr.pa_mis_sa_disp_cursr) is
data_cursr pkg_sa_reprts_ref_cursr.pa_mis_sa_disp_cursr;
begin
data_cursr:= sf_sa_dispatch_reprt(:P_USER,:P_USER_TYPE,:P_AREA_CD,:P_RPT_LEVEL,:P_PARNT_GROP,:P_LOCTN_CD,:P_DATE);
end; -
Can we have an example of using update, insert, and delete stored procedure
I would like to see an example of using retrieve (return resultset), update, insert, and delete stored procedures in JSF. I need to see syntax how JSF can call those stored procedures. This option is absolutely important when building web-application. Currently, I haven't found resource to do for this purpose yet. The database can be any such Oracle, DB2, pointbase, etc that support stored procedures.
Anyone knows?
Thanks,
Tue VuHi ttv,
I asked around a bit and here's some more info:
To bind a ResultSet to a read only Data Table component just set the "value" property of the Data Table component to point at it, and JSF will synthesize a DataModel around it.
* Note that because we can't call the stored procedure at design time, Creator can't do the fancy table layout stuff it does for rowsets. You'll need to hand craft the columns just like the Google Client example.
* As I mentioned previously, you will have to manually code the stored procedure access in your java code - see the code clip I mentioned in previous reply (and if this is via a stored procedure, then any textbook about JDBC will undoubtedly have examples). Simplest way might be a getter method on the page bean that contains the call to the stored procedure and returns the resulting ResultSet object.
* Don't forget to close the result set - we typically do this at the end of the request (i.e. add a close in the afterRenderResponse() method.
* Don't throw exceptions - or if you have to, make sure you close the result set in a finally clause (thrown exceptions bypass the afterRenderResponse method in the lifecycle).
* You give up on the caching provided by our RowSetDataModel (which can't be connected to a ResultSet even manually), so I would recommend that you only use datatables to display the data and then go to a single row page to do edits/deletes (similar to the TwoPage example in AppModel and the Update, Insert Delete tutorial).
And yes please do submit an example - we will gladly post it!!! :) The best way to submit this kind of thing would be through:
http://developers.sun.com/prodtech/javatools/jscreator/reference/codesamples/sampleapps.html
on the right side, Related Links, under Creator Heros, click Submit Content and there you can send it in!
Hope this helps!
Val -
My ipod is cracked and it chipped away a little more last night and that's when my wifi stopped working. My wifi works on every other device in my house except for my ipod. Is there something wrong with my ipod?
Does the iOS device connect to other networks?
Does the iOS device see the network?
Any error messages?
Try right next to the router
Do other devices now connect?
Did the iOS device connect before?
Try the following to rule out a software problem:
- Reset the iOS device. Nothing will be lost
Reset iOS device: Hold down the On/Off button and the Home button at the same time for at
least ten seconds, until the Apple logo appears.
- Power off and then back on your router
.- Reset network settings: Settings>General>Reset>Reset Network Settings
- iOS: Troubleshooting Wi-Fi networks and connections
- Wi-Fi: Unable to connect to an 802.11n Wi-Fi network
- iOS: Recommended settings for Wi-Fi routers and access points
- Restore from backup. See:
iOS: How to back up
- Restore to factory settings/new iOS device.
If still problem and it does not connect to any networks make an appointment at the Genius Bar of an Apple store since it appears you have a hardware problem.
Apple Retail Store - Genius Bar
Could it be this?
iOS: Wi-Fi or Bluetooth settings grayed out or dim
One user reported that placing the iPod in the freezer fixed the problem. A trick that works frequently with iPhones:
Settings > AirPlane Mode ON, Do Not Disturb ON
Power down and wait 5-10 minutes
Power up
Settings > AirPlane Mode OFF, Do Not Disturb OFF
If not successful, an appointment at the Genius Bar of an Apple store is usually in order.
Apple Retail Store - Genius Bar -
Using a first gen iPad. Video and audio from internet sites simply stopped working all of a sudden. Any suggestions? Thanks.
1)access the router web ui
2)go to the Mac Address Clone subtab , enable it and click "Clone" . Save the settings
3)do a power cycle
4)check whether the router gets an internet ip add now .. -
My question mark and forward slash key have suddenly stopped working. Have I pressed something I shouldn't have. Any ideas what to do.
judith147 wrote:
My question mark and forward slash key have suddenly stopped working.
If they do nothing at all, double check system preferences/speech and make sure they have not somehow gotten set as the trigger for Text to speech or speech recognition, etc.
Also try an external keyboard. If it works ok, then your internal keyboard is probably damaged and needs repair or replacement. -
The Welcome screen somes up but then fades and error message says "Photoshop has stopped working." Then Windows closes the program.
I shut down the computer, waited, then did restart, clicked on PSE, and the same message came up again. That was last night, thought I might get a message this morning, but same thing happened again. I'm trying to not panic - this is all new to me.
Any help welcome!If you have not updated to the most current version, you might try that.
-
My Photoshop CC and also my CS6 has suddenly stopped working. I'm using Windows 7 - 64 bit. I need help, does anyone know what to do?
We can't know. You have not told us what exactly the problem is. If there are any warnings, you need to provide them along with other info like the crash logs. If not you have to explain the situation in more detail. Just saying that it doesn't work anymore is not particularly useful.
Mylenium -
I have full membership to CC and have been using it for 4 months. Randomly Photoshop stopped opening jpgs, so I uninstalled and re-installed. Photoshop then stopped working all together. I signed out of the app manager and when I signed back in all my info was gone and only "TRIAL VERSIONS" of CC apps were available. I paid for this software. I need to be able to download it again.
Wow, Karan Taneja, you've just embarrassed yourself on a worldwide support forum. Not only is your post ridiculous and completely inappropriate for a technical support forum, but it also shows your ignorance as to whom you think the audience is. Apple is not here. It's users, like you.
If you would have spent half the time actually reading the Terms of Use of this forum that YOU agreed to by signing up to post, as you did composing that usesless, inappropriate post, you (and the rest of us on this forum) would have been much better off. -
Using Adobe Captivate 7 and keep getting Adobe Captivate has stopped working...
I am new to Using Adobe Captivate 7 and keep getting Adobe Captivate has stopped working on Slide 7. What can I try?
Will you be delivering this content from an LMS? If so, then the LMS should handle the menu. Break your project into separate modules and use the Multi-SCORM Packager to create a bundled set.
If you are not using an LMS, but ARE serving content from a web server, then YES you could create a menu module that you use to launch the other modules.
If you are intending to serve this content from a LAN or CD ROM, then you could create a normal HTML web page with hyperlinks to launch individual modules. -
I have Windows 8 64 bit. iTunes works fine with my iPHONE but when I try to go to the iTunes store it loads to about 80% and then the message "iTunes has stopped working"
COPY QTMovieWin.dll FROM c:\program files (x86)\common files\apple\apple application support\ INTO c:\program files (x86)/iTunes"
-
Using iMovie and the voice over sound has stopped working?
Using iMovie and the voice over sound has stopped working?
Are these the internal speakers?
Have you done a PRAM reset, CMD+Option+p+r...
http://support.apple.com/kb/HT1379
In fact, do 3 in a row, takes a bit of time.
Intel-based Macs: Resetting the System Management Controller (SMC)...
http://support.apple.com/kb/HT3964
Maybe you are looking for
-
Webex can no longer connect to meetings after upgrading to Yosemite.
I recently upgraded to Yosemite 10.10.1 and found thereafter that Webex, which is a screen share application used for online meetings, can no longer connect to Webex services using the most current versions of Safari, FireFox and Chrome. Java scripts
-
Cinema display 30" power plug caught on fire
Hi everyone, I have a 30" Apple Cinema display (A1083) purchased in 2008. Recently, it's power cable/wire came slightly unplugged from the 150w power supply while the monitor was on. The wire was still plugged in, but it was at a fairly severe angle.
-
Why does Adobe Reader X1 show text as weird characters in online pdf?
Updated to Reader X1 recently. When I open a PDF on my desktop, it displays normally. When I look at a PDF online, it displays a series of random characters (like fl fl fl) replacing the text. I want to upload a screenshot of an example but get an
-
Exporting Music listing from Creative Media Sou
Is there anyway of exporting my music listing from My Music Library to Smartlisttogo program? Leif
-
Hello Experts, Can You help me; I get the follwing error in my query Msg 1087, Level 15, State 2, Line 31 Must declare the table variable "@ASE_SUBART_GROEP". the @ASE_SUBART_GROEP is a self-defined table in this SQL environment. Maybe you know the