Insert Records in one table that's not in other table
Really need your help, I have spent the last five hours on the following code, but can't get it working. What I want done is INSERT records in persons where the same records do not exist in table new_person.
see the below error: rror at Command Line:1 Column:441
Error report:
SQL Error: ORA-00936: missing expression
00936. 00000 - "missing expression"
INSERT INTO person (last_name, first_name, mi, full_name, id_number, rank, rank_value, temporary, group_number, status, classification, hire_date, unit_code, phone_update, agency, username, agencycourtcode) select last, first_name, mi, full_name, id_number, rank, rank_value, temporary, group_number, status, classification, hire_date, unitcode, phone_update, 'MSP', 'MSP'||id_number, 'MSP' from new_person a where a.status= 'Active' AND where not exists (select last_name, first_name, mi, full_name, id_number, rank, rank_value, group_number, status, classification, hire_date, unit_code, phone_update, agency, username, agencycourtcode from person where a.id_number = person.id_number);
Please post your code using tags as this is pretty much unreadable. See instructions here: http://forums.oracle.com/forums/help.jspa
But it looks to me like your INSERT has 16 columns and your SELECT has 17, so you probably have something misaligned.
Also, you have AND WHERE NOT EXISTS, change it to AND NOT EXISTS.
Also, the select list in your NOT EXISTS subquery doesn't need all those columns. Just do a SELECT 1. Oracle doesn't care about the columns only whether a row exists.
Similar Messages
-
Can EJB 3.0 beans be used with tables that do not have a primary key?
Can a EJB 3.0 persistence bean be used with tables that do not have a primary key defined? I am building a test application based on the HowTo - Building EJB 3.0 Faces App paper posted after Openworld (schalk). The issue I am running into when trying to run the application is: Exception Description: Entity class [class com.persistence.Rpthead] has no primary key specified. Note: I get a simular error when using toplink directly.
The tables I am binding to do not have primary keys defined. They use unique constraints to manage the table integrity.
Is it possible to use EJB 3.0 on tables without a primary key? If not, are there plans to support this in the future?The spec requires a primary key Id annotation. I will take your suggestion to EJB 3.0 expert group.
Can you also send an email to [email protected] with your requirement?
-Debu -
PLSQL - Creating a cursor for a table that does not exist
I am writing my first PLSQL program, and I have run into a problem creating a cursor.
I have a cursor that accesses a table on another database via a database link. The database link does not yet exist, so the first thing that my PLSQL does is create the database link. The problem is that I have to define my cursor before I have executed the code for the database link, and the compiler gives me an error for referring to a table that does not yet exist. How can I get around this?
Here is the basic structure of my program
DECLARE
--cursor defined here
BEGIN
--code creates database link if it does not yet exist
--code executes cursor
ENDI'm still not sure I understand why the database link can't be created in advance... Once you run your code once, the database link is going to exist permanently. Why not just create it at compile time like every other object in your application?
It's sort of like trying to create a table at runtime-- if you do that, you can't refer to that table in static SQL later on. You can do everything with dynamic SQL, but that's going to substantially increase the complexity of your code.
Additionally, you have to have the CREATE DATABASE LINK privilege granted directly to the user running your code, not through a role, which seems like a huge security hole.
Justin -
Hi folks,
We are facing an issue here with a custom web dynpro application that export an excel. The following piece of code has been written in this application to export an excel:
cl_wd_runtime_services=>attach_file_to_response(
EXPORTING
i_filename = c_filename
i_content = xtext
i_mime_type = c_mimetype
i_in_new_window = abap_false
i_inplace = abap_false ).
Now, the issue is this - it works fine in one system but does not in other system. HttpWatch shows ERROR_HTTP_INVALID_SERVER_RESPONSE in the system where it does not work. Any ideas?
Regards,
ShiromaniHi Shiromani,
You mean "Other System" is other PC. If so, it seems that there is an issue with browser
Please check the below SAP note
1679126 - Server sends timeouts that cannot be reproduced
Also, compare the browsers versions in both systems.
Regards,
Rama -
When receiving a Group iMessage, i am only seeing one person's message, not the other.
Hi RumplestilskinToo!
You may need to check and make sure that your Group Messaging setting is turned on:
Messages settings - iPhone
http://help.apple.com/iphone/7/#/iphf2d853e3
Go to Settings > Messages to set options for Messages, including:
Turning iMessage on or off
Notifying others when you’ve read their messages
Specifying an Apple ID or email address to use with Messages
SMS and MMS options
Turning group messaging on or off
Showing the Subject field
Showing the character count
Blocking unwanted messages
Thanks for using the Apple Support Communities. Have a good one!
-Braden -
How can I get ALL of my Google Calendars to show on the iCal on my iPhone?
I see all of my Google Calendars on the iCal on my Mac, but I do not see them in the iCal on my iPhone. I only see one Google Cal, but not the others.https://www.google.com/calendar/iphoneselect
-
How we can restrict record in CTL file on the basis of other table ?
Hello all,
How we can restrict record in CTL file on the basis of other table ?
Eg.
I have following control file to load the records in the table through the sql loader.
LOAD DATA
INTO TABLE THIST APPEND
FIELDS TERMINATED BY "|" TRAILING NULLCOLS
LNUM POSITION(1) Char "substr(:LOAN_NUM, 4, 13)",
TSRNUM Char "rtrim:TRAN_SR_NUM)" ,
TPROCDT Char "to_char(to_date rtrim:TRAN_PROC_DT), 'MMDDYYYY'), 'YYYYMMDD')"
I have another table c all TFILE in which I have LNUM. I want to import only those records from input text file using the control file and sql loader in which LNUM is exist in the TFILE.
So how i can restrict it in the Control File.
Thanks
Kamlesh Gujarathi
[email protected]Hello Satyaki De.
Thank you very much for your suggestion but my Private information is totally apart from this question & I already I have changed each and every information from the question.
Thanks
Kamlesh Gujarathi
[email protected] -
Create Trigger to insert records from one table to another
I created the below trigger to move data from one table to another after records have been inserted from another table to that table. What I need done is that each time records have been inserted into TEST_TBL, one of these actions codes should be implimented: U-update, N-insert, D-delete and inserted into TEST_TBL1. But each time I run the script, I get bunch of errors. Please see the script below: - Your help will be appreciated.
create or replace
trigger POWER_tr
after update or insert or delete ON test_tbl
for each row
begin
if updating then
insert into test_tbl1
(idx, mke, ctl, ori, nam, sex, rac, pob, dob, hgt, action_code, date_added
VALUES
(idx, mke, ctl, ori, nam, sex, rac, pob, dob, hgt, 'U', sysdate);
ELSif INSERTING then
insert insert into test_tbl1
(idx, mke, ctl, ori, nam, sex, rac, pob, dob, hgt, action_code, date_added
VALUES
(idx, mke, ctl, ori, nam, sex, rac, pob, dob, hgt, 'N', sysdate);
ELSIF deleting then
insert into test_tbl1
(idx, mke, ctl, ori, nam, sex, rac, pob, dob, hgt, action_code, date_added
VALUES
(idx, mke, ctl, ori, nam, sex, rac, pob, dob, hgt, 'D', sysdate);
END IF;
END POWER_tr;
Thank you,
Albert Zaza
Edited by: azaza on Mar 1, 2009 4:14 PMHello
At the end of trigger show errors / and post what errors are you getting exactly?
Here is a simple example for your reference, this will save old values in history table; you can replace it with new values if that's what do you want.
CREATE OR REPLACE TRIGGER TRG_DU
AFTER DELETE OR UPDATE
ON EMPLOYEE REFERENCING NEW AS New OLD AS Old
FOR EACH ROW
DECLARE
BEGIN
IF UPDATING
THEN
INSERT INTO employee_hist
VALUES ('UPDATE',
:OLD.empid,
:OLD.name,
:OLD.deptid);
ELSIF DELETING
THEN
INSERT INTO employee_hist
VALUES ('UPDATE',
:OLD.empid,
:OLD.name,
:OLD.deptid);
END IF;
EXCEPTION
WHEN OTHERS
THEN
-- Consider logging the error and then re-raise
RAISE;
END TRG_DU;
/Regards
Edited by: OrionNet on Mar 1, 2009 7:27 PM -
Insert record from one table to another with help of cursor
Plz help!!!
tables are - 1. country( country_id pk, country_name, region_id)
2. a( country_id , country_name, region_id)
table a data are
1 a 1
2 b 2
3 c 3
null d 4
5 e 5
6 f 6
7 g 7
insert record from table a to country table with help of cursor, insert all not null records.
this procedure does not give correct result
create or replace
procedure amit as
cursor c1 is select * from a;
rw a%rowtype;
begin
open c1;
fetch c1 into rw;
while(c1%found)
loop
insert into countries values(rw.country_id,rw.country_name,rw.region_id);
commit;
fetch c1 into rw;
if rw.country_id is null then
fetch c1 into rw;
end if;
end loop;
close c1;
exception
when others then
dbms_output.put_line('exception name= '||rw.country_name);
end;bluefrog wrote:
You don't need cursor at all;
create or replace procedure amit as
begin
insert into countries (Country_ID, Country_Name, Region_ID)
(select a.Country_ID
,a.Country_Name
,a.Region_ID
from a
dbms_output.put_line('Rows inserted : ' || sql%rowcount);
commit;
end;
Bluefrog you missed where clause. :)
insert into countries (Country_ID, Country_Name, Region_ID)
(select a.Country_ID
,a.Country_Name
,a.Region_ID
from a
where country_id is not null
); -
Best way to obtain records that are NOT in another table
I have two rather large tables in oracle. An Account table that has millions of rows. Each account may be enrolled into a particular program and therefore can also be in an Enrollment table, also with millions of rows. I'm trying to find the most optimal way to find any accounts in ACCOUNT that are NOT in the Enrollment table.
I was doing something like this:
select /*+ index(ACCOUNT idx_acct_no) */
a.acct_no
from ACCOUNT a
where a.acct_no not in (Select e.acct_no from ENROLLMENT e);
This takes a VERY long time to execute, even though I am using the index.
I even tried to use the PK on the ACCOUNT table, as it is also a FK on the ENROLLMENT table as such:
select a.acct_no
from ACCOUNT a
where a.id not in (Select e.id from ENROLLMENT e);
this too takes too long to get back (if at all).
Is there a better way to do this selection please?Well if you have the energy to type in the whole list, the syntax you've given will work, unless you blow the permitted number of elements.
But a practical solution would be to turn the list into a table. You still haven't got the hang of this "giving us enough information" concept, so let's presume:
(1) you're on a version of the databasse whoch is 9i or higher
(2) you have this list in a file of some sort.
In which case use an external table or perhaps a pipelined function to generate output which can be used in a SQL statement.
If neither of these solutions works for you please provide sufficient information for us to answer your question correctly. Your future co-operation is appreciated.
cheers, APC -
Answers shows error for table that is not used in query
Hi,
I have two fact tables, both share one common dimension and also have other dimensions. For simplicity let's assume there are only two dimensions for each fact: Dim1 and Dim2 have joins to Fact1 and Dim2 and Dim3 joins to Fact2. (Dim2 is joined to both).
When I query in answers aggregated data from Dim2, Fact1 and Fact2 everything is ok. When I query data from Dim2 and only Fact1 also everything looks fine, however when I query data from Dim1 and Fact1 I get error about Fact2
Error Codes: OPR4ONWY:U9IM8TAC:OI2DL65P
State: HY000. Code: 10058. [NQODBC] [SQL_STATE: HY000] [nQSError: 10058] A general error has occurred. [nQSError: 15018] Incorrectly defined logical table source (for fact table fakti - Grāmatojumu rindas) does not contain mapping for [dim - Piegādātājs.Hansa kods]. (HY000)
SQL Issued: SELECT "dim - Piegādātājs"."Hansa kods" saw_0, "fakti - Piegādātāju rēķinu rindas"."Summa ar PVN (LVL)" saw_1 FROM "Kreditori single source" ORDER BY saw_0
As you can see table "fakti - Grāmatojumu rindas" is even not shown in SQL Issued.
One more thing - if I first query data from Dim1, Dim2 and Fact1, look at results and afterwards delete Dim2 (leaving Dim1 and Fact1) then query returns data without error.
Must be that error is in Business Layer, but I have no idea what should I do to correct it.Sveiks!
I am not really sure what could have caused this. And, obviously, rebuilding the repository helped.
It seems you could get it to work if you queried dim1, dim2 and fact and then removed dim2 (like you said). So, that suggests something almost on the order of a glitch or, possibly, a bug. The fact that simply rebuilding the repository helped seems to support my glitch hunch, but I am not really sure.
I am relatively new to this product, and the only thing I can suggest as far as business model goes is to pay attention to any warnings when you do "Check Global Consistency". Sometimes, things work even with warnings, but you might encounter strange problems down the line.
-sb -
Select multiple row in a table that are not connected
I want to be able to select multiple rows, but want to be able to select rows that are not next to each other. They maybe have one or two rows between. Is there anyway to do this in a table?
ThanksSo do a lot of other people, but you can’t.
Tell Adobe here: https://www.adobe.com/cfusion/mmform/index.cfm?name=wishform
Bob -
Record disappear on the form, but not in the table
Hi,
I have a main form which ties to table tab1 and subform which ties to table
tab2
User entered a record in the main form and not completely finished and go to another form and try to setup something else. And click "Refresh All"
When the user went back to the main form, the record is lost on the form, but the record in tab1, I think information of the subform is not entered, and maybe because it is an inner join, that's it is not shown on the form?
Please advice how I can fix this or how we can prevent this in the future.
Thanks in advance.I think you are right about the inner join causing the problem. Can you post the SQL of the query you are using as the main form's record source? Usually, when you have a main form/sub form setup, each form has a table (not a query) as its record source.
If you set up the master/child links between the two it becomes an implied outer join.
Bill Mosca
www.thatlldoit.com
http://tech.groups.yahoo.com/group/MS_Access_Professionals -
I have 2 iPods one I don't use anymore. I would like to make a new account for one but not the other. Is that possible? If I wipe the memory in one will the other wipe out too? How can I do all of this?
You don't have to do anything with the first iPod that you don't use anymore. If you are planning on keeping it, put in a drawer in your house and forget about it.
You don't need a second account to use with the new iPod. I use one Appl e ID and iTunes library for two iPods, and two iPad. I have different content on all four devices. You can select exactly what you want to sync to each device and it can be different content on all devices. -
I have one website that will not let me open the emails within in it?
I am on a dating website Christianmingle.com Up until 3 days ago this site worked fine? All other sites within my internet are working and opening fine. Just this site will not let me open the internet information and emails within this site?
After a couple of attempts I can get into the site. This is one problem that I cannot open this site like it is suppose to. Then when try to open information within the site it fills the work bar to about 90% then it just keeps working and nothing opens?
I have tried the cookies, pop-up blocker, called the site for help and called Xfinity? They can do nothing? Maybe you can help me it has to be something simple?
Let me know
Thanks- Try contacting iTunes for the password problem:
Apple - Support - iTunes - Contact Us
- For the other problem you can try a reset. Nothing will be lost
Reset iPod touch: Hold down the On/Off button and the Home button at the same time for at
least ten seconds, until the Apple logo appears.
- The next standard thing to do is to download/install a new app but you cant 'do that.
- Instead, try restoring from backup.
Maybe you are looking for
-
The agency I work for is currently using CS3, but there is a debate about upgrading to CS4 or to CS5. Because we work with a lot of print pieces one of the concerns is that most printers are probably still on CS4 so we shouldn't be more advanced than
-
Using visual studio entity frameworks in crystal reports
Can visual studio entity frameworks be used in designing crystal reports?
-
Sql loader control file path........
Hello all, I am running the below query through sql loader from client machine..... saved the below query in loader.ctl file, which I kept in "D:\loader.ctl" path.... options (skip=1) load data infile 'D:\flat.txt' into table GL_INTERFACE fields term
-
How to read Exchange Emails Offline?
On Apples site it says there should be an Advanced Option. I want to store my sent and inbox emails complete off-line on my iphone. However, whenever I read an email it's "talking" to the server.. Help.. Thanks.
-
Exception condition "INVALID_POS"
Hi, I am getting the error while monitoring the outbound queue in SMQ1 very rarely as FM-------"BBP_NOTIFY_FOLLOWON_INBOUND" with exception condition "INVALID_POS". Kindly assit me what could be the reason for this error. regards, Kannan B