PL/SQL REFCURSOR ERR
CREATE OR REPLACE PACKAGE QUERIESLOOKUP_PKG
AS
TYPE PKG_REC_TYPE IS RECORD(
OP_DATE DATE);
TYPE pkgrec IS REF CURSOR RETURN pkg_rec_type;
END QUERIESLOOKUP_PKG;
CREATE OR REPLACE PROCEDURE QUERIESLOOKUP_PRC(
outrec OUT QUERIESLOOKUP_PKG.PKGREC) AS
querystr1 varchar2(4000);
BEGIN
querystr1:='select SYSDATE FROM DUAL';
EXECUTE IMMEDIATE querystr1 INTO OUTREC;
END QUERIESLOOKUP_PRC;
SET SERVEROUTPUT ON
declare
REC1 QUERIESLOOKUP_Pkg.pkgrec;
TEST REC1%ROWTYPE;
begin
QUERIESLOOKUP_PRC(REC1);
LOOP
FETCH REC1 INTO TEST;
EXIT WHEN REC1%NOTFOUND;
DBMS_OUTPUT.PUT_LINE('======' );
DBMS_OUTPUT.PUT_LINE(TEST.OP_DATE );
END LOOP;
CLOSE rec1;
END;
declare
ERROR at line 1:
ORA-00932: inconsistent datatypes: expected NUMBER got DATE
ORA-06512: at "QUERIESLOOKUP_PRC", line 9
ORA-06512: at line 6
Hi,
I'm getting this err plz help me!
Thomas
The problem is ref cursor cannot be dynamic.Come again??
SQL> CREATE OR REPLACE FUNCTION dynamic_refcurs
2 ( rpt IN NUMBER := 0)
3 RETURN sys_refcursor
4 AS
5 querystr1 varchar2(4000);
6 q sys_refcursor;
7 BEGIN
8 IF rpt = 0 THEN
9 querystr1:='select sysdate from dual';
10 ELSIF rpt = 1 THEN
11 querystr1:='select sysdate from dual union select sysdate+1 from dual';
12 ELSE
13 querystr1:='select sysdate from dual union select sysdate+1 from dual union select sysd
ate+2 from dual';
14 END IF;
15 OPEN q FOR querystr1;
16 RETURN q;
17 END dynamic_refcurs;
18 /
Function created.
SQL>
SQL> SELECT dynamic_refcurs(1) FROM dual
2 /
DYNAMIC_REFCURS(1)
CURSOR STATEMENT : 1
CURSOR STATEMENT : 1
SYSDATE
08-NOV-04
09-NOV-04
SQL> SELECT dynamic_refcurs(2) FROM dual
2 /
DYNAMIC_REFCURS(2)
CURSOR STATEMENT : 1
CURSOR STATEMENT : 1
SYSDATE
08-NOV-04
09-NOV-04
10-NOV-04
SQL> CREATE OR REPLACE FUNCTION dynamic_refcurs
2 ( incr IN NUMBER := 0)
3 RETURN sys_refcursor
4 AS
5 querystr1 varchar2(4000);
6 q sys_refcursor;
7 BEGIN
8 querystr1:='select sysdate + :1 from dual';
9 OPEN q FOR querystr1 USING incr;
10 RETURN q;
11 END dynamic_refcurs;
12 /
Function created.
SQL> SELECT dynamic_refcurs(1) FROM dual
2 /
DYNAMIC_REFCURS(1)
CURSOR STATEMENT : 1
CURSOR STATEMENT : 1
SYSDATE+:
09-NOV-04
SQL> SELECT dynamic_refcurs(2) FROM dual
2 /
DYNAMIC_REFCURS(2)
CURSOR STATEMENT : 1
CURSOR STATEMENT : 1How much more dynamism do you require?
Cheers, APC
Similar Messages
-
HI all,
with the below query i want to update status of outer table jo_orders to FF ...
where select query returns status as UF(all 284 rows it returns with status UF)
i want all the matching as FF in outer jo_orders status to FF
Kindly help
update jo_orders set
status='FF' where (select jii.status from jo_orders jii, picking_lists pil where jii.jo_id=pil.ext_sys_ref_no
and pil.status='FF'and jii.status in('UF') and Jii.created_on
between to_date('21-MAY-2006') and to_date('30-MAY-2006')) ='UF';
ERR--i get is ----single row subquery return more than one row..Hi,
Don't you need to join your subquery with the main updating table ?
I would try this :
update jo_orders jii
set jii.status='FF'
where jii.status = 'UF'
and Jii.created_on between to_date('21-MAY-2006')and to_date('30-MAY-2006')
and exists (select 1
from picking_lists pil
where jii.jo_id=pil.ext_sys_ref_no
and pil.status='FF')Nicolas. -
Help - SQL with err ORA-12801 or rewrite SQL recommendation
When trying delete statement below am getting the error , can you please recommend alternate ways of do this DML .. am sure change in memory allocation is not required just the way current DML is constructed is not correct\ inefficient , am getting the same error even when the trying to select for same DML conditions below and it works fine in tables with less data.
DELETE
FROM temp_test t1
WHERE t1.reltid = 240
AND EXISTS
(SELECT x.combid
,x.csbid
FROM temp_both x
WHERE x.combid = t1.combid
AND x.csbid = t1.csbid
GROUP BY x.combid
,x.csbid
HAVING COUNT(*) > 1
AND EXISTS
(SELECT a.reltid, a.end_dt,b.reltid,b.end_dt
from (SELECT combid,csbid,end_dt,reltid
from temp_both where reltid = 239) a
(SELECT combid,csbid,end_dt,reltid
from temp_both where reltid = 240) b
where a.end_dt >= b.end_dt
and a.csbid = b.csbid
and b.combid = t1.combid
and a.csbid = t1.csbid
and a.combid = t1.combid);
ERROR at line 1:
ORA-12801: error signaled in parallel query server P034
ORA-04030: out of process memory when trying to allocate
Can some explain the flow the above SQL is processing, recomened alternate ways of writing the same.Ask your DBA to look into this matter. It looks like the database server facing a resource crunch.
If you are running a dedicated server mode, you might need to switch over to shared server mode. Again, the DBA has to look into this. -
LOAD
INFILE *
append
INTO TABLE edw_bis.temp
fields terminated by '|' optionally enclosed by '~~'
(clean_supplier_name ,
supplier_category
begindata
~~WSDFHH-ISAFL}~~~|~~sdgfdi~~
~~WSDFHH-ISAFL}~~|~~afgkjg83~~
errorr:
Record 1: Rejected - Error on table EDW_BIS.TEMP, column CLEAN_SUPPLIER_NAME.
no terminator found after TERMINATED and ENCLOSED field
Please help!
Thanks.LOAD
INFILE *
append
INTO TABLE edw_bis.temp
fields terminated by '|' optionally enclosed by '~~'
(clean_supplier_name "replace(:clean_supplier_name,'~~','')",
supplier_category "replace(:supplier_category,'~~','')"
begindata
~~ANAND~~~|~~sdgfdi~~
~~IJAY~~|~~afgkjg83~~
the first record error out . Help please! -
Hi,
I have created procedure in that i m creating a table and merging it with some other table and after that i fetching the records in the ref cursor and at last i m droping the same table.I m working on Oracle 9i.Sometimes i m able to complie the procedure but sometime i m getting the err ORA-00942 Table or View doesnot exist.I dont understand the reason y it is coming.I have restarted the database server but still i m getting the err.Give me some solution for thatYour procedure probably looks like this:
SQL> CREATE OR REPLACE PROCEDURE p_test IS
2 BEGIN
3 EXECUTE IMMEDIATE 'create table tt ( a number )';
4 INSERT INTO tt VALUES ( 4 );
5 -- some other coding
6 EXECUTE IMMEDIATE 'drop table tt';
7 END;
8 /
Warning: Procedure created with compilation errors.And the error during compilation is:
SQL> show err
Errors for PROCEDURE P_TEST:
LINE/COL ERROR
4/3 PL/SQL: SQL Statement ignored
4/15 PL/SQL: ORA-00942: table or view does not existThat's because table tt doesn't exist during compilation and PL/SQL compiler cannot validate INSERT statement. To avoid it you must make INSERT as dynamic SQL:
SQL> ed
Wrote file afiedt.buf
1 CREATE OR REPLACE PROCEDURE p_test IS
2 BEGIN
3 EXECUTE IMMEDIATE 'create table tt ( a number )';
4 EXECUTE IMMEDIATE 'INSERT INTO tt VALUES ( 4 )';
5 -- some other coding
6 EXECUTE IMMEDIATE 'drop table tt';
7* END;
SQL> /
Procedure created.
SQL> exec p_test;
PL/SQL procedure successfully completed.
SQL>
But in general, it's very bad idea to create table, do some processing and drop the table at the end of it. You may face another run time error when two or more users running the same procedure at the same time - they may not be able to create 2 or more tables with the same name ( depends on what ID they use to connect to DB, generic or individual ). In your situation it's better to use temporary tables. -
Calling a procedure (with refcursor) from another procedure
I have a procedure that returns refcursor (it's used by a Java application).
I am able to run the proc via SQLPlus like below:
var a refcursor;
exec MY_PKG.get_content_prc(:a);
print a;
I would like to use/call this proc from another procedure and I am not able to, since arg is refcursor.
create or replace procedure p
is
v refcursor;
begin
MY_PKG.get_content_prc(:v);
end;
Error I get is:
SQL> show err
Errors for PROCEDURE P2:
LINE/COL ERROR
4/3 PL/SQL: Item ignored
4/7 PLS-00201: identifier 'CURSOR' must be declared
6/5 PL/SQL: Statement ignored
6/57 PLS-00320: the declaration of the type of this expression is
incomplete or malformed
Hope someone can direct me.
RegardsBecause you are not using the right syntax.
You need to do something like this
LOOP
/* Fetch from cursor variable. */
FETCH emp_cv INTO emp_rec;
EXIT WHEN emp_cv%NOTFOUND; -- exit when last row is fetched
-- process data record
END LOOP;This is from the PL/SQL User's Guide and Reference.
I would recommend reading this fine manual, it is faster than guessing. -
PL/SQL: ORA-00904:
Hello..
We have custom package which is working fine since long time. But all at once we are getting compilation errors.. The following are the error messages that we are getting
233/13 PL/SQL: SQL Statement ignored
248/20 PL/SQL: ORA-00904: "SLIP_TYPE": invalid identifier
254/13 PL/SQL: SQL Statement ignored
262/20 PL/SQL: ORA-00904: "SLIP_TYPE": invalid identifier
527/16 PL/SQL: SQL Statement ignored
593/36 PL/SQL: ORA-00904: "SLIP_DATE": invalid identifier
597/16 PL/SQL: SQL Statement ignored
636/36 PL/SQL: ORA-00904: "SLIP_DATE": invalid identifier
The same package is working fine in all the other instances .I don't know what else to suggest, so I'll point you to the error code:
ORA-00904: string: invalid identifier
Cause: The column name entered is either missing or invalid.
Action: Enter a valid column name. A valid column name must begin with a letter, be less
than or equal to 30 characters, and consist of only alphanumeric characters and the
special characters $, _, and #. If it contains other characters, then it must be
enclosed in double quotation marks. It may not be a reserved word.And here you can see how an ORA-00904 happens.
SQL> create table pos_header
2 ( slip_date date
3 , slip_type varchar2(1)
4 )
5 /
Tabel is aangemaakt.
SQL> create procedure test1
2 as
3 begin
4 update pos_header
5 set slip_date = sysdate
6 where slip_type = 'A'
7 ;
8 end;
9 /
Procedure is aangemaakt.
SQL> show err
Er zijn geen fouten.
SQL> exec test1
PL/SQL-procedure is geslaagd.
SQL> alter table pos_header drop column slip_type
2 /
Tabel is gewijzigd.
SQL> exec test1
BEGIN test1; END;
FOUT in regel 1:
.ORA-06550: line 1, column 7:
PLS-00905: object RWK.TEST1 is invalid
ORA-06550: line 1, column 7:
PL/SQL: Statement ignored
SQL> alter procedure test1 compile
2 /
Waarschuwing: procedure is gewijzigd met compilatiefouten.
SQL> show err
Fouten voor PROCEDURE TEST1:
LINE/COL ERROR
4/3 PL/SQL: SQL Statement ignored
6/10 PL/SQL: ORA-00904: "SLIP_TYPE": invalid identifierHope this helps assuring you that the column is missing and I hope you'll find out the table and schema where this column is missing.
Regards,
Rob. -
PL/SQL: ORA-00932: inconsistent datatypes: expected REF got CHAR
SQL> desc o.rel_module;
Name Null? Type
ID NOT NULL NUMBER(6)
TYPE NOT NULL CHAR(7)
BUILDDATE NOT NULL NUMBER(4)
DESIGNROOT NOT NULL NUMBER(6)
SQL> desc rel_module
Name Null? Type
ID NOT NULL NUMBER(6)
DESIGNROOT NOT NULL NUMBER(6)
REL_COMPOSITEPARTS REL_COMPOSITEPART_TAB
SQL> desc REL_COMPOSITEPART_TAB
REL_COMPOSITEPART_TAB TABLE OF REL_COMPOSITEPART
SQL> desc REL_COMPOSITEPART
Name Null? Type
TYPE CHAR(7)
BUILDDATE NUMBER(4)
SQL> create or replace procedure rel_module_p
2 as
3 cursor c is select ID, TYPE, BUILDDATE, DESIGNROOT from o.rel_module;
4 begin
5 FOR i in c
6 LOOP
7 INSERT into rel_module(id,REL_CompositeParts,DESIGNROOT)
Values (i.ID,REL_CompositePart_TAB(i.type,i.builddate), i.designroot);
8 END LOOP;
9 END;
10 /
Warning: Procedure created with compilation errors.
SQL> show err
Errors for PROCEDURE REL_MODULE_P:
LINE/COL ERROR
7/1 PL/SQL: SQL Statement ignored
7/93 PL/SQL: ORA-00932: inconsistent datatypes: expected REF got CHAR
Can you please tell me where needs correction.801556 wrote:
Can you please tell me where needs correction.Just a fix would be:
create or replace procedure rel_module_p
as
cursor c is select ID, TYPE, BUILDDATE, DESIGNROOT from o.rel_module;
begin
FOR i in c
LOOP
INSERT into rel_module(id,REL_CompositeParts,DESIGNROOT)
values (i.ID,REL_CompositePart_TAB(REL_COMPOSITEPART(i.type,i.builddate)), i.designroot);
END LOOP;
END;
/However, I'd assume what you want is:
create or replace procedure rel_module_p
as
cursor c is select ID,CAST(COLLECT(REL_COMPOSITEPART(TYPE,BUILDDATE)) AS REL_CompositePart_TAB) REL_COMPOSITEPARTS, DESIGNROOT
from rel_module
group by id,DESIGNROOT;
begin
FOR i in c
LOOP
INSERT into rel_moduleX(id,REL_CompositeParts,DESIGNROOT)
values (i.ID,i.REL_COMPOSITEPARTS, i.designroot);
END LOOP;
END;
/SY. -
Using variable coulmn name in sql function
Hi there,
I am not an expert with PL/SQL and I can not figure out how to use variable column names in my function.
My function is:
CREATE OR REPLACE FUNCTION RESET_TRIGGERS(aTrigger VARCHAR2) RETURN NUMBER IS
TEMP_ID NUMBER;
TEMP_USER_ID NUMBER;
BEGIN
SELECT 'LIMS.'||'$aTrigger'||'.NEXTVAL' INTO TEMP_ID FROM DUAL;
SELECT 'LIMS.'||'$aTrigger'||'_USER.NEXTVAL' INTO TEMP_USER_ID FROM DUAL;
IF TEMP_ID > TEMP_USER_ID THEN
LOOP
SELECT LIMS.SQ_U_FINALRESULT_USER.NEXTVAL INTO TEMP_USER_ID FROM DUAL;
EXIT WHEN TEMP_USER_ID = TEMP_ID;
END LOOP;
ELSE
WHILE TEMP_ID < TEMP_USER_ID LOOP
SELECT LIMS.SQ_U_FINALRESULT.NEXTVAL INTO TEMP_ID FROM DUAL;
END LOOP;
END IF;
COMMIT;
RETURN (TEMP_ID);
END;
What I want is that I pass a seqencename with aTrigger and that two triggers will be equal if not.
eg ifaTrigger = 'SQ_U_FINALRESULT'
than I want the triggers LIMS.SQ_U_FINALRESULT and LIMS.SQ_U_FINALRESULT_USER to be set equal.
The above function will not work, but what will?????
I hope you can help me out!
CheersA very strange function indeed.
But here is what I think he meant to do:
SQL> create procedure reset_sequences
2 ( p_sequence_name in varchar2
3 , p_nextval out number
4 )
5 is
6 l_nextval1 number;
7 l_nextval2 number
8 ;
9 procedure reset_sequence_value
10 ( p_sequence_name in varchar2
11 , p_current_value in number
12 , p_new_value in number
13 )
14 is
15 l_dummy number;
16 begin
17 execute immediate 'alter sequence ' || p_sequence_name || ' increment by ' || to_char(p_new_value-p_current_value);
18 execute immediate 'select ' || p_sequence_name || '.nextval from dual' into l_dummy;
19 execute immediate 'alter sequence ' || p_sequence_name || ' increment by 1';
20 end reset_sequence_value
21 ;
22 begin
23 execute immediate
24 'select ' || p_sequence_name || '.nextval,' || p_sequence_name || '_user.nextval from dual'
25 into l_nextval1, l_nextval2
26 ;
27 if l_nextval1 < l_nextval2
28 then
29 reset_sequence_value(p_sequence_name,l_nextval1,l_nextval2);
30 end if
31 ;
32 if l_nextval1 > l_nextval2
33 then
34 reset_sequence_value(p_sequence_name || '_user',l_nextval2,l_nextval1);
35 end if
36 ;
37 p_nextval := greatest(l_nextval1,l_nextval2)
38 ;
39 end reset_sequences;
40 /
Procedure is aangemaakt.
SQL> show err
Er zijn geen fouten.
SQL> create sequence testseq start with 5 increment by 1
2 /
Reeks is aangemaakt.
SQL> create sequence testseq_user start with 2 increment by 1
2 /
Reeks is aangemaakt.
SQL> declare
2 l_new_value number;
3 begin
4 reset_sequences('testseq',l_new_value);
5 dbms_output.put_line(l_new_value);
6 end;
7 /
5
PL/SQL-procedure is geslaagd.
SQL> select testseq.currval from dual
2 /
CURRVAL
5
1 rij is geselecteerd.
SQL> select testseq_user.currval from dual
2 /
CURRVAL
5
1 rij is geselecteerd.Regards,
Rob. -
Limit on XML Tag Name's under PL/SQL?
If I run the following SQL against my database I don't get any errors:-
SQL> SELECT XMLAGG(
2 XMLELEMENT("courtresultextractstructure"
3 ,CASE
4 WHEN courtresultotheroffen IS NULL THEN NULL
5 ELSE XMLELEMENT("courtresultotheroffencesticquantity", courtresultotheroffen)
6 END
7 )) as "courtresultextractstr"
8 FROM courtresultextractstr;
courtresultextractstr
----------------------------------------------------------------------------------------But if I embed the query within a function I get:-
SQL> CREATE FUNCTION a_courtresultextracts ( p_id NUMBER ) RETURN XMLTYPE IS
2 v_xml XMLTYPE;
3 BEGIN
4 SELECT XMLAGG(
5 XMLELEMENT("courtresultextractstructure"
6 ,CASE
7 WHEN courtresultotheroffen IS NULL THEN NULL
8 ELSE XMLELEMENT("courtresultotheroffencesticquantity", courtresultotheroffen)
9 END
10 )) as "courtresultextractstr"
11 INTO v_xml
12 FROM courtresultextractstr
13 WHERE ref_id_courtresultextractstr=p_id;
14 RETURN(v_xml);
15 END a_courtresultextracts;
16 /
Warning: Function created with compilation errors.
SQL> sho err
Errors for FUNCTION A_COURTRESULTEXTRACTS:
LINE/COL ERROR
8/21 PLS-00114: identifier 'courtresultotheroffencesticqua' too long
SQL>Please tell me there isn't a 30 character limit on the size of the XML tags that are allowed when you perform the queries through PL/SQL.....
Any ideas anyone?I've now tracked down this as a bug on Metalink (3461263)
It's fixed in 10g Release 2 apparently, and I'm using 10g Release 1 at the moment.
Time to upgrade methinks.... -
Stored Procedures for Simple SQL statements
Hi Guys,
We are using Oracle 10g database and Web logic for frontend.
The Product is previously developed in DotNet and SQL Server and now its going to develop into Java (Web Logic) and Oracle 10g database.
Since the project is developed in SQL Server, there are lot many procedures written for simple sql queries. Now I would like to gather your suggestions / pointers on using procedures for simple select statements or Inserts from Java.
I have gathered some list for using PL/SQL procedure for simple select queries like
Cons
If we use procedures for select statements there are lot many Ref Cursors opened for Simple select statements (Open cursors at huge rate)
Simple select statements are much faster than executing them from Procedure
Pros
Code changes for modifying select query in PL/SQL much easier than in Java
Your help in this regard is more valuable. Please post your points / thoughts here.
Thanks & Regards
Srinivas
Edited by: Srinivas_Reddy on Dec 1, 2009 4:52 PMSrinivas_Reddy wrote:
Cons
If we use procedures for select statements there are lot many Ref Cursors opened for Simple select statements (Open cursors at huge rate)No entirely correct. All SQLs that hit the SQL engine are stored as cursors.
On the client side, you have an interface that deals with this SQL cursor. It can be a Java class, a Delphi dataset, or a PL/SQL refcursor.
Yes, cursors are created/opened at a huge rate by the SQL engine. But is is capable of doing that. What you need to do to facilitate that is send it SQLs that uses bind variables. This enables the SQL engine to simply re-use the existing cursor for that SQL.
Simple select statements are much faster than executing them from ProcedureAlso not really correct. SQL performance is SQL performance. It has nothing to do with how you create the SQL on the client side and what client interface you use. The SQL engine does not care whether you use a PL/SQL ref cursor or a Java class as your client interface. That does not change the SQL engine's performance.
Yes, this can change the performance on the client side. But that is entirely in the hands of the developer and how the developer selected to use the available client interfaces to interface with the SQL cursor in the SQL engine.
Pros
Code changes for modifying select query in PL/SQL much easier than in JavaThis is not a pro merely for ref cursors, but using PL/SQL as the abstraction layer for the data model implemented, and having it provide a "business function" interface to clients, instead of having the clients dealing with the complexities of the data model and SQL.
I would seriously consider ref cursors in your environment. With PL/SQL servicing as the interface, there is a single place to tune SQL, and a single place to update SQL. It allows one to make data model changes without changing or even recompiling the client. It allows one to add new business logical and processing rules, again without having to touch the client. -
Execute immediate 'alter session set current_schema = ' failed in PL/SQL
Hi
I am trying to run
EXECUTE IMMEDIATE 'ALTER SESSION SET CURRENT_SCHEMA = TEST ' ;
in a pl/sql block but it is failing.Can anyone update me on this.
CREATE OR REPLACE PROCEDURE test3
IS
A_COUNT NUMBER(15);
BEGIN
EXECUTE IMMEDIATE 'ALTER SESSION SET CURRENT_SCHEMA = TEST ' ;
SELECT COUNT(*) INTO A_COUNT FROM (
select id from solutions );
END;
/The user who owns the procedure needs to be granted direct select rights on table test.solutions (not via a role). Still will not help. Look what OP is trying to do. In a stored procedure owned by some user (other than TEST) OP is trying to reference user TEST owned table solution without prefixing it with owner. Something like:
SQL> create table u1.test_tbl(x number);
Table created.
SQL> select * from test_tbl;
select * from test_tbl
ERROR at line 1:
ORA-00942: table or view does not exist
SQL> alter session set current_schema = U1;
Session altered.
SQL> select * from test_tbl;
no rows selected
SQL> However, OP tries to do it in a SP using dynamic SQL to change current schema to test. Such change will occur when SP will be executed, not when is it compiled. At compile time we are still under SP owner's schema and therefore select from solutions implies table solutions owned by SP owner, not by TEST. The only way to make SP compile and work OK is to select from solutions also dynamically:
SQL> select sys_context('userenv','current_schema') from dual
2 /
SYS_CONTEXT('USERENV','CURRENT_SCHEMA')
SCOTT
SQL> CREATE OR REPLACE PROCEDURE test3
2 IS
3 A_COUNT NUMBER(15);
4 BEGIN
5 EXECUTE IMMEDIATE 'ALTER SESSION SET CURRENT_SCHEMA = U1' ;
6 SELECT COUNT(*) INTO A_COUNT FROM (
7 select x from test_tbl );
8 END;
9 /
Warning: Procedure created with compilation errors.
SQL> sho err
Errors for PROCEDURE TEST3:
LINE/COL ERROR
6/1 PL/SQL: SQL Statement ignored
7/15 PL/SQL: ORA-00942: table or view does not exist
SQL> set serveroutput on
SQL> CREATE OR REPLACE PROCEDURE test3
2 IS
3 A_COUNT NUMBER(15);
4 c sys_refcursor;
5 BEGIN
6 EXECUTE IMMEDIATE 'ALTER SESSION SET CURRENT_SCHEMA = U1' ;
7 OPEN C FOR 'SELECT COUNT(*) FROM (select x from test_tbl )';
8 FETCH c INTO A_COUNT;
9 dbms_output.put_line(a_count);
10 CLOSE c;
11 END;
12 /
Procedure created.
SQL> insert into u1.test_tbl select rownum from emp;
14 rows created.
SQL> exec test3
14
PL/SQL procedure successfully completed.
SQL> Obviously, as you noted SP owner must have directly granted select on test3.solutions.
SY. -
Tuxedo buildserver : use SQL in cobol applics
Hi,
I'm trying to use SQL through COBOL applications in a Tuxedo (8.0) environment.
I've added the ODBC libpath to the buildserver command. The execution/compilation of the buildserver seems to be ok, but upon execution of the cobol program the SQL CONNECT fails with SQL-error err 10000.
I have no idea how to make SQL work ? Can anyone help ?
I read about RM (resources manager), is this required to make it work ?
thanks !
Hugo
Our platform is HP/UX and we use SQL/COBOL outside tuxedo without problems.
This is the make file :
# Fc 970618: incremental compilation for Cobol added
TUXINC=$(TUXDIR)/include
BTNINC=$(BTNDIR)/incl
INCLUDES=-I $(TUXINC) -I $(BTNINC) -I /jates/progs/srcs
ODBCLIBS="-L /usr/local/unixODBC/lib -lodbc"
COBOPT="-t"
COBCPY="/jates/tuxedo80/cobinclude:/jates/btn/btndevl/incl:/jates/cobol/cobol4000sp2/cpylib"
#avoid unwanted C-compiler warnings
NLSPATH=$NLSPATH:/opt/ansic/lib/nls/msg/C/%N.cat
# btnrouter
btnrouter: /jates/progs/tps/btnrouter.cbl /jates/progs/tps/btn400.cbl /jates/progs/tps/mod461.cbl /jates/progs/tps/mod470.cbl
buildserver -C -v -o $@ \
-f /jates/progs/tps/btnrouter.cbl \
-f /jates/progs/tps/btn400.cbl \
-f /jates/progs/tps/mod461.cbl \
-f /jates/progs/tps/mod470.cbl \
-f /jates/progs/tps/res400.cbl \
-f ${ODBCLIBS} \
-s SJETAIR
-tmshutdown -s $@
cp -p $@ ..
-tmboot -s $@
# general instructions
.SUFFIXES: .cbl .c .o
.c.o: $(BTNINC)/fml_flds.h
cc -c $(INCLUDES) $<
.cbl.o: $(BTNINC)/fml_flds.h
cob -xc $<
#******************************************************The normal way to use Tuxedo with an XA-compliant resource manager is to
1. Have the Tuxedo administrator add a line for the resource manager to the
$TUXDIR/udataobj/RM file including the resource manager name, XA switch
name, and libraries required for linking.
2. Build servers using the resource manager with the "-r rmname" line.
This will include the resource manager lines specified in
$TUXDIR/udataobj/RM in the buildserver line, and the application will not
need to manually provide the libraries to buildserver.
3. If using transactions, have the Tuxedo administrator build a TMS process
for the RM using the buildtms command, or do this yourself. If not using
transactions, this step can be omitted.
When a server is built with the "-r rmname" option, Tuxedo will
automatically call TPOPEN to connect to the resource manager within
TPSVRINIT.
(The only exception to this is if the application programmer replaces the
default verion of TPSVRINIT with their own version and does not include a
call to TPOPEN, so it is good to verify that this is not the case.) Since
Tuxedo opens the resource manager when the server is started, there is no
need to include SQL CONNECT statements within the application logic in such
a server.
If your resource manager is not XA compliant then you will need to manage
connection to the database yourself, but most databases are XA compliant
nowadays.
<Paul Debleecker> wrote in message news:[email protected]...
Hi,
I'm trying to use SQL through COBOL applications in a Tuxedo (8.0)
environment.
I've added the ODBC libpath to the buildserver command. The
execution/compilation of the buildserver seems to be ok, but upon
execution of the cobol program the SQL CONNECT fails with SQL-error err
10000.
I have no idea how to make SQL work ? Can anyone help ?
I read about RM (resources manager), is this required to make it work ?
thanks !
Hugo
Our platform is HP/UX and we use SQL/COBOL outside tuxedo without
problems.
This is the make file :
# Fc 970618: incremental compilation for Cobol added
TUXINC=$(TUXDIR)/include
BTNINC=$(BTNDIR)/incl
INCLUDES=-I $(TUXINC) -I $(BTNINC) -I /jates/progs/srcs
ODBCLIBS="-L /usr/local/unixODBC/lib -lodbc"
COBOPT="-t"
COBCPY="/jates/tuxedo80/cobinclude:/jates/btn/btndevl/incl:/jates/cobol/cobol4000sp2/cpylib"
#avoid unwanted C-compiler warnings
NLSPATH=$NLSPATH:/opt/ansic/lib/nls/msg/C/%N.cat
# btnrouter
btnrouter: /jates/progs/tps/btnrouter.cbl /jates/progs/tps/btn400.cbl
/jates/progs/tps/mod461.cbl /jates/progs/tps/mod470.cbl
buildserver -C -v -o $@ \
-f /jates/progs/tps/btnrouter.cbl \
-f /jates/progs/tps/btn400.cbl \
-f /jates/progs/tps/mod461.cbl \
-f /jates/progs/tps/mod470.cbl \
-f /jates/progs/tps/res400.cbl \
-f ${ODBCLIBS} \
-s SJETAIR
-tmshutdown -s $@
cp -p $@ ..
-tmboot -s $@
# general instructions
.SUFFIXES: .cbl .c .o
.c.o: $(BTNINC)/fml_flds.h
cc -c $(INCLUDES) $<
.cbl.o: $(BTNINC)/fml_flds.h
cob -xc $< -
How to specify a table column that is a PL/SQL reserved word
I am writing the following trigger
CREATE OR REPLACE TRIGGER SMS_MSG_TR_B_U
BEFORE UPDATE ON sms_msg
FOR EACH ROW
BEGIN
IF :OLD.BODY != :NEW.BODY THEN
RAISE_APPLICATION_ERROR(-20001,'Invalid update');
END IF;
END SMS_MSG_TR_B_U;
and I get the following error: PLS-00306: wrong number or types of arguments in call to '!='
This is because BODY is a reserved word in PL/SQL but it is not in SQL.
I tried to quote it with " but this does not work.
Does anybody knows the syntax to be able to test a column that has the name of PL/SQL reserved word?You are exactly right, BODY is of type CLOB. So the problem does not lie with the name of the column but the type.
Thanks!
<BLOCKQUOTE><font size="1" face="Verdana, Arial, Helvetica">quote:</font><HR>Originally posted by Gints Plivna ([email protected]):
Hmm, quite interesting
I tried:::::
SQL> create table sms_msg (body VARCHAr2(100));
Table created.
SQL> CREATE OR REPLACE TRIGGER SMS_MSG_TR_B_U
2 BEFORE UPDATE ON sms_msg
3 FOR EACH ROW
4 BEGIN
5 IF :OLD.BODY != :NEW.BODY THEN
6 RAISE_APPLICATION_ERROR(-20001,'Invalid update');
7 END IF;
8 END SMS_MSG_TR_B_U;
9 /
Trigger created.
SQL> show err
No errors.
SQL> insert into sms_msg values ('qaqa');
1 row created.
SQL> update sms_msg set BODY=body;
1 row updated.
SQL> update sms_msg set BODY='qaqa1';
update sms_msg set BODY='qaqa1'
ERROR at line 1:
ORA-20001: Invalid update
ORA-06512: at "GINTS2.SMS_MSG_TR_B_U", line 3
ORA-04088: error during execution of trigger 'GINTS2.SMS_MSG_TR_B_U'
So You can see no problem!
Maybe body is of some exotic data type like long or clob, blob?
Is valid to use "!=" for these data types?
P.S. I tried this example on 8.0.3 and 8.1.6<HR></BLOCKQUOTE>
null -
PL/SQL: ORA-01031: insufficient privileges
Hi Guys,
I am trying to create a package, inside that package create a function.
I am getting error - PL/SQL: ORA-01031: insufficient privileges.
I have done -
1. Conn system/system@mydb
2. Grant select on system.v_db_name to <user>
3. Conn <user>/<pwd>@mydb
4. Create or Replace Function get_db_name Return VARCHAR2 IS
v_db_name1 VARCHAR2(100):= NULL;
BEGIN
Select instance_name into v_db_name1
from system.v_db_name
where rownum<2;
IF Lower(v_db_name1) = 'vdev9i' THEN
v_db_name1 := 'vd';
ELSIF Lower(v_db_name1) = 'vcal9i' THEN
v_db_name1 := 'vc';
ELSIF Lower(v_db_name1) = 'vlive9i' THEN
v_db_name1 := 'vl';
END IF; RETURN v_db_name1;
END;
I understand that privileges have to be given directly and not through role.
That is what i have done in first step, but still this error persists.
Can anyone please help in this?
Thanks!
Av.Hi Mtichel,
Thanks for your feedback,
I have given explicit grants to User1 on sys.v_$instance as follows -
SQL> Conn sys/<pwd>@dbname as sysdba
SQL> grant select on sys.v_$instance to User1
SQL> Conn system/<pwd>@dbname
SQL> Grant select on system.v_db_name to User1
SQL> Conn User1/<pwd>@dbname
SQL> Select * from v_db_name - successfull
SQL>
1 create or replace Function get_db_name Return VARCHAR2 IS
2 v_db_name VARCHAR2(100):= NULL;
3 BEGIN
4 Select instance_name into v_db_name
5 from system.v_db_name
6 where rownum<2;
7 IF Lower(v_db_name) = 'vdev9i' THEN
8 v_db_name := 'vd';
9 ELSIF Lower(v_db_name) = 'vcal9i' THEN
10 v_db_name := 'vc';
11 ELSIF Lower(v_db_name) = 'vlive9i' THEN
12 v_db_name := 'vl';
13 END IF; RETURN v_db_name;
14* END;
SQL> /
Warning: Function created with compilation errors.
SQL> sho err
Errors for FUNCTION GET_DB_NAME:
LINE/COL ERROR
4/2 PL/SQL: SQL Statement ignored
5/14 PL/SQL: ORA-01031: insufficient privileges
Maybe you are looking for
-
Adobe Bridge zentrale Bilddatenbank
Hallo zusammen! In Adobe Bridge habe ich ja bekanntlich die Möglichkeit, Bilder mit Schlagworten zu sortieren, und somit eine struktuierte Bilddatenbank zu erstellen. In unserer Agentur hat sich im Laufe der Zeit eine große Anzahl an Bilder und Grafi
-
In looking at other forum members with the same question, there seems to be little to no instrucion amongst the responses.
-
Create PO, Goods Receipt, invoice verification, then cancellation for that goods. I want after invoice verification, User are not allowed to cancel that PO anymore. IMG : t-code : ombz, uncheck mvtype 102 and 122 then process po to miro me21n, migo,
-
Why won't a cursor show up in the shape when I double click it?
I thought you could just double click the shape to type in it...The cursor shows up outside the shape in the main part of the document or it highlights unrelated text from a text box, but it won't put a cursor in the shape. After trying 50 times, I
-
I created a very simple car reservation system in CF. Basically, the customer enters their account number, the start date (pickup) and end date (return). At the end of the month, i simply count (sum) the number of occurances of each account number, c