1 trigger on multiple tables

I am new to triggers (never coded one) and need to create a trigger (prefer 1) on multiple tables.  Basically when the trigger is run I need to capture info from whichever table is being triggered and insert a row into a history table. 
Thanks in advance.

It is better to use the OUTPUT clause if that is feasible in your application:
http://www.sqlusa.com/bestpractices2005/auditwithoutput/
Kalman Toth Database & OLAP Architect
SQL Server 2014 Design & Programming
New Book / Kindle: Exam 70-461 Bootcamp: Querying Microsoft SQL Server 2012

Similar Messages

  • Trigger on Multiple tables

    Hello,
    I need some help rewriting a trigger, the data structure changed for one of our tables and now my trigger is invalid. I know that we can't have a trigger on multiple tables but I was hoping that someone could give me some ideas.
    Trigger:
    create or replace
    TRIGGER
    "CMKAT"."USER_STATUS_CHANGE"
    Before update on WOB
    For each row
    Declare
    Catalog_name varchar2(40);
    Variant_name varchar2(40);
    Wp varchar2(10);
    Old_status varchar2(40);
    New_status varchar2(40);
    Begin
    If (:old.wobstakeys <> :new.wobstakeys) Then
    Select katbezc into catalog_name from kat where katkeyi = *:new.dokkatkeyi;* - COLUMN BELONGS TO DOK TABLE
    Select kvtbezc into variant_name from kvt,kav where kvtkeyi=kavkvtkeyi and kavkeyi = :new.wobvarkeyi;
    Wp := *:new.doksnei || '-' || :new.doksnli*;* - COLUMNS BELONG TO DOK TABLE
    Select stabezc into old_status from sta where stakeys = :old.wobstakeys;
    Select stabezc into new_status from sta where stakeys = :new.wobstakeys;
         Insert into status_log values (catalog_name, variant_name, wp,old_status, new_status);
    End if;
    End;
    Of course I get errors when I attempt to compile .....
    bad bind variable :new.DOKKATKEYI
    bad bind variable :new.doksnei
    bad bind variable :new.doksnli
    Any help would be great ... Thank you!
    Edited by: user10448714 on Aug 18, 2009 12:45 PM

    Hi,
    It sounds like you need to SELECT some values from the dok table into local variables. You can then use those local variables in SQL statements:
    Select  katbezc
    into    catalog_name
    from    kat
    where   katkeyi = new_dokkatkeyi;        -- new_dokkatkeyi is a local variableor PL/SQL statements:
    Wp := new_doksnei
       || '-'
       || new_doksnli;If you need help, post
    an "UPDATE wob ..." statement
    the existing row in wob,
    any relevant data from any other tables, and
    what the UPDATEd row should be when everything is over.
    Please don't post unformatted code.
    Add white space to make the code more readable.
    When posting formatted text on this site, type these 6 characters:
    &#123;code&#125;
    (small letters only, inside curly brackets) before and after sections of formatted text, to preserve spacing.

  • One trigger for Multiple tables

    Hi all,
    I want write a trigger for mutiple tables.
    For Example,
    In database schema,some user update one table.I want to capture what the table and capture old value and new value.
    the above example for all insert and delete also.
    Regards
    Fame

    Hi, Fame,
    Sorry, a trigger only works on one table, so you need a separate trigger on each separate table.
    All of those triggers can call a common procedure.
    If you'd like to give a more detailed description of what you want to do, using two or three tables, then someone can give you more detailed instructions on how to do it.
    Always say which version of Oracle you're using.

  • How to build a form with multiple tables in oracle application express

    Hi everyone,
    I have got problem in building a form with multiple tables.I have a main table with (20) columns and this main table is related to the other tables with the primary key-foreign key relation ship.My requirement is i have to build a form which has fields from many tables and all the fields are related to the main table using (ID) column.In that form if i enter ID field i have to get information from differnt tables.
    Please help me to solve this (building a form with mutiple tables)
    Thank you
    sans

    Sans,
    I am no Apex expert, but with a situation as "complex" as yours, have you thought about creating a VIEW that joins these 7/8 tables, placing an INSTEAD OF trigger on that view to do all the business logic in the database, and base your application on the view?
    This is the "thick-database" approach that has been gaining momentum of late. The idea is to put your business logic in the database wherever possible, and let the application (Form, Apex, J2EE, whatever) concentrate on UI issues,

  • Delete records from multiple table

    Hi,
    I need to delete records from multiple tables using a single delete statement. Is it possible ? If so please let me know the procedure.
    Kindly Help.
    Thanks,
    Alexander.

    Hi Tim,
    Syntax of DELETE statement does not allow for multiple tables to be specified in this way. Infact, none of the DMLs allow you to specify table names like this.
    Technically, there are other ways of deleting from multiple tables with one statement.
    1. "Use a trigger":
    What was probably meant by this is that you have a driving-table on which you create a on-delete trigger. In this trigger, you write the logic for deleting from other tables that you want to delete from.
    This does mean a one-time effort of writing the trigger. But the actual DML operation of deleting from all the tables would be simply triggered by a delete on driving-table.
    2. Dynamic SQL:
    Write a PL/SQL code to open a cursor with table-names from which you want the data to be deleted from. In the cursor-for loop, write a dynamic SQL using the table-name to delete from that table.
    3. Using Foreign-Key constraint with Cascade-Delete:
    This I feel is a more 'cleaner' way of doing this.
    Having to delete data from multiple tables means that there is some kind of parent-child relationship between your tables. These relationships can be implemented in database using foreign-key constraints. While creating foreign-key constraint give the 'on delete cascade' clause to ensure that whenever data is deleted from parent-table, its dependent data is deleted from child-table.
    Using foreign-key constraint you can create a heirarchy of parent-child relationships and still your DELETE would be simple as you would only have to delete from parent-table.
    IMPORTANT: Implementing foreign-key constraints would also impact other DML operations that you should keep in mind.

  • How to alter a Form to modify multiple tables

    I want to create a form that will insert or update into multiple tables at once.
    I have provided a picture of what i have in mind: http://imageshack.us/photo/my-images/21/custformexample.jpg
    In this example I have 3 tables:
    Customer (Cust_ID, Name,Address,Email,Phone);
    Account_Manager(AM_ID, Name,Address,Email);
    Customer_Account_Managers(Cust_ID,AM_ID);
    A customer can have 0 to many Account Managers.
    I have created a form on table with report with which I can see a report of all customers and click Edit to edit a customer or Create to create a new one.
    In this form I want to add a select list that includes all Managers (I know how to create a select list and how to access it's value). I also want a report on the Account Managers which are associated with the customer, and I want to be able to add to this list, which will be saved into the Customer_Account_managers table as soon as i click Save.
    Please provide me with some tips as to how to do this.
    Thanks a lot!

    Always include the following information when asking a question:
    <ul>
    <li>Full APEX version</li>
    <li>Full DB/version/edition/host OS</li>
    <li>Web server architecture (EPG, OHS or APEX listener/host OS)</li>
    <li>Browser(s) and version(s) used</li>
    <li>Theme</li>
    <li>Template(s)</li>
    <li>Region/item type(s)</li>
    </ul>
    popovitsj wrote:
    I want to create a form that will insert or update into multiple tables at once.
    I have provided a picture of what i have in mind: http://imageshack.us/photo/my-images/21/custformexample.jpg
    In this example I have 3 tables:
    Customer (Cust_ID, Name,Address,Email,Phone);
    Account_Manager(AM_ID, Name,Address,Email);
    Customer_Account_Managers(Cust_ID,AM_ID);
    A customer can have 0 to many Account Managers.
    I have created a form on table with report with which I can see a report of all customers and click Edit to edit a customer or Create to create a new one.
    In this form I want to add a select list that includes all Managers (I know how to create a select list and how to access it's value). I also want a report on the Account Managers which are associated with the customer, and I want to be able to add to this list, which will be saved into the Customer_Account_managers table as soon as i click Save.You can create a database views based on these tables, and create a instead of insert/update/delete trigger to populate the corresponding tables when fired.
    Create an APEX form using wizard based on this database view.

  • Insert into multiple table view

    I have a view with multiple table query and and INSTEAD OF trigger on the view that inserts into multiple tables. When I attempt to do a commit out of a ADF Creation Form, I get the following error: ORA-01779: cannot modify a column which maps to a non key-preserved table ORA-06512: at line 1.
    Has anyone had success inserting into multiple tables via a view that has more than one table?
    Thanks,
    Lisa

    Lisa,
    Sounds like your instead-of trigger may not be being called and you are trying to insert directly into the view.
    I did write a [url http://stegemanoracle.wordpress.com/2006/03/15/using-updatable-views-with-adf/]blog entry about using a view with instead-of triggers last year.
    John

  • Audit multiple tables using PLSQL

    Hi
    I need to audit multiple tables. I need to delete everything from 14 related tables and insert it into one denormalized audit table each time a service is not active anymore(when that field in inserted into the table).
    Do I need to have just one 'ON DELETE trigger' on the master table and it would insert everything from the master table and child tables into the audit table... do I need a 'where statement' in the trigger for inserting each child record?
    enclosing a part of code:
    CREATE OR REPLACE TRIGGER vbnsServiceAudit
    BEFORE DELETE ON mciw_vbns_service_t
    BEGIN
    INSERT INTO service_audit
    (service_id, Datetime, User, contract_term, contract_exp_date, pricing_plan_type, subscription_type)
    VALUES
    (service_audit.service_id, SYSDATE, USER, service_audit.contract_exp_date,
    service_audit.pricing_plan_type,
    service_audit.subscription_type);
    INSERT INTO service_audit
    (disconnect_req_date, disconnect_prov_date)
    VALUES
    (srvc_disconnect.disconnect_req_date,
    srvc_disconnect.disconnect_prov_date);
    END vbnsServiceAudit;
    Any help with the code will be much appreciated as I am new doing DBA stuff.
    Thanks
    null

    You can use JDBC from within the bean managed persistence EJB

  • Indexing multiple columns of multiple tables

    Hi,
    I'm trying to index multiple columns of multiple tables.
    As I have seen, the way to do this is using User_Datastore.
    have the tables to share a (foreign)key? My tables have only 2 or 3 similar columns(description, tagnr...)
    I want to get the different tagnr belonging to the same description etc.
    Can I do this?
    Has anyone a Samplecode indexing multiple tables?
    Any suggestion would be helpful.
    Arsineh

    A USER_DATASTORE works like this:
    create table A
    ( id number primary key,
    textA varchar2(100));
    create table B
    ( id number primary key,
    textB varchar2(100));
    procedure foo (rid in rowid, v_document in out varchar2)
    v_textA varchar2(2000);
    v_idA number;
    v_textB varchar2(2000);
    begin
    select id, textA
    into v_idA, v_textA
    from A
    where rowid = rid;
    select textB
    into v_textB
    from B
    where id = v_idA;
    v_document := textA &#0124; &#0124; ' ' &#0124; &#0124; textB;
    end;
    create preferences for USER_DATASTORE
    create index ...
    on table A ( text) ...
    you also can build on table B
    This depends where you want the
    trigger to be build to sync the
    documents.
    null

  • XML datagram to multiple tables

    Hi !
    Can anybody help me ? I would like to store datagram in multiple tables, I tried using instead of trigger, but it's not working.
    following is an example of datagram:
    <PURCHASE_ORDERS>
    <PURCHASE_ORDER>
    <BATCH_ORDER_HEADER>
    <CUST_PO>26795849</CUST_PO>
    <HEADER_IDENTIFIER>OH1</HEADER_IDENTIFIER>
    <CUST_NUM>26700</CUST_NUM>
    <SHIP_TO_NUM>001</SHIP_TO_NUM>
    <REQ_SHIP_DATE>010322</REQ_SHIP_DATE>
    <ORDER_TYPE>A</ORDER_TYPE>
    <SHIP_COMPLETE>0</SHIP_COMPLETE>
    <PRIORITY_CODE>6</PRIORITY_CODE>
    <WH_CODE>113</WH_CODE>
    <USER_ID>CAN_BATCH</USER_ID>
    <CURRENCY_CODE>USD</CURRENCY_CODE>
    <MODE_OF_SHIP>TRCK</MODE_OF_SHIP>
    <CONSIGNEE_NUM>26700I</CONSIGNEE_NUM>
    <FREIGHT>A</FREIGHT>
    <INSURANCE></INSURANCE>
    <PAYMENT_TERMS></PAYMENT_TERMS>
    </BATCH_ORDER_HEADER>
    <BATCH_ORDER_LINE_ITEM>
    <CUST_PO>26795849</CUST_PO>
    <HEADER_IDENTIFIER>OL1</HEADER_IDENTIFIER>
    <UNIX_LINE_ITEM>001</UNIX_LINE_ITEM>
    <CPN>03766409</CPN>
    <QTY>1</QTY>
    <NET_PRICE> 0.00</NET_PRICE>
    <MANUAL_PRICE_FLAG> </MANUAL_PRICE_FLAG>
    </BATCH_ORDER_LINE_ITEM>
    <BATCH_ORDER_LINE_ITEM>
    <CUST_PO>26795849</CUST_PO>
    <HEADER_IDENTIFIER>OL1</HEADER_IDENTIFIER>
    <UNIX_LINE_ITEM>002</UNIX_LINE_ITEM>
    <CPN>03010899</CPN>
    <QTY>2</QTY>
    <NET_PRICE> 0.00</NET_PRICE>
    <MANUAL_PRICE_FLAG> </MANUAL_PRICE_FLAG>
    </BATCH_ORDER_LINE_ITEM>
    <BATCH_ORDER_LINE_ITEM>
    <CUST_PO>26795849</CUST_PO>
    <HEADER_IDENTIFIER>OL1</HEADER_IDENTIFIER>
    <UNIX_LINE_ITEM>003</UNIX_LINE_ITEM>
    <CPN>03766722</CPN>
    <QTY>1</QTY>
    <NET_PRICE> 0.00</NET_PRICE>
    <MANUAL_PRICE_FLAG> </MANUAL_PRICE_FLAG>
    </BATCH_ORDER_LINE_ITEM>
    <BATCH_ORDER_TEXT>
    <CUST_PO>26795849</CUST_PO>
    <TEXT_TYPE>2</TEXT_TYPE>
    <TEXT_NUM>1</TEXT_NUM>
    <UNIX_LINE_ITEM>0</UNIX_LINE_ITEM>
    <TEXT>CUSTOMER P.O.# 10000989</TEXT>
    </BATCH_ORDER_TEXT>
    <BATCH_ORDER_TEXT>
    <CUST_PO>26795849</CUST_PO>
    <TEXT_TYPE>1</TEXT_TYPE>
    <TEXT_NUM>1</TEXT_NUM>
    <UNIX_LINE_ITEM>0</UNIX_LINE_ITEM>
    <TEXT>CUSTOMER P.O.# 10000989</TEXT>
    </BATCH_ORDER_TEXT>
    <BATCH_DROP_SHIP>
    <CUST_PO>26795849</CUST_PO>
    <DROP_SHIP_ZONE></DROP_SHIP_ZONE>
    <DROP_SHIP_NAME>3L INDUSTRIES</DROP_SHIP_NAME>
    <DROP_SHIP_ADDR1>44 AVALON DRIVE</DROP_SHIP_ADDR1>
    <DROP_SHIP_ADDR2>LABRADOR CITY, NFLD.</DROP_SHIP_ADDR2>
    <DROP_SHIP_ADDR3>A2V1K2 NF CA</DROP_SHIP_ADDR3>
    </BATCH_DROP_SHIP>
    </PURCHASE_ORDER>
    </PURCHASE_ORDERS>
    This is master-detail-detail relationship.
    Whoever knows the solution, please let me know.
    Thanks
    ...Madhuri
    null

    My book dedicates an entire chapter to building and explaining an XMLLoader utility that helps you handle situations like this.
    Steve Muench
    Development Lead, Oracle XSQL Pages Framework
    Lead Product Manager for BC4J and Lead XML Evangelist, Oracle Corp
    Author, Building Oracle XML Applications
    null

  • Single Trigger for muliple tables

    Hi All,
    I have one requirement to create a trigger to populate a table (X) based on the any insert or update on few tables (A,B,C,D,E,F).
    Do I need to create trigger for each table ??. any idea of using all tables in one trigger.

    Hi,
    this is not possible.
    but you can use multiple trigger on single table
    if you can use view, then you can use INSTEAD OF Trigger on view
    for example
    CREATE OR REPLACE VIEW manager_info AS
        SELECT e.ename, e.empno, d.dept_type, d.deptno, p.prj_level,
               p.projno
            FROM   Emp_tab e, Dept_tab d, Project_tab p
            WHERE  e.empno =  d.mgr_no
            AND    d.deptno = p.resp_dept;
    CREATE OR REPLACE TRIGGER manager_info_insert
    INSTEAD OF INSERT ON manager_info
    REFERENCING NEW AS n                 -- new manager information
    FOR EACH ROW
    DECLARE
       rowcnt number;
    BEGIN
       SELECT COUNT(*) INTO rowcnt FROM Emp_tab WHERE empno = :n.empno;
       IF rowcnt = 0  THEN
           INSERT INTO Emp_tab (empno,ename) VALUES (:n.empno, :n.ename);
       ELSE
          UPDATE Emp_tab SET Emp_tab.ename = :n.ename
             WHERE Emp_tab.empno = :n.empno;
       END IF;
       SELECT COUNT(*) INTO rowcnt FROM Dept_tab WHERE deptno = :n.deptno;
       IF rowcnt = 0 THEN
          INSERT INTO Dept_tab (deptno, dept_type)
             VALUES(:n.deptno, :n.dept_type);
       ELSE
          UPDATE Dept_tab SET Dept_tab.dept_type = :n.dept_type
             WHERE Dept_tab.deptno = :n.deptno;
       END IF;
       SELECT COUNT(*) INTO rowcnt FROM Project_tab
          WHERE Project_tab.projno = :n.projno;
       IF rowcnt = 0 THEN
          INSERT INTO Project_tab (projno, prj_level)
             VALUES(:n.projno, :n.prj_level);
       ELSE
          UPDATE Project_tab SET Project_tab.prj_level = :n.prj_level
             WHERE Project_tab.projno = :n.projno;
       END IF;
    END;see more : http://download.oracle.com/docs/cd/B19306_01/appdev.102/b14251/adfns_triggers.htm
    Edited by: Mahir M. Quluzade on Oct 12, 2011 9:23 AM

  • "Failed to open the connection" problem related to multiple tables in the report?

    Post Author: Gadow
    CA Forum: Data Connectivity and SQL
    System specifics:
    Web environment using ASP.Net 2.0 (from Visual Studio 2005 Professional)
    Crystal Reports 2008, v. 12.0.0.549, Full
    We have set up the following method for displaying reports via our website:
    User is sent to a report-specific page. The user is given some filtering options specific to the report that will be viewed. When the user has specified the data filters, the user clicks a button.
    The page wraps up the report parameters -- selection query, formula values, report location, the name to be displayed, etc. -- into a class which gets put into the Session object.
    The page redirects to DisplayReport.aspx. ALL reports redirect to this page.
    DisplayReport.aspx retrieves the report parameters from Session. A ReportDocument object is created and loaded, then set with the data from the parameters class.
    A ConnectionInfo object is created and set with the relevant log on credentials. All of the reports draw from the same database, so the connection information is hard-coded as the same for all reports. The page then iterates through all of the tables in the Database.Tables collection of the ReportDocument and calls ApplyLogOnInfo to each table using the ConnectionInfo object.
    The page is rendered and the user gets the filtered report.
    We currently have seven reports. Five reports work fine and display the correctly filtered data with no error messages. Two reports generate a Failed to open the connection error and do not display. I have verified that the queries being sent to DisplayReport.aspx are valid, and as I said the connection information itself is hard-coded in the one page that displays the reports and this is identical to all reports.
    The five reports that do work all have a single data table, either an actual database table or a single view. The two reports that do not work all have multiple tables. As far as I can tell, this is the only difference between the sets; all seven reports are based on the same DSN and I have verified the database on all of the reports. All of the reports were written using Crystal Reports 8, and all of the reports display fine in a Windows app I wrote some years ago using Crystal Reports 8. Again, the only difference between those reports that do work and those that do not is the number of tables used in the report: one table or view in the reports that display, more than one table (tables only, none use views) in the reports that do not display.
    As for the code I am using, below are the relevant methods. The function MakeConnectionInfo simply parses out the components of a standard SQL connection string into a ConnectionInfo object. DisplayedReport is the ID of the CrystalReportViewer on the page.Protected Sub Page_Init(ByVal sender As Object, ByVal e As System.EventArgs)
            Dim o As Object = Session("ReportParams")
            Dim ReportURL As String = ""
            'Verify that there is a ReportParameters object
            If o Is Nothing OrElse o.GetType IsNot GetType(ReportParameters) Then 'Redirect to the error page
                Response.Redirect("/errors/MissingReport.aspx")
            End If
            ReportParams = CType(o, ReportParameters)
            'Verify that the report exists
            ReportURL = "/Reports/ReportFiles/" + ReportParams.ReportName
            ReportPath = Server.MapPath(ReportURL)
            If Not File.Exists(ReportPath) Then
                Response.Redirect("/errors/MissingReport.aspx?Report=" + ReportParams.ReportTitle)
            End If
            InitializeReport()       
        End Sub
        Protected Sub InitializeReport()
            Dim RD As New ReportDocument
            Dim CI As ConnectionInfo = MakeConnectionInfo(DB_Bonus)
            Dim RPF As CrystalDecisions.Shared.ParameterField = Nothing
            RD.Load(ReportPath)
            If ReportParams.SelectString <> "" Then
                Dim Adapt As New SqlDataAdapter(ReportParams.SelectString, DB_Bonus)
                Dim DS As New Data.DataSet
                Adapt.Fill(DS)
                RD.SetDataSource(DS.Tables(0))
            End If
            For Each kvp As KeyValuePair(Of String, String) In ReportParams.Formulas
                Dim FFD As FormulaFieldDefinition = Nothing
                Try
                    FFD = RD.DataDefinition.FormulaFields(kvp.Key)
                Catch ex As Exception
                    'Do nothing
                End Try
                If FFD IsNot Nothing Then
                    Select Case FFD.ValueType
                        Case FieldValueType.DateField, FieldValueType.DateTimeField
                            If IsDate(kvp.Value) Then
                                FFD.Text = String.Format("Date()", Convert.ToDateTime(kvp.Value).ToString("yyyy, MM, dd"))
                            Else
                                FFD.Text = "Date(1960, 01, 01)"
                            End If
                        Case FieldValueType.StringField
                            FFD.Text = String.Format("""""", kvp.Value)
                        Case Else
                            'For now, treat these as if they were strings. If things blow up here,
                            'we will need to add the appropriate formatting for the field type.
                            FFD.Text = String.Format("""""", kvp.Value)
                    End Select
                End If
            Next
            For Each T As CrystalDecisions.CrystalReports.Engine.Table In RD.Database.Tables
                Dim TLI As TableLogOnInfo = T.LogOnInfo
                TLI.ConnectionInfo = CI
                T.ApplyLogOnInfo(TLI)
            Next
            DisplayedReport.ReportSource = RD
        End Sub
    Does this approach not work with reports containing multiple tables, or is there something I'm missing? Any meaningful suggestions would be much appreciated.

    Dear Dixit,
    Please refer to the Crystal report landing page to get the details
    information about the support for crystal report issues.
    Please use the following thread to post your questions related to
    crystal report.
    SAP Business One and Crystal Reports
    Regards,
    Rakesh Pati
    SAP Business One Forum Team.

  • Want to update data in a view based on multiple tables

    Hi
    I am facing a problem i want to update data in tables using a view. As that view is based on multiple tables so i am unable to update data. i came to know we can update table from view only if view is based on single table. so if anyone knows any alternative please let me know.
    Thanx
    Devinder

    Devinder,
    The table can be updated through a view based on multiple tables, if and only if the table is a "key preserved" table. Rather than explaining myself, i avoided the burden of typing by finding the material in Oracle Docs and pasting it for you :-)
    If you want a join view to be updatable, all of the following conditions must be
    true:
    1. The DML statement must affect only one table underlying the join.
    2. For an INSERT statement, the view must not be created WITH CHECK
    OPTION, and all columns into which values are inserted must come from a
    key-preserved table. A key-preserved table in one for which every primary
    key or unique key value in the base table is also unique in the join view.
    3. For an UPDATE statement, all columns updated must be extracted from a
    key-preserved table. If the view was created WITH CHECK OPTION, join
    columns and columns taken from tables that are referenced more than once
    in the view must be shielded from UPDATE.
    4. For a DELETE statement, the join can have one and only one key-preserved
    table. That table can appear more than once in the join, unless the view was
    created WITH CHECK OPTION.
    HTH
    Naveen

  • Multiple tables with the possibility of multiple records in each table

    Post Author: viper
    CA Forum: .NET
    Hi
    I have been trying for a few days now to come up with a CR solution to displaying data from multiple tables.  These tables, in some cases, have more then one record that needs to be displayed.  This is basically what I am trying to do.....
    I am developing a .net web application(vb) using vs2005 and an oracle 10g backend.  There is a data entry part of the site that users will enter data related to a property.  Other users will be able to search these records and have a list of records returned based on the search criteria.  The user then can click on one of these records to view a pop up CR report containing all the data related to that one property.  The PropID is passed to the pop up page and is used in the WHERE clause of my SQL statement to bring back only one property.  This data can come from as many as 18 tables if all the fields have been entered for this property.  I have tried many different solutions to get the data from multiple tables...and have had some that were close to what I need.  The best one I have will display data from multiple tables but only one record per table.....which doesn't work in my case since some of the tables have more then one record per table.
    Is there anybody that has had success in setting up similar reports?
    Does anybody know how I could use the "Group Expert" to group by the tables in my application?  I can only figure out how to group within a single table.
    It would be great if I could group by table....then just display the record(s) in each table that had the same PropID.  I am not sure if the pdf export would show all the data in that situation but it would be worth a try.  If fact...maybe I could create a new table called MyTables and just add two colums like MyTableID and MyTableName.  Then add all the table names to MyTables that I want to see in the report and add the associated MyTableID value to each table as a new column.  I could then group by MyTableID and PropID.  Just guessing here.
    Any ideas would be appreciated.

    Post Author: quafto
    CA Forum: .NET
    Your query is not too clear so I'll do my best to answer it broadly.
    You mentioned that you have a .NET web application where your users enter data on one screen and then may retrieve it on another. If the data is written in real time to a database then you can create a standard Crystal Report by adding multiple tables. The tables should be linked together using the primary and foreign keys in order to optimize the database query and give you a speedy report. Using unlinked tables is not recommended and requires the report engine to index the tables (it is quite slow).
    You also mentioned you have a "PropID" to be used in a WHERE clause. This is a great place to use a parameter in your report. This parameter can then be used in your record selection formula inside Crystal Reports. The report engine will actually create the WHERE clause for you based on the parameter value. This is helpful because it allows you to simply concentrate on your code rather than keeping track of SQL queries.
    Now, what Crystal does not do well with is uncertainty. When you design a report with X number of tables the report engine expects X number of tables to be available at processing time. You should not surprise the print engine with more or less tables because you could end up with processing errors or incorrect data. You may need to design multiple reports for specific circumstances.
    Regarding the group expert question. I'm not sure how you would/could use the group expert to group a table? A table is a collection of fields and cannot be compared to another table without a complex algorithm. The group expert is used to group and sort records based on a field in the report. Have a look at the group expert section of the help file for more information.
    Hopefully my comments have given you a few ideas.

  • Reading Multiple Tables with VB

    I'm attempting to retrieve records from multiple tables base on info returned from the previous call.
    This code fails on the second call to " IF RFC_Read_TableTJ.Call = True"
    also if I comment out "IF RFC_Read_TableTJ.Call = True" is creates the next text file with records from the previous table"
    Why is this happening and how do I change tables?
    thanks!
      Dim RFC_ReadTableTJ, TblFields, TblData, TblOptions As Object
       Dim I, J, K, IntCol As Integer
       Dim IntRow, LastRow As Long
       Dim StopTJ As Boolean
       Dim StrTemp, OutLine, OutLine2, TempChar, DelimitFromXL As String
       Dim strExport1, strExport2 As Object
       Dim ObjFileSystemObject As Object
       Dim MATNO(1 To 10) As String
    '   Dim R3 As SAPFunctions
    'Create Server object and Setup the connection
       Set R3 = CreateObject("SAP.Functions")
       R3.Connection.ApplicationServer = SAPServerIP
       R3.Connection.SystemNumber = SAPSystemNo
       R3.Connection.System = SAPSystem
       R3.Connection.client = SAPClient
       R3.Connection.language = SAPLang
       If R3.Connection.Logon(0, False) <> True Then
          Exit Sub
       End If
       Set ObjFileSystemObject = CreateObject("Scripting.FileSystemObject")
       Set TblFields = Nothing
       Set TblData = Nothing
       Set TblOptions = Nothing
    'Call RFC function RFC_READ_TABLE
       Set RFC_Read_TableTJ = R3.Add("RFC_READ_TABLE")
       Set strExport1 = RFC_Read_TableTJ.Exports("QUERY_TABLE")
       Set strExport2 = RFC_Read_TableTJ.Exports("DELIMITER")
       Set TblOptions = RFC_Read_TableTJ.Tables("OPTIONS")
       Set TblData = RFC_Read_TableTJ.Tables("DATA")
       Set TblFields = RFC_Read_TableTJ.Tables("FIELDS")
    'MATERIAL DESCRIPTION***********************************************
    'LOOK UP MATERIAL DESC TO GET MATERIAL NO
       strExport1.Value = "MAKT"
       DelimitFromXL = ","
       strExport2.Value = Chr(165)
    'Criteria
        TblOptions.AppendRow
        TblOptions(1, "TEXT") = "MAKTX LIKE '%A19118N1A%'"
    'Fields to retrieve
        TblFields.AppendRow
        TblFields(1, "FIELDNAME") = "MANDT" 'Client
        TblFields.AppendRow
        TblFields(2, "FIELDNAME") = "MATNR" 'Material Number
        TblFields.AppendRow
        TblFields(3, "FIELDNAME") = "SPRAS" 'Language Key
        TblFields.AppendRow
        TblFields(4, "FIELDNAME") = "MAKTX" 'Material Description
        TblFields.AppendRow
        TblFields(5, "FIELDNAME") = "MAKTG" 'Material description in upper case for matchcodes
    'Call RFC and write output
        If RFC_Read_TableTJ.Call = True Then
            If TblData.RowCount > 0 Then
                'Write output to file
                'MANDT , MATNR, SPRAS, MAKTX, MAKTG
                Set OutFile = ObjFileSystemObject.CreateTextFile("c:\MAKT.txt", True)
                OutFile.WriteLine "MANDT , MATNR, SPRAS, MAKTX, MAKTG" 'Header
                For IntRow = 1 To TblData.RowCount
                    'Replace all instances of the delimeter that occur in the data with a ";"
                    OutLine = ""
                    For K = 1 To Len(TblData(IntRow, "WA"))
                        If Mid(TblData(IntRow, "WA"), K, 1) = DelimitFromXL Then
                            TempChar = ";"
                        Else
                            TempChar = Mid(TblData(IntRow, "WA"), K, 1)
                        End If
                        OutLine = OutLine & TempChar
                    Next K
                        'Put in delimeter
                    OutLine2 = ""
                    For K = 1 To Len(OutLine)
                        If Mid(OutLine, K, 1) = Chr(165) Then
                            TempChar = DelimitFromXL
                        Else
                            TempChar = Mid(OutLine, K, 1)
                        End If
                        OutLine2 = OutLine2 & TempChar
                    Next K
                    'Write to file
                    OutFile.WriteLine OutLine2
                Next
                'MsgBox "Completed Successfully"
            Else
                'MsgBox "No records returned"
            End If
        Else
        '    MsgBox "Error calling SAP RFC_READ_TABLE"
        End If
    ''MAST Material to BOM Link*****************************************

    hi John
    you can create a join of those multiple tables in an internal table
    and then u can view that on this single internal table....
    like:-
    example
    SELECT c~carrname
                  p~connid
                  f~fldate
    INTO CORRESPONDING FIELDS OF TABLE itab
        FROM ( ( scarr AS c INNER JOIN spfli AS p
                      ON pcarrid   = ccarrid
                      AND p~cityfrom = p_cityfr
                      AND p~cityto   = p_cityto )
             INNER JOIN sflight AS f ON fcarrid = pcarrid
                                    AND fconnid = pconnid ).
    LOOP AT itab INTO wa.
      WRITE: / wa-fldate, wa-carrname, wa-connid.
    ENDLOOP.

Maybe you are looking for

  • Goods receipt for Shedule agreement

    hi all we are using SA to go for subcontracting . Process is like creating agreements by  ME31L and then Delivery schedules are created by ME38. then goods are issued to subcontractors by MVT type 541 with SA as ref. then challan is created by J1ifo1

  • Acrobat Pro 9.4.6 Printing Strange Characters

    I currently use Acrobat Pro 9.4.6 and when printing to a PDF file it prints strange characters...not at all what I want to be printed. I'm using Windows 7 Home Premium. Have others experienced this? Any assistance would be greatly appreciated. Jim

  • Download file opens when Firefox is started

    I just reinstalled Firefox on my Mac. Now whenever I open the program the download .dmg file pops up on my desktop and the dialog box where I needed to drag the firefox icon into my Applications folder pops up as well. Firefox starts and works fine,

  • A small logo of Dolby Digital or DVD-Audio missing when play DVD-A or DVD software with SPDIF

    I can see these logo before when I play DVD-A or play DVD movies with SPDIF enabled on DVD software such as PowerDVD. And now it's gone, when play SPDIF, it does not show these logos at all. I appreciate any advises. Thanks

  • Different Support Pack Levels

    Hi experts, we are running a federated portal network, between our BI Portal with a ABAP daat source and our EP Portal which is your standard ldap data source. We are looking at implementing ESS MSS or XSS into our portal landscape. I understand from