Data Missing in table FAGLFLEXA
Hi,
I noticed that table FAGLFLEXA does not match with table BSEG. This is visible in certain P&L accounts. As a result of this values in FBL3N and FAGLB03. Also since we use table FAGLFLEXA to pull in financial data for BI there is an inconsistency. What can be done to correct table FAGLFLEXA as BSEG so that the data pulled for BI is correct??
Looking forward to hear a solution!
Thanks,
Maleeq
Dear Ricardo and All,
After reading the series of answers in this post i too have a similar issue (which is most burning), request your kind help on this.
When trial balance is extracted profit center wise in F.01 - Tcode there is some amount shown under accounts not assigned head.
Up on investigation, we learnt that all the GL masters are perfectly assigned to financial statement version, and this data is missing only in GL View for business area clearing for some documents, where profit center is missing in these automatically generated line item.
Hence please tell us how to solve this and remove that amount under unassigned head. Its bit urgent please...
Thanks and Regards
Nagendra
Similar Messages
-
FAGLFLEXA and BKPF data missing
Hi ,
End user unable to print the accounting document since data missing in FAGLFLEXA and BKPF table for the ledger type OL.
Transaction code "/SOL/FI_CN_VOUCHER", I guess it is an program issue we have to include the OL .
Please advise how to fix this issue.
Regards,
Udaya Kumar.KDear Udaya,
Check whether scenario has been transported to the system properly. If you have scenarion missing in the configuration, you will have data inconsistencies. It is depending upon your Document Spiliting conditin and no of parallel ledger etc.
If all customization are correct, then I don't know if it is usefull for you or not but it may be correct all data.
FAGL_DELETE_RELOAD_LEDGERS, run it in SA38 and everything will be all right.
There are other programs you can find usefull RGURECGLFLEX and FAGL_DELETE_DOCUMENT.
I hope it helps you.
With regards,
Uttam Maity -
Insert old missing data from one table to another(databaase trigger)
Hello,
i want to do two things
1)I want to insert old missing data from one table to another through a database trigger but it can't be executed that way i don't know what should i do in case of replacing old data in table_1 into table_2
2)what should i use :NEW. OR :OLD. instead.
3) what should i do if i have records exising between the two dates
i want to surpress the existing records.
the following code is what i have but no effect occured.
CREATE OR REPLACE TRIGGER ATTENDANCEE_FOLLOWS
AFTER INSERT ON ACCESSLOG
REFERENCING NEW AS NEW OLD AS OLD
FOR EACH ROW
DECLARE
V_COUNT NUMBER(2);
V_TIME_OUT DATE;
V_DATE_IN DATE;
V_DATE_OUT DATE;
V_TIME_IN DATE;
V_ATT_FLAG VARCHAR2(3);
V_EMP_ID NUMBER(11);
CURSOR EMP_FOLLOWS IS
SELECT EMPLOYEEID , LOGDATE , LOGTIME , INOUT
FROM ACCESSLOG
WHERE LOGDATE
BETWEEN TO_DATE('18/12/2008','dd/mm/rrrr')
AND TO_DATE('19/12/2008','dd/mm/rrrr');
BEGIN
FOR EMP IN EMP_FOLLOWS LOOP
SELECT COUNT(*)
INTO V_COUNT
FROM EMP_ATTENDANCEE
WHERE EMP_ID = EMP.EMPLOYEEID
AND DATE_IN = EMP.LOGDATE
AND ATT_FLAG = 'I';
IF V_COUNT = 0 THEN
INSERT INTO EMP_ATTENDANCEE (EMP_ID, DATE_IN ,DATE_OUT
,TIME_IN ,TIME_OUT,ATT_FLAG)
VALUES (TO_NUMBER(TO_CHAR(:NEW.employeeid,99999)),
TO_DATE(:NEW.LOGDATE,'dd/mm/rrrr'), -- DATE_IN
NULL,
TO_DATE(:NEW.LOGTIME,'HH24:MI:SS'), -- TIME_IN
NULL ,'I');
ELSIF V_COUNT > 0 THEN
UPDATE EMP_ATTENDANCEE
SET DATE_OUT = TO_DATE(:NEW.LOGDATE,'dd/mm/rrrr'), -- DATE_OUT,
TIME_OUT = TO_DATE(:NEW.LOGTIME,'HH24:MI:SS'), -- TIME_OUT
ATT_FLAG = 'O'
WHERE EMP_ID = TO_NUMBER(TO_CHAR(:NEW.employeeid,99999))
AND DATE_IN <= (SELECT MAX (DATE_IN )
FROM EMP_ATTENDANCEE
WHERE EMP_ID = TO_NUMBER(TO_CHAR(:NEW.employeeid,99999))
AND DATE_OUT IS NULL
AND TIME_OUT IS NULL )
AND DATE_OUT IS NULL
AND TIME_OUT IS NULL ;
END IF;
END LOOP;
EXCEPTION
WHEN OTHERS THEN RAISE;
END ATTENDANCEE_FOLLOWS ;
Regards,
Abdetu..INSERT INTO SALES_MASTER
( NO
, Name
, PINCODE )
SELECT SALESMANNO
, SALESMANNAME
, PINCODE
FROM SALESMAN_MASTER;Regards,
Christian Balz -
Creation of a generic extractor and data source for the FAGLFLEXA table
Hi All,
Need to create a generic extractor and data source for the FAGLFLEXA table to support AR reporting. This table contains the necessary profit center information to perform LOB reporting against the AR data.
Please advice on how to do this.
Regards, VishalHi Vishal,
Its seems a simple a work out.
1.Go to RSO2 & choose the relevant option ie. whether you want to create Transactional DS, Master Data DS or Text DS.
2. Name it accordingly & then create.
3. Give description to it & then give table name FAGLFLEXA.
4. Save it & activate. If you need it to be delta enabled then click over Delta & you can choose accordingly.
If you still face some problem then do mail me at [email protected]
Assign points if helpful
Regards,
Himanshu -
Selecting Missing Days from a given range of Date from a table
Dear Oracle Guru's
Consider the following table
txndetails
Rundate date
Txncnt Number
userid varchar2(100)
Data will be as follows
Rundate txncnt userid
17-Nov-2009 4 admin
18-Nov-2009 7 admin
21-Nov-2009 3 admin
23-Nov-2009 4 admin
We populate this table on the basis of txn generated. This is supposed to run daily based on the transactions. Certain days there wont be any transaction at all. hence there will be no entry on this table .
At any given point of time , we would like to know the days on which there is no entries in this table
In the above sample data, there is no entries on 19th, 20th and 22nd
we have to list out those days
I got confused while trying some methods
Kindly guide me in this regard
with warm regards
SsrHi,
As Centinul and Bhushan said, you need a list of all the possible dates; "CONNECT BY LEVEL <= x" is an efficient way to generate such a list in Oracle SQL.
Once you have the list of all days, you can use MINUS, like Centinul or Bhushan did. You can also use an outer join, as shown below.
WITH extrema AS
SELECT TRUNC (MIN (rundate)) AS start_date
, TRUNC (MAX (rundate)) AS end_date
FROM txndetails
all_days AS
SELECT start_date + LEVEL - 1 AS a_date
, start_date + LEVEL AS next_date
FROM extrema
CONNECT BY LEVEL <= 1 + end_date - start_date
SELECT a.a_date
FROM all_days a
LEFT OUTER JOIN txndetails t ON t.rundate >= a.a_date
AND t.rundate < a.next_date
WHERE t.rundate IS NULL
;Remember that all DATEs include hours, minutes and seconds. In the list of all days that you generate, the hours, minutes and seconds will probably be 00:00:00; be careful if the hours, minutes and seconds in your actual DATEs are not always 00:00:00.
The query above shows missing dates between the first date that is actually in the table and the last date in the table.
In practice, most people are interested in a deffierent range, such as all dates between two given parameters, or all dates within the last year.
If that's the case, you don't need the sub-query extrema; you can use the paremters (or compute the values) in all_days, based on dual.
For example, to get the most recent 365 days:
WITH all_days AS
SELECT TRUNC (SYSDATE) + LEVEL - 365 AS a_date
, TRUNC (SYSDATE) + LEVEL - 364 AS next_date
FROM dual
CONNECT BY LEVEL <= 365
SELECT a.a_date
... -- Same as beforeEdited by: Frank Kulash on Nov 23, 2009 10:54 AM -
(R11) HOW TO FIX MISSING CM DATA IN AR_PAYMENT_SCHEDULES_ALL TABLE
제품 : FIN_AR
작성날짜 : 2004-11-09
(R11) HOW TO FIX MISSING CM DATA IN AR_PAYMENT_SCHEDULES_ALL TABLE
==================================================================
PURPOSE
Credit Memo data가
AR_PAYMENT_SCHEDULES_ALL TABLE과 AR_RECEIVABLE_APPLICATIONS_ALL 에 생성
이 되어 있지 않는 경우 datafix script 으로 해결할 수 있도록 한다.
Problem Description
주로 타 시스템에서 autoinvoice 를 통해 넘어온 cm data에서 자주 발생하는 문제로 credit transaction 화면을 통해 보았을때 100% 로 applied 된 credit memo 임에도 applied 된 transaction의 balance에 전혀 영향을 주지 않는다.
cm_info_11.sql 을 수행해 보면 ar_payment_schedules_all table과 ar_receivable_applications_all table에 해당 데이타가 존재하지 않음을 알수 있다.
Workaround
Solution Description
1. AR Support Script Page (http://eastapps.us.oracle.com/appsar/SQL/SQL.htm) 에서 trx.sql과 pay.sql을 download 받는다. 이때 홈페이지 상의 90 Days, 150 Days 등은 transaction date scope을 의미한다. 즉 현재일로 부터 90일전까지의 transaction인 경우는 trx.sql을 150 일전까지의 transaction인 경우는 trx150.sql 을 download 받아야 한다.
2. trx.sql 을 수행한다.
3. trx.sql 수행시 생성되는 trx_<trx_id>.log 를 trx.sql 로 rename하여 다시 수행한다.
4. 정상적으로 수행되었는지 확인 후 pay.sql을 수행한다.
5. pay_<ps_id>.log 를 pay.sql로 rename한 후 수행한다.
Reference Documents
BUG 1401610'ORA-29278: SMTP transient error: 421 Service not available' --> "Oracle had a problem communicating with the SMTP server"
Did you check:
How I can resolve the error " 421 Service not available"
Also look at document id 604763.1
Edited by: MccM on Feb 23, 2010 11:38 AM -
Missing Data in JCO.Table passed as Function Parameter
I am running a JCO server & in my handleRequest(), I am trying to get the data from the tables paased as function parameters from the SAP system.
Somehow I am not able to see any data in the tables, though the SAP system has put some data in the tables before sending.
The no. of rows in the table is 0 always on the JCO side. I tried to dunp the content of the Function & Table with writeHTML() & it shows no data too.
I am able to pass simple strings & integers, but the tables doesn't work. Can anyone tell me where might be the problem.Can you post the code you have used !
-
Error while selecting date from external table
Hello all,
I am getting the follwing error while selecting data from external table. Any idea why?
SQL> CREATE TABLE SE2_EXT (SE_REF_NO VARCHAR2(255),
2 SE_CUST_ID NUMBER(38),
3 SE_TRAN_AMT_LCY FLOAT(126),
4 SE_REVERSAL_MARKER VARCHAR2(255))
5 ORGANIZATION EXTERNAL (
6 TYPE ORACLE_LOADER
7 DEFAULT DIRECTORY ext_tables
8 ACCESS PARAMETERS (
9 RECORDS DELIMITED BY NEWLINE
10 FIELDS TERMINATED BY ','
11 MISSING FIELD VALUES ARE NULL
12 (
13 country_code CHAR(5),
14 country_name CHAR(50),
15 country_language CHAR(50)
16 )
17 )
18 LOCATION ('SE2.csv')
19 )
20 PARALLEL 5
21 REJECT LIMIT UNLIMITED;
Table created.
SQL> select * from se2_ext;
SQL> select count(*) from se2_ext;
select count(*) from se2_ext
ERROR at line 1:
ORA-29913: error in executing ODCIEXTTABLEOPEN callout
ORA-29400: data cartridge error
KUP-04043: table column not found in external source: SE_REF_NO
ORA-06512: at "SYS.ORACLE_LOADER", line 19It would appear that you external table definition and the external data file data do not match up. Post a few input records so someone can duplicate the problem and determine the fix.
HTH -- Mark D Powell -- -
Not able to get the data in COSB Table
Hi Colleagues,
I have created a Project and assign the WBS number to a Sales order and also have done all the settings in Result Analysis.
But still not able to get the data in COSB table.
Could you please suggest me the steps and process, Might be i have missed something..
Thanks in Advance
Regards
NitinHi Ken,
I have below mentioned requirement
COSB will show value by object number and need to pass the object number to PRPS table to find the corresponding WBS element and then pass the WBS element to VBAP table to find the corresponding SO line item.
Please let me know as Functional prospect what I have to do to bring this values in COSB table.
Regards
Nitin -
Trading partner Data missing in FBL3N report for GL stock account
Hi All,
Can anyone help me identify the reasons why I am not able to view trading partner data when I run FBL3N t-code to view the line items of my GL stock account?
Many Thanks in Advance for your help,
VigneshHi ,
When I am able to view the Trading partner details when I run customised program (which pulls data from customised table). May I know the reason why I am not able to find out the same details when I run FBL3N T-code?
In the given case, I pulled out details of stock by trading partner by running a customised program. I expected the same by running FBL3N for Stock GL account. But the details of trading partner is missing for many line items
Many Thanks in Advance for your help,
Vignesh -
Error while Inserting data into flow table
Hi All,
I am very new to ODI, I am facing lot of problem in my 1st interface. So I have many questions here, please forgive me if it has irritated to you.
========================
I am developing a simple Project to load a data from an input source file (csv) file into a staging table.
My plan is to achieve this in 3 interfaces:
1. Interface-1 : Load the data from an input source (csv) file into a staging table (say Stg_1)
2. Interface-2 : Read the data from the staging table (stg_1) apply the business rules to it and copy the processed records into another staging table (say stg_2)
3. Interface-3 : Copy the data from staging table (stg_2) into the target table (say Target) in the target database.
Question-1 : Is this approach correct?
========================
I don't have any key columns in the staging table (stg_1). When I tried to execute the Flow Control of this I got an error:
Flow Control not possible if no Key is declared in your Target Datastore
With one of the response (the response was - "FLOW control requires a KEY in the target table") in this Forum I have introduced a column called "Record_ID" and made it a Primary Key column into my staging table (stg_1) and my problem has been resolved.
Question-2 : Is a Key column compulsary in the target table? I am working in BO Data Integrator, there is no such compulsion ... I am little confused.
========================
Next, I have defined one Project level sequence. I have mapped the newly introduced key column Record_Id (Primary Key) with the Project level sequence. Now I am got another error of "CKM not selected".
For this, I have inserted "Insert Check (CKM)" knowledge module in my Project. With this the above problem of "CKM not selected" has been resolved.
Question-3 : When is this CKM knowledge module required?
========================
After this, the flow/interface is failing while loading data into the intermediar ODI created flow table (I$)
1 - Loading - SS_0 - Drop work table
2 - Loading - SS_0 - Create work table
3 - Loading - SS_0 - Load data
5 - Integration - FTE Actual data to Staging table - Drop flow table
6 - Integration - FTE Actual data to Staging table - Create flow table I$
7 - Integration - FTE Actual data to Staging table - Delete target table
8 - Integration - FTE Actual data to Staging table - Insert flow into I$ table
The Error is at Step-8 above. When opened the "Execution" tab for this step I found the message - "Missing parameter Project_1.FTE_Actual_Data_seq_NEXTVAL RECORD_ID".
Question-4 : What/why is this error? Did I made any mistake while creating a sequence?Everyone is new and starts somewhere. And the community is there to help you.
1.) What is the idea of moving data from stg_1 and then to stg_2 ? Do you really need it for any other purpose other than move data from SourceFile to Target DB.
Otherwise, its simple to move data from SourceFile -> Target Table
2.) Does your Target table have a Key ?
3.) CKM (Check KM) is required when you want to do constraint validation (Checking) on your data. You can define constraints (business rules) on the target table and Flow Control will check the data that is flowing from Source File to Target table using the CKM. All the records that donot satisfy the constraint will be added to E$ (Error table) and will not be added to the Target table.
4.) Try to avoid ODI sequences. They are slow and arent scalable. Try to use Database sequence wherever possible. And use the DB sequence is target mapping as
<%=odiRef.getObjectName( "L" , "MY_DB_Sequence_Row" , "D" )%>.nextval
where MY_DB_Sequence_Row is the oracle sequence in the target schema.
HTH -
Issue with using BAPI_ACC_DOCUMENT_POST to write to table FAGLFLEXA.
Hi,
I'm using BAPI_ACC_DOCUMENT_POST to do intercompany posting. The posting is successful and I got the document created. The only problem is data is not written into table FAGLFLEXA. I searched in the forum and it said to make us of BTE RWBAPI01 to pass in the ledger to the document header. I have tried that, but that only writting the ledger to the document header in BKPF, still the data is not writting to the FAGLFLEXA table.Hi,
I'm having the same problem. Could you solve this?
Thank you in advance.
Andrea -
How to populate data of two tables in a single block
In form developer2000, I have created a block using one table and have created two new items in that block manually that will collect data from another table.
How can I fetch data for the first table using execute_query as the same time collect data for the two manuly created items from the 2nd table?You can have two entities as base for a ViewObject.
Every entity maps to a Table in the database. You create two entities, one for each table.
You create one ViewObject based on those two entities.
Is that what you had in mind?
And what do you mean by 'two manually created items'?
Sorry i never used Form developer2000
Regards
Johan
EDIT:
I think i miss understood your post completly. I thought you where asking how to do this in JDeveloper. But you are using developer 2000. I think you better post your question in Developer tools >> Forms
Message was edited by:
Smolders Johan -
SAP Script - How to write data in a table format.
Hi All,
In my requirement, I need to show item data in a table format ( In a box, with horizental & veritcal lines.
can somebody pl give me a small code to do this.
Regards,
HardikHi
SCRIPT BOXES
POSITION WINDOW
SIZE WIDTH '160' MM HEIGHT '140' MM
BOX FRAME 10 TW
Box
BOX HEIGHT '11' MM WIDTH '160' MM FRAME 10 TW INTENSITY 35
linessssssss
BOX XPOS '20' MM WIDTH 0 TW HEIGHT '140' MM FRAME 10 TW
BOX XPOS '45' MM WIDTH 0 TW HEIGHT '140' MM FRAME 10 TW
BOX XPOS '80' MM WIDTH 0 TW HEIGHT '140' MM FRAME 10 TW
BOX XPOS '120' MM WIDTH 0 TW HEIGHT '140' MM FRAME 10 TW
Boxes, Lines, Shading: BOX, POSITION, SIZE
Use the BOX, POSITION, and SIZE commands for drawing boxes, lines, and shading to print particular windows within a form or passages of text within a window in a frame or with shading.
The SAP printer drivers that are based on page-oriented printers (the HP LaserJet driver HPL2, the Postscript driver POST, the Kyocera Prescribe driver PRES) employ these commands when printing. Line printers and page-oriented printers not supported in the standard ignore these commands. You can view the resulting printer output in the SAPscript print preview.
Syntax:
/: BOX [XPOS] [YPOS] [WIDTH] [HEIGHT] [FRAME] [INTENSITY]
/: POSITION [XORIGIN] [YORIGIN] [WINDOW] [PAGE]
/: SIZE [WIDTH] [HEIGHT] [WINDOW] [PAGE]
BOX Command
Syntax
/: BOX [XPOS] [YPOS] [WIDTH] [HEIGHT] [FRAME] [INTENSITY]
Effect: draws a box of the specified size at the specified position.
Parameters: For each of XPOS, YPOS, WIDTH, HEIGHT, and FRAME, you must specify both a measurement and a unit of measurement. Specify the INTENSITY parameter as a percentage between 0 and 100.
XPOS, YPOS
Upper left corner of the box, relative to the values of the POSITION command.
Default: Values specified in the POSITION command.
The following calculation is performed internally to determine the absolute output position of a box on the page:
X(abs) = XORIGIN + XPOS
Y(abs) = YORIGIN + YPOS
WIDTH
Width of the box. Default: WIDTH value of the SIZE command.
HEIGHT
Height of the box. Default: HEIGHT value of the SIZE command.
FRAME
Thickness of frame.
Default: 0 (no frame).
INTENSITY
Grayscale of box contents as %.
Default: 100 (full black)
Measurements: You must specify decimal numbers as literal values (like ABAP numeric constants) by enclosing them in inverted commas. Use the period as the decimal point character. See also the examples listed below.
Units of measurement: The following units of measurement may be used:
TW (twip)
PT (point)
IN (inch)
MM (millimeter)
CM (centimeter)
LN (line)
CH (character).
The following conversion factors apply:
1 TW = 1/20 PT
1 PT = 1/72 IN
1 IN = 2.54 CM
1 CM = 10 MM
1 CH = height of a character relative to the CPI specification in the form header
1 LN = height of a line relative to the LPI specification in the form header
/: BOX FRAME 10 TW
Draws a frame around the current window with a frame thickness of 10 TW (= 0.5 PT).
/: BOX INTENSITY 10
Fills the window background with shading having a gray scale of 10 %.
/: BOX HEIGHT 0 TW FRAME 10 TW
Draws a horizontal line across the complete top edge of the window.
/: BOX WIDTH 0 TW FRAME 10 TW
Draws a vertical line along the complete height of the left hand edge of the window.
/: BOX WIDTH '17.5' CM HEIGHT 1 CM FRAME 10 TW INTENSITY 15
/: BOX WIDTH '17.5' CM HEIGHT '13.5' CM FRAME 10 TW
/: BOX XPOS '10.0' CM WIDTH 0 TW HEIGHT '13.5' CM FRAME 10 TW
/: BOX XPOS '13.5' CM WIDTH 0 TW HEIGHT '13.5' CM FRAME 10 TW
Draws two rectangles and two lines to construct a table of three columns with a highlighted heading section.
POSITION Command
Syntax
/: POSITION [XORIGIN] [YORIGIN] [WINDOW] [PAGE]
Effect: Sets the origin for the coordinate system used by the XPOS and YPOS parameters of the BOX command. When a window is first started, the POSITION value is set to refer to the upper left corner of the window (default setting).
Parameters: If a parameter value does not have a leading sign, then its value is interpreted as an absolute value, in other words, as a value that specifies an offset from the upper left corner of the output page. If a parameter value is specified with a leading sign, then the new value of the parameter is calculated relative to the old value. If one of the parameter specifications is missing, then no change is made to this parameter.
XORIGIN, YORIGIN
Origin of the coordinate system.
WINDOW
Sets the values for the left and upper edges to match those of the current window (default setting).
PAGE
Sets the values for the left and upper edges to match those of the current output page (XORIGIN = 0 cm, YORIGIN = 0 cm).
/: POSITION WINDOW
Sets the origin for the coordinate system to the upper left corner of the window.
/: POSITION XORIGIN 2 CM YORIGIN '2.5 CM'
Sets the origin for the coordinate system to a point 2 cm from the left edge and 2.5 cm from the upper edge of the output page.
/: POSITION XORIGIN '-1.5' CM YORIGIN -1 CM
Shifts the origin for the coordinates 1.5 cm to the left and 1 cm up.
SIZE Command
Syntax
/: SIZE [WIDTH] [HEIGHT] [WINDOW] [PAGE]
Effect: Sets the values of the WIDTH and HEIGHT parameters used in the BOX command. When a window is first started, the SIZE value is set to the same values as the window itself (default setting).
Parameters: If one of the parameter specifications is missing, then no change is made to the current value of this parameter. If a parameter value does not have a leading sign, then its value is interpreted as an absolute value. If a parameter value is specified with a leading sign, then the new value of the parameter is calculated relative to the old value.
WIDTH, HEIGHT
Dimensions of the rectangle or line.
WINDOW
Sets the values for the width and height to the values of the current window (default setting).
PAGE
Sets the values for the width and height to the values of the current output page.
/: SIZE WINDOW
Sets WIDTH and HEIGHT to the current window dimensions.
/: SIZE WIDTH '3.5' CM HEIGHT '7.6' CM
Sets WIDTH to 3.5 cm and HEIGHT to 7.6 cm.
/: POSITION WINDOW
/: POSITION XORIGIN -20 TW YORIGIN -20 TW
/: SIZE WIDTH +40 TW HEIGHT +40 TW
/: BOX FRAME 10 TW
A frame is added to the current window. The edges of the frame extend beyond the edges of the window itself, so as to avoid obscuring the leading and trailing text characters.
<REMOVED BY MODERATOR>
Regards
Anji
Edited by: Alvaro Tejada Galindo on Jul 8, 2008 10:59 AM -
Fetch data from two tables and insert into one table
I have similar to the following data in two tables (@Plant, @PlantDirector) and need to consolidate into one table (@PlantNew) as follows.
DECLARE @Plant TABLE (PlantID INT, PlantName VARCHAR(100))
INSERT INTO @Plant (PlantID, PlantName) VALUES (1, 'Name One'),(2, 'Name Two'),(3, 'Name Three'),(4, 'Name Four'),(5, 'Name Five'),(6, 'Name Six')
Director data for the Plants exist in the following table. Assistant value 1 means Assistant Director and 0 means Director.
Data exists only for subset of plants and a Plant may have one or both roles.
DECLARE @PlantDirector TABLE (PlantID INT, PlantDirectorID INT, Assistant bit)
INSERT INTO @PlantDirector (PlantID, PlantDirectorID, Assistant) VALUES (2, 111, 1),(2, 222, 0),(4, 333, 0),(6,444,1)
The above data needs to be inserted into one table (@PlantNew) as follows:
PlantID in @Plant table is IDENTITY value and needs to be inserted as-is into this table.
PlantDirExists will get a value of 1 if at least one record exists in @PlantDirector table for a PlantID. PlantAssistantDirID and PlantDirID should be set to the corresponding PlantDirID or NULL appropriately depending on the data.
DECLARE @PlantNew TABLE (PlantID INT, PlantName VARCHAR(100), PlantDirExists bit, PlantAssistantDirID INT, PlantDirID INT)
INSERT INTO @PlantNew (PlantID, PlantName, PlantDirExists, PlantAssistantDirID, PlantDirID)
VALUES (1, 'Name One', 0, NULL, NULL),(2, 'Name Two', 1, 111, 222),(3, 'Name Three', 0, NULL, NULL),(4, 'Name Four', 1, NULL, 333),(5, 'Name Five', 0, NULL, NULL),(6, 'Name Six',1, 444, NULL)
How do I achieve the above using SQL ? Thanks.like this
INSERT @PlantNew (PlantID, PlantName, PlantDirExists, PlantAssistantDirID, PlantDirID)
SELECT p.PlantID,
p.PlantName,
CASE WHEN pd.PlantID IS NULL THEN 0 ELSE 1 END,
PlantAssistantDirID,
PlantDirID
FROM @Plant p
LEFT JOIN (SELECT PlantID,
MAX(CASE WHEN Assistant = 1 THEN PlantDirectorID END) AS PlantAssistantDirID,
MAX(CASE WHEN Assistant = 0 THEN PlantDirectorID END) AS PlantDirID
@PlantDirector
GROUP BY PlantID)pd
ON pd.PlantID = p.PlantID
Please Mark This As Answer if it helps to solve the issue Visakh ---------------------------- http://visakhm.blogspot.com/ https://www.facebook.com/VmBlogs
You're missing a FROM
insert into @PlantNew
SELECT p.PlantID,
p.PlantName,
CASE WHEN pd.PlantID IS NULL THEN 0 ELSE 1 END,
PlantAssistantDirID,
PlantDirID
FROM @Plant p
LEFT JOIN (SELECT PlantID,
MAX(CASE WHEN Assistant = 1 THEN PlantDirectorID END) AS PlantAssistantDirID,
MAX(CASE WHEN Assistant = 0 THEN PlantDirectorID END) AS PlantDirID
from @PlantDirector
GROUP BY PlantID)pd
ON pd.PlantID = p.PlantID
Maybe you are looking for
-
Why are Java SASLFactories missing when called via PL/SQL but not from JRE?
Hi This may be quite a technical point about SASL and JCE Providers etc OR it may just be a question about how Oracle PL/SQL interfaces with Java. The background is that I am trying to get a Java opensource library to run in Oracle DB - this is for s
-
Can a movie open in a new window and auto play on a server other than .mac?
-
Cannot read from menu file!
Hi All, When I put the menu property for some form, the form shows this error: cannot read from menu file How to solve it?
-
Adjust audio BitRate for a Quicktime .MOV export
I am trying to export a >MOV file. Settings are Quicktime > H.264 codec. Everything looks and sounds fine, but I am uploading to a TV station and they are saying that the audio BitRate is too low. I can't seem to find anywhere to adjust the audio bit
-
Hi, i am using version 1 build 253229 of Coldfusion Builder. I am accessing my file via RDS on a remote Server running CF MX 6.1 and Apache 2. I was wondering, what character encoding is being used for transfering data, since my files have all missin