Problems with Dynamical SQL Querys on Access Databases!
This thread is for everyone who has the same problems like me.
I tried to change SQL-Querys via Javascript to fill in my PDF sheet some data from my database.
But whenever I want to change the Query, I never get some data back.
The main problem was:
THE ACCESS DATABASE
Access has locked the database whenever I tried to run the Query.
Now Iam using MySQL and everything is working fine.
This thread is for everyone who has the same problems like me.
I tried to change SQL-Querys via Javascript to fill in my PDF sheet some data from my database.
But whenever I want to change the Query, I never get some data back.
The main problem was:
THE ACCESS DATABASE
Access has locked the database whenever I tried to run the Query.
Now Iam using MySQL and everything is working fine.
Similar Messages
-
Does anyone out there use dynamic SQL with DB2? If so, are the sql statements causing a PreparedStatement to be executed on DB2. I posted this question similarly before, but never resolved it, and it is killing me. I have to resolve this ASAP!
Here is the problem: My DB2 Admin says that EVERY TIME I access the database, my Java app is causing the database to create a PreparedStatement. However, I'm using Statement objects exclusively, with dynamic SQL. He says that DB2 needs an "access path" for the client, and that it converts the Statement to a PreparedStatement, as this is the only way to get this "access path". He says the only solution is either stored procedures or SQLJ, which will do the binding in advance, and increase performance tremendously. However, I am STRONGLY opposed to using SQLJ, and if we do stored procedures, we'd have to write one for every possible SQL statment! I KNOW there is a better solution.
Is anyone out there having these problems with JDBC and DB2? Surely someone out there uses DB2 and JDBC and either has these problems or can confirm that something is incorrectly configured on the database side.
Any help would be great. Thanks, WillNow I'm wondering if maybe the PreparedStatements are ONLY being called on the database when I call getConnection(), and not when I call executeQuery() or executeUpdate() from the Statement object. I just can't see why the database would have to make an access path for every SQL statement executed, but I could see it creating an access path for every connection requested. Any thoughts on that theory?
-
Writing to a temp table in a stored procedure with dynamic sql
Hi
I am writing into a temp table with dynamic sql:
select coloum_name into #temp_table from
+
@DestinationDBName+'.information_schema.tables
and then I am trying to use #temp_table in the procedure:
select coloum_name into #anotherTable from #temp_table
but I am getting an error that #temp_table is not recognized.
Can a temp table not be used in dynamic sql ?
How can I overcome this problem ?Temp Table Can used easily in Dynamic Query in SQL Server and here is small Exmaple you can check it and do like it
CREATE PROC test
AS
BEGIN
CREATE TABLE #T1
(ID int , NAME Nvarchar(50))
CREATE TABLE #T2
(ID int , NAME Nvarchar(50))
DECLARE @SQL NVARCHAR(MAX)='Insert into #T1
SELECT database_id , Name FROM Sys.Databases
Insert into #T2 Select ID , Name from #T1 '
EXEC SP_ExecuteSQL @SQL
SELECT * FROM #T2
DROP TABLE #T1
DROP TABLE #T2
END
Exec Test
If you found My reply is helpful for you please vote me
thanks
Mustafa EL-Masry
Principle Database Administrator & DB Analyst
SQL Server MCTS-MCITP
M| +966 54 399 0968
MostafaElmasry.Wordpress.Com -
Problem in starting SQL*PLUS in oracle database 10g
Hi
Well I am facing one problem while starting SQL*PLUS in oracle database 10g
ERROR - "Procedure entry point longjmp could not be located in dynamic link library orauts.dll"
This has happened when I installed Oracle Database 11g on same machine and when I deinstalled Oracle 11g then SQL*PLUS is started...no error came
Can anybody tell me the reason please...hi
pls im having the same problem but in my own case i installed oracle apex using 11g.
im env variable is:
C:\Oracle\product\10.1.0\Client_1\bin;C:\Oracle\product\10.1.0\Client_1\jre\1.4.2\bin\client;C:\Oracle\product\10.1.0\Client_1\jre\1.4.2\bin;C:\app\Xty\product\11.2.0\dbhome_1\bin;%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;;C:\Program Files\TortoiseSVN\bin;C:\Program Files\Microsoft SQL Server\80\Tools\Binn\;C:\Program Files\Microsoft SQL Server\90\DTS\Binn\;C:\Program Files\Microsoft SQL Server\90\Tools\binn\;C:\Program Files\Microsoft SQL Server\90\Tools\Binn\VSShell\Common7\IDE\;C:\Program Files\Microsoft Visual Studio 8\Common7\IDE\PrivateAssemblies\
pls which is my apex_home so i can interchange it?
i also have oracle 10g client installed -
Problems with PL/SQL packages
Hello,
I face the following problem with PL/SQL stored procedures. The Oracle
version is 8.0.5 on Windows NT 4. The PL/SQL package has a set of procedures and functions.
The main procedure of the PL/SQL package is triggered from VC++ executable. If for some reason,
an exception is caught in the stored procedure (like no_data_found
exception), then the following problem occurs.
If we try to trigger the stored procedure again through the VC++ executable,
the variables in the stored procedures have the values as in the previous
execution. They are not getting initialised. (The same database connection
is used in VC++ executable).
Currently, only if a new connection to the database is used , the problem is
solved.
Also, change in the input parameters of the procedure is not reflected, once the procedure fails because of any exception. Only the input which was given during the time of execution when the procedure failed,is considered.
What could be the reason for this problem and how can this be corrected?
Please send in your suggestions.
Thanks and Regards,
Ramya Priya
nullHi Keith,
I am connecting to the database as the package owner..
I have noticed earlier that I have problems when capturing triggers also.. The content of one large trigger contains 36371 characters and when capturing it from DB, the content was truncated to 28020 characters in Designer.
Our ideas with capturing the DB packages/procedures were to use the Designer as version control system.
We wanted to have all objects used in a project in Designer.. entities, tables, triggers, packages, procedures, Forms files, etc. in order to make a configuration for a project release.
Thank you,
Claudia -
Backup DB with dynamic sql - want to substitute in dbname and disk file path
Re: Backup DB with dynamic sql - want to substitute in dbname and disk file path
Hope I can explain this. Below is a small snippet of code. I want to set @SQLTemplate_TSQL once at the top of the script and then execute the SET @SQLCommand and sp_executesql in a loop that reads a list of databases. It all works, except for the
BACKUP DATABASE. Right now it evaluates when the SET @SQLTemplate_TSQL is evaluated. I want it to evaluate when it is executed. I want the DB_NAME() of the USE @dbname.
-- change @dbname and @dbbackuppath
DECLARE @SQLCommand NVARCHAR(MAX)
DECLARE @SQLTemplate_TSQL NVARCHAR(MAX)
DECLARE @dbname varchar(128) = 'Bank04'
-- one time setting of @SQLTemplate_TSQL
set @SQLTemplate_TSQL =
DECLARE @dbbackuppath varchar(128) = ''''d:\backups''''
IF RIGHT(@dbbackuppath, 1) <> ''''\''''
SET @dbbackuppath = @dbbackuppath + ''''\''''
SET @dbbackuppath = @dbbackuppath + DB_Name() + ''''.bak''''
PRINT @dbbackuppath
BACKUP DATABASE ' + DB_NAME() + ' to DISK=''' + QUOTENAME(@dbbackuppath, CHAR(39)) + '''
-- Execute this several times over different databases
SET @SQLCommand = '
USE ' + QUOTENAME(@dbname) + ';
EXEC(''' + @SQLTemplate_TSQL + ''') '
PRINT @SQLCommand
EXECUTE sp_executesql @SQLCommandHere is a stripped down version of my code. Someone writes a script. I then take the script and seperate it by GO statement block. Each GO block gets its own row into the
#SQLTemplate_TSQL. I then replace single quote with 4 quotes and run it. Then I run against my list of databases. I am unable to get the BACKUP DATA base to work with this model.
Run scripts against multiple databases.sql
Do a FIND on "CHANGE THIS" to see the databases returned from the SELECT statement
DECLARE @DatabaseName varchar(128)
DECLARE @SQLCommand NVARCHAR(MAX)
DECLARE @SQLTemplate_Seq INT
DECLARE @SQLTemplate_OperationDesc NVARCHAR(128)
DECLARE @SQLTemplate_TSQL NVARCHAR(MAX)
DECLARE @SQLTemplate_Diagnostics INT
DECLARE @Note VARCHAR(500)
IF OBJECT_ID('tempdb..#SQLTemplate_TSQL') IS NOT NULL
DROP TABLE #SQLTemplate_TSQL
CREATE TABLE [dbo].[#SQLTemplate_TSQL](
[SQLTemplate_RecID] [int] Identity,
[SQLTemplate_ID] [int] NOT NULL,
[SQLTemplate_Seq] [int] NOT NULL,
[SQLTemplate_OperationDesc] [varchar](128) NOT NULL,
[SQLTemplate_TSQL] [varchar](max) NOT NULL,
[SQLTemplate_Diagnostics] [int] NOT NULL,
[SQLTemplate_Enabled] [int] NOT NULL)
DELETE FROM #SQLTemplate_TSQL WHERE SQLTemplate_Seq = 65
DECLARE @SeqID INT
SELECT @SeqID = MAX(SQLTemplate_ID) FROM #SQLTemplate_TSQL
SET @SeqID = ISNULL(@SeqID,0)
SET @SeqID = @SeqID + 1
INSERT INTO #SQLTemplate_TSQL VALUES(@SeqID ,65,@SeqID,'
SELECT * FROM ifs_config
',1,1)
SET @SeqID = @SeqID + 1
INSERT INTO #SQLTemplate_TSQL VALUES(@SeqID ,65,@SeqID,'
DECLARE @HistoryODS INT
SET @HistoryODS = 1
SELECT * FROM ifs_tablelist WHERE HistoryODS = @HistoryODS and Tablename like ''''%HIST%''''
',1,1)
-- Setup Cursor to Loop through each of the Prior Period databases
DECLARE db_cursor CURSOR FOR
SELECT [Database Name] --<<<<<<<< CHANGE THIS SELECT statement to select DBs >>>>>>
FROM v_ifs_PPODSDBInfo_Curr
WHERE [Database Frequency] <> 'CURRENT'
ORDER BY [Database Frequency], [Database Number]
OPEN db_cursor
FETCH NEXT FROM db_cursor INTO @DatabaseName
-- Loop through each of the databases
WHILE @@FETCH_STATUS = 0
BEGIN
-- Setup Cursor to Loop through each of the SQL Statements
DECLARE #SQLTemplate_TSQL_cursor CURSOR FOR
SELECT [SQLTemplate_TSQL], [SQLTemplate_OperationDesc], [SQLTemplate_Seq], [SQLTemplate_Diagnostics]
FROM #SQLTemplate_TSQL
WHERE [SQLTemplate_Enabled] = 1 AND SQLTemplate_Seq = 65
ORDER BY SQLTemplate_ID
OPEN #SQLTemplate_TSQL_cursor
FETCH NEXT FROM #SQLTemplate_TSQL_cursor INTO @SQLTemplate_TSQL, @SQLTemplate_OperationDesc, @SQLTemplate_Seq, @SQLTemplate_Diagnostics
-- Loop through each of the SQL statements
WHILE @@FETCH_STATUS = 0
BEGIN
SET @SQLCommand = '
USE ' + QUOTENAME(@Databasename) + ';
EXEC(''' + @SQLTemplate_TSQL + ''') '
EXECUTE sp_executesql @SQLCommand
FETCH NEXT FROM #SQLTemplate_TSQL_cursor INTO @SQLTemplate_TSQL, @SQLTemplate_OperationDesc, @SQLTemplate_Seq, @SQLTemplate_Diagnostics
END
CLOSE #SQLTemplate_TSQL_cursor
DEALLOCATE #SQLTemplate_TSQL_cursor
FETCH NEXT FROM db_cursor INTO @DatabaseName
END
CLOSE db_cursor
DEALLOCATE db_cursor -
Problem with mapping the Entity beans onto database tables
Hi,
I got a problem with mapping the Entity beans onto database tables. Here are what I did:
First Step:
asant capture-schema
Second Step:
capture-schema -driver com.pointbase.jdbc.jdbcUniversalDriver -dburl jdbc:pointbase:server://localhost/sun-appserv-samples -username pbPublic -password pbpublic -table APPLICANT -table APPLICANTSKILL -table CUSTOMER -table LOCATION -table job -table JOBSKILL -table SKILL -out build/agency.dbschema
The first step was fine. But, in the second step, I got the error message as follow:
using dburl:jdbc:pointbase:server://localhost/sun-appserv-samples
using username:pbPublic
using password:pbpublic
using driver:com.pointbase.jdbc.jdbcUniversalDriver
using schemaname:null
using output file:build/agency.dbschema
JDO71100: Failed to find a class. Verify that the class is available on your CLASSPATH
java.lang.ClassNotFoundException: com.pointbase.jdbc.jdbcUniversalDriver
at java.net.URLClassLoader$1.run(URLClassLoader.java:199)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:187)
at java.lang.ClassLoader.loadClass(ClassLoader.java:289)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:274)
at java.lang.ClassLoader.loadClass(ClassLoader.java:235)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:302)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:141)
at com.sun.forte4j.modules.dbmodel.jdbcimpl.ConnectionProvider.<init>(Co
nnectionProvider.java:38)
at com.sun.jdo.api.persistence.mapping.ejb.CaptureSchema.main(CaptureSch
ema.java:130)
at com.sun.jdo.spi.persistence.support.ejb.util.CaptureSchemaWrapper.mai
n(CaptureSchemaWrapper.java:29)
Thanks for your help!You need to add the pbclient.jar or some similar name like that, in the CalssPath.
-
After Effects won't close/Problems with dynamic links
When I quit After Effects the icon still shows up and it says that it is still open, even force quit will not work. Also having problems with dynamically linked files between after effects and Premiere pro. Rendering in Premiere doesn't work unless I go to AE, save the project, then go back to Premiere. I have OSX Mavericks 10.9.2, a late 2012 mac pro, and AE CC 12.2.1.5
Kevin: would appreciate further thoughts on this.
I am using Pr2014, version 8.0.0 I am using AE2014, version 13.0.2.3. When I was on earlier versions of each, I had no problem importing AE comps into Pr. I'd choose import in Pr, then select the AE project, then select the comp. But with my new and improved versions of AE and Pr, I keep getting "importer reported a generic error."
I also tried to go the other way. I selected in Pr the clips I wanted to work on in AE, and then tried "replace with AE comp" but got the "generic error" message again..
Finally, I attempted to create a Dynamic Link from Pr via the File menu, but with each of the options from there, I got "failed to connect to AE Dynamic Link"
Any advice you can share, would be most welcome. -
Hello,
I have the following function that works ok:
CREATE OR REPLACE FUNCTION Get_Partition_Name (sTable VARCHAR2, iImportIndex INTEGER)
RETURN VARCHAR2 IS
cursor c is select A.partition_name from (select table_name, partition_name,
extractvalue (
dbms_xmlgen.
getxmltype (
'select high_value from all_tab_partitions where table_name='''
|| table_name
|| ''' and table_owner = '''
|| table_owner
|| ''' and partition_name = '''
|| partition_name
|| ''''),
'//text()') import_value from all_tab_partitions) A where table_name = sTable and A.import_value = iImportIndex;
sPartitionName VARCHAR(20);
err_num NUMBER;
BEGIN
open c;
fetch c into sPartitionName;
IF c%ISOPEN THEN
CLOSE c;
END IF;
RETURN sPartitionName;
EXCEPTION
WHEN OTHERS THEN
err_num := SQLCODE;
--save error in log table
LOG.SAVELINE(SQLCODE, SQLERRM);
END Get_Partition_Name;
I am trying to replace the cursor statement with dynamic SQL, something like (see below) but it doesn't work any more; I think I am missing some quotes.
CREATE OR REPLACE FUNCTION Get_Partition_Name (sTable VARCHAR2, iImportIndex INTEGER)
RETURN VARCHAR2 IS
TYPE t1 IS REF CURSOR;
c t1;
sSql VARCHAR2(500);
sPartitionName VARCHAR(20);
err_num NUMBER;
BEGIN
sSql := 'select A.partition_name from (select table_name, partition_name,
extractvalue (
dbms_xmlgen.
getxmltype (
''select high_value from all_tab_partitions where table_name=''''
|| table_name
|| '''' and table_owner = ''''
|| table_owner
|| '''' and partition_name = ''''
|| partition_name
|| ''''''),
''//text()'') import_value from all_tab_partitions) A where table_name = :a and A.import_value = :b';
OPEN c FOR sSql USING sTable, iImportIndex;
fetch c into sPartitionName;
IF c%ISOPEN THEN
CLOSE c;
END IF;
RETURN sPartitionName;
EXCEPTION
WHEN OTHERS THEN
err_num := SQLCODE;
--save error in log table
LOG.SAVELINE(SQLCODE, SQLERRM);
END Get_Partition_Name;
Please advise,
Regards,
M.R.Assuming the requirement is to find the partition in the supplied table with the supplied high value and the issue is that dba/all_tab_partitions.high_value is a long, one alternative along the same lines as you've done already is as follows. (I've just used a cursor rather than a function for simplicity of demo).
SQL> var r refcursor
SQL> set autoprint on
SQL> declare
2 ctx dbms_xmlgen.ctxhandle;
3 v_table_name VARCHAR2(40) := 'LOGMNR_USER$';
4 v_value NUMBER := 100;
5 begin
6 ctx := DBMS_XMLGEN.NEWCONTEXT
7 ('select table_name
8 , partition_name
9 , high_value hi_val
10 from dba_tab_partitions
11 where table_name = :table_name');
12 dbms_xmlgen.setbindvalue(ctx,'TABLE_NAME',v_table_name);
13 open:r for
14 with x as
15 (select xmltype(dbms_xmlgen.getxml(ctx)) myxml
16 from dual)
17 select extractvalue(x.object_value,'/ROW/TABLE_NAME') table_name
18 , extractvalue(x.object_value,'/ROW/PARTITION_NAME') partition_name
19 , extractvalue(x.object_value,'/ROW/HI_VAL') hi_val
20 from x
21 , TABLE(XMLSEQUENCE(EXTRACT(x.myxml,'/ROWSET/ROW'))) x
22 where extractvalue(x.object_value,'/ROW/HI_VAL') = v_value;
23 end;
24 /
PL/SQL procedure successfully completed.
TABLE_NAME
PARTITION_NAME
HI_VAL
LOGMNR_USER$
P_LESSTHAN100
100
SQL> I'm sure there are other ways as well. Especially with XML functionality, there's normally many ways to skin a cat. -
Problems while creating a Java stored proc with dynamic SQL
Hi,
I am trying to write a stored procedure which uses dynamic SQL. The code runs fine outside the database (on DOS PROMPT),but gives me an exception when I try to execute it as a procedure. Could somebody help me out?
The exception given is:
ERROR at line 1:
ORA-29532: Java call terminated by uncaught Java exception:
java.security.AccessControlException: the Permission (java.net.SocketPermission
elcamino.mcasolutions.com resolve) has not been granted by
dbms_java.grant_permission to SchemaProtectionDomain(SPO|PolicyTableProxy(SPO))
Does it have anything to access permissions to that user?
Thanks in advance!
JoeHi:
This store procedure is a Java stored procedure (JSP)?
If true, change your Java code to connect to database because you are connected.
For example:
Connection con = new OracleDriver().defaultConnection();
instead of
Connection con = DriverManager.getConnection(..);
Bye.
J. -
Problem with Dynamically accessing EJB Class objects in WL 7.0 SP1
I am trying to build a component which has the ability to instantiate and execute
an known EJB method on the fly.
I have managed to build the component but when I try and execute it I get a ClassNotFoundException.
I know that the EJB I am trying to invoke is deployed and available on the server,
as I can see it in the console, I also seen to have been able to get the remote
interface of the object, my problem occurs when I try and access the class object
so I can perform a create on the object and then execute my method
The code I have written is below:
private Object getRemoteObject(Context pCtx, String pJNDIName, String pHomeBean)
throws Exception {
String homeCreate = "create";
Class []homeCreateParam = { };
Object []homeCreateParamValues = {};
try {
//This call seems to work and doesn't throw an exception
Object home = pCtx.lookup(pJNDIName);
//However this call throws a java.lang.ClassNotFoundException
Class homeBean = Class.forName(pHomeBean);
Method homeCreateMethod = homeBean.getMethod(homeCreate,homeCreateParam);
return homeCreateMethod.invoke(home, homeCreateParamValues);
} catch (NamingException ne) {
logStandardErrorMessage("The client was unable to lookup the EJBHome.
Please make sure ");
logStandardErrorMessage("that you have deployed the ejb with the JNDI
name "+pJNDIName+" on the WebLogic server ");
throw ne;
} catch (Exception e) {
logStandardErrorMessage(e.toString());
throw e;
Any advice would be really appreciated, I'm fast running out of ideas, I suspect
it has something to do with the class loader but I'm not sure how to resolve it
Regards
Jo CorlessHello Joanne,
Congratulations! I'm very happy that you've managed to fix your problem. It's
always essential to understand how to package applications when deploying on BEA
WebLogic. Usually, by throwing everything into an EAR file solves just about all
the class loader problems. :-) Let us know if you have any further problems that
we can assist you with.
Best regards,
Ryan LeCompte
[email protected]
http://www.louisiana.edu/~rml7669
"Joanne Corless" <[email protected]> wrote:
>
>
I've fixed it!!!!!!!!
Thanks to everyone who gave me help!!!!
The class loader was the culprit which is what I suspected all along.
As soon
as I put the 2 jar files I was using into an EAR file the problem went
away!!!!!
Thanks again
Jo Corless
"Ryan LeCompte" <[email protected]> wrote:
Hello Joanne,
As Mr. Woollen mentioned, I also believe it's a problem with the class
loader.
You need to be careful how you arrange your EJBs, because WebLogic has
a specific
method in which it loads classes in an EAR, JAR, and WAR file(s). Please
refer
to http://dev2dev.bea.com/articles/musser.jsp for more information about
BEA WebLogic
class loading mechanisms and caveats. Also, try printing out the various
methods
that are available on the object that was returned to you via reflection.
For
example, use the getMethods() method, which returns an array of Method
objects
that you can subsequently cycle through and print out the various method
names.
This way you can discover if the class found/returned to you is indeed
the one
you intend to locate.
Hope this helps,
Ryan LeCompte
[email protected]
http://www.louisiana.edu/~rml7669
Rob Woollen <[email protected]> wrote:
I believe the issue is the home interface class for this EJB is not
available in the class loader which is doing the reflection.
If you do:
getClass().getClassLoader().loadClass(homeInterfaceClassName)
I suspect it will fail. Reflection still requires that the class be
loadable.
-- Rob
Joanne Corless wrote:
Hi Slava,
If I make my code look like you describe below I get a compliationerror telling
me that
home.getMethod() is not recognised (no such method)
If I change it slightly and use
Method homeCreateMethod =
home.getClass().getMethod(homeCreate,homeCreateParam);
The code will compile OK but when executed it still throws a NoSuchMethodException
Any ideas ?
Thanks for your help so far
Regards
Jo Corless
Your code should look like
Object home = pCtx.lookup(pJNDIName);
Method homeCreateMethod =
home.getMethod(homeCreate,homeCreateParam);
return homeCreateMethod.invoke(home, homeCreateParamValues);
Regards,
Slava Imeshev
"Joanne Corless" <[email protected]> wrote in message
news:[email protected]...
Hi Ryan,
I also wanted to mention that if you do a "header search" in this
particular
newsgroup
with the search query as "reflection", you will see many previousmessages
regarding
reflection and EJBs. I believe you could learn a lot from thedifficulties
that
others have faced and solved.I tried that and although there was a number of similar cases noneof them
actually
seem to fix my issue. Thanks for the suggestion though
Are the EJBs that you are trying to access accessible via your
system
classpath?
Try to avoid having them accessible via the main system classpath,and
only bundle
them in your appropriate EJB jar files (contained in an EAR file,for
example).Maybe I should have laid the problem out a little clearer.
I have a number of EJB's bundled up in a JAR file which is hot deployedto
the
server. Within this first JAR file is an EJB (SSB) component that
needs
to
be
able to invoke a known method on another EJB. This second EJB may
or
may
not be
within the first JAR file but it also will be hot deployed.
The component trying to invoke the method on the 2nd EJB has to
be
able to
create
an instance of the 2nd EJB without actually knowing anything bar
a
JNDI
Name which
is passed in at runtime.
I can get as far as doing the
Object home = pCtx.lookup(pJNDIName);
This returned a class with the name
"com.csc.edc.projects.allders.httppostoffice.postman.PostmanBean_mp8qy2_Home
Impl_WLStub"
My problem seems to occur when I try and invoke the create method
Method homeCreate = home.getClass().getMethod("create", new Class[0]);
My code throws a java.lang.NoSuchMethodException at this point so
I
am
unable
to progress to the next step of :
Object bean = homeCreate.invoke(home, null);
So I can return the instantiated bean back to the calling client.
Why am I getting the NoSuchMethodException, is is because I am gettinga
stub
back rather than the home interface and if so how do I get the truehome
interface
from the bean
Thanks in advance
Jo Corless -
Using bind variables (in & out) with dynamic sql
I got a table that holds pl/sql code snippets to do validations on a set of data. what the code basically does is receiving a ID and returning a number of errors found.
To execute the code I use dynamic sql with two bind variables.
When the codes consists of a simpel query, it works like a charm, for example with this code:
BEGIN
SELECT COUNT (1)
INTO :1
FROM articles atl
WHERE ATL.CSE_ID = :2 AND cgp_id IS NULL;
END;however when I get to some more complex validations that need to do calculations or execute multiple queries, I'm running into trouble.
I've boiled the problem down into this:
DECLARE
counter NUMBER;
my_id NUMBER := 61;
BEGIN
EXECUTE IMMEDIATE ('
declare
some_var number;
begin
select 1 into some_var from dual
where :2 = 61;
:1 := :2;
end;
USING OUT counter, IN my_id;
DBMS_OUTPUT.put_line (counter || '-' || my_id);
END;this code doesn't really make any sense, but it's just to show you what the problem is. When I execute this code, I get the error
ORA-6537 OUT bind variable bound to an IN position
The error doesn't seem to make sense, :2 is the only IN bind variable, and it's only used in a where clause.
As soon as I remove that where clause , the code will work again (giving me 61-61, in case you liked to know).
Any idea whats going wrong? Am I just using the bind variables in a way you're not supposed to use them?
I'm using Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bitCorrection. With execute immediate binding is by position, but binds do not need to be repeated. So my statement above is incorrect..
You need to bind it once only - but bind by position. And the bind must match how the bind variable is used.
If the bind variable never assigns a value in the code, bind as IN.
If the bind variable assigns a value in the code, bind as OUT.
If the bind variable assigns a value and is used a variable in any other statement in the code, bind as IN OUT.
E.g.
SQL> create or replace procedure FooProc is
2 cnt number;
3 id number := 61;
4 begin
5 execute immediate
6 'declare
7 n number;
8 begin
9 select
10 1 into n
11 from dual
12 where :var1 = 61; --// var1 is used as IN
13
14 :var2 := n * :var1; --// var2 is used as OUT and var1 as IN
15 :var2 := -1 * :var2; --// var2 is used as OUT and IN
16 end;
17 '
18 using
19 in out id, in out cnt; --// must reflect usage above
20
21 DBMS_OUTPUT.put_line ( 'cnt='||cnt || ' id=' || id);
22 end;
23 /
Procedure created.
SQL>
SQL> exec FooProc
cnt=-61 id=61
PL/SQL procedure successfully completed.
SQL> -
How to create a function with dynamic sql or any better way to achieve this?
Hello,
I have created below SQL query which works fine however when scalar function created ,it
throws an error "Only functions and extended stored procedures can be executed from within a
function.". In below code First cursor reads all client database names and second cursor
reads client locations.
DECLARE @clientLocation nvarchar(100),@locationClientPath nvarchar(Max);
DECLARE @ItemID int;
SET @locationClientPath = char(0);
SET @ItemID = 67480;
--building dynamic sql to replace database name at runtime
DECLARE @strSQL nvarchar(Max);
DECLARE @DatabaseName nvarchar(100);
DECLARE @localClientPath nvarchar(MAX) ;
Declare databaselist_cursor Cursor for select [DBName] from [DataBase].[dbo].
[tblOrganization]
OPEN databaselist_cursor
FETCH NEXT FROM databaselist_cursor INTO @DatabaseName
WHILE @@FETCH_STATUS = 0
BEGIN
PRINT 'Processing DATABASE: ' + @DatabaseName;
SET @strSQL = 'DECLARE organizationlist_cursor CURSOR
FOR SELECT '+ @DatabaseName +'.[dbo].[usGetLocationPathByRID]
([LocationRID])
FROM '+ @DatabaseName +'.[dbo].[tblItemLocationDetailOrg] where
ItemId = '+ cast(@ItemID as nvarchar(20)) ;
EXEC sp_executesql @strSQL;
-- Open the cursor
OPEN organizationlist_cursor
SET @localClientPath = '';
-- go through each Location path and return the
FETCH NEXT FROM organizationlist_cursor into @clientLocation
WHILE @@FETCH_STATUS = 0
BEGIN
SELECT @localClientPath = @clientLocation;
SELECT @locationClientPath =
@locationClientPath + @clientLocation + ','
FETCH NEXT FROM organizationlist_cursor INTO
@clientLocation
END
PRINT 'current databse client location'+ @localClientPath;
-- Close the Cursor
CLOSE organizationlist_cursor;
DEALLOCATE organizationlist_cursor;
FETCH NEXT FROM databaselist_cursor INTO @DatabaseName
END
CLOSE databaselist_cursor;
DEALLOCATE databaselist_cursor;
-- Trim the last comma from the string
SELECT @locationClientPath = SUBSTRING(@locationClientPath,1,LEN(@locationClientPath)- 1);
PRINT @locationClientPath;
I would like to create above query in function so that return value would be used in
another query select statement and I am using SQL 2005.
I would like to know if there is a way to make this work as a function or any better way
to achieve this?
Thanks,This very simple: We cannot use dynamic SQL from used-defined functions written in T-SQL. This is because you are not permitted do anything in a UDF that could change the database state (as the UDF may be invoked as part of a query). Since you can
do anything from dynamic SQL, including updates, it is obvious why dynamic SQL is not permitted as per the microsoft..
In SQL 2005 and later, we could implement your function as a CLR function. Recall that all data access from the CLR is dynamic SQL. (here you are safe-guarded, so that if you perform an update operation from your function, you will get caught.) A word of warning
though: data access from scalar UDFs can often give performance problems and its not recommended too..
Raju Rasagounder Sr MSSQL DBA
Hi Raju,
Can you help me writing CLR for my above function? I am newbie to SQL CLR programming.
Thanks in advance!
Satya
-
ACS 5.3 Authorization problem with using Identity Groups in Access Policy Rule
Hello guys, I am found a problem which I can't solve regarding authorization with using Identity Groups in Access Policy rule.
ACS version: 5.3.0.40.6 (internal build B.839)
I have very simple RADIUS Authorization rule which authorize user on behalf of right Identity Group.
Requested Identity Group exist
Testing user is created in Internal Users and has assigned requested Identity Group
Radius Access Policy:
Authentication against Identity Store Sequence, where authorization server is external RSA SecurID device and additional attributes retrieval is configured from Internal Users.
Authorization is very simple – One Rule with only one Condition which is: Identity Group - in - Requested_Testing_Rule. Then Default rule is set to Deny.
When I will try login with my testing user then authentication against RSA SecurID is OK, but authorization will be denied by Default rule – It looks like my Rule with Identity Group is totally omitted.
I am managing several other ACS servers (version 5.3 but with older patches) where similar rules are working without problem.
What I am tested:
Remove testing user and create his account again.
Rename Identity Group
Use another Identity Group
Remove Access Policy rule and create it again
Use Compound Condition: System:Identity Group
Use Compound Condition: System:UserID instead of Identity Group in Rule (it is working without problem)
Do you have any idea where problem can be?OK guys, it started working yesterday without any configuration change. Maybe it was some database inconsistence wich was solved by ACS itself.
-
Problem with dynamic LOV and function
Hello all!
I'm having a problem with a dynamic lov in APEX 3.0.1.00.08. Hope you can help me!
I have Report and Form application. On the Form page i have a Page Item (Popup Key LOV (Displays description, returns key value)).
When i submit the sql code in the 'List of vaules defention' box. I get the following message;
1 error has occurred
LOV query is invalid, a display and a return value are needed, the column names need to be different. If your query contains an in-line query, the first FROM clause in the SQL statement must not belong to the in-line query.
When i excecute the code below in TOAD or in the SQL Workshop it returns the values i want to see. But somehow APEX doesn't like the sql....
SELECT REC_OMSCHRIJVING d, REC_DNS_ID r FROM
TABLE(CAST(return_dns_lov_fn(:P2_DNS_ID) AS dns_table_type)) order by 1
returns_dns_lov_fn is a function, code is below;
CREATE OR REPLACE FUNCTION DRSSYS.return_dns_lov_fn (p2_dns_id number)
RETURN dns_table_type
AS
v_data dns_table_type := dns_table_type ();
BEGIN
IF p2_dns_id = 2
THEN
FOR c IN (SELECT dns_id dns, omschrijving oms
FROM d_status dst
WHERE dst.dns_id IN (8, 10))
LOOP
v_data.EXTEND;
v_data (v_data.COUNT) := dns_rectype (c.dns, c.oms);
END LOOP;
RETURN v_data;
END IF;
END;
and the types;
CREATE OR REPLACE TYPE DRSSYS.dns_rectype AS OBJECT (rec_dns_id NUMBER, rec_omschrijving VARCHAR2(255));
CREATE OR REPLACE TYPE DRSSYS.dns_table_type AS TABLE OF dns_rectype;
I tried some things i found on this forum, but they didn't work as well;
SELECT REC_OMSCHRIJVING display_value, REC_DNS_ID result_display FROM
TABLE(CAST(return_dns_lov_fn(:P2_DNS_ID) AS dns_table_type)) order by 1
SELECT REC_OMSCHRIJVING display_value d, REC_DNS_ID result_display r FROM
TABLE(CAST(return_dns_lov_fn(:P2_DNS_ID) AS dns_table_type)) order by 1
SELECT a.REC_OMSCHRIJVING display_value, a.REC_DNS_ID result_display FROM
TABLE(CAST(return_dns_lov_fn(:P2_DNS_ID) AS dns_table_type)) a order by 1
Edited by: rajan.arkenbout on 8-mei-2009 14:41
Edited by: rajan.arkenbout on 8-mei-2009 14:51I just had the same problem when I used a function in a where clause.
I have a function that checks if the current user has acces or not (returning varchar 'Y' or 'N').
In where clause I have this:
where myFunction(:user, somePK) = 'Y'
It seems that when APEX checked if my query was valid, my function triggered and exception.
As Varad pointed out, check for exception that could be triggered by a null 'p2_dns_id'
Hope that helped you out.
Max
Maybe you are looking for
-
Lost connection between ovm-manager and ovm-server (ovm 3.1)
Hi, I have a manager as a VM on my laptop and a physical server as an ovm-server. Everything is fine when i boot the server but after some time, the manager stop to show the information from the server. in the ovs-agent log file the following message
-
Screen is dead, and restoring isn't fixing it
A few days after updating my 1st gen iPod touch to 3.1.3, I was suddenly given a white screen. This was followed by a black screen after reseting it. After restoring my iPod, the screen will not turn on at all but the iPod will behave as if it is in
-
Accessing c4 Variables in Javascript
How do you pass a Captivate 4 variable (User or System) in Javascript when the published .SWF is embedded in another tool like Lectora or Flash? In Captivate, you can set a value into a Lectora variable (VARmyLectoraVariable.set('myvalue');, but I do
-
1280 X 720 29.97 FPS Setup
Greeting, I'm starting up Premier Pro CS6 and I get this huge selection of formats I could setup for everything but what I "think" I need. What I Need Final output will be to YouTube but I want to set the file up for full res and then render from tha
-
Periodic Schedule failures due to locked objects
We are periodically encountering issues with nightly schedules against BW Bex universes. Some schedules will fail with the error "A database error occured. The database error text is: Error getting variables for cube (Cube\Query name) (catalog cube