Insertion of a DML statement as string in a table column
Hello
Is there a way I can insert a dml statement (such as "update a SET COL1 = 10") in a table column using a procedure or a function.
I can do it by simply running an INSERT statement. But how can I do with a proc or function without getting an error "Cannot perform a DML operation inside a query"
Please advice
Hello
937454 wrote:
In fact, it can be done through a procedure. I was trying to see if I can do this with a function.
Of course, you can do so via a function; you just can not call this function of a SQL statement.
If the function returns a VARCHAR2, then you could call it like this:
DECLARE
foo VARCHAR2 (100);
BEGIN
foo: = fun_a;
END;
or like this:
BEGIN
dbms_output.put_line (fun_a);
END;
Tags: Database
Similar Questions
-
How can I get the chart inserted with "Senior officer" at the center inside a table column?
I'm trying to insert graphics into the columns of the table using 'Frame' above, but the inserted chart, don't Center not within the column, such as the text of paragraph. Horizontal alignment settings seems to be ignored for the chart.
I can solve this problem by changing the image containing the graph in the reference page, alternatively by changing the margins of cell parameter in the paragraph designer but neiter of these solutions is really good. I would like a solution that really centers the chart in the column of table not only simulates, as I like it to be compatible with the design of future changes in master pages, etc. of lika.
Is there a nice way to fix this?
It seems rather as if senior / lower frame is always aligned to the left. This isn't just a problem of Table. It does the same thing in ordinary text blocks.
I worked in a store, at home, we knew as our column width (which was constant) and controlled the placement of art in affecting the graphic block of reference Page at the address named full column width, then precisely position the art to the breast.
Were I faced with columns or cells of variable thickness, I had probably not use FA/FB, but rather a framework anchored in graphic design, anchored at the point of Insertion, to a specific tag para (say CellAnchor), which is centered. The NextPgfTag would be CellBody.
-
Can someone help me create a procedure with the DML statements that insert values from 1 to 100 in a table "abc" and the procedure must connect the numbers into words in another table "xyz" without doing a commit explicitly. "."
Currently on trial...
SQL > create table abc (num number);
Table created.
SQL > create table xyz (num varchar2 (100));
Table created.
SQL > ed
A written file afiedt.buf1. insert all
2 values of 1 = 1 then in abc (num) (l)
3 when the values of 1 = 1 then in xyz (num) (to_char (to_date(l,'j'), 'jsp'))
4 * Select the level from dual connect by level<=>=>
SQL > /.200 rows created.
And the result...
SQL > select * from abc;
NUM
----------
1
2
3
4
5
6
7
8
9
10
11
12
..
..
..
98
99
100100 selected lines.
SQL > select * from xyz;
NUM
----------------------------------------------------------------------------------------------------
one
two
three
four
five
six
seven
eight
nine
ten
Eleven
twelve
..
..
..
98
Nineteen eighty
Cent100 selected lines.
-
12 c call Webservice JDeveloper get "SQL string is not a DML statement" as a SQLException exception
Hi guys,.
I developed a java class to access the database using the OracleDataSource class and run a SQL query with a select statement. It works very well. I have built a wrapper class and as a Web service. I get "SQL string is not a DML statement" as a SQLException exception when I run as a Web service, but it works very well as an application.
No idea why I get this error? Not sure why WebSercie is having a problem while this works as an application.
Thank you and best regards,
Srini Mel
Solved the problem by myself.
The first release "SQL string is not a DML statement" is due to an additional line (pstmt2.executeUpdate ()) in the code.
Second question, receives not the query response is due to bad user input. I walked into 13.21651 instead of 31.21651.
Thank you!
Srini
-
I have the table of 3 columns A, B, C. I want to store the sum of columns A B in the C column without using the DML statements. Can anyone help please how to do. ?
11.1 and especially you have virtual column
SQL> create table t 2 ( 3 a number 4 , b number 5 , c generated always as (a+b) virtual 6 ); Table created. SQL> insert into t (a, b) values (1, 2); 1 row created. SQL> select * from t; A B C ---------- ---------- ---------- 1 2 3
Before that, a front insert - trigger
SQL> create table t 2 ( 3 a number 4 , b number 5 , c number 6 ); Table created. SQL> create or replace trigger t_default before insert on t for each row 2 begin 3 :new.c := :new.a+:new.b; 4 end; 5 / Trigger created. SQL> insert into t (a, b) values (1, 2); 1 row created. SQL> select * from t; A B C ---------- ---------- ---------- 1 2 3
-
PLS-00435: without LINKING DML statement to BULK cannot be used
My requirement
I dynamically create a staging table my_stg and then fill it out. Seems simple, but do not know why I get this error
create table gtest4 (myid varchar2 (10), mykey varchar2 (10));
create table gtest5 (myid varchar2 (10), mykey varchar2 (10));
insert into gtest4 values (1.3);
insert into gtest4 values (2.7);
insert into gtest5 values (5,3);
insert into gtest5 values (1, 7);
commit;
/ * Formatted on 2012/01/27 17:52 (trainer more v4.8.8) * /.
CREATE OR REPLACE PROCEDURE px
IS
RecType (RECORD IS of TYPE)
MyID VARCHAR2 (100),
MyKey VARCHAR2 (100)
);
TYPE tabtype IS rectype TABLE
INDEX OF DIRECTORY;
REC tabtype;
News sys_refcursor;
BEGIN
EXECUTE IMMEDIATE ' create table my_stg (myid varchar2 (100), mykey varchar2 (100)) ';
Heart OPEN FOR "select a.myid, b.mykey
gtest4 a, gtest5 b
where a.mykey = b.mykey';
LOOP
News FETCH
COLLECTING LOOSE rec LIMIT 500;
FORALL I IN 1... recomm. COUNTY
EXECUTE IMMEDIATE "insert into my_stg (myid, mykey) values (rec (i) .myid,
Rec (i). MyKey)';
OUTPUT WHEN heart % NOTFOUND;
END LOOP;
END;
/
I compile the above proc and get
PLS-00435: without LINKING DML statement to BULK cannot be used
the reason why I put in run is immediate because the my_stg table does not exist, it is created on the flyMaybe
INSERT INTO my_stg (myid, mykey, id_seq) VALUES (rec1(i), rec2(i). sequence.nextval);
Concerning
Etbin
-
DBMS_FGA &; DML statements
Hello
I was able to set up and configure FGA in my database and get my SQLs get connected in DBA_FGA_AUDIT_TRAIL. However my requirement is to put the DML statements from the front of the table triggers.
When I run an insert/update/delete statement against a table say i.e. EMP. I would llike to see education performed in the front insert/update / deletion of the respective table triggers. But even after configuration FGA i.e of Audit policy for the EMP table I am unable to get all records if inserted in DBA_FGA_AUDIT_TRAIL when I ask this view BEFORE the trigger Update of the table
How to get my DML statement or clause of the DML where atleast in my before triggers. Please help in this regard.
I went through the links and documents below, but none of that speaks my requirment.
The notes that I have visited.
http://download.Oracle.com/docs/CD/B19306_01/network.102/b14266/cfgaudit.htm#i1011302
Metalink notes
10g: Fine grain auditing (Doc ID 266896.1()
How to use DBMS_FGA with a complex audit_condition (include/exclude multiple users) (Doc ID 832856.1()
Thanks in advanceI make my own comments of Nicolas - it doesn't make much sense to check if an UPDATE statement updates of each row in the table.
If you don't want to verify such a thing (it being understood that it is almost certainly a bad idea), the classical approach would be to have
-A BEFORE level trigger UPDATE statement which has initialized a collection
-A BEFORE the UPDATE to the row-level trigger who populated the collection (i.e. Add the primary key for each update of the collection line)
-AFTER level trigger UPDATE statement which compared the number of rows affected number of rows in the tableIf you want to get the SQL statement that caused an audit event to end grain, you are probably looking for
SYS_CONTEXT( 'USERENV', 'CURRENT_SQL')
But trying to use it to determine if each row is updated in the way you mentioned sounds even worse than three trigger approach.
Justin
-
How to get the last DML statement in each block
Hello
How can I get the latest DML statements in each block.
As SYSTEM. LAST_QUERY returns the last select statement, I need to get the last Insert/Update/Delete statement
in each block.
Thanks in advance
RizlyRizly,
You can use the GET_BLOCK_PROPERTY to get the last query executed on this block.
MESSAGE(GET_BLOCK_PROPERTY('
', LAST_QUERY)); Kind regards
Manu.
If this answer is useful or appropriate, please mark. Thank you.
-
Run simultaneously multiple dml statements.
Hi all
I have an obligation to perform multiple dml instructions at the same time. I tried to do this using dbms_job, in vain.
I planned 3 dbms_job at the same time. Each task has a bulk insert statement, inserting into a single target table. Kick off 3 jobs, but there was almost a minute apart.
Is there another way to do this?You can launch 3 separate SQL more sessions, but how run you dml statements at the same exact time?
My desktop computer, here's how I would do:
Create a batch back file (for example runall.cmd) that looks like this:
Start some_command.cmd
Start some_command.cmd
Start some_command.cmdThen double-click it. This will lauch some_command.cmd in 3 separate sessions. Each will be launched but will not wait to complete before starting the next.
In the batch file, some_command.cmd, you can have everything you want. But it will probably take sqlplus.exe with command line options (one of them a .sql script).
That's how I used "Parallelization DIY" of Tom Kite. But I would normally have a parameter (such as a range or something) to keep the LMD are mutually exclusive.
-
Format of variable varchar2 to the course insert in a trigger statement
I have a trigger in my form that emits an insert into another table.
Insert the dropper
(phone)
values
(: dropperprospect.phone);
On the insert, I want the value to include dashes, like 703-923-7000 instead of just being a string of numbers like 7039237000. I need to do because of the transmission of data is stored on the table of the dropper. How can I apply this format on my insert.
Note: dropperprospect.phone is a varchar2 data type (12). The phone on the dropper table column is also a varchar2 data type (12).
Any help would be greatly appreciated.
You'll have to SUBSTR() number phone and it concatenates return as well as dashes. For example:
DECLARE v_formatted_phone VARCHAR2(15); BEGIN v_formatted_phone := SUBSTR(:dropperprospect,1,3)||'-'||SUBSTR(:dropperprospect,4,5)||'-'||SUBSTR(:dropperprospect,5,9); insert into dropper values(v_formatted_phone); END;
Craig...
-
transactions and failure of DML statement
Hello
Say I have 10 DML statements as part of my operation and the 9th one fails (and I have no to autocommit).
Is it possible to have an exception that deals with this and 10th instruction and allow the validation of the transaction, or the whole operation should be cancelled?
Thank you.
Your session will automatically rollback the statement failed. All prior statements remain uncommitted. What you do then, it's up to you.
-
validation for each 1,000 records to be inserted in the select statement
Hi, I have the following INSERTION in the SELECT statement.
The SELECT statement (who joined) data fo about 6 crores. I need to insert this data into another table.
Please suggest me the best way to do it.
I use the INSERT in the SELECT statement, but I want to use the statement commit for each 1,000 records.
How can I do this...
Thank youinsert into emp_dept_master select e.ename ,d.dname ,e.empno ,e.empno ,e.sal from emp e , dept d where e.deptno = d.deptno ------ how to use commit for every 1000 records .
Method 4 is the best
You could combine method 3 and 1 (without dynamic SQL)
Method 2 is the less optimal solution from the list.
-
Insert the tab character in a string
I am trying to create a string that will be eventually written to a text file, which must be delimited by tabs. I can't figure out how to insert a tab character in the string. Here is an example:
< cfset headerline 'H' & TAB = & #FORM.order_ID # >
Obviously, "TAB" doesn't work here. Help?
Michelle
michellezee@Comcast. wrote:
> I am trying to create a string that will be eventually written to a text file
> who should be delimited by tabs. I can't understand how to insert a tab in the
> string. Here is an example:
>
>
>
> Of course, "TAB" doesn't work here. Help?
>
> Michelle
>
>TAB = #chr (9).
--
Azadi Saryev
SABAI - Dee.com
http://www.SABAI-Dee.com -
Hi guru,.
Is less than a valid SQL | Statement of PLSQL? or several instructions and what it does?
insert into table (col1, col2, col3, col4)
with table_tmp as
(select ccol1, ccol2, ccol3, ccol4, ccol5, ccol6
from table1, table2 t2 t1
where t1.id = t2.id
and t2.start > sysdate()
)
Select tcol1, tcol2, tcol3, tcol4
of table_tmp tt1, table3 t3
where tt1.id = tt3.id;
I checked the SQL quick reference card and don't see anything similar to this... I wonder where I can find a better book of reference for the syntax.
Thanks in advance
KHuser5885318 wrote:
Is less than a valid SQL | Statement of PLSQL? or several instructions and what it does?It inserts data into the table
insert into table (col1, col2, col3, col4)
(ok, ignoring the fact that you can't have a table named table)
using the select statement located below
with table_tmp as
(select ccol1, ccol2, ccol3, ccol4, ccol5, ccol6
from table1, table2 t2 t1
where t1.id = t2.id
and t2.start > sysdate()
)
Select tcol1, tcol2, tcol3, tcol4
of table_tmp tt1, table3 t3
where tt1.id = tt3.id;I checked the SQL quick reference card and don't see anything similar to this... I wonder where I can find a better book of reference for the syntax.
SQL reference documentation contains the complete syntax for Oracle SQL, so how can you find a better reference for the syntax. I think your concept to better is all simply because you are not familiar with things and don't know where to find things. SQL is a huge beast, so you cannot expect to find things very quickly in all cases, especially if you don't really know what you are looking for.
I'm guessing you are struggling to find information about the clause "WITH"?
It is called subquery factoring and lie under the SELECT statement in the SQL reference:
http://download.Oracle.com/docs/CD/B19306_01/server.102/b14200/statements_10002.htm#i2161315
An equivalent statement without the WITH clause (using your insert as a base statement)...
insert into table(col1, col2, col3, col4) select tcol1, tcol2, tcol3, tcol4 from (select ccol1, ccol2, ccol3, ccol4, ccol5, ccol6 from table1 t1, table2 t2 where t1.id=t2.id and t2.start > sysdate() ) tt1 , table3 t3 where tt1.id=tt3.id;
The done WITH clause takes the subquery in the main query. This is useful if the same subquery is needed more than once in the main query.
-
Hi all
Problem: Build a VI to display a string in the table of the lights. Each letter must be posted in a separate table and letters must move from one table to the other in the direction from left to right.
I did program mentioned above but it does not work. Can you tell me what is the problem?
There is no error is indicated in the program. If someone knows about it please try to find solutions and help me out of this problem.
I have attached my program with this message.
Thank you in advance!
(1) FOR loops are your friend here. You can make a slight restructuring using loops, and then you will have less mess to deal with, the inner loop through tunnels of autoindexing to make it even simpler.
(2) I would only treat the numeric values of the characters. So go terminal of control of the chain, the capital letters and byte array to before the outer loop. You can use a size of Board over there to tell how many times the outer loop to iterate.
(3) the Index table is extensible. So you only need over the index of the first, and it will increment itself, as it develops.
(4) you need to finish the lookup table (table 3D)
Maybe you are looking for
-
As he says, I had a difficult time with Firefox lately, and I think that it's corrupted. I tweaked the settings according to the suggestions on this forum and others like him, but they made the problem worse. I've updated to the latest version of the
-
Firefox won't let me open other windows even my trusted sites, which can do to fix this?
When I check my email tickets and places of work that I will I know they are approved, but whenever I click on the link, a message appears saying Firefox prevented this page automatically redirecting to another page. What can I do to stop this? It is
-
Satellite Pro P200 (PSPB7E) - where to find the new display drivers?
Laptop bought in July 2007, the Windows Vista Business operating system.Vista windows update immediately so don't know not if the following problem was there before I updated. When put in a slideshow for all images almost immediately a blue screen ap
-
R6300 get 100/100 but I have gigabit connection
I have a R6300 and I have a gigabit connection. If I bypass the router I get a very fast speed, but if I connect via Ethernet through the router I get 100 MB up and down. What should I do to get the gigabit on the router?
-
MFP: MFP with fax to email/smb
Looking to buy a Mono Laser multifunction with Fax E-mail/smb feature. Anyone know what models are available?