Zero error of iteration - the treatment of dynamic sql statements in dbms_xmlgen
HelloI have a procedure that creates a dynamic sql v_sql
cursor v_curr is
Select *.
of btctl_msg_log;
BEGIN
Select count (*) in the v_cnt of btctl_msg_log;
IF v_cnt > 0 THEN
C1 in v_curr
LOOP
v_sql: = "' | ' SELECT * from '. C1.msg_rcrd_src_tbl_nm | |' where rowid = ' | " ' ||'' ' || C1.msg_rcrd_src_tbl_id | " ' ||'' ' ||'' ' ;
Select DBMS_XMLGEN.getXMLtype (v_sql) in the double v_xml;
gives me an error
ORA-19202: an error has occurred in the processing of XML
ORA-24333: zero number of iterations
ORA-06512: at "SYS." DBMS_XMLGEN", line 288
ORA-06512: at line 1
I don't know why is this error happening.
Any help much appreciated.
881575 wrote:
HelloI have a procedure that creates a dynamic sql v_sql
cursor v_curr is
Select *.
of btctl_msg_log;BEGIN
Select count (*) in the v_cnt of btctl_msg_log;IF v_cnt > 0 THEN
C1 in v_curr
LOOP
v_sql: = "' | ' SELECT * from '. C1.msg_rcrd_src_tbl_nm | |' where rowid = ' | " ' ||'' ' || C1.msg_rcrd_src_tbl_id | " ' ||'' ' ||'' ' ;
Select DBMS_XMLGEN.getXMLtype (v_sql) in the double v_xml;gives me an error
ORA-19202: an error has occurred in the processing of XML
ORA-24333: zero number of iterations
ORA-06512: at "SYS." DBMS_XMLGEN", line 288
ORA-06512: at line 1I don't know why is this error happening.
Any help much appreciated.
Standard when boards (ab) use of EXECUTE IMMEDIATE is to compose the SQL statement in a single VARCHAR2 variable
Then print the variable before passing to EXECUTE IMMEDIATE.
COPY the statement & PASTE in sqlplus to validate its correctness.
Tags: Database
Similar Questions
-
Helps with the syntax of dynamic sql statements
Hi all
How can I pass the value of the result of my dynamic select statement to a Ref Cursor?
I try the following statement but does not work, I get this error:
ORA-00932: inconsistent data types: expected - was - ORA-06512: at
Any ideas?Procedure getItems(v_first In number, v_second In Number, arg_Cursor IN OUT CUSTOM_REF_CURSOR) is sqlString varchar(3000); Begin sqlString := 'select* from bla where o.arg_1 = :1 and arg_2 = :2'; execute immediate sqlString into arg_Cursor using v_first, v_second; End getItems;
Thank you
JohnnyPROCEDURE getitems (v_first IN NUMBER, v_second IN NUMBER, arg_cursor IN OUT sys_refcursor) IS sqlstring VARCHAR (3000); BEGIN sqlstring := 'select* from bla where o.arg_1 = :1 and arg_2 = :2'; OPEN arg_cursor FOR sqlstring USING v_first, v_second; END getitems;
-
Cannot display the results to the database during "Update": SQL statement
Hello
I get this error trying to update a VO via the UI or BCBrowser.
Cannot display the results to the database during "Update": SQL statement
This is a default single front & right THAT VO creates on the object of the entity (Database Table)
On the same table and with the same credentials of DB, I could update the record.
Any guess on what went wrong?
Thanks in advance for any help.
p.s Jdev 11.1.1.6
Journal:
oracle.jbo.DMLException: Houston-26041: could not publish data from database in "Update": SQL statement "START the CAR UPDATED CarEO SET SEL_ITEM =: 1 WHERE TXN_NO =: 2 AND LOGID =: AND SEQNO = 3: 4 POLL DELIVERY_MODE, CERTIFICATION_REQ, SOFT_COPY_IND, SELITEM IN: 5,: 6,: 7,: 8; END; ».
at oracle.jbo.server.OracleSQLBuilderImpl.doEntityDML(OracleSQLBuilderImpl.java:583)
at oracle.jbo.server.EntityImpl.doDML(EntityImpl.java:8575)
at oracle.jbo.server.EntityImpl.postChanges(EntityImpl.java:6816)
at oracle.jbo.server.DBTransactionImpl.doPostTransactionListeners(DBTransactionImpl.java:3290)
at oracle.jbo.server.DBTransactionImpl.postChanges(DBTransactionImpl.java:3093)
at oracle.jbo.server.DBTransactionImpl.commitInternal(DBTransactionImpl.java:2097)
at oracle.jbo.server.DBTransactionImpl.commit(DBTransactionImpl.java:2378)
at oracle.adf.model.bc4j.DCJboDataControl.commitTransaction(DCJboDataControl.java:1615)
at oracle.adf.model.binding.DCDataControl.callCommitTransaction(DCDataControl.java:1417)
at oracle.jbo.uicli.binding.JUCtrlActionBinding.doIt(JUCtrlActionBinding.java:1437)
at oracle.adf.model.binding.DCDataControl.invokeOperation(DCDataControl.java:2150)
at oracle.jbo.uicli.binding.JUCtrlActionBinding.invoke(JUCtrlActionBinding.java:740)
at oracle.jbo.uicli.jui.JUActionBinding.actionPerformed(JUActionBinding.java:193)
at oracle.jbo.uicli.controls.JUNavigationBar.doAction(JUNavigationBar.java:412)
at oracle.jbo.jbotester.NavigationBar.doAction(NavigationBar.java:111)
to oracle.jbo.uicli.controls.JUNavigationBar$ NavButton.actionPerformed (JUNavigationBar.java:118)
at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1995)
in javax.swing.AbstractButton$ Handler.actionPerformed (AbstractButton.java:2318)
at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:387)
at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:242)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:236)
at java.awt.AWTEventMulticaster.mouseReleased(AWTEventMulticaster.java:272)
at java.awt.Component.processMouseEvent(Component.java:6289)
at javax.swing.JComponent.processMouseEvent(JComponent.java:3267)
at java.awt.Component.processEvent(Component.java:6054)
at java.awt.Container.processEvent(Container.java:2041)
at java.awt.Component.dispatchEventImpl(Component.java:4652)
at java.awt.Container.dispatchEventImpl(Container.java:2099)
at java.awt.Component.dispatchEvent(Component.java:4482)
at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4577)
at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4238)
at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4168)
at java.awt.Container.dispatchEventImpl(Container.java:2085)
at java.awt.Window.dispatchEventImpl(Window.java:2478)
at java.awt.Component.dispatchEvent(Component.java:4482)
at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:644)
to java.awt.EventQueue.access$ 000 (EventQueue.java:85)
in java.awt.EventQueue$ 1.run(EventQueue.java:603)
in java.awt.EventQueue$ 1.run(EventQueue.java:601)
at java.security.AccessController.doPrivileged (Native Method)
in java.security.AccessControlContext$ 1.doIntersectionPrivilege(AccessControlContext.java:87)
in java.security.AccessControlContext$ 1.doIntersectionPrivilege(AccessControlContext.java:98)
in java.awt.EventQueue$ 2.run(EventQueue.java:617)
in java.awt.EventQueue$ 2.run(EventQueue.java:615)
at java.security.AccessController.doPrivileged (Native Method)
in java.security.AccessControlContext$ 1.doIntersectionPrivilege(AccessControlContext.java:87)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:614)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:269)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:184)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:174)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:169)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:161)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)
Caused by: java.sql.SQLException: invalid column type
at oracle.jdbc.driver.OracleCallableStatement.registerOutParameterInternal(OracleCallableStatement.java:150)
at oracle.jdbc.driver.OracleCallableStatement.registerOutParameter(OracleCallableStatement.java:399)
at oracle.jdbc.driver.OracleCallableStatement.registerOutParameter(OracleCallableStatement.java:581)
at oracle.jdbc.driver.OracleCallableStatementWrapper.registerOutParameter(OracleCallableStatementWrapper.java:1765)
at oracle.jbo.server.OracleSQLBuilderImpl.bindUpdateStatement(OracleSQLBuilderImpl.java:2243)
at oracle.jbo.server.EntityImpl.bindDMLStatement(EntityImpl.java:10524)
at oracle.jbo.server.OracleSQLBuilderImpl.doEntityDML(OracleSQLBuilderImpl.java:412)
... 52 more
The problem is solved now.
new columns added to the database table, after the creation of the entity object. Those changes were not picked up in the entity object.
I found this difference after object entity with the DB Table comparison.
And when I added these new columns to EO & VO, I don't get this error more.
Thanks to all who tried to help
-
to DECLARE * ERROR at line 1: ORA-00900: invalid SQL statement
This works fine when I use the System user to create a schema and then run this script.
When I create another user with grant connect, resources, create view permissions I get this error:
DECLARE
*
ERROR on line 1:
ORA-00900: invalid SQL statement
ORA-06512: at...
DECLARE
ID MY_TABLE.ID%TYPE;
tNom my_table. % TABLENAME TYPE;
PName MY_TABLE_TWO. PROPERTYNAME % TYPE;
CURSOR c1 IS
SELECT distinct evt.id, evt. TABLENAME, vid.propertyname
FROM my_table evt, vid MY_TABLE_TWO
WHERE the evt. COL_1 = 1
AND evt. COL_2 = vid. COL_2
and not exists (select facts FROM MY_TABLE_THREE 1)
where evt.id = facts.eventid and facts.displayname = vid.propertyname);
BEGIN
OPEN c1;
LOOP
FETCH c1 INTO id, tNom, pname;
OUTPUT WHEN c1% NOTFOUND;
INSERT INTO MY_TABLE_THREE (ID, COLUMNLENGTH)
VALUES (S_ANALYTICS_SEQUENCE.nextval, 255);
RUN IMMEDIATELY 'ALTER TABLE ' | tNom | 'Add ' | PName | ' _ NVARCHAR2 (255);
END LOOP;
CLOSE c1;
END;Hello
Maybe missing a privilege. If I were you, I'll try this first:
DECLARE id MY_TABLE.ID%TYPE; tname MY_TABLE.TABLENAME%TYPE; pname MY_TABLE_TWO.PROPERTYNAME%TYPE; CURSOR c1 IS SELECT DISTINCT evt.id, evt.TABLENAME, vid.propertyname FROM MY_TABLE evt, MY_TABLE_TWO vid WHERE evt.COL_1 = 1 AND evt.COL_2 = vid.COL_2 AND NOT EXISTS (SELECT 1 FROM MY_TABLE_THREE facts WHERE evt.id = facts.eventid AND facts.displayname = vid.propertyname); BEGIN OPEN c1; LOOP FETCH c1 INTO id, tname, pname; EXIT WHEN c1%NOTFOUND; INSERT INTO MY_TABLE_THREE (ID, COLUMNLENGTH) VALUES (S_ANALYTICS_SEQUENCE.NEXTVAL, 255); DBMS_OUTPUT.put_line('ALTER TABLE ' || tname || ' add ' || pname || '_ NVARCHAR2(255)'); --EXECUTE IMMEDIATE 'ALTER TABLE ' || tname || ' add ' || pname || '_ NVARCHAR2(255)'; END LOOP; CLOSE c1; EXCEPTION WHEN OTHERS THEN DBMS_OUTPUT.put_line(SQLERRM); END; /
Using this approach, you can see the sentences to run without run, I also added an exception block.
Kind regards
-
Hi all
We have a problem with the profile option "initialize SQL statement - Custom." We put this at the user level. After awhile, we have erased the value of the this user profile option.
But you can still see the trace files generated are getting updated. We checked this files trc pathname returned at the bottom of the query.
Select name, value
the parameter $ v
WHERE name like 'user_dump_dest;
Please help us on how to solve this problem. We use Oracle Apps R 12.1.2 version.
Thanks in advance
Rambaud
Find the trace file creation session and kill this session
HTH
Srini -
In SQL Developer, is it possible to send the results of a sql statement?
In SQL Developer, is it possible to send the results of a sql statement?Right-click on the query results pane, select "Export data" in the context menu, then select "xls".
-
GETTING AN ERROR - slider 'P_REFCUR' cannot be used in the OPEN dynamic SQL stat
DECLARE
create or replace procedure partial_single (p_fileid in NUMBER, p_filename IN VARCHAR2 (2000), p_temptablename IN VARCHAR2 (2000), p_temppartialtablename IN VARCHAR2 (2000), p_retval ON the NUMBER)
--)
p_fileid NUMBER;
p_filename VARCHAR2 (2000);
p_temptablename VARCHAR2 (2000);
p_temppartialtablename VARCHAR2 (2000);
p_retval NUMBER;
p_refcur types_pkg.return_cur;
v_strquery varchar2 (4000);
BEGIN
p_fileid: = 5080;
p_filename: = "TAGSUR1HM2011013111160838654.000019265";
-p_temptablename: = "TEMP_RECORDS_MED_0004";
p_temptablename: = 'TEMP_RECORDS_MED_DATE ';
p_temppartialtablename: = 'TEMP_MED_PARTIAL_RECORDS_0002 ';
p_retval: = 0;
v_strquery: = 'SELECT imsi, connectedcallingnumber, callstart MIN (calleventstarttimestamp), SUM (calleventduration), MAX (sequence_number) sequencenumber, msisdn, max (callreleasetime) callreleasetime period';
v_strquery: = v_strquery | ' A ' | p_temppartialtablename | ' GROUP BY connectedcallingnumber, imsi, msisdn';
OPEN p_refcur - GETTING AN ERROR - slider 'P_REFCUR' cannot be used in a dynamic OPEN SQL statement
FOR v_strquery;
FOR CC IN (SELECT imsi,
connectedcallingnumber,
Callstart MIN (calleventstarttimestamp),
Duration of the SUM (calleventduration),
SequenceNumber MAX (sequence_number),
MSISDN,
Max (callreleasetime) callreleasetime
OF TEMP_MED_PARTIAL_RECORDS_0002
GROUP BY connectedcallingnumber, imsi, msisdn)
LOOP
UPDATE TEMP_RECORDS_MED_DATE
SET calleventstarttimestamp = cc.callstart,
calleventduration = calleventduration + cc.duration
WHERE connectedcallingnumber = cc.connectedcallingnumber
AND imsi = cc.imsi
AND sequencenumber = cc.sequencenumber + 1
AND msisdn = cc.msisdn
AND calleventstarttimestamp = cc.callreleasetime;
IF SQL % ROWCOUNT > 0
THEN
UPDATE TEMP_MED_PARTIAL_RECORDS_0002
SET isprocessed = 1
WHERE connectedcallingnumber = cc.connectedcallingnumber
AND imsi = cc.imsi
AND msisdn = cc.msisdn;
- AND callreleasetime = cc.callreleasetime;
ON THE OTHER
UPDATE TEMP_MED_PARTIAL_RECORDS_0002
SET calleventduration = calleventduration + cc.duration
IMSI WHERE = cc.imsi
AND msisdn = cc.msisdn
AND callreleasetime = cc.callreleasetime
AND calleventduration! = cc.duration;
END IF;
END LOOP;
REMOVE FROM TEMP_MED_PARTIAL_RECORDS_0002
WHERE isprocessed = 1;
p_retval: = 0;
-VALIDATION;
/ * EXCEPTION
WHILE OTHERS
THEN
-RESTORATION;
p_retval: = 1;
p3_errorlog ("partial" p_fileid, SQLERRM, |) ':' || p_filename);
COMMIT;
*/
END;Is - what your refcursor has a return type? In this case you can not open it with dynamic SQL. Change the Refcursor as a weakly typed cursor and give it a try.
-
Hi all
I'm moving a table as a variable in dynamic SQl but with no result. Suppose that I it running on HR diagram example:
I get this error of invalid table name without knowing what was read for the variable. Any advice?declare sql_state varchar(100); hire_date date; temp_table varchar(9):='employees'; begin sql_state:= 'select hire_date from :1 where employee_id=206'; execute immediate sql_state into hire_date using temp_table; dbms_output.put_line('hire_date is '||hire_date); end; declare * ERROR at line 1: ORA-00903: invalid table name ORA-06512: at line 9
Best regards
ValHi Valerie,
To add to what Peter, said
"Binding" values in a query is done for a specific purpose, and this purpose is so that the optimizer can use the same query as the previous execution plan runs the query, which prevent it from having to analyze the hard the query each time. A query execution plan is based on the tables and columns are presented in the query, but with respect to the actual "values" of these columns, they are unlikely to change the execution plan. So, to keep the same execution plan, the query must seem identical (in terms of a query string) like the previous series, so if you want the same query, but just with different values, they can be replaced with bind variables (these things have a ': ' character) and then the values passed in the query, when it is run.
Now, if Oracle were to allow you to link in the names of objects, such as tables, this means that it could not use the previous execution plans, because he doesn't know until run time what tables will be consulted. Therefore, it would be useless link in the values of the query and it would be just as quick to implement your query string by concatenating all the values inside rather than link them. Considering that a query is parsed first and then the values in it, then it cannot be analyzed if the tables are not known everything first. (Take a look at how queries are formed and variables when you use the DBMS_SQL package).
So the key thing to remember is that, when it comes to bind variables, you can bind only the 'values', not 'objects '.
-
Char invalid when you use dynamic sql statements with cursor
Hello guys,.
I'm opening a following cursor with dynamic sql
my cursor statement isv_sql := 'SELECT OS.table_name FROM OBJECT_STATS_CONTROL OS, ALL_TABLES AT WHERE OS.analyze_flag <> ''N'' AND OS.last_analyze < sysdate -1 AND AT.last_analyzed < sysdate - 1 '||v_1||';';
I get an error messageBEGIN OPEN v_cur FOR v_sql; LOOP FETCH v_cur INTO v_tabname; ......
can any body suggest me where I'm wrong0911 invalid char
Thank youRemove the semicolon at the end:
||';' -- remove this.
-
catch the collection returned by the function in a SQL statement
I have a select like query: (I need all the values returned by the function in the select list)
Select t1.col1, t2.col2, (by selecting t.a, t.b., t.c in fn (t2.col3) t)
Of
T1, t2
where t1.col1 = t2.col2;
My function is like:
FN (T2.col3) returns an array in format of the object
Here, I was able to select only one value from the table returned by the funcation both. If I select all of the values as above, she gave too much error vales.
Please someone help me in thisuser13044793 wrote:
I have a select like query: (I need all the values returned by the function in the select list)Select t1.col1, t2.col2, (by selecting t.a, t.b., t.c in fn (t2.col3) t)
Of
T1, t2
where t1.col1 = t2.col2;No specific reason for this? It adds additional complexity to the projection of SQL, and there are additional costs of failover for the motor of PL/SQL (per line) of context. Overall - not your typical approach and one that should have sound justification.
With regard to the basic method - the SQL multiset() function should be used to create a collection. Here is an example of the approach:
SQL> create or replace type TFoo as object( 2 id number, 3 bar varchar2(5) 4 ); 5 / Type created. SQL> SQL> create or replace type TFooSet as table of TFoo; 2 / Type created. SQL> SQL> create or replace function GetSomeFoo( n number ) return TFooSet is 2 foo TFooSet; 3 begin 4 foo := new TFooSet(); 5 foo.Extend( 5 ); 6 7 for i in 1..5 8 loop 9 foo(i) := new TFoo( n+i-1, to_char(i-1,'0000') ); 10 end loop; 11 12 return( foo ); 13 end; 14 / Function created. SQL> SQL> select 2 object_id, 3 object_name, 4 cast( 5 multiset( select * from table(GetSomeFoo(object_id)) ) as TFooSet 6 ) as FOO 7 from all_objects 8 where owner = 'SYS' 9 and rownum <= 5; OBJECT_ID OBJECT_NAME FOO(ID, BAR) ---------- ------------------------------ -------------------------------------------------- 27538 /1000e8d1_LinkedHashMapValueIt TFOOSET(TFOO(27538, ' 0000'), TFOO(27539, ' 0001') , TFOO(27540, ' 0002'), TFOO(27541, ' 0003'), TFOO (27542, ' 0004')) 28544 /1005bd30_LnkdConstant TFOOSET(TFOO(28544, ' 0000'), TFOO(28545, ' 0001') , TFOO(28546, ' 0002'), TFOO(28547, ' 0003'), TFOO (28548, ' 0004')) 11718 /10076b23_OraCustomDatumClosur TFOOSET(TFOO(11718, ' 0000'), TFOO(11719, ' 0001') , TFOO(11720, ' 0002'), TFOO(11721, ' 0003'), TFOO (11722, ' 0004')) 30094 /100c1606_StandardMidiFileRead TFOOSET(TFOO(30094, ' 0000'), TFOO(30095, ' 0001') , TFOO(30096, ' 0002'), TFOO(30097, ' 0003'), TFOO (30098, ' 0004')) 684122 /1023e902_OraCharsetUTFE TFOOSET(TFOO(684122, ' 0000'), TFOO(684123, ' 0001 '), TFOO(684124, ' 0002'), TFOO(684125, ' 0003'), TFOO(684126, ' 0004')) SQL> SQL> with dataset as( 2 select 3 object_id, 4 object_name, 5 cast( 6 multiset( select * from table(GetSomeFoo(object_id)) ) as TFooSet 7 ) as FOO 8 from all_objects 9 where owner = 'SYS' 10 and rownum <= 5 11 ) 12 select 13 d.object_id, 14 d.object_name, 15 f.id, 16 f.bar 17 from dataset d, 18 table(d.foo) f 19 / OBJECT_ID OBJECT_NAME ID BAR ---------- ------------------------------ ---------- --------------- 217 DUAL 217 0000 217 DUAL 218 0001 217 DUAL 219 0002 217 DUAL 220 0003 217 DUAL 221 0004 268 SYSTEM_PRIVILEGE_MAP 268 0000 268 SYSTEM_PRIVILEGE_MAP 269 0001 268 SYSTEM_PRIVILEGE_MAP 270 0002 268 SYSTEM_PRIVILEGE_MAP 271 0003 268 SYSTEM_PRIVILEGE_MAP 272 0004 271 TABLE_PRIVILEGE_MAP 271 0000 271 TABLE_PRIVILEGE_MAP 272 0001 271 TABLE_PRIVILEGE_MAP 273 0002 271 TABLE_PRIVILEGE_MAP 274 0003 271 TABLE_PRIVILEGE_MAP 275 0004 274 STMT_AUDIT_OPTION_MAP 274 0000 274 STMT_AUDIT_OPTION_MAP 275 0001 274 STMT_AUDIT_OPTION_MAP 276 0002 274 STMT_AUDIT_OPTION_MAP 277 0003 274 STMT_AUDIT_OPTION_MAP 278 0004 815 RE$NV_LIST 815 0000 815 RE$NV_LIST 816 0001 815 RE$NV_LIST 817 0002 815 RE$NV_LIST 818 0003 815 RE$NV_LIST 819 0004 25 rows selected. SQL>
-
The analysis of a sql statement without executing it
Hello everyone,
I would like to know a way of parsing sql statements to validate them, so I would get the error messages in advance without executing them.
Here we have the difficult task to analyze several sql scripts and send corrections to the development team and thirty third companies before applying them in our production databases. I am ready to create a program web/pl sql, making this difficult task, at least one program to identify errors such as lack of owner of the table, nonexistent tables, syntax errors and so on...
Any information will be a great help!
Thanks in advance.Hi and welcome to the forum.
Tip1:
http://asktom.Oracle.com/pls/asktom/f?p=100:11:0:P11_QUESTION_ID:3648254441315Tip2:
to bookmark this forum (SQL and PL/SQL)
Bookmark http://tahiti.oracle.com (The Oracle Documentation)
Bookmark http://asktom.oracle.comTip3:
On all the sites mentioned, you can do a quick search on key words of your interest and you will get the examples and explanations returned. -
Using a Bind Variable in the FROM of a SQL statement part?
Hi all
I have a problem, I am trying to execute a SQL statement. However, I need the FROM part of the SQL statement in a variable binding. This is because the end user will have to choose between 2 views of database.
I tried this:
Select CON_ID from: P23_DB_NAME where CON_LEGACY_ID =: P23_CONLEG_NO
I had no chance. The error I got was,
'+ The query cannot be parsed in the generator. If you believe that your request is
syntactically correct, choose the generic "columns" box below the
the source of the region without analysis.
"ORA-00903: invalid table name +".
What makes sence, but now I'm a little stuck.
Does anyone have ideas for a workaround?
Thanks in advance.
-N.S.N.O.
The example I gave you is quite simple. You must take some time to study it to see where you need to be very careful what put you where. Now, of course your example does not work becaues you have several errors. It will work for you:
DECLARE x VARCHAR2 (4000); BEGIN x := x || 'SELECT CON_ID FROM '; x := x || :p23_db_name; x := x || ' WHERE CON_LEGACY_ID = ' || :p23_conleg_no; RETURN (x); END;
Denes Kubicek
-------------------------------------------------------------------
http://deneskubicek.blogspot.com/
http://www.Opal-consulting.de/training
http://Apex.Oracle.com/pls/OTN/f?p=31517:1
------------------------------------------------------------------- -
Display dynamic SQL statement result
Hello
Is it possible to view the sql statement in the procedure below, after that the variables are applied?
In my view, a solution would be to put the entire statement in an important variable, then use DBMS_OUTPUT. Put_line (my_large_variable) but I'm hoping to save this step.
Thanks in advance for your help,
Lou
create or replace
PROCEDURE TEST1_PROC)
p_refcur ON SYS_REFCURSOR,
p_where in VARCHAR2,
p_order_by in VARCHAR2
)
IS
v_id ci_summrpt_report_codes.id% TYPE;
v_descr ci_summrpt_report_codes.descr% TYPE;
v_valid_flag ci_summrpt_report_codes.valid_flag% TYPE;
v_order_by VARCHAR2 (100);
BEGIN
IF p_order_by IS NULL THEN
v_order_by: = NULL;
ON THE OTHER
v_order_by: = "ORDER BY". p_order_by;
END IF;
DBMS_OUTPUT. Put_line (p_where);
DBMS_OUTPUT. Put_line (v_order_by);
P_refcur OPEN FOR ' SELECT id, descr, valid_flag OF |
«(SELECT 1 AS 'ID', "A" AS "DESCR", "Y" AS "VALID_FLAG" OF THE DOUBLE ' |)»
"UNION ALL" |
"SELECT 2,"TWO","Y"OF THE DOUBLE ' |
"UNION ALL" |
"SELECT 3,"THREE"," Y "DOUBLE" |
"UNION ALL" |
SELECT 4, "FOUR", "Y" DOUBLE) ' |
p_where |
v_order_by
;
END TEST1_PROC;In my view, a solution would be to put the entire statement in an important variable, then use DBMS_OUTPUT. Put_line (my_large_variable) but I'm hoping to save this step.
This isn't a big problem, I think, is - this? :
create or replace procedure test1_proc (p_refcur out sys_refcursor, p_where in varchar2, p_order_by in varchar2) is v_id ci_summrpt_report_codes.id%type; v_descr ci_summrpt_report_codes.descr%type; v_valid_flag ci_summrpt_report_codes.valid_flag%type; v_order_by varchar2 (100); v_stmt long; begin if p_order_by is null then v_order_by := null; else v_order_by := ' ORDER BY ' || p_order_by; end if; dbms_output.put_line (p_where); dbms_output.put_line (v_order_by); v_stmt := 'SELECT id, descr, valid_flag FROM ' || '(SELECT 1 AS "ID", ''ONE'' AS "DESCR", ''Y'' AS "VALID_FLAG" FROM DUAL ' || 'UNION ALL ' || 'SELECT 2, ''TWO'', ''Y'' FROM DUAL ' || 'UNION ALL ' || 'SELECT 3, ''THREE'',''Y'' FROM DUAL ' || 'UNION ALL ' || ' SELECT 4, ''FOUR'',''Y'' FROM DUAL) ' || p_where || v_order_by; dbms_output.put_line (v_stmt); open p_refcur for v_stmt; end test1_pro;
-
Back to zero/recalculate value if the element with dynamic action
Hi all
What I have is a part of "total amount". When the other elements on the form are filled, these values are subtracted from the total. My problem is that when a few points to say a filled out, but then set to zero, the figure in the total does not reset. If no new figure added, are more excluded.
For example:
total = 10
Value of 1 changed to 5. Total = 5.
Value of item 2 changed to 1. Total = 4.
Value of 1 changed to 2. Total = 2.
I find it tricky is because the total is derived from an action of current setpoint led other points. Finally, I would like to reset or re - run the calculation for the total, without duplicating the original action of the set value. I tried to use a dynamic action "Refresh" but I don't think that work in this way. Is there another way?Why not save the original value to an item hidden page (or even in a global variable set before you run the JS calculation for the first time in javascript).
During the reset, set the value of the element with the value of the hidden (or variable). -
bind the parameter to dynamic sql
Dear user
I want to bind the variable at run time
the problem is as follows:-
I have a table like this: -.
type_id, rule_dtls, rule_id, using_paramter
rule_id and type_id is an idea just to the rule and object
using_paramter:-is parameters used to bind the variable to the rule, it may be different
as examples of data the spouse;
using_paramter can be different parameter as AREA, BOARD_NO or face_no,
rule_id, board_type, rule_dtls using_paramter 1 7 CASE WHEN: BOARD_NO < 1000 then 10 when: BOARD_NO > 1000 then CEIL (: BOARD_NO/5000) * 5 end BOARD_NO,BOARD_NO,BOARD_NO 2 5 WHEN BOX: AREA < 3 then 15 when : AREA > 3 then (: SPACE - 3 * 2) + 15 end BOX, BOX, BOX and I have the function of database 10g as follows:-
CREATE OR REPLACE FUNCTION get_bord_price(area number,face_no number,BOARD_NO number,BOARD_TYPE_v varchar2) RETURN number IS amt number:=0; sql_v varchar2(500); BOARD_RULE varchar2(500); using_clom varchar2(500); price number; ERR varchar2(500); ERR_CODE NUMBER; BEGIN price:=0; select rule_dtls ,using_paramter into BOARD_RULE,using_clom from BOARD_RULE where BOARD_TYPE=BOARD_TYPE_v; sql_v:='select '||BOARD_RULE ||' from dual'; execute immediate sql_v INTO price using using_clom; RETURN price; exception when others THEN ERR:=SQLERRM; return 0; END;
the error is in
using using_clom;
How can I bind varable this:
or is there another solution
Hello
Bind variables cannot be a variable.
Identify the parts to be replaced (e.g.,: BOARD_NO,: AREA) and write statements to REPLACE to replace those.
Manu.
Maybe you are looking for
-
Boot Camp Windows 10 incorrect use of storage
Hello I have a 2015 end MacBook Pro with 500g of ssd. I have 10 windows entirely running and allocated approximately 250 g for it. But when I go to the use of the storage in the settings, it shows that my C: drive is 698g. I also checked command prom
-
Hello I was using Fitbit load for some time with MFP now I intend to spend at Apple Watch. Synchronization with Fitbit was little flaky and not always with success. What about combination of PTF with Apple Watch? I've never used Apple Watch before an
-
Open excel sheet by sheet name... Subvi without closing the
Hi all I'm experimenting with excel and labview and I want to open a spreadsheet by name. I created a project with a main vi where I hit a button to start the process. When this button is hit an event handler opens my Subvi who actually asks for a f
-
How to enable breakpoints in a c# application
We have a c# application that works as a wrapper around TestStand. Is there a way to activate the breakpoints of execution via a current method call?
-
Portable 1 350: USB 3.0 driver for Notebook 350 G1
I can't find driver in the driver for my phone G1 350 download page. Help, please