regexp_replace to remove the clause of a sql statement
Select regexp_replace ("select Column1, Column2 in var1, var2 from table1, table2")where 1 = 1', '(into|) IN). * \w. (a |) (FROM)', null) double
Returns
Select Column1, Column2 table1, table2
where 1 = 1
Problem: I'm missing 'of' or 'FROM '.
Question: How do you fit in before the "from" or "FROM" so that my output is:
SELECT column1, Column2 from table1, table2
where 1 = 1
Summer experiences $' etc, but no dice. Clues?
or you can try the following:
select regexp_replace( '
select column1,
/*+ into */ column2
into var1,
var2
from table1,
table2
where 1=1',
'into\s((\s*,\s*)?[a-z0-9_#$]{1,30})*\s*from',
'from', 1, 1, 'i')
from dual;
gives the following output
select column1,
/*+ into */ column2
from table1,
table2
where 1=1
Even if you have strange line breaks it works
select regexp_replace( '
select column1,
/*+ into */ column2 into var1,
var2 from table1,
table2
where 1=1',
'into\s((\s*,\s*)?[a-z0-9_#$]{1,30})*\s*from',
'from', 1, 1, 'i')
from dual;
gives
select column1,
/*+ into */ column2 from table1,
table2
where 1=1
and
select regexp_replace( 'select column1, /*+ into */ column2 into var1, var2 from table1, table2 where 1=1',
'into\s((\s*,\s*)?[a-z0-9_#$]{1,30})*\s*from',
'from', 1, 1, 'i')
from dual;
gives
select column1, /*+ into */ column2 from table1, table2 where 1=1
Tags: Database
Similar Questions
-
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
-
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".
-
REQUEST to remove the clause SSELECT
My version of the database is oracle 12 c.
I have a table named sql_test, it stores the name of the table and SQL used for this table.
create table sql_test
(
table-name varchar2 (30),
SQL clob,
clob sql_no_slct
);
INSERT INTO (table_name, sql) sql_test values ('XYZ',' SELECT * () IN OF XYZ Z WHERE Z.ABC)
SELECT PQR IRD A, PLS B
(WHERE A.ID = B.ID AND B.STAGE = 209)');
INSERT INTO (table_name, sql) sql_test values ('ABT',' SELECT * () IN OF ABT WHERE LDD)
SELECT PQR IRD A, PLS B
(WHERE A.ID = B.ID AND B.STAGE = 209)');
commit;
Now, I need to update the sql_no_clct column. This column value must come from a SQL column but the first part of the slect... Of... is deleted. It starts from after the WHERE clause.
For example, for the first records table_name = "XYZ" update should be like this: -.
Update sql_test
set sql_no_slct ='Z.ABC IN (SELECT IRD OF the PQR, PLS B
WHERE A.ID = B.ID AND B.STAGE = 209)';
commit;
In the above example, I have here the query update with manual changes. In fact, I have several lines in the table so I prefer to take the value of the SQL column and handle to remove the first select... Of... Where the query and update records.
Please some advice/help on this.
Thank you.
When you have an SQL statement that uses different 'values', but are essentially is the same SQL statement, then bind using variable avoids having to one) hard to analyze the statement each time to generate a new execution plan and b) use essential internal resources such as the shared pool to store multiple copies of, what is essentially, the same statement.
Don't not using bind variables can have an impact on the performance of the query itself as well as the performance of the server for everyone use it somewhere else.
When you write a SQL, PL/SQL statement, then the values you pass are automatically transformed into bind variable (PL/SQL is smart like that). When dynamically SQL statements you issue yourself, you must always aim to use bind variables in order to change the values, rather than hard-coding values in the statement.
for example if your SQL string is:
"Select empno, comm, sal from emp where empno = 7788'."
the "7788' so is this value.
To run this string dynamically using bind variables, you would do something (in PL/SQL) as:
run immediately "select empno, comm, sal from emp where empno =: 1' using 7788;"
So, if you need to use a different value, you go just this different value in, but the SQL statement in the shared pool is identical, with the same execution plan and can be soft parsed (rather than hard analysis and put a new entry in the shared pool).
-
Zero error of iteration - the treatment of dynamic sql statements in dbms_xmlgen
Hello
I 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. -
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
------------------------------------------------------------------- -
Can I omit THEN in a when then the clause of an insert statement multi-table?
Example of a test of the demo:
You have been appointed as the DBA for a National Bank that provides services of credit and debit cards to its customers. The records for these two types of card users are stored and preserved in the card_customers of Bank data table.
You decide to create separate tables for credit card users and users of debit cards and then use the data in the card_customers table to populate the new tables. Information for clients who hold both types of card must be added to the time of the tables.
Which of the two following options provide the most effective way of inserting the customer data in the credit_card_holders and debit_card_holders tables? (Choose two.)Explanation:
In this scenario, the following statement provides the most effective way of inserting data in the credit_card_holders and debit_card_holders tables:
INSERT ALL
When card_type = 'Crédit' THEN credit_card_holders
When card_type = 'Throughput' THEN debit_card_holders
SELECT * FROM card_customers;
Le INSERT all THE statement verifies the conditions in the two clauses WHEN , regardless whether one of them is true or false. If a condition when is true, then the line corresponding to the INSERT statement is executed is inserted in the card_customers in the credit_card_holders table or the debit_card_holders table. If a customer has a credit card and a debit card, there will be two rows in the table card_customers for the same customer, one with card_type = 'Crédit' and the other with card_type = 'Throughput'. This statement inserts the correct lines in the tables in a single pass.The TIME is here (in bold) are not present in answer C.
basic question: can I omit the keyword THEN in a moment, then clause?
What happened when you tried the failure THEN?
Do not be afraid to break the Oracle by actually TRYING things.
The best and fastest, to learn is to try things yourself.
Then, see the documentation for the basic issues.
http://docs.Oracle.com/CD/B28359_01/server.111/b28286/statements_9014.htm
View the diagram of syntax for the 'conditional_insert_clause' and you will see that the word is necessary.
-
The collection of Pl/SQL statement-
Hello
Can we declare pl/sql outside of a package, and according to a specific schema collections?
Creates an object the right way. Please correct me if wrong.
Thank you
GoussardHi guy,
You can try like this...You can use PL/SQL in objects that are defined outside a PL/SQL package!! Use object bodies: CREATE TYPE person_typ AS OBJECT ( idno NUMBER, first_name VARCHAR2(20), last_name VARCHAR2(25), email VARCHAR2(25), phone VARCHAR2(20), MAP MEMBER FUNCTION get_idno RETURN NUMBER, MEMBER PROCEDURE display_details ( SELF IN OUT NOCOPY person_typ )); / CREATE TYPE BODY person_typ AS MAP MEMBER FUNCTION get_idno RETURN NUMBER IS BEGIN RETURN idno; END; MEMBER PROCEDURE display_details ( SELF IN OUT NOCOPY person_typ ) IS BEGIN -- use the PUT_LINE procedure of the DBMS_OUTPUT package to display details DBMS_OUTPUT.PUT_LINE(TO_CHAR(idno) || ' ' || first_name || ' ' || last_name); DBMS_OUTPUT.PUT_LINE(email || ' ' || phone); END; END; /
Kind regards
Symph. -
Under certain conditions, update a table based on the comparison with a SQL statement
I have a table (table 1) that has 4 columns:
UID. THE NEST | VALUE1 | VALUE2
I have another statement SQL (STMT) that returns the 3 columns of a few other tables:
UID. THE NEST | VALUE1
Now this is the condition of the way in which I want to put up-to-date TABLE1:
First, to compare a pair of UID and PID of STMT with those in TABLE1,
-1, for any new pair UID and PID not in TABLE1, insert a new line of STMT in TABLE1 set TABLE1. Value2 = 0 (I already did this).
2, for an existing UID and PID pair in STMT and TABLE1, do:
a. in TABLE1. Value2 > 0, update TABLE1. VALUE1 = STMT. VALUE1
b. to TABLE1. Value2 = 0 and if TABLE1. VALUE1! = STMT. Value1, update of TABLE1. VALUE1 = STMT. Value1, otherwise nothing to do.
I can't seem to come with a solution for condition 2. Any help is appreciated!Hello
Here's one way:
MERGE INTO table1 dst USING ( SELECT ... -- your stmt query goes here ) src ON ( src.uid = dst.uid AND src.pid = dst.pid ) WHEN MATCHED THEN UPDATE SET dst.value1 = CASE WHEN dst.value2 > 0 OR ( dst.value2 = 0 AND dst.calue1 != src.value1 ) THEN src.value1 END WHERE dst.value2 > 0 OR ( dst.value2 = 0 AND dst.calue1 != src.value1 ) ;
This assumes that the combination (uid, pid) is unique in stmt. It doesn't have to be unique in table1.
sb92075 wrote:
-1, for any new pair UID and PID not in TABLE1, insert a new line of STMT in TABLE1 set TABLE1. Value2 = 0 (I already did this).
FUSION could also do parts 1 and 2 together, in the same statement.
2, for an existing UID and PID pair in STMT and TABLE1, do:
a. in TABLE1. Value2 > 0, update TABLE1. VALUE1 = STMT. VALUE1
b. to TABLE1. Value2 = 0 and if TABLE1. VALUE1! = STMT. Value1, update of TABLE1. VALUE1 = STMT. Value1, otherwise nothing to do.
Why are they not simply your needs ' uid and pid that already exist in stmt and table1, if table1.value2 > = 0, then the value table1.value1 = stmt.value1 "? Are you concerned about shooting triggers unnecessarily? It has something to do with null values? The MERGE statement above does exactly what you asked, but, depending on your needs, something simpler and more efficient could do it as well.
I hope that answers your question.
If not, post a small example data (CREATE TABLE and only relevant columns, INSERT statements) for all of the tables involved and also publish outcomes from these data.
If you ask on a DML statement, such as UPDATE, the sample data will be the content of the or the tables before the DML, and the results will be the State of the or the tables changed when it's all over.
Explain, using specific examples, how you get these results from these data.
Always tell what version of Oracle you are using.
See the FAQ forum {message identifier: = 9360002}Published by: Frank Kulash, June 6, 2012 14:51
-
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;
-
by using the stored procedure in sql statement?
I have the following sample tables:
project id project name
====== ===============
1 project one
2 two project
3 three of the project
employee_id fname lname
=========== ============= =====
Amy 100a
Better B 200
Carrie 300 C
project number
=========== ===========
1,200 people
2 300
of 3 100
There's a getFullname (empployee_id) of the procedure in place that combines the fname lname full name
what I need to accomplish is the following.
project is created by employee
==============================
project a is created by better b
two project is created by carrie C
three project is created by amy A
but the rule is: you need to call the getFullName (employee_id) procedure to perform the above task and do not use join tables to get the employee full nameI suspect that you want something along the lines of
SELECT 'Project ' || p.project_name || ' was created by ' || get_full_name( pe.employee_id ) FROM project p, project_employee pe WHERE p.project_id = pe.project_id
If you need other attributes in the employee table, you can join at the table of the employees as well.
Justin
-
Need to remove the name clause and the storage of schema DDL script.
Try to remove the clause name and storage schema of the DDL script.
Example:
"
CREATE TABLE 'CPDFP '. "" PS_PT_LN_TA_SRVC_BRANCH_DTLS ".
(ACTIVATE THE "SL_NO" NUMBER NOT NULL,)
ACTIVATE THE "SESSION_ID" NUMBER NOT NULL,
ACTIVATE THE "COMPANY_CODE" VARCHAR2 (15) NOT NULL,
ACTIVATE THE "SRVC_BRANCH_CODE" VARCHAR2 (6) NOT NULL,
ENABLE 'DEALER_CODE' VARCHAR2 (15) NOT NULL
) CREATION OF IMMEDIATE SEGMENT
PCTFREE, PCTUSED, INITRANS 40 10 1 MAXTRANS 255
REGISTRATION OF NOCOMPRESS
STORAGE (INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645)
PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1
USER_TABLES FLASH_CACHE, CELL_FLASH_CACHE DEFAULT DEFAULT)
"TABLESPACE"CPDFP"
On top of the query, I have to delete the name and storage schema clause...
Can anyone suggest pls as how to do it...
I used script below to get the ddl of the tables and I have to remove the schema name and terms of storage so pls help...
SELECT DBMS_METADATA. GET_DDL ('TABLE', u.table_name)
FROM USER_TABLES;
Rgds,
Nitesh.DROP TABLE t; create table t as select * from all_objects where 1=0; begin dbms_metadata.set_transform_param( DBMS_METADATA.SESSION_TRANSFORM, 'SEGMENT_ATTRIBUTES', false ); dbms_metadata.set_transform_param( DBMS_METADATA.SESSION_TRANSFORM, 'SQLTERMINATOR', TRUE ); end; / SELECT REPLACE( DBMS_METADATA.GET_DDL( 'TABLE', 'T'), '"'||USER||'".', '' ) from dual; CREATE TABLE "T" ( "OWNER" VARCHAR2(30) NOT NULL ENABLE, "OBJECT_NAME" VARCHAR2(30) NOT NULL ENABLE, "SUBOBJECT_NAME" VARCHAR2(30), "OBJECT_ID" NUMBER NOT NULL ENABLE, "DATA_OBJECT_ID" NUMBER, "OBJECT_TYPE" VARCHAR2(19), "CREATED" DATE NOT NULL ENABLE, "LAST_DDL_TIME" DATE NOT NULL ENABLE, "TIMESTAMP" VARCHAR2(19), "STATUS" VARCHAR2(7), "TEMPORARY" VARCHAR2(1), "GENERATED" VARCHAR2(1), "SECONDARY" VARCHAR2(1), "NAMESPACE" NUMBER NOT NULL ENABLE, "EDITION_NAME" VARCHAR2(30) ) ;
For instructions CREATE TABLE for all the tables in your schema:
begin dbms_metadata.set_transform_param( DBMS_METADATA.SESSION_TRANSFORM, 'SEGMENT_ATTRIBUTES', false ); dbms_metadata.set_transform_param( DBMS_METADATA.SESSION_TRANSFORM, 'SQLTERMINATOR', TRUE ); end; / SELECT REPLACE( EXTRACTVALUE( XMLTYPE( DBMS_XMLGEN.GETXML( 'SELECT DBMS_METADATA.GET_DDL( ''TABLE'', '''||TABLE_NAME||''' ) SCR FROM DUAL' ) ) , '/ROWSET/ROW/SCR' ), '"'||USER||'".', '' ) OBJECT_SCRIPT FROM USER_TABLES;
I post out ;)
Published by: Ashton stew on March 7, 2013 11:47
Maybe you are looking for
-
Part number Elitebook 840 G1 docking station?
Hello I am based in the Canada and are looking for the right manufacturer for a docking station for an Elitebook 840 G1. Thanbks for your help
-
Need idea of new printer for my continuous ink system
Hello, my old HP 6510 comes to break, which had been hung to a CIS I liked (refills waiting so want to continue to use this particular CIS). Looking for ideas on printer of the new HPs that will work with my CIS (HP02/802) Please! Regarding my use:
-
Photosmart b109n cannot print in color black
I have a Photosmart b109n. I tried to print a bunch of images and half of the images was good, but the other half was very strange. As you know a printer when it prints a picture, it makes all the colours of yellow, magenta and cyan, even in the dark
-
Deploy my Application via Desktop download instead of OTA
I know how to deploy and have people download my app OTA but what files do I need for clients to download onto their desktop computer and then install via Blackberry Desktop Manager (why some people want to do this is beyond me...). Should I just the
-
NoClassDefFoundError with Bouncy Castle Library
Hello I build and preverified Bouncy Castle bccore and bcpkix libraries and included in a BlackBerry project in Eclipse using the 7.1.0 plugin SDK BlackBerry. When you try to instantiate the CMSSignedData class I see a NoClassDefFoundError exception