[Insert values in table with the output values of the procedure]
HelloI wrote the following procedure
<>PROCEDURE
create or replace procedure experience is
cursor curexp is e.employee_id, trunc (months_between (jh.end_date, jh.start_date)) select exp, e.first_name, e.last_name, d.department_name, l.city, c.country_name, l.street_address
e employees, job_history jh, departments d, places the country c
where e.employee_id = jh.employee_id
and e.department_id = d.department_id
and d.location_id = l.location_id
and l.country_id = c.country_id;
v_result curexp % rowtype;
Start
Open curexp;
loop
extract the curexp in v_result;
When the output curexp % notfound;
dbms_output.put_line (v_result.employee_id |) ' '|| v_result.exp | ' '|| v_result.first_name | v_result.last_name);
end loop;
end;
< / procedure >
to get the values as below
< output >
101 NeenaKochhar 49
101 NeenaKochhar 40
102 66 LexDe Haan
114 DenRaphaely 21
122 PayamKaufling 11
176 helenethibaut 9
176 helenethibaut 11
200 JenniferWhalen 69
200 JenniferWhalen 53
201 MichaelHartstein 46
< / output >
After that, I created a table as below
< table >
create table exp_recored (employee_id number, number of exp_mon, name varchar2 (20))
< /table >
Now I want to insert values in the table above
I tried like below
< Insert >
Start
insert into exp_recored (employe_id, exp_mon, name) values (experience);
end;
< / insetr >
but I got error like below
PL/SQL: ORA-00947: not enough values
Could someone tell me please on the above point
Thank you
Thelak
thelakbe wrote:
HelloI tried too
During this operation
Start
insert into exp_recored (employe_id, exp_mon, name) values (v_result.employee_id, v_result.exp, v_result.first_name | v_result.last_name);
end;I got the below error
PL/SQL: ORA-00984: column not allowed here
You can try this?
CREATE OR REPLACE
PROCEDURE experience
IS
CURSOR curexp
IS
SELECT e.employee_id,
TRUNC(months_between(jh.end_date,jh.start_date)) exp,
e.first_name,
e.last_name,
d.department_name,
l.city,
c.country_name,
l.street_address
FROM employees e,
job_history jh,
departments d,
locations l,
countries c
WHERE e.employee_id=jh.employee_id
AND e.department_id=d.department_id
AND d.location_id =l.location_id
AND l.country_id =c.country_id;
v_result curexp%rowtype;
BEGIN
OPEN curexp;
LOOP
FETCH CUREXP INTO V_RESULT;
EXIT WHEN CUREXP% NOTFOUND;
INSERT INTO EXP_RECORED (EMPLOYEE_ID,EXP_MON,NAME)
VALUES (V_RESULT.EMPLOYEE_ID,V_RESULT.EXP,V_RESULT.FIRST_NAME||V_RESULT.LAST_NAME);
END LOOP;
COMMIT;
END;
Tags: Database
Similar Questions
-
How the values to insert into the table with the command insertion
Dear all
can someone tell me how the values to insert into the table with the command insert, I want to say I always use command insert behind my forms on what shutter release button press the button of my save, but today I had a form of 6i, where controls (textbox, combo, etc.) are delineated with directly the table with I guess than the Properties Windows , I created 3 columns in tand 3 text on forms fields, now kindly tell me how to do this fields to fill and do not insert command, I mean directly defined with table column
Please help me its urgentHello
If the block is based on your database table, just committed the shape, then changes will be applied to the database.
François
-
update to column values (false) in a copy of the same table with the correct values
Database is 10gr 2 - had a situation last night where someone changed inadvertently values of column on a couple of hundred thousand records with an incorrect value first thing in the morning and never let me know later in the day. My undo retention was not large enough to create a copy of the table as it was 7 hours comes back with a "insert in table_2 select * from table_1 to timestamp...» "query, so I restored the backup previous nights to another machine and it picked up at 07:00 (just before the hour, he made the change), created a dblink since the production database and created a copy of the table of the restored database.
My first thought was to simply update the table of production with the correct values of the correct copy, using something like this:
Update mnt.workorders
Set approvalstat = (select b.approvalstat
mnt.workorders a, mnt.workorders_copy b
where a.workordersoi = b.workordersoi)
where exists (select *)
mnt.workorders a, mnt.workorders_copy b
where a.workordersoi = b.workordersoi)
It wasn't the exact syntax, but you get the idea, I wanted to put the incorrect values in x columns in the tables of production with the correct values of the copy of the table of the restored backup. Anyway, it was (or seem to) works, but I look at the process through OEM it was estimated 100 + hours with full table scans, so I killed him. I found myself just inserting (copy) the lines added to the production since the table copy by doing a select statement of the production table where < col_with_datestamp > is > = 07:00, truncate the table of production, then re insert the rows from now to correct the copy.
Do a post-mortem today, I replay the scenario on the copy that I restored, trying to figure out a cleaner, a quicker way to do it, if the need arise again. I went and randomly changed some values in a column number (called "comappstat") in a copy of the table of production, and then thought that I would try the following resets the values of the correct table:
Update (select a.comappstat, b.comappstat
mnt.workorders a, mnt.workorders_copy b
where a.workordersoi = b.workordersoi - this is a PK column
and a.comappstat! = b.comappstat)
Set b.comappstat = a.comappstat
Although I thought that the syntax is correct, I get an "ORA-00904: 'A'. '. ' COMAPPSTAT': invalid identifier ' to run this, I was trying to guess where the syntax was wrong here, then thought that perhaps having the subquery returns a single line would be cleaner and faster anyway, so I gave up on that and instead tried this:
Update mnt.workorders_copy
Set comappstat = (select distinct)
a.comappstat
mnt.workorders a, mnt.workorders_copy b
where a.workordersoi = b.workordersoi
and a.comappstat! = b.comappstat)
where a.comappstat! = b.comappstat
and a.workordersoi = b.workordersoi
The subquery executed on its own returns a single value 9, which is the correct value of the column in the table of the prod, and I want to replace the incorrect a '12' (I've updated the copy to change the value of the column comappstat to 12 everywhere where it was 9) However when I run the query again I get this error :
ERROR on line 8:
ORA-00904: "B". "" WORKORDERSOI ": invalid identifier
First of all, I don't see why the update statement does not work (it's probably obvious, but I'm not)
Secondly, it is the best approach for updating a column (or columns) that are incorrect, with the columns in the same table which are correct, or is there a better way?
I would sooner update the table rather than delete or truncate then re insert, as it was a trigger for insert/update I had to disable it on the notice re and truncate the table unusable a demand so I was re insert.
Thank youHello
First of all, after post 79, you need to know how to format your code.
Your last request reads as follows:
UPDATE mnt.workorders_copy SET comappstat = ( SELECT DISTINCT a.comappstat FROM mnt.workorders a , mnt.workorders_copy b WHERE a.workordersoi = b.workordersoi AND a.comappstat != b.comappstat ) WHERE a.comappstat != b.comappstat AND a.workordersoi = b.workordersoi
This will not work for several reasons:
The sub query allows you to define a and b and outside the breakets you can't refer to a or b.
There is no link between the mnt.workorders_copy and the the update and the request of void.If you do this you should have something like this:
UPDATE mnt.workorders A -- THIS IS THE TABLE YOU WANT TO UPDATE SET A.comappstat = ( SELECT B.comappstat FROM mnt.workorders_copy B -- THIS IS THE TABLE WITH THE CORRECT (OLD) VALUES WHERE a.workordersoi = b.workordersoi -- THIS MUST BE THE KEY AND a.comappstat != b.comappstat ) WHERE EXISTS ( SELECT B.comappstat FROM mnt.workorders_copy B WHERE a.workordersoi = b.workordersoi -- THIS MUST BE THE KEY AND a.comappstat != b.comappstat )
Speed is not so good that you run the query to sub for each row in mnt.workorders
Note it is condition in where. You need other wise, you will update the unchanged to null values.I wouold do it like this:
UPDATE ( SELECT A.workordersoi ,A.comappstat ,B.comappstat comappstat_OLD FROM mnt.workorders A -- THIS IS THE TABLE YOU WANT TO UPDATE ,mnt.workorders_copy B -- THIS IS THE TABLE WITH THE CORRECT (OLD) VALUES WHERE a.workordersoi = b.workordersoi -- THIS MUST BE THE KEY AND a.comappstat != b.comappstat ) C SET C.comappstat = comappstat_OLD ;
This way you can test the subquery first and know exectly what will be updated.
This was not a sub query that is executed for each line preformance should be better.Kind regards
Peter
-
kindly tell how to use the unique value of a table with the index 0
kindly tell how to use the unique value of a table with the index 0
Hi
Yep, use Index Array as Gerd says. Also, using the context help (+ h) and looking through the array palette will help you get an understanding of what each VI does.
This is fundamental LabVIEW stuff, perhaps you'd be better spending some time going through the basics.
-CC
-
Hi Please help me how to use cascade, if I don't have only one table with the customer name and the name of the product in the ADF... I use Jdeveloper 11.1.
For the client, I used customer VO with client list to fill but to populate the product that I use bind variable PrODUCT_NAME select distinct from TABLE where client_name =: bindCustomer
so first of all, I need to set the variable of liaison on behalf of the selected customer.
Can you please tell me how to set this variable binding in this case.
After you set the LOV to your product attribute, correspondting VO in the LOV will appear under view accessors.
Change the accessor of the view, you will see the variable binding. Set its value to the customer field of the parent object.
Visit this link: https://www.youtube.com/watch?v=nXwL2_RP7AQ
Kind regards
Elias.
-
How to compare the length of the data to a staging table with the definition of the base table
Hello
I have two tables: staging of the table and the base table.
I get flatfiles data in the staging of the table, depending on the structure of the requirement of staging of the table and the base table (length of each column in the staging table is 25% more data dump without errors) are different for ex: If we have the city long varchar 40 column in table staging there 25 in the base table. Once data are discharged into the intermediate table that I want to compare the actual length of the data for each column in the staging table with the database table definition (data_length for each column of all_tab_columns) and if no column is different length that I need to update the corresponding line in the intermediate table which also has an indicator called err_length.
so for that I use the cursor c1 is select length (a.id), length (b.SID) of staging_table;
c2 (name varchar2) cursor is select data_length all_tab_columns where table_name = 'BASE_TABLE' and column_name = name;
But we get atonce data in the first query while the second slider, I need to get for each column and then compare with the first?
Can someone tell me how to get the desired results?
Thank you
Manoi.Hey, Marco.
Of course, you can set src.err_length in the USING clause (where you can reference all_tab_columns) and use this value in the SET clause.
It is:MERGE INTO staging_table dst USING ( WITH got_lengths AS ( SELECT MAX (CASE WHEN column_name = 'ENAME' THEN data_length END) AS ename_len , MAX (CASE WHEN column_name = 'JOB' THEN data_length END) AS job_len FROM all_tab_columns WHERE owner = 'SCOTT' AND table_name = 'EMP' ) SELECT s.ename , s.job , CASE WHEN LENGTH (s.ename) > l.ename_len THEN 'ENAME ' END || CASE WHEN LENGTH (s.job) > l.job_len THEN 'JOB ' END AS err_length FROM staging_table s JOIN got_lengths l ON LENGTH (s.ename) > l.ename_len OR LENGTH (s.job) > l.job_len ) src ON (src.ename = dst.ename) WHEN MATCHED THEN UPDATE SET dst.err_length = src.err_length ;
As you can see, you have to hardcode the names of the columns common to several places. I swam () to simplify that, but I found an interesting (at least for me) alternative grouping function involving the STRAGG user_defined.
As you can see, only the subquery USING is changed.MERGE INTO staging_table dst USING ( SELECT s.ename , s.job , STRAGG (l.column_name) AS err_length FROM staging_table s JOIN all_tab_columns l ON l.data_length < LENGTH ( CASE l.column_name WHEN 'ENAME' THEN ename WHEN 'JOB' THEN job END ) WHERE l.owner = 'SCOTT' AND l.table_name = 'EMP' AND l.data_type = 'VARCHAR2' GROUP BY s.ename , s.job ) src ON (src.ename = dst.ename) WHEN MATCHED THEN UPDATE SET dst.err_length = src.err_length ;
Instead of the user-defined STRAGG (that you can copy from AskTom), you can also use the undocumented, or from Oracle 11.2, WM_CONCAT LISTAGG built-in function.
-
Insert into multiple tables; Enter the id of the first
I apologize if this has been answered elsewhere, but I tried searching and got no results.
I try inserting the contents of a form in two tables. After you insert fields in a table, I want to enter the id of the first table key in the second table with the other fields.
I tried a few different things, including trying to use SCOPE_IDENTITY(), but just kept a lot of mistakes.
The current version of my code works perfectly, * except for the fact that it does not insert the ID *!
Can someone tell me what I am doing wrong? or offer another way to do this?
Thanks for your help, as usual.
Very well! I got it to work. Thank you very much! Here's what I ended up doing (I write just the code for INSERTs). I'll play with cfqueryparam some more later - thanks a lot for the valuable info!
-
Hi everyone, yet once landed upward with a problem.
After trying many things to myself, finally decided to post here...
I created a form in form builder 6i in which clicking on a button, the data gets exported to the excel sheet.
It works very well with a single table. The problem now is that I cannot do the same with 2 tables.
Because the tables have the same number of columns and the columns names.
Here are the 2 tables with column names:
Table-1 (MONTHLY_PART_1) Table-2 (MONTHLY_PART_2) SL_NO SL_NO MODEL MODEL END_DATE END_DATE U-1 U-1 U-2 U-2 U-4 U-4 .......... ........ .......... ........ U-20 U-20 U-25 U-25 Given that the tables have the same column names, I get the following error :
402 error at line 103, column 4
required aliases in the SELECT list of the slider to avoid duplicate column names.
So how to export data to excel that has 2 tables with the same number of columns and the column names?
Should I paste the code? Should I publish this query in 'SQL and PL/SQL ' Forum?
Help me with this please.
Thank you.
Wait a second... is this a kind of House of partitioning? Shouldn't it is a union of two tables instead a join?
see you soon
-
Fill a table with the results of the refresh groups
Hello world
I need a little help.
I'm working on an Oracle 10.2.0.4 on windows.
I have a table I created like this:
Table name: DIM_REPLICA
COD_SEZ VCHAR2 (2)
NOME_SEZ VCHAR2 (20)
FLAG TANK (1)
DATE OF D_REPLICA
This DB I have 210 discount groups running every night. I need fill this table with the results of the refresh groups.
So when the refresh for example called ROME group runs I need to write on the table the name ROME in the field "NOME_SEZ", a Y or N if the refresh Group has worked in the field of the INDICATOR and LAST_DATE refresh force ran into the field of the D_REPLICA. The COD_SEZ field is a code that I get other things. It is not necessary for the moment. I can add it myself on my own.
Can someone help me please?
I was looking on the tables SYS DBA_JOBS and DBA_REFRESH these data, but I don't know what to take and how to fill the table. Trigger? Procedure? Any help will be great!
Thank you all in advance!This forum is for SQL * PLus, questions and your question is about general issues Oracle. You will get a better response by posting your question in another forum - probably the General database instance.
Please close this thread and start over in another forum.
-
Drop a large number of tables with the same prefix
Hello
can you help me to make a script to move all the tables with the same prefix = TEST_LINK_?
Thank you very much.
CrystalHi crystal,
Here's something to start. It does not all FK constraints on those tables and assumes that the executor is the owner.
declare pstmt constant varchar2(255) := 'drop table :t purge'; vstmt varchar2(255); begin for rec in (select table_name from user_tables where table_name like 'TEST_LINK\_%' escape '\') loop vstmt := replace(pstmt, ':t', rec.table_name); dbms_output.put_line(vstmt || ';'); -- execute immediate vstmt; end loop; end; /
Concerning
Peter -
How to create the table with the rows and columns using the layout?
One of my friends advised me to put my site on the mode of provision as it is better than the standard as he said
but I couldnot make an ordinary table with the rows and columns in mode available th
y at - there someone who can tell me how to?
Thank you very muchWednesday, April 18, 2007 21:01:38 + 0000 (UTC), "Mr.Ghost".
wrote: > A friend of mine advised me to put my whole site on the mode of disposal as its
> better than standard, as he saysYour friend won't. Don't listen to him any more. Mode of disposal creates
very fragile and rigid code pauses at the first opportunity.Gary
-
It is possible to have two tables with the same name in Oracle!
Oracle Version: 10 gr 2
MS Access 2007, I had to use the 'Export' by which I copy a table (and its data) to an Oracle schema via an ODBC connection. Later, I realized that, during the copy of tables with a mix of lower and upper case names, the table does not copied (exported). But MS Access will give you the message that table obtained export successfully.
MS-Access mess around Oracle data dictionary.
When you issue
You will see the names of the tables. But when you try to DESCRIBE or SELECT this table, you willSQL>select * from tab; TNAME TABTYPE CLUSTERID ------------------------------ ------- ---------- AMStates TABLE Version TABLE
You can even create another table with the same name in the schemaSQL>desc Version ERROR: ORA-04043: object Version does not exist
Why this is happening and how can I bring these items 'non-existent '?SQL>create table VERSION (X NUMBER); Table created.
Hello
Use
SQL > desc 'Version '.
Or
SQL > select * from 'Version '.
Or
SQL > drop table 'Version '.
To overcome the problems of mixed-case.
-
OWB, I need to update the target table with the same field for game/update
OWb, I try to update the target table with the game and the update on the same ground is this possible. I'm a match merge error indicating that you cannot update and match on the same ground. But in SQl is my selection
Update table
define RFID = 0
where RFID = 1
and ID_processus = 'TEST '.
Can HWO I do this in OWB.I have check but in the case later (last one) that he warns no error if you can go with it.
and I tested it it worksYou can check the first case (from where we start) if it has been warned and then try to run.
-
CSS Display table with the bottom border only
Hi all
I'm very bad in CSS, I seriously need a style.
I want the table with the bottom border only
I tried like
< table frame = "below" cellpadding = "2px" cellspacing = "0" style = "overflow: scroll;" empty-cells: show; border: 1px solid #285577; "width ="350px"> ';
but frame = 'below' does not work with IE - 7
Please could give me a solution.
Thanks in advance
Good bye
Sonny_starckSonny_starck,
I don't know what kind of table you need exactly but
< table style = "" border-bottom: 1px solid #285577; ">"
should do the job.
Denes Kubicek
-------------------------------------------------------------------
http://deneskubicek.blogspot.com/
http://www.Opal-consulting.de/training
http://Apex.Oracle.com/pls/OTN/f?p=31517:1
------------------------------------------------------------------- -
Hello, in my office we recently bought printer HP Designjet T2500 and, so far, works great but I have a doubt with the procedure of the Analyzer in the case where the main panel is malfunctioning. How can I scan a document without the help of the main panel or a plan?
I know the printing can be done with the supplied software, but he made no reference to the case where we need to scan a document.
Any help will be great, thank you.
Hello
Analysis cannot be done froom the front panel of the printer.
If you have a problem with the Panel, you will need to repair the device because you won't be only able to scan, as you will not be able to load paper or calibrations.
-
Create temporary table in the procedure
I have a procedure which can be called at any time by multiple users. So I cann't use table in there, because on each call, the table is truncated and inserted. How can I create a temporary table in the procedure?
Temporary tables in Oracle are different from other RDBMS like SQL Server.
In Oracle, you create a global temporary table ONCE as part of the design of your database.
create a global temporary table MyTableName (... columns...) on commit preserve rows;
You can then use this table in your code as you would any other table.
The difference is that any data that you insert in this table are only available/visible so that the code runs in the session, and if delete you / truncate the table it only removes the data for this session. In this way, several sessions we can table without interfering with each other.
(Note: instead of "preserve" you can change this to "delete" If you want that deleted data automatically when a commit is issued in your session, otherwise the data will be automatically deleted at the end of the session)
Maybe you are looking for
-
Model: m6-1045dx laptop, cp1525nw printer wireless
Laptop: model: m6-1045dx B5S08UA #ABA Moving up to 15 years in router technology. A router dual-band would work with both of these? What I need to look for if I buy a new router fancy then try to connect with older hardware? Even a WII? Know any
-
Legit or a scam? -unsolicited from Windows Live Help calls
Help please! My just called and said she received a call from a compnay called Windows Live Help (I know what it is, I don't think they have made appeals to the people). Anyway, they said their servers showed that his IP address of the computer was h
-
Genuine key of Windows Vista Starter DVD already used after formatting PC!
I have a real DVD of Windows Vista Starter. It has been activated and worked very well. But after a few PC, formatting and reinstalling, it says key already used and I'll have a temporary profile with features in need! My copy is authentic and I have
-
My computer asks me what language I want in there, then it say's it's a startup repair.
My computer asks me what language I want in there, then it say's it's a startup repair. And nothing happens, it keeps the of saying I should send him the info at microsoft, but he's going through. What is the problem with my computer? Help I have a p
-
Date and avoid changes to my computer Compaq Mini CQ10
HelloW Microsoft Community, I've got this Compaq Mini CQ10, whose battery is dead. Its CMOS battery also died and I took a step to replace since when I turn my pc off and disconnect the power adapter and plug it back, turn on I display the Date and t