DYNAMIC SQL & ORA 01002 :-( What's Wrong ????
Hi all !
i must set a stored procedure in dynamic pl/sql which must update a
group of tables owned by two different users.
I've set up correctly the authorisations to those users, no problems
for this.
My problem is this one : when I try to fetch a second cursor based on
a id which comes form the first one, i've got an ORA-01002 error.
Since I 've already read a lot of news and nearly all the technet on
this topic (and my collegues don't find any problem to the code), I
really wonder what's going on :(
Each help, idea, or even smoke signal (even without fire) would be
very grateful for me, because I'm really lost ! Please help !!
Thanks for your answers !
Here is a little sample of the code which seems to be wrong (i don't
give the complete package which is nearly 400 lines long).
CREATE OR REPLACE PROCEDURE TEST IS
cursor_work INTEGER; --- for the primary table
cursor_work2 INTEGER; --- for the secondary table linked to the
first one by a foreign key
dir_id NUMBER; --- primary key of my primar table
id NUMBER; --- primary key of my secondary table
ignore NUMBER;
ignore2 NUMBER;
BEGIN
curseur_travail := DBMS_SQL.OPEN_CURSOR; -- open my cursor
DBMS_SQL.PARSE(curseur_travail, 'SELECT DIR_ID FROM USER1.TABLE1',
DBMS_SQL.native); -- parse it
DBMS_SQL.DEFINE_COLUMN(curseur_travail, 1, dir_id); -- definition of
my column
ignore := DBMS_SQL.EXECUTE(curseur_travail); -- execution
LOOP
IF DBMS_SQL.FETCH_ROWS(curseur_travail)>0 THEN -- fetch it while
not empty
DBMS_SQL.COLUMN_VALUE(curseur_travail, 1, dir_id); -- get data
BEGIN
EXECUTE IMMEDIATE 'INSERT INTO USER1.TABLE1 SELECT * FROM
USER2.TABLE1 WHERE ID='||id'; -- try to insert
EXCEPTION WHEN DUP_VAL_ON_INDEX THEN -- if it doesn'ty work i update
it
EXECUTE IMMEDIATE 'UPDATE USER1.TABLE1 SET [..] WHERE
ID='||dir_id;
END;
BEGIN -- open the secondary cursor based on the result of my first
cursor (dir_id)
curseur_travail2 := DBMS_SQL.OPEN_CURSOR; -- goes right
DBMS_SQL.PARSE(curseur_travail2, 'SELECT * FROM USER1.TABLE1-1
WHERE ID = '||dir_id, DBMS_SQL.native); -- ok, goes well
DBMS_SQL.DEFINE_COLUMN(curseur_travail2, 1, id); -- no problems
ignore2 := DBMS_SQL.EXECUTE(curseur_travail2); -- it works
LOOP --- ok
IF DBMS_SQL.FETCH_ROWS(curseur_travail2)>0 THEN --- ==[ HERE IS
THE BUG ORA-01002]==
BEGIN
DBMS_SQL.DEFINE_COLUMN(curseur_travail2, 1, id);
EXECUTE IMMEDIATE 'INSERT_INTO USER1.TABLE1-1 SELECT
USER2.TABLE1-1 WHERE ID='||id;
EXCEPTION WHEN DUP_VAL_ON_INDEX THEN
EXECUTE IMMEDIATE 'UPDATE USER1.TABLE1-1 SET [..] WHERE ID =
'||id;
END;
END IF;
END LOOP;
DBMS_SQL.CLOSE_CURSOR(cursor_work2);
END;
END LOOP;
DBMS_SQL.CLOSE_CURSOR(cursor_work);
END;
ok i've found the solution
so simple :-(
i've forgot to set an
ELSE
EXIT
END IF;
for the second cursor !
Similar Messages
-
Sql query? What is wrong with this??
High everyone. I was trying to solve problem with jsp-servlet combination. I nailed the problem down to the last point, but surprisingly I got an error message which is completely out of any reason.
Here is the problem. Im using tomcat 5.5 and MySql DB.
I've got a servlet with a method that returns ID of the member according to his name. Here is the relevant code:public static int getMemberID (String name) {
int id = 5;
try {
Class.forName("com.mysql.jdbc.Driver").newInstance();
ResultSet rs = st.executeQuery("select MemberID from member where MemberName =" + name);
if (rs!=null && rs.next()) {
id = rs.getInt("MemberID");
st.close();
conn.close();
}I call this method from the JSP:
<% int a = ThreadMembers.getMemberID("Merlin");.....
Now what happens...I got the SQL exception message:
Unknown column 'Merlin' in 'where' clause !?!?!
Of course I checked my database and tried the same query manually, everything is OK. There are only two records in my member table.
And, just in case, I entered manually the next query:
select MemberID from member where Merlin = 'Merlin' :)
and of course got the same error message.
I would really like to hear if anybody had similar problem, or is able to explain what's going on here.
Thank youAt least this has nothing to do with JSP/JSTL. It may reach JDBC http://forum.java.sun.com/forum.jspa?forumID=48 , but it is still just an ordinary SQL problem. Starting reading some SQL tutorials will help you to gain more SQL knowledge. Here are some useful links in one page: http://www.google.com/search?q=sql+tutorial
-
Why an "ORA-01006: bind variable does not exist" error when no dynamic SQL?
Hi all,
While running PL/SQL in SQL Developer 3.2.09, I got the following error after adding a section of code. Note that nothing I'm doing has anything to do with dynamic SQL (which is what 01006 is supposedly about).
Error report:
ORA-01006: bind variable does not exist
01006. 00000 - "bind variable does not exist"
*Cause:
*Action:
After commenting out the new chunk of code that caused the error, the error persisted.
After deleting the new code, the error went away.
What the heck!?!? If you have any ideas, please lay 'em on me.
Thanks so much,
Kim
P.S. It's a few hundred lines of code, so I didn't append it to this post and I don't see how to attach a file.Let's review a few facts:
1. You post a question in the sql developer forum that has no apparent relation to sql developer. You could confirm this by doing the test using sql*plus or some other tool.
2. You provide NO information about what database you are even using. The only clue is an ORA -xxx message that means SOME version of Oracle is involved.
3. You provide NO information about what the four digit version of Oracle DB is being used.
4. You provide NO information about what the code in general or what that specific section of the code is even doing. The code could be doing literally anything that Oracle is capable of doing.
That's a bit like calling a mechanic you don't know, telling them your car is making a funny noise and asking them what the problem with your car is.
>
While running PL/SQL in SQL Developer 3.2.09, I got the following error after adding a section of code. Note that nothing I'm doing has anything to do with dynamic SQL (which is what 01006 is supposedly about).
Error report:
ORA-01006: bind variable does not exist
01006. 00000 - "bind variable does not exist"
*Cause:
*Action:
The error gives no indication of where the error occurred in the code.
>
Your first clue that your troubleshooting method is seriously flawed is when you make statements that aren't supported by any evidence at all but appear to be nothing but your opinion.
Your second clue is when those statements appear to directly contradict what Oracle is telling you.
I'm talking about these two statements you make; which you state as if they were universal truths
>
nothing I'm doing has anything to do with dynamic SQL
(which is what 01006 is supposedly about).
>
If thoe were true then your 'unstated' conclusion appears to be that Oracle is wrong in saying 'bind variable does not exist'
Sorry - but I would place my money on Oracle.
I'm sure the above may sound harsh - it is intended to be. My four major rules (there are more) when troubleshooting Oracle problems.
1. Assume that Oracle is CORRECT when it tells you there is a problem.
2. Assume that you are WRONG if your opinion conflicts with what Oracle is telling you - see rule #1.
3. Don't make ANY other assumptions. You can form hypotheses but don't state them as facts until they are proven.
4. Your 'opinion' is only useful to the extent that it can help you form meaningful hypotheses - see rule #3.
>
To reiterate, there is no dynamic SQL in the code.
>
To reiterate - if, as you state, that error relates to dynamic SQL and bind variables then it can not be disputed that:
ORACLE DOESN'T AGREE WITH YOU!
So let's try it my way and hypothesize that Oracle is correct (see rule #1 above).
Then by definition this statement by Oracle is correct
>
ORA-01006: bind variable does not exist
>
And that should immediately raise this question:
1. where might there be a bind variable that does not exist?
which leads to a prerequisite question:
2. where are ALL of the bind variables that might be being used?
Question #2 is where you need to start your search. Here are at least five possibilities (there are more)
1. your code - this should be easiest to check and you state that your 'anonymous' block does not have any.
2. a table trigger - triggers that use the :NEW, :OLD or :PARENT pseudocolumns. Those psuedocolumns are BIND variables and the trigger code that uses them is, by definition, dynamic sql.
3. a pl/sql package/function/procedure - any of these might be being called from trigger code or a view that is involved in the transaction. Any of these could take a parameter and/or use bind variables and cause your problem if that bind variable does 'not exist'.
4. a functional index - can also trigger code from #3 above
5. an audit trigger that logs the audit activity that your user or your code is performing. This code could be trying to use a SYS_CONTEXT environment variable that has not been created and cause a 'bind variable does not exist' error.
See rule #1 - Oracle is CORRECT. Until you have identified and examined ALL of the code (not just your anonymous block) being executed and ruled it out you should continue with the hypotheses that Oracle is CORRECT.
In the (extremely) unlikely event that you can show that Oracle is NOT correct you should file a SOR with Oracle. -
What is wrong with this PL/SQL block
declare
v_count integer := 0;
begin
-- execute immediate 'select count(1) into v_count from ' || 'abc' || '.table1';
execute immediate 'select count(1) into v_count from abc.table1';
dbms_output.put_line('v_count: ' || v_count);
end;
When i execute the above pl/sql block, I get the following error:
ORA-00905: missing keyword
ORA-06512: at line 6
What am I doing wrong?
When I use SELECT COUNT(1) INTO v_count FROM abc.table1; ( instead of the dynamic sql ), it works.
I realize I don't need to use execute immediate for SELECT, but I need to do the dynamic SQL because the table1 will be under multiple schemas.
Would appreciate an explanation for the above error, and/or alternate solution(s) for dynamic sql.
ThanksDECLARE
v_count INTEGER := 0;
BEGIN
-- execute immediate 'select count(1) into v_count from ' || 'abc' || '.table1';
EXECUTE IMMEDIATE 'select count(1) from abc.table1' into v_count;
dbms_output.put_line('v_count: ' || v_count);
END;TEST
DECLARE
v_count INTEGER := 0;
BEGIN
-- execute immediate 'select count(1) into v_count from ' || 'abc' || '.table1';
EXECUTE IMMEDIATE 'select count(1) from dual ' into v_count;
dbms_output.put_line('v_count: ' || v_count);
END;
v_count: 1
PL/SQL procedure successfully completed.HTH
SS -
Hello,
I'm trying to create a function utilizing Dynamic SQL. The function compiles fine, but when I go to call it using the select staement below, I get :
ORA-01006: bind variable does not exist
ORA-06512: at "ICIM.PROD_SALES_DATA", line 24
select prod_sales_data('09','I',2009,'Awning')
from dual;
CREATE OR REPLACE FUNCTION prod_sales_data
(p_ahl1 IN VARCHAR2, p_phl1 IN VARCHAR2, p_fisyr IN NUMBER,
p_prod_str IN VARCHAR2)
RETURN NUMBER IS
v_return NUMBER;
query_str VARCHAR2(10000);
BEGIN
query_str :='select sum(a.qsh*a.unitcnt)'||chr(13)
||'from sh_units a, sh_product_desc b, sh_ad_glass c'||chr(13)
||'where a.unittype = b.unittype'||chr(13)
||'and a.sh_id = c.sh_id(+)'||chr(13)
||'AND a.ahl1 = '||chr(39)||p_ahl1||chr(39)||chr(13)
||'AND a.phl1 = '||chr(39)||p_phl1||chr(39)||chr(13)
||'AND a.fisyr ='|| p_fisyr||chr(13)
||'AND UPPER(b.descrip) = UPPER('||chr(39)||p_prod_str||chr(39)||')'||chr(13)
||'AND a.invdt between b.eff_beg and b.eff_end'||chr(13)
||'and a.parts_flag <>'||chr(39)||'Y'||chr(39)||chr(13)
||'and a.unittype <>'||chr(39)||'OTHE'||chr(39)||chr(13)
||'and icim.sh_rept_chk_ortp(a.ortp) = 1'||chr(13)
||'and A.REPT_RELEASE_DT is not null';
DBMS_OUTPUT.PUT_LINE(query_str) ;
EXECUTE IMMEDIATE query_str
INTO v_return
USING p_ahl1,p_phl1,p_fisyr,p_prod_str;
RETURN v_return;
EXCEPTION
WHEN NO_DATA_FOUND THEN
NULL;
END prod_sales_data ;
Any help as to what is going wrong would be greatly appreciated.
Thanks,
TylerHello,
>
I'm trying to create a function utilizing Dynamic SQL. But why?
Whenever you turn towards dynamic SQL, ask yourself why?
I bet for a couple of years you aren't able rto come up with an answer. Meaning you shouldn't.
Even if you do come up with an answer, think again. The answer may very well be wrong.
Wouldn't it be nice if your function was as simple as:
CREATE OR REPLACE FUNCTION prod_sales_data
( p_ahl1 IN VARCHAR2
, p_phl1 IN VARCHAR2
, p_fisyr IN NUMBER,
p_prod_str IN VARCHAR2)
RETURN NUMBER
IS
v_return NUMBER;
BEGIN
select sum(a.qsh*a.unitcnt)
into v_return
from sh_units a
, sh_product_desc b
, sh_ad_glass c
where a.unittype = b.unittype
and a.sh_id = c.sh_id(+)
and a.ahl1 = p_ahl1
and a.phl1 = p_phl1
and a.fisyr = p_fisyr
and upper(b.descrip) = upper(p_prod_str)
and a.invdt between b.eff_beg and b.eff_end
and a.parts_flag != 'Y'
and a.unittype != 'OTHE'
and icim.sh_rept_chk_ortp(a.ortp) = 1
and a.rept_release_dt is not null;
RETURN v_return;
EXCEPTION
WHEN NO_DATA_FOUND THEN
RETURN NULL;
END prod_sales_data ;
/Now using proper bind variables, plain static pre-compiled SQL. And even works properly WITH NO DATA FOUND.
I know it's dangerous to use words as always and never, but i dare say
Always (Whenever you can) use static SQL. Never (Unless you must) use dynamic SQL (When you can use static).
Regards
Peter -
ORA-01008 with ref cursor and dynamic sql
When I run the follwing procedure:
variable x refcursor
set autoprint on
begin
Crosstab.pivot(p_max_cols => 4,
p_query => 'select job, count(*) cnt, deptno, row_number() over (partition by job order by deptno) rn from scott.emp group by job, deptno',
p_anchor => Crosstab.array('JOB'),
p_pivot => Crosstab.array('DEPTNO', 'CNT'),
p_cursor => :x );
end;I get the following error:
^----------------
Statement Ignored
set autoprint on
begin
adsmgr.Crosstab.pivot(p_max_cols => 4,
p_query => 'select job, count(*) cnt, deptno, row_number() over (partition by
p_anchor => adsmgr.Crosstab.array('JOB'),
p_pivot => adsmgr.Crosstab.array('DEPTNO', 'CNT'),
p_cursor => :x );
end;
ORA-01008: not all variables bound
I am running this on a stored procedure as follows:
create or replace package Crosstab
as
type refcursor is ref cursor;
type array is table of varchar2(30);
procedure pivot( p_max_cols in number default null,
p_max_cols_query in varchar2 default null,
p_query in varchar2,
p_anchor in array,
p_pivot in array,
p_cursor in out refcursor );
end;
create or replace package body Crosstab
as
procedure pivot( p_max_cols in number default null,
p_max_cols_query in varchar2 default null,
p_query in varchar2,
p_anchor in array,
p_pivot in array,
p_cursor in out refcursor )
as
l_max_cols number;
l_query long;
l_cnames array;
begin
-- figure out the number of columns we must support
-- we either KNOW this or we have a query that can tell us
if ( p_max_cols is not null )
then
l_max_cols := p_max_cols;
elsif ( p_max_cols_query is not null )
then
execute immediate p_max_cols_query into l_max_cols;
else
RAISE_APPLICATION_ERROR(-20001, 'Cannot figure out max cols');
end if;
-- Now, construct the query that can answer the question for us...
-- start with the C1, C2, ... CX columns:
l_query := 'select ';
for i in 1 .. p_anchor.count
loop
l_query := l_query || p_anchor(i) || ',';
end loop;
-- Now add in the C{x+1}... CN columns to be pivoted:
-- the format is "max(decode(rn,1,C{X+1},null)) cx+1_1"
for i in 1 .. l_max_cols
loop
for j in 1 .. p_pivot.count
loop
l_query := l_query ||
'max(decode(rn,'||i||','||
p_pivot(j)||',null)) ' ||
p_pivot(j) || '_' || i || ',';
end loop;
end loop;
-- Now just add in the original query
l_query := rtrim(l_query,',')||' from ( '||p_query||') group by ';
-- and then the group by columns...
for i in 1 .. p_anchor.count
loop
l_query := l_query || p_anchor(i) || ',';
end loop;
l_query := rtrim(l_query,',');
-- and return it
execute immediate 'alter session set cursor_sharing=force';
open p_cursor for l_query;
execute immediate 'alter session set cursor_sharing=exact';
end;
end;
/I can see from the error message that it is ignoring the x declaration, I assume it is because it does not recognise the type refcursor from the procedure.
How do I get it to recognise this?
Thank you in advanceThank you for your help
This is the version of Oracle I am running, so this may have something to do with that.
Oracle9i Enterprise Edition Release 9.2.0.8.0 - Production
With the Partitioning, OLAP and Oracle Data Mining options
JServer Release 9.2.0.8.0 - Production
I found this on Ask Tom (http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:3027089372477)
Hello, Tom.
I have one bind variable in a dynamic SQL expression.
When I open cursor for this sql, it gets me to ora-01008.
Please consider:
Connected to:
Oracle8i Enterprise Edition Release 8.1.7.4.1 - Production
JServer Release 8.1.7.4.1 - Production
SQL> declare
2 type cur is ref cursor;
3 res cur;
4 begin
5 open res for
6 'select * from (select * from dual where :p = 1) connect by 1 = 1'
7 using 1;
8 end;
9 /
declare
ERROR at line 1:
ORA-01008: not all variables bound
ORA-06512: at line 5
SQL> declare
2 type cur is ref cursor;
3 res cur;
4 begin
5 open res for
6 'select * from (select * from dual where :p = 1) connect by 1 = 1'
7 using 1, 2;
8 end;
9 /
PL/SQL procedure successfully completed.
And if I run the same thing on 10g -- all goes conversely. The first part runs ok, and the second
part reports "ORA-01006: bind variable does not exist" (as it should be, I think). Remember, there
is ONE bind variable in sql, not two. Is it a bug in 8i?
What should we do to avoid this error running the same plsql program code on different Oracle
versions?
P.S. Thank you for your invaluable work on this site.
Followup June 9, 2005 - 6pm US/Eastern:
what is the purpose of this query really?
but it would appear to be a bug in 8i (since it should need but one). You will have to work that
via support. I changed the type to tarray to see if the reserved word was causing a problem.
variable v_refcursor refcursor;
set autoprint on;
begin
crosstab.pivot (p_max_cols => 4,
p_query =>
'SELECT job, COUNT (*) cnt, deptno, ' ||
' ROW_NUMBER () OVER ( ' ||
' PARTITION BY job ' ||
' ORDER BY deptno) rn ' ||
'FROM emp ' ||
'GROUP BY job, deptno',
p_anchor => crosstab.tarray ('JOB'),
p_pivot => crosstab.tarray ('DEPTNO', 'CNT'),
p_cursor => :v_refcursor);
end;
/Was going to use this package as a stored procedure in forms but I not sure it's going to work now. -
What's wrong with this SQL?
what's wrong with this SQL?
Posted: Jan 16, 2007 9:35 AM Reply
Hi, everyone:
when I insert into table, i use the fellowing SQL:
INSERT INTO xhealthcall_script_data
(XHC_CALL_ENDED, XHC_SWITCH_PORT, XHC_SCRIPT_ID, XHC_FAX_SPECIFIED)
VALUES (SELECT TO_DATE(HH_END_DATE||' '||HH_END_TIME,'MM/DD/YY HH24:MI:SS'), HH_SWITCHPORT, HH_SCRIPT,'N'
FROM tmp_healthhit_load WHERE HH_SCRIPT !='BROCHURE' UNION
SELECT TO_DATE(HH_END_DATE||' '||HH_END_TIME,'MM/DD/YY HH24:MI:SS'), HH_SWITCHPORT, HH_SCRIPT,'N' FROM tmp_healthhit_load WHERE HH_SCRIPT !='BROCHURE');
I always got an error like;
VALUES (SELECT TO_DATE(HH_END_DATE||' '||HH_END_TIME,'MM/DD/YY HH24:MI:SS'), HH_SWITCHPORT,
ERROR at line 3:
ORA-00936: missing expression
but I can't find anything wrong, who can tell me why?
thank you so much in advance
mpowel01
Posts: 1,516
Registered: 12/7/98
Re: what's wrong with this SQL?
Posted: Jan 16, 2007 9:38 AM in response to: jerrygreat Reply
For starters, an insert select does not have a values clause.
HTH -- Mark D Powell --
PP
Posts: 41
From: q
Registered: 8/10/06
Re: what's wrong with this SQL?
Posted: Jan 16, 2007 9:48 AM in response to: mpowel01 Reply
Even I see "missing VALUES" as the only error
Eric H
Posts: 2,822
Registered: 10/15/98
Re: what's wrong with this SQL?
Posted: Jan 16, 2007 9:54 AM in response to: jerrygreat Reply
...and why are you doing a UNION on the exact same two queries?
(SELECT TO_DATE(HH_END_DATE||' '||HH_END_TIME,'MM/DD/YY HH24:MI:SS') ,HH_SWITCHPORT ,HH_SCRIPT ,'N' FROM tmp_healthhit_load WHERE HH_SCRIPT !='BROCHURE' UNION SELECT TO_DATE(HH_END_DATE||' '||HH_END_TIME,'MM/DD/YY HH24:MI:SS') ,HH_SWITCHPORT ,HH_SCRIPT ,'N' FROM tmp_healthhit_load WHERE HH_SCRIPT !='BROCHURE');
jerrygreat
Posts: 8
Registered: 1/3/07
Re: what's wrong with this SQL?
Posted: Jan 16, 2007 9:55 AM in response to: mpowel01 Reply
Hi,
thank you for your answer, but the problem is, if I deleted "values" as you pointed out, and then execute it again, I got error like "ERROR at line 3:
ORA-03113: end-of-file on communication channel", and I was then disconnected with server, I have to relogin SQLplus, and do everything from beganing.
so what 's wrong caused disconnection, I can't find any triggers related. it is so wired?
I wonder if anyone can help me about this.
thank you very much
jerry
yingkuan
Posts: 1,801
From: San Jose, CA
Registered: 10/8/98
Re: what's wrong with this SQL?
Posted: Jan 16, 2007 9:59 AM in response to: jerrygreat Reply
Dup Post
jerrygreat
Posts: 8
Registered: 1/3/07
Re: what's wrong with this SQL?
Posted: Jan 16, 2007 10:00 AM in response to: Eric H Reply
Hi,
acturlly what I do is debugging a previous developer's scipt for data loading, this script was called by Cron work, but it never can be successfully executed.
I think he use union for eliminating duplications of rows, I just guess.
thank you
jerry
mpowel01
Posts: 1,516
Registered: 12/7/98
Re: what's wrong with this SQL?
Posted: Jan 16, 2007 10:03 AM in response to: yingkuan Reply
Scratch the VALUES keyword then make sure that the select list matches the column list in number and type.
1 insert into marktest
2 (fld1, fld2, fld3, fld4, fld5)
3* select * from marktest
UT1 > /
16 rows created.
HTH -- Mark D Powell --
Jagan
Posts: 41
From: Hyderabad
Registered: 7/21/06
Re: what's wrong with this SQL?
Posted: Jan 16, 2007 10:07 AM in response to: jerrygreat Reply
try this - just paste the code and give me the error- i mean past the entire error as it is if error occurs
INSERT INTO xhealthcall_script_data
(xhc_call_ended, xhc_switch_port, xhc_script_id,
xhc_fax_specified)
SELECT TO_DATE (hh_end_date || ' ' || hh_end_time, 'MM/DD/YY HH24:MI:SS'),
hh_switchport, hh_script, 'N'
FROM tmp_healthhit_load
WHERE hh_script != 'BROCHURE'
UNION
SELECT TO_DATE (hh_end_date || ' ' || hh_end_time, 'MM/DD/YY HH24:MI:SS'),
hh_switchport, hh_script, 'N'
FROM tmp_healthhit_load
WHERE hh_script != 'BROCHURE';
Regards
Jagan
jerrygreat
Posts: 8
Registered: 1/3/07
Re: what's wrong with this SQL?
Posted: Jan 16, 2007 11:31 AM in response to: Jagan Reply
Hi, Jagan:
thank you very much for your answer.
but when I execute it, I still can get error like:
ERROR at line 1:
ORA-03113: end-of-file on communication channel
so wired, do you have any ideas?
thank you very muchAnd this one,
Aother question about SQL?
I thought I already told him to deal with
ORA-03113: end-of-file on communication channel
problem first.
There's nothing wrong (syntax wise) with the query. (of course when no "value" in the insert) -
What is wrong with this simple PL/SQL..
Hello,
I made a PL/SQL to recreate user (if user exits already, then drop/recreate)
I run this script and it won't drop the existed user as expected, what is wrong..?
run like:
$ sqlplus system/password@dbname @create_user.sql 'A1' --A1 is a user who already existed.
conn /as sysdba
SET FEEDBACK OFF SERVEROUTPUT ON VERIFY OFF TERMOUT OFF
DECLARE
v_count INTEGER := 0;
v_statement VARCHAR2 (200);
BEGIN
SELECT COUNT (1)
INTO v_count
FROM dba_users
WHERE username = UPPER ('&1');
IF v_count != 0
THEN
EXECUTE IMMEDIATE ('DROP USER &1 CASCADE');
END IF;
v_statement :=
'CREATE USER &1 IDENTIFIED BY &1'
|| ' DEFAULT TABLESPACE USER_DATA'
|| ' TEMPORARY TABLESPACE TEMPORARY_DATA'
|| ' PROFILE DEFAULT ACCOUNT UNLOCK';
EXECUTE IMMEDIATE (v_statement);
-- Grant permissions
EXECUTE IMMEDIATE ('GRANT READ_USER TO &1 WITH ADMIN OPTION');
EXECUTE IMMEDIATE ('ALTER USER &1 DEFAULT ROLE ALL');
EXECUTE IMMEDIATE ('GRANT CREATE PUBLIC SYNONYM TO &1');
EXECUTE IMMEDIATE ('GRANT CREATE DATABASE LINK TO &1');
EXECUTE IMMEDIATE ('GRANT CREATE SNAPSHOT TO &1');
EXECUTE IMMEDIATE ('GRANT CREATE TABLE TO &1');
EXECUTE IMMEDIATE ('GRANT DROP PUBLIC SYNONYM TO &1');
EXECUTE IMMEDIATE ('GRANT QUERY REWRITE TO &1');
EXECUTE IMMEDIATE ('GRANT RESTRICTED SESSION TO &1');
EXECUTE IMMEDIATE ('GRANT SELECT ANY DICTIONARY TO &1');
EXECUTE IMMEDIATE ('GRANT SELECT ANY TABLE TO &1');
EXECUTE IMMEDIATE ('GRANT UNLIMITED TABLESPACE TO &1');
EXECUTE IMMEDIATE ('GRANT SELECT ON SYS.CHANGE_TABLES TO &1');
EXECUTE IMMEDIATE ('GRANT SELECT ON SYS.DBA_SUBSCRIBED_TABLES TO &1');
EXECUTE IMMEDIATE ('GRANT SELECT ON SYS.DBA_SUBSCRIPTIONS TO &1');
EXECUTE IMMEDIATE ('GRANT EXECUTE ON SYS.DBMS_CDC_PUBLISH TO &1');
EXECUTE IMMEDIATE ('GRANT EXECUTE ON SYS.DBMS_CDC_SUBSCRIBE TO &1');
EXECUTE IMMEDIATE ('GRANT EXECUTE ON SYS.DBMS_CDC_UTILITY TO &1');
EXECUTE IMMEDIATE ('GRANT EXECUTE ON SYS.DBMS_LOCK TO &1');
EXECUTE IMMEDIATE ('GRANT EXECUTE ON SYS.DBMS_SYSTEM TO &1');
EXECUTE IMMEDIATE ('GRANT EXECUTE ON SYS.DBMS_UTILITY TO &1');
EXECUTE IMMEDIATE ('GRANT READ, WRITE ON DIRECTORY SYS.PUBLIC_ACCESS TO &1 WITH GRANT OPTION');
DBMS_OUTPUT.put_line (' ');
DBMS_OUTPUT.put_line ('User &1 created successfully');
DBMS_OUTPUT.put_line (' ');
EXCEPTION
WHEN OTHERS
THEN
DBMS_OUTPUT.put_line (SQLERRM);
DBMS_OUTPUT.put_line (' ');
END;
Exit;
EOF
Thank you
JerryHi,
I try to run this command in a shel scriptl, following this pl/sql excuting is a exp core shcema/imp to this user by using pipe.
(--this part is working well)
so I try to debug the pl/sql part first that is why I didn't use & or &&, which need to interactive with computer on scene, but this shell script will run automatically by scheduler.
this is the whole shell,
#!/bin/ksh
INPUT_DATABASE_SCHEMA=$1
OUTPUT_DATABASE_SCHEMA=$2
TARGET_DATABASE=$3
#drop/recreate user $2
sqlplus system/$3@$3 @create_user.sql '$2' ---this is also the question? how make it as real variable $2, not literal
#exp
mknod ./$1_exp p
gzip < $1_exp > ./$1_exp.dmp.gz &
exp \
rows=y \
userid=system/$3@$3 \
owner=$1 \
log=$1_exp.log \
file=$1_exp \
direct=y \
recordlength=65535 \
statistics=none \
consistent=y \
compress=n \
grep 'ORA-' $1_exp.log
if [ $? = 0 ]
then
mail -s "Problem in regression snapshort export" email < $1_exp.log
fi
#imp
mknod ./$1_exp p
gunzip < $1_exp.dmp.gz > $1_exp &
imp \
userid=system/$3@$3 \
file=$1_exp \
log=$2_IMP.log \
buffer=500000000 \
ignore=y \
commit=y \
fromuser=$1 \
touser=$2 \
feedback=100000 \
GRANTS=n \
grep 'ORA-' $2_IMP.log
if [ $? = 0 ]
then
mail -s "Erros found in regression snapshort import" email < $2_IMP.log
else
mail -s "regression snapshort is done sucessfully" email < $2_IMP.log
fi
#recompile invalid
sqlplus system/$3@$3 << EOF
conn /as sysdba
@?/rdbms/admin/utlrp.sql
Exit;
EOF
thank you in advance -
Dynamic SQL Issue ORA-00904:invalid identifier error
Here is my SP
create or replace procedure srini_ref_cursor_test(p_county_code IN VARCHAR2,
p_ref_cur out PK_FR_TYPES.cursor_type) is
query_str varchar2(5000);
begin
query_str := 'SELECT * FROM dw_county where county_name = :P ';
open p_ref_cur for query_str USING p_county_code;
insert into srini_query_str_test values (query_str);
commit;
end srini_ref_cursor_test;
When I pass the p_county_code = Adams working find.
create or replace procedure srini_ref_cursor_test(p_county_code IN VARCHAR2,
p_ref_cur out PK_FR_TYPES.cursor_type) is
query_str varchar2(5000);
begin
query_str := 'SELECT * FROM dw_county where county_name in ('||p_county_code||')';
open p_ref_cur for query_str;
insert into srini_query_str_test values (query_str);
commit;
end srini_ref_cursor_test;
When I pass the p_county_code = Adams for above SP I got the following error
ORA-00904: "ADAMS": invalid identifier error
With out Bind variables how Can I pass the Char type values in Dynamic SQL ?
I would like to pass multipule values to p_county_code like 'Adams','Ashley' etc
How Can I do this ?
Thank for great help.
SriniHow do I write the Dynamic SQL for
SELECT * FROM DW_COUNTY WHERE COUNTY_NAME LIKE 'Ad%'
The usual way...
hr@ORA10G>
hr@ORA10G> var str varchar2(1000);
hr@ORA10G> var cr refcursor;
hr@ORA10G>
hr@ORA10G> exec :str := 'select * from employees where first_name like ''A%''';
PL/SQL procedure successfully completed.
hr@ORA10G> -- note the escape character for each single quote
hr@ORA10G> print str
STR
select * from employees where first_name like 'A%'
hr@ORA10G>
hr@ORA10G> exec open :cr for :str;
PL/SQL procedure successfully completed.
hr@ORA10G> print cr
EMPLOYEE_ID FIRST_NAME LAST_NAME EMAIL PHONE_NUMBER HIRE_DATE JOB_ID SALARY COMMISSION_PCT MANAGER_ID DEPARTMENT_ID
103 Alexander Hunold AHUNOLD 590.423.4567 03-JAN-90 IT_PROG 9000 102 60
115 Alexander Khoo AKHOO 515.127.4562 18-MAY-95 PU_CLERK 3100 114 30
121 Adam Fripp AFRIPP 650.123.2234 10-APR-97 ST_MAN 8200 100 50
147 Alberto Errazuriz AERRAZUR 011.44.1344.429278 10-MAR-97 SA_MAN 12000 .3 100 80
158 Allan McEwen AMCEWEN 011.44.1345.829268 01-AUG-96 SA_REP 9000 .35 146 80
167 Amit Banda ABANDA 011.44.1346.729268 21-APR-00 SA_REP 6200 .1 147 80
175 Alyssa Hutton AHUTTON 011.44.1644.429266 19-MAR-97 SA_REP 8800 .25 149 80
185 Alexis Bull ABULL 650.509.2876 20-FEB-97 SH_CLERK 4100 121 50
187 Anthony Cabrio ACABRIO 650.509.4876 07-FEB-99 SH_CLERK 3000 121 50
196 Alana Walsh AWALSH 650.507.9811 24-APR-98 SH_CLERK 3100 124 50
10 rows selected.
hr@ORA10G>
hr@ORA10G>pratz -
What's wrong with this SQL Statement?
I hope somebody can help explain to me what is wrong wiht the
following SQL statement in my Recordest. It does not return an
error, but it will only filter records from the first variable
listed, 'varFirstName%'. If I try to use any other variables on my
search form,for example LastName, it returns all records. Why is it
doing this?
Here is the SQL statement:
SELECT *
FROM [Sysco Food Show Contacts]
WHERE FirstName LIKE 'varFirstName%' AND LastName LIKE
'varLastName%' AND OrganizationName LIKE 'varOrganizationName%' AND
Address LIKE 'varAddress%' AND City LIKE 'varCity%' AND State LIKE
'varState' AND PostalCode LIKE 'varPostalCode%'
The variables are defined as below:
Name Default Value Run-Time Value
varFirstName % Request.Form("FirstName")
varLastName % Request.Form("LastName")
...and such with all variables defined the same way.
Any help would be much appreciated. I am pulling my hair out
trying to make this Search Form work.
Thanks, mparsons2000PLEASE IGONRE THIS QUESTION!
There was nothing wrong with the statement. I had made
another STUDIP mistake! -
What's wrong with my listener.ora?
Hello.
I must say I've never understood how listener.ora works (it used to work but someone modified it), but by now it'd be enough to know what's wrong with this:
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC2))
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = zippo)(PORT = 1522))
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(GLOBAL_DBNAME = CSR2)
(ORACLE_HOME = /opt/oracle/product/9.2.0)
(SID_NAME = CSR2)
My problem is that when I try to connect from my PC "sqlplus csr_admin@csr2/csr" I get "ERROR: ORA-12154: TNS: could not resolve service name"
This is my entry in my local tnsnames.ora:
CSR2.world =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = zippo)(PORT = 1521))
(CONNECT_DATA =
(SERVICE_NAME = CSR2)
An this, the entry in the entntry at the server's tnsnames.ora:
CSR2 =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = zippo)(PORT = 1521))
(CONNECT_DATA =
(SERVICE_NAME = CSR2)
Release 9.2.0.3.0
Thanks in advance.It's funny but the date I posted this topic isn't OK (more than 3 years ago)
-
What's wrong with dynamic data?
I am starting this thread to showcase what I might call "dynamic data abuse": The use of dynamic data where it has no business to be used (does it ever?).
Everybody is invited to contribute with their own examples!
One of the problems when operating on dynamic data is its opacity. We can never really tell what's going on by looking at the code. It also seems to hide serious programming mistakes by adapting in ways to mask horrendous code and making it seemingly functional, glossing over the glaring programming errors.
To get it all started, here are a few recent sightings:
(A)
(Seen here). No Kidding! The users joins a scalar with a waveform, then wires the resulting dynamic data to the index input of "replace array subset". He cannot see anything wrong, because the program actually works (coercing the dynamic data to a scalar will, by a happy coincidence, return the value of the scalar joined earlier. I have no idea what thought process led to this code in the first place (maybe just randomly connecting functions until the result is as expected? ).
(B)
(seen here)
What's wrong with simply branching the wire???
(C)
I don't remember the link, but here's how somebody transposed a 2D array a while ago (bottom part of image). No way to tell from looking at the code picture! (The "FromDDT" and "ToDDT" need to be configured just right ...).
ARRRRGH!
LabVIEW Champion . Do more with less code and in less time .
Attachments:
join.png 2 KB
split.png 3 KB
DynamicTranspose.png 18 KBHere's another one for you. Found here:http://forums.ni.com/t5/LabVIEW/Program-unresponsive-after-a-dialog-box-input/m-p/2447608#U2447608
Put a bunch of booleans into a Combine Signals and then do a Dynamic Data to Boolean Array.
I supplied the much more cleaned up version of the code below.
EDIT: I just realized I needed to subtract 1 frm the power before using the Scale by Power of 2. Oops.
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
Attachments:
Button Press Decoder_BD.png 41 KB -
Dynamic SQL Error -ORA-00904: invalid identifier
Hello!
I'm really hoping I can get some fast help on this. In the interest of honesty, this is for a university oracle programming assignment. I've searched everywhere I can for the answer and haven't had any luck.
Anyway, the problem in a nutshell. I have to write a package to write a text file. The formatting information for the file is held in a table, which has columns to define the various characteristics like justification, padding character and field value.
RECORDTYPE FIELDNAME FIELDVALUE FIELDSIZE FIELDORDER PADDINGCHAR JUSTIFICATION DATASOURCE
7 CreditTotal v_credit 10 5 '0' LPAD PROGRAM
7 RecordType '7' 1 1 ' ' RPAD HARDCODE
I can build the whole file except this footer. the FieldValue "v_credit" references a variable that has the calculated total of the credit amounts for the file. There are also "v_debit", and "(v_credit-v_debt)" entries.
My question seems simple... How can I use this VARCHAR2 value from the table, and have it reference the variable within a Dynamic SQL string? If I use the textvalue of the column in the SQL string it gives me the invalid identifier error when it hits the EXECUTE IMMEDIATE statement. There is another row for the header which has "to_char(sysdate,'DDMMYYYY')" in it, and that runs fine. I'm assuming because they are native SQL statements and variables.
I have tried encapsulating the v_credit in "s, and using dynamica bind variables but had the same problem passing the names to the USING clause.
The SQL string created by the procedure is: SELECT LPAD(v_credit,10,'0' ) FROM dual
The full error is:
ORA-00904: "V_CREDIT": invalid identifier
ORA-06512: at "BWOOD.PKG_BRIAN", line 108
ORA-06512: at line 2
Line 108 is the EXECUTE IMMEDIATE statement
I would really appreciate someones help! I'm happy to post the procedure I've written, with the caveat that it's sloppy student work and needs cleaning up of all the experimental commented attempts:)
Edited by: user5426606 on 20-May-2009 03:34 - Added a few more facts.Thank you for the fast replies. I'll post a short chunk of code to demonstrate.
The actual procedure is quite a bit longer, but this should give you the idea.
PROCEDURE build_dbfile (p_settlement_date IN DATE, p_settlement_key IN VARCHAR2, p_type IN VARCHAR2) AS
v_sqlString VARCHAR2(4000) := 'SELECT ';
v_rectype NUMBER := 7;
v_line LONG;
v_debit NUMBER := 0;
v_credit NUMBER := 0;
v_nrRecords NUMBER := 0;
CURSOR c_settlement IS... -- to select records for data rows
-- cursor to select the rows with the file formatting and data info
CURSOR c_header IS SELECT NVL(fieldvalue,fieldname) db_field, <---- selects the data column
fieldsize,
NVL(paddingchar, ''' ''') paddingchar,
NVL(justification,'LPAD') justification,
datasource
FROM FSS_DESKBANK_REF
WHERE recordtype = r_rec_types.recordtype
ORDER BY recordType, fieldorder;
-- SELECT to get the SUM of datarows for v_credit
SELECT SUM(transactionamount)
INTO v_credit...
-- SELECT to get the SUM of datarows for v_debit
SELECT SUM(transactionamount)
INTO v_debit....
FOR r_head IN c_header LOOP
v_sqlString := v_sqlString || r_head.justification|| '('
|| r_head.db_field ||','
|| r_head.fieldsize || ','
|| r_head.paddingchar || ')';
v_sqlString := v_sqlString || ' FROM ' || v_tbl_name;
DBMS_OUTPUT.PUT_LINE('SQL --> '||v_sqlString);
EXECUTE IMMEDIATE v_sqlString INTO v_line;
END LOOP;
DBMS_OUTPUT.PUT_LINE(v_line);
END build_dbfile;So the loop goes through the table rows, grabs each data value and formatting column, and builds the sql string, which is then passed to the execute statement. The issue is the ones where the datarow contains a reference to v_credit, and the error is generated. ie r_head.db_field contains the string "v_credit"
Satish, the sql does look like that in the string, but the string is built from the table, not hardcoded. ie v_sqlString = "SELECT LPAD(v_credit,10,'0' ) FROM dual" when it is passed to the EXECUTE IMMEDIATE.
Edited by: user5426606 on 20-May-2009 05:19 -
ORA-06502: PL/SQL: numeric or value error: character string buffer too small.
I have an HTMLDB report that errors with the above message. The query is over 7000 characters long so I'm guessing this is the cause. If I retrieve the query from a query table, replace the variables in the LONG query using PL/SQL and execute using dynamic SQL, are the HTMLDB reporting features the same as if I was using a simple SQL query? Is there a better way? I will need to 'drill-down' from this report so how do I create the links? The only HTMLDB PL/SQL package I can find mentioned in the User's Guide is HTMLDB_PLSQL_JOB.
Cheers, PaulHello All,
I have the same problem.
For me it started when i got about 500 rows in the table
on which the LOV is based.
With a lot of trying with substr I managed to find the size of the string which it still accepted, which was 51 characters.
So I thought it was some glitch in the APEX insides, and since I had no time to resolve it further, I went on working.
But I have to resolve it now, because the following mysterious behaviour is occurring:
Every few records added to the base table, the problem occurs again, and I can resolve it by cutting down the string
with one character.
I have now reached 39 characters !?
I am afraid that I will end up with 1 character or even null.
If I switch to Popup list based on LOV there's no problem, and the complete strings are shown.
The maximum length of the string in my basetable is 252, but the data in it now reaches 55 at most.
Any idea welcome!
I did already recreate the master-detail form from scratch, but there the same behaviour.
greetings,
Richard Kloostra -
Java.sql.SQLException: ORA-01002: fetch out of sequence
We are getting 'Fetch out of sequence' error whrn we try to execute a 'for update' query.
We are first inserting values into the DLX_ASSET table and if there is image to be inserted the particualr row is fetched using the query. The insert query inserts values into the database.
'SELECT HIGH_RES_IMAGE FROM DLX_ASSET WHERE ASSET_ID ="+assetId+ " FOR UPDATE'. While executing this query we are getting this exception. This is not happening when we are trying it from our local machine. But its happening everywhere else where its deployed.
We are using Websphere Application Server 6 and Oracle 9i. We have set autommit to false before the method is called and are commiting the transaction only after the whole set of queries are executed.
Please see below the code snippet,
/* UPDATE HIGH RESOLUTION IMAGE INTO DLX_ASSET TABLE */
logger.logInfo("inside IF condition ,,,,,,,,,,,"+assetId);
String query ="SELECT HIGH_RES_IMAGE FROM DLX_ASSET WHERE ASSET_ID ="+assetId+ " FOR UPDATE ";
logger.logInfo("QUERY is...."+query);
logger.logInfo("Connection closed:"+ con.isClosed());
psHighResObj =(OraclePreparedStatement) con.prepareStatement(query);
logger.logInfo("inside updating high res AFTER prepare statement"+psHighResObj);
rsHighRes = (OracleResultSet) psHighResObj.executeQuery(); logger.logInfo("inside updating high res image 1");
while (rsHighRes.next()) {
logger.logInfo("inside while high res image 2");
highResImg =(OrdImage)rsHighRes.getCustomDatum(1,OrdImage.getFactory());
highResImg.loadDataFromInputStream(assetCustomTo.getHighResolutionImageIn());
assetCustomTo.getHighResolutionImageIn().close();
logger.logInfo("before update high res");
UPDATE_QRY = "UPDATE DLX_ASSET SET HIGH_RES_IMAGE = ? WHERE ASSET_ID=" + assetId;
stmt1 =(OraclePreparedStatement) con.prepareCall(UPDATE_QRY);
highResImg.setSource(assetCustomTo.getHighresFileType(),"",assetCustomTo.getSys_file_name1());
highResImg.setContentLength(Integer.parseInt(assetCustomTo.getHighresFileSize()));
highResImg.setProperties();
logger.logInfo(" after update query asset id: " + assetId);
logger.logInfo(" query high res:: " + UPDATE_QRY);
stmt1.setCustomDatum(1, highResImg);
stmt1.execute();
logger.logInfo("after update high res");
//checking if thumbnail is present: if bulk upload thumb nail won't be present
the exception is occuring in the line 'rsHighRes = (OracleResultSet) psHighResObj.executeQuery();'
This is exception trace
java.sql.SQLException: ORA-01002: fetch out of sequence
at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:134)
at oracle.jdbc.ttc7.TTIoer.processError(TTIoer.java(Inlined Compiled Code))
at oracle.jdbc.ttc7.Oall7.receive(Oall7.java(Compiled Code))
at oracle.jdbc.ttc7.TTC7Protocol.doOall7(TTC7Protocol.java(Compiled Code))
at oracle.jdbc.ttc7.TTC7Protocol.fetch(TTC7Protocol.java:1198)
at oracle.jdbc.driver.OracleStatement.doExecuteQuery(OracleStatement.java:2400)
at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:2672)
at oracle.jdbc.driver.OraclePreparedStatement.executeUpdate(OraclePreparedStatement.java:589)
at oracle.jdbc.driver.OraclePreparedStatement.executeQuery(OraclePreparedStatement.java:527)
at com.deluxe.imax.dataaccess.impl.extended.TelevisionAssetCustomDAOImpl.createWebElectronicTrailersAsset(Unknown Source)
at com.deluxe.imax.business.television.ejb.TelevisionFacadeJBean.createWebElectronicTrailersAsset(Unknown Source)
at com.deluxe.imax.business.television.handler.TelevisionHandler.createWebElectronicTrailersAsset(Unknown Source)
at com.deluxe.imax.business.television.action.WebNewAction.processExecute(Unknown Source)
at com.deluxe.imax.business.framework.BaseAction.execute(Unknown Source)
at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:419)
at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:224)
at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1194)
at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:432)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:763)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
at com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:1284)
at com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:1241)
at com.ibm.ws.webcontainer.filter.WebAppFilterChain.doFilter(WebAppFilterChain.java:136)
at com.deluxe.imax.business.framework.security.SecurityFilter.doFilter(Unknown Source)
at com.ibm.ws.webcontainer.filter.FilterInstanceWrapper.doFilter(FilterInstanceWrapper.java:142)
at com.ibm.ws.webcontainer.filter.WebAppFilterChain.doFilter(WebAppFilterChain.java:121)
at com.ibm.ws.webcontainer.filter.WebAppFilterChain._doFilter(WebAppFilterChain.java:82)
at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:671)
at com.ibm.ws.webcontainer.webapp.WebApp.handleRequest(WebApp.java:3003)
at com.ibm.ws.webcontainer.webapp.WebGroup.handleRequest(WebGroup.java:221)
at com.ibm.ws.webcontainer.VirtualHost.handleRequest(VirtualHost.java:210)
at com.ibm.ws.webcontainer.WebContainer.handleRequest(WebContainer.java:1958)
at com.ibm.ws.webcontainer.channel.WCChannelLink.ready(WCChannelLink.java:88)
at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleDiscrimination(HttpInboundLink.java:472)
at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleNewInformation(HttpInboundLink.ja
Please share your feedback.
Thanks in advance!
Edited by: Sanu Sasidharan on May 11, 2011 4:26 AMHi Peter,
We tried pointing to the same database from local as well as QA. Works from local but not from QA.
assetId is the generated primary key in the same method.
Yes the exception is thrown from execute statement itself. the logger put just after the execute is not coming.
This is the method
public boolean createWebElectronicTrailersAsset(TelevisionResultDTO[] teleResultDTO, OracleConnection con) throws DAOException {
methodName ="createWebElectronicTrailersAsset(TelevisionResultDTO[] teleResultDTO,OracleConnection con) :: ";
//Value to be returned by method
boolean createInd = false;
OraclePreparedStatement psHighResObj = null;
OraclePreparedStatement psThumbnailObj = null;
OracleResultSet rsHighRes = null;
OracleResultSet rsThumbnail = null;
PreparedStatement psmt = null;
OraclePreparedStatement stmt1 = null;
OraclePreparedStatement stmt2 = null;
OrdImage highResImg = null;
OrdImage thumbnailImg = null;
ImaxGroupsTO groupsTO = null;
try {
long tvAssetId = 0;
long assetId = 0;
long cst_dwnld_asset_id = 0;
AssetCustomTO assetCustomTo = null;
AssetCustomDownloadTO assetCustDwnldTO = null;
CustomTVAssetTO tvAssetTo = null;
String DLX_ASSET_QRY = "";
String UPDATE_QRY = "";
String DLX_ASSET_TV_QRY = "";
String DLX_CUSTOM_DOWNLOAD_ASSET = "";
int k = 1;
for (int iCount = 0; iCount < teleResultDTO.length; iCount++) {
tvAssetId = (int) OraclePKGenerator.getInstance().getKey(InternalConstants.TV_ASSET_SEQUENCE);
assetId =(long) OraclePKGenerator.getInstance().getKey(InternalConstants.ASSET_SEQUENCE);
assetCustomTo = teleResultDTO[iCount].getAssetCustomTO();
tvAssetTo = teleResultDTO[iCount].getTv_Asset();
groupsTO= teleResultDTO[iCount].getGroupsTO();
if (assetCustomTo.getHighResolutionImageIn() != null) {
DLX_ASSET_QRY ="INSERT INTO DLX_ASSET("
+ "ASSET_ID,"
+ "CREATED_BY,"
+ "CREATED_DATE,"
+ "REVISED_BY,"
+ "REVISED_DATE,"
+ "FILE_NAME,"
+ "FILE_SIZE,"
+ "FILE_TYPE,"
+ "SYS_FILE_NAME,"
+ "HIGH_RES_IMAGE,"
+ "THUMBNAIL_IMAGE,"
+ "ASSET_STATUS_ID,"
+ "DMX_PART1_REF,"
+ "DMX_PRODUCT_ID_REF,"
+ "DMX_PRODUCT_DESC_REF,"
+ "ASSET_AVAIL_1_IND,"
+ "DMX_PART_2,"
+ "DMX_PRODUCT_2,"
+ "DMX_PRODUCT_DESC_2,"
+ "ASSET_AVAIL_2_IND,"
+ "EFFECTIVE_DATE,"
+ "EXPIRATION_DATE,"
+ "FILE_NAME1,"
+ "SYS_FILE_NAME1,"
+ "ASSET_TYPE_ID,"
+ "MATERIALS_CATEGORY,"
+ "PART_1_NOTES,"
+ "PART_2_NOTES,"
+ "PHY_ORDER_STATUS)"
+ "VALUES (?,?,SYSDATE,?,SYSDATE,?,?,?,?,ORDSYS.ORDImage.init(),"
+" ORDSYS.ORDImage.init(),?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
}else if(){
// condition if images are not uploaded
psmt = con.prepareStatement(DLX_ASSET_QRY);
k=1;
psmt.setLong(k++, assetId);
psmt.setString(k++, assetCustomTo.getCreated_by());
psmt.setString(k++, assetCustomTo.getRevised_by());
if(assetCustomTo.getAssetTextIn()!=null ){
psmt.setString(k++, assetCustomTo.getFile_name());
psmt.setString(k++, assetCustomTo.getFile_size());
psmt.setString(k++, assetCustomTo.getFile_type());
psmt.setString(k++, assetCustomTo.getSys_file_name());
/* UPLOAD PREVIEW VIDEO FILE INTO FILE SYSTEM .....*/
Util.upLoadFile(assetCustomTo.getAssetTextIn(),assetCustomTo.getSys_file_name());
}else if(assetCustomTo.getAssetTextIn()==null && assetCustomTo.getSys_file_name() != null
&& assetCustomTo.getSys_file_name().trim().length() != 0){
psmt.setString(k++, assetCustomTo.getFile_name());
psmt.setString(k++, assetCustomTo.getFile_size());
psmt.setString(k++, assetCustomTo.getFile_type());
psmt.setString(k++, assetCustomTo.getSys_file_name());
} else{
psmt.setNull(k++,Types.VARCHAR);
psmt.setNull(k++,Types.VARCHAR);
psmt.setNull(k++,Types.VARCHAR);
psmt.setNull(k++,Types.VARCHAR);
psmt.setLong(k++, assetCustomTo.getAsset_status_id());
if(assetCustomTo.getDmx_product_desc_1()!=null && assetCustomTo.getDmx_product_desc_1().trim().length()!=0){
psmt.setLong(k++, assetCustomTo.getDmx_part_1());
psmt.setLong(k++, assetCustomTo.getDmx_productId_1());
psmt.setString(k++, assetCustomTo.getDmx_product_desc_1());
psmt.setString(k++, assetCustomTo.getAsset_order_status_1());
}else{
psmt.setNull(k++,Types.INTEGER);
psmt.setNull(k++,Types.INTEGER);
psmt.setNull(k++,Types.VARCHAR);
psmt.setNull(k++,Types.VARCHAR);
if(assetCustomTo.getDmx_product_desc_2()!=null && assetCustomTo.getDmx_product_desc_2().trim().length()!=0){
psmt.setLong(k++, assetCustomTo.getDmx_part_2());
psmt.setLong(k++, assetCustomTo.getDmx_productId_2());
psmt.setString(k++, assetCustomTo.getDmx_product_desc_2());
psmt.setString(k++, assetCustomTo.getAsset_order_status_2());
}else{
psmt.setNull(k++,Types.INTEGER);
psmt.setNull(k++,Types.INTEGER);
psmt.setNull(k++,Types.VARCHAR);
psmt.setNull(k++,Types.VARCHAR);
if(assetCustomTo.getEffectiveDate()!=null){
psmt.setTimestamp(k++, assetCustomTo.getEffectiveDate());
}else{
psmt.setNull(k++,Types.TIMESTAMP);
if(assetCustomTo.getExpirationDate()!=null){
psmt.setTimestamp(k++, assetCustomTo.getExpirationDate());
}else{
psmt.setNull(k++,Types.TIMESTAMP);
psmt.setString(k++, assetCustomTo.getHighresFileName());
if(assetCustomTo.getSys_file_name1()!=null && assetCustomTo.getSys_file_name1().trim().length()!=0){
psmt.setString(k++, assetCustomTo.getSys_file_name1());
}else{
psmt.setNull(k++, Types.VARCHAR);
psmt.setLong(k++, assetCustomTo.getAsset_type_id());
psmt.setLong(k++, assetCustomTo.getMaterialCategory());
if(assetCustomTo.getPart_notes_1()!=null && assetCustomTo.getPart_notes_1().trim().length()!=0){
psmt.setString(k++, assetCustomTo.getPart_notes_1());
}else{
psmt.setNull(k++,Types.VARCHAR);
if(assetCustomTo.getPart_notes_2()!=null && assetCustomTo.getPart_notes_2().trim().length()!=0){
psmt.setString(k++, assetCustomTo.getPart_notes_2());
}else{
psmt.setNull(k++,Types.VARCHAR);
if(assetCustomTo.getDmx_product_desc_1()!=null){
psmt.setLong(k++,assetCustomTo.getPhy_asset_status());
}else{
psmt.setNull(k++,Types.INTEGER);
psmt.execute();
if (assetCustomTo.getHighResolutionImageIn() != null) {
/* UPDATE HIGH RESOLUTION IMAGE INTO DLX_ASSET TABLE */
logger.logInfo("inside IF condition ,,,,,,,,,,,"+assetId);
String query ="SELECT HIGH_RES_IMAGE FROM DLX_ASSET WHERE ASSET_ID ="+assetId+ " FOR UPDATE ";
psHighResObj =(OraclePreparedStatement) con.prepareStatement(query);
logger.logInfo("inside updating high res AFTER prepare statement"+psHighResObj);
rsHighRes = (OracleResultSet) psHighResObj.executeQuery();
while (rsHighRes.next()) {
highResImg =(OrdImage)rsHighRes.getCustomDatum(1,OrdImage.getFactory());
highResImg.loadDataFromInputStream(assetCustomTo.getHighResolutionImageIn());
assetCustomTo.getHighResolutionImageIn().close();
UPDATE_QRY = "UPDATE DLX_ASSET SET HIGH_RES_IMAGE = ? WHERE ASSET_ID=" + assetId;
stmt1 =(OraclePreparedStatement) con.prepareCall(UPDATE_QRY);
highResImg.setSource(assetCustomTo.getHighresFileType(),"",assetCustomTo.getSys_file_name1());
highResImg.setContentLength(Integer.parseInt(assetCustomTo.getHighresFileSize()));
highResImg.setProperties();
stmt1.setCustomDatum(1, highResImg);
stmt1.execute();
The connection in the method is passed from the service layer.
Thanks
Edited by: Sanu Sasidharan on May 12, 2011 2:30 AM
Maybe you are looking for
-
Sound files not playing from inDesign SWF file
Using Dropbox file transfer, I'm sending a colleague an inDesign project as a SWF file - a flip book with audio. The files in Dropbox are the SWF Movie files, the HTML and the Resources folder. My colleague is trying upload these to his website. I p
-
My Mail applications has suddenly and inexplicably started removing mail from my inbox after 1 month. I went through preferences and indeed have it set to NEVER delete mail. Any thoughts? Thanks in advance!
-
Problems while creating local service order on client in MAM
I have MAM2.5 on PC. I have created a local notification and synced it. based on that notif , I am trying to create a service order.But after Sync , I get following error in monitor (merep_mon on MI server) under MAM_001: Return code from RFC BAPI Wr
-
Eclipse ME with SDK 3.0 problem
Hello, There is actually a thread a few below this one on the same issue, but it has been locked as someone bumped it from many pages down. My problem is that I can no longer run my Java ME projects on the emulator in Eclipse, having just changed fro
-
Adobe Dreamweaver CS3 Expandable Lists
Adobe Communities, I have yet another problem. A Few Examples of what I am trying to achieve: Demo Expandable list Pure CSS collapsible tree menu | The CSS Ninja The Spry Menu doesn't work exactly how I would like it. Those scripts didn't exactly wor