Help needed in dynamic sql

Hi,
Can we use dynamic table name in PL/SQL.
My query is “select col_nm from table_nm”. Here I have to pass the table_nm using cursor.
I tried giving “select col_nm from cursor.table_nm”. But it not taking the cursor value for table name.
How can we do this in oracle?
Can we store the output of EXECUTE IMMEDIATE statement in a variable?

Here is a small example.
DECLARE
     my_table VARCHAR2(10) := 'DUAL';
     my_value INTEGER;
BEGIN
     EXECUTE IMMEDIATE 'SELECT 1 FROM ' || my_table INTO my_value;
     DBMS_OUTPUT.PUT_LINE(my_value);
END;
you can use your cursor value in the place of my_table.
Thanks,
Karthick.
http://www.karthickarp.blogspot.com/

Similar Messages

  • Help Needed in Dynamic Sql or alternate to Dynamic Sql

    Hi Am working in sqlserver 2008 R2 and here is my Table structure and SPC
    ;create table SalaryReport(IdSalary int primary key identity(1,1),
    IDMainCompany int,IDSubCompany int,Salary money,Incentive int,NoofEmployees int, SalaryDate datetime, Creditscore int );
    insert into SalaryReport (IDMainCompany,IDSubCompany,Salary,Incentive,NoofEmployees,SalaryDate,Creditscore)
    ( Select 100 as IDMainCompany , 1000 as IDSubCompany ,200000 AS Salary, 20000 as Incentive, 500 as NoofEmployees,
    '2014-01-01' as SalaryDate, 60 as Creditscore union all
    Select 100 as IDMainCompany , 1001 as IDSubCompany ,300000 AS Salary, 40000 as Incentive, 600 as NoofEmployees,
    '2014-01-01' as SalaryDate , 70 as Creditscore union all
    Select 100 as IDMainCompany , 1002 as IDSubCompany ,400000 AS Salary, 40000 as Incentive, 1500 as NoofEmployees,
    '2014-01-01' as SalaryDate , 45 as Creditscore union all
    Select 101 as IDMainCompany , 1003 as IDSubCompany ,30000 AS Salary, 2000 as Incentive, 100 as NoofEmployees,
    '2014-01-01' as SalaryDate, 60 as Creditscore union all
    Select 102 as IDMainCompany , 1004 as IDSubCompany ,450000 AS Salary, 25000 as Incentive, 700 as NoofEmployees,
    '2014-01-01' as SalaryDate, 30 as Creditscore)
    Sample Test Script:
    DECLARE @IDMainCompany int = 100;
    DECLARE @Process_Date datetime = '2014-01-01';
    declare @Query nvarchar(max);
    SELECT
    CAST(SR.IDMainCompany AS VARCHAR(12)) AS IDMainCompany
    ,CAST(SR.IDSubCompany AS VARCHAR(12)) AS IDSubCompany
    ,CAST(SR.Salary AS VARCHAR(12)) AS Salary
    ,CAST(SR.Incentive AS VARCHAR(12)) AS Incentive
    ,CAST(SR.NoofEmployees AS VARCHAR(12)) AS NoofEmployees
    ,CAST(SR.SalaryDate AS VARCHAR(15)) AS SalaryDate
    ,CAST((SR.Creditscore) AS VARCHAR(15)) AS average
    FROM SalaryReport SR
    WHERE SR.IDMainCompany = @IDMainCompany
    AND DATEPART(MM, SR.SalaryDate) = DATEPART(MM, @Process_Date)
    UNION ALL
    SELECT
    '' AS IDMainCompany
    ,'' AS IDSubCompany
    ,'Total: ' + CAST(SUM(SR.Salary) AS VARCHAR(12)) AS Salary
    ,'Total: ' + CAST(SUM(SR.Incentive) AS VARCHAR(12)) AS Incentive
    ,'Total: ' + CAST(SUM(SR.NoofEmployees) AS VARCHAR(12)) AS NoofEmployees
    ,'' AS SalaryDate
    ,'Total: ' +CAST(avg(SR.Creditscore) AS VARCHAR(12)) AS Totalaverage
    FROM SalaryReport SR
    WHERE SR.IDMainCompany = @IDMainCompany
    AND DATEPART(MM, SR.SalaryDate) = DATEPART(MM, @Process_Date)
    group by IDMainCompany, DATEPART(MM, SalaryDate)
    the sample data i posted is having less columns. actually i have 20 columns in the select list. Also the parameters to the where condition i gave two i.e IDMainCompany, SalaryDate. I will also need to use IDSubCompany for some case. My skeleton will be 
    Create Procedure Test(@IDMainCompany int, @IDSubCompany int = null, @SalaryDate datetime)
    as
    BEGIN
    IF(@IDMainCompany is not null && @IDMainCompany > 0 && @SalaryDate is not null && @SalaryDate <> ' ' &&
    @IDSubCompany is null)
    BEGIN
    --The logic what discussed on previous posts will falls here with @IDMainCompany, @SalaryDate as parameter to the where condition
    END
    IF(@IDMainCompany is not null && @IDMainCompany > 0 && @SalaryDate is not null && @SalaryDate <> ' ' &&
    @IDSubCompany is null && @IDSubCompany > 0 )
    BEGIN
    --The logic what discussed on previous posts will falls here with @IDMainCompany, @SalaryDate,@IDSubCompany as parameter to the where condition
    END
    END
    As said i need to include 20 columns in the select list and as union all used on the previous sample there are 20 columns on the first query and 20 columns on the second query after the union all. The SPC will become big. If i repeat this for second if condition,
    it will be too big. How can i reduce this writing more lines.
    I am aware of the concept dynamic sql. Is there any other way to do this? or if dynamic sql is the only option, can anyone help me rewriting this select statements as dynamic sql
    Could anyone please assist me 
    loving dotnet

    >>
    thanks for your reply and yes, i am invoking this from my asp.net application using C# language.  Would you like to share something?
    <<
    Yes,
    You can use client side dynamic sql. I'm not talking about concatenating strings. I'm talking about using Runtime Text Tamplates (preprocesed templates in Visual Studio 2010).
    Add a new "Runtime Text Template" item to your VS project. Be "MyReportTemplate.tt" the file name of the runtime text template.  The content of this file should be something like the following:
    <#@ template language="C#" #>
    <#@ assembly name="System.Core" #>
    SELECT
    -- part of your query goes here
    -- the interesting part come next
    FROM
    SalaryReport SR
    WHERE
    SR.IDMainCompany = @IDMainCompany
    <# if (IDSubCompany.HasValue && IDSubCompany.Value > 0) { #>
    AND SR.IDSubCompany = @IDSubCompany
    <# } #>
    AND
    DATEPART(MM, SR.SalaryDate) = DATEPART(MM, @Process_Date)
    GROUP BY
    IDMainCompany, DATEPART(MM, SalaryDate)
    Add a new c# code file named MyReportTemplate.partial.cs closed to MyReportTemplate.tt with the following code:
    public partial class MyReportTemplate
    public int? IDSubCompany { get; set; }
    Then, to execute the query you can write a code similar to the following:
    public DataTable ExecuteReport(int mainCompanyId, int? subCompanyId, DateTime processDate )
    using (var cn = CreateConnection())
    using (var cmd = new SqlCommand())
    using (var adapter = new SqlDataAdapter(cmd))
    cmd.Connection = cn;
    var template = new MyReportTemplate
    IDSubCompany = subCompanyId
    cmd.CommandText = template.TransformText();
    cmd.Parameters.AddWithValue("@IDSubCompany", subCompanyId == null ? (object) DBNull.Value : subCompanyId.Value);
    cmd.Parameters.AddWithValue("@IDMainCompany", mainCompanyId);
    cmd.Parameters.AddWithValue("@Process_Date", processDate);
    var table = new DataTable();
    adapter.Fill(table);
    return table;
    EntityLite: A Lightweight, Database First, Micro ORM

  • Help needed in a SQL

    Hi,
    We run a heavy batch load in many of our tables. Prior to the load we need to drop the indexes and then re create the indexes.
    I worte a dynamic sql like
    SELECT 'create index '||owner||'.'||a.index_name||' on '||owner||'.'||a.table_name||'('||column_name||');'
    from dba_indexes a, dba_ind_columns b
    where a.owner=b.index_owner
    and a.table_name=b.table_name
    and a.index_name=b.index_name
    and a.owner='owner_name'
    and a.table_name='table_name';
    The problem with this query is that it is giving wrong result for composite indexes.
    How to write a query that would pick up composite indexes as well.
    Any help will be highly appreciated.
    Thanks

    SID3 wrote:
    Are you referring to making the indexes unusable. In this case we have to rebuild them and index rebuilding is a big performance issue especially when millions of rows are involved.
    Our DB is 10g R2.And recreating the indexes isn't rebuilding them? ?:|

  • Need generic dynamic sql query to generate nodes depending on dealer levels

    Input table:
    create table #test(dealerid integer ,dealerlvl integer)
    insert into #test values(1,1)
    insert into #test values(1,2)
    insert into #test values(1,3)
    insert into #test values(1,4)
    insert into #test values(2,1)
    insert into #test values(2,2)
    insert into #test values(2,3)
    insert into #test values(2,4)
    insert into #test values(2,5)
    insert into #test values(2,6)
    go
    create table #test2(dealerid integer,node integer,prntnode integer,dealerlvl integer)
    insert into #test2 values (1,234,124,2)
    insert into #test2 values (1,123,234,1)
    insert into #test2 values (1,238,123,2)
    insert into #test2 values (1,235,238,3)
    insert into #test2 values (1,253,235,4)
    insert into #test2 values (2,21674,124,3)
    insert into #test2 values (2,1233,21674,1)
    insert into #test2 values (2,2144,1233,2)
    insert into #test2 values (2,2354,2144,3)
    insert into #test2 values (2,24353,2354,4)
    insert into #test2 values (2,245213,24353,5)
    insert into #test2 values (2,2213,245213,6)
    Expected result :
    I have two test case here with dealerID1 and dealerID 2 
    Result for DealerID1
    Result needed for DealerID2:
    the levels for dealers might change (Dealer1 has 4 levels, and Dealer 2 has 6 levels) so i need to create an dynamic sql query which lists each node as separate columns depending on the levels. 
    I have hacked the query to give the result I need 
    select a.dealerid,a.node as Lvl1,b.node as lvl2,c.node as lvl3,d.node as lvl4
    from #test2 a 
    join #test2 b on a.node=b.prntnode
    join #test2 c on b.node=c.prntnode
    join #test2 d on c.node=d.prntnode
    where a.dealerid=1 and a.dealerlvl=2
    select  a.dealerid,a.node asLvl1,
    b.node as lvl2,c.node as lvl3,d.node as lvl4,e.node as lvl5,f.node as lvl6--,a.dealerlvl,a.dealerid
    from #test2 a 
    join #test2 b on a.node=b.prntnode
    join #test2 c on b.node=c.prntnode
    join #test2 d on c.node=d.prntnode
    join #test2 e on d.node=e.prntnode
    join #test2 f on e.node=f.prntnode
    where a.dealerid=2 and a.dealerlvl=3
    I am sure there is a better way to do this with dynamic sql. please help.
    Thanks

    -- Dynamic PIVOT
     DECLARE @T AS TABLE(y INT NOT NULL PRIMARY KEY);
    DECLARE
       @cols AS NVARCHAR(MAX),
       @y    AS INT,
       @sql  AS NVARCHAR(MAX);
    -- Construct the column list for the IN clause
     SET @cols = STUFF(
       (SELECT N',' + QUOTENAME(y) AS [text()]
        FROM (SELECT DISTINCT dealerlvl AS y FROM dbo.test2) AS Y
        ORDER BY y
        FOR XML PATH('')),
       1, 1, N'');
    -- Construct the full T-SQL statement
     -- and execute dynamically
     SET @sql = N'SELECT *
     FROM (SELECT dealerid, dealerlvl, node
           FROM dbo.Test2) AS D
       PIVOT(MAX(node) FOR dealerlvl IN(' + @cols + N')) AS P;';
    EXEC sp_executesql @sql;
     GO

  • Help needed in framing SQL query.

    Hi,
    I have table having following schema:
    PRODUCT_ID         INT
    DATE                   DATETIME
    ITEMS_SOLD         INT
    This table contains data for a week (sunday to saturday). I want to write an SQL query to get (filter out) PRODUCT_ID of products which has same no. of ITEMS_SOLD for all 7 days. Also for given PRODUCT_ID I need to find the longest period of successive days where the no. of ITEMS_SOLD is same for all days in this period. Eg.(PRODUCT_ID 23 was sold as following along the week in no. of units sold: 4,6,6,6,6,7,4 .So the longest period is *4 days* from Monday to Thursday.) The first condition is special case of second condition where no. of days is 7.
    Any help to get the SQL query will be appreciated.
    Thanks,
    Akshay.

    PRODUCT_ID      DATE           ITEMS_SOLD
    1          10/10/2011     3
    1          11/10/2011     3
    1          12/10/2011     3
    1          13/10/2011     3
    1           16/10/2011     5
    2          10/10/2011     4
    2           11/10/2011     4
    2          12/10/2011     4
    2          13/10/2011     4
    2           14/10/2011     4
    2          15/10/2011     4
    2          16/10/2011     4
    Output:
    PRODUCT_ID ITEMS_SOLD NO_OF_DAYS
    1          3                4     
    2          4               7
    Explanation of results:
    The table to be queried contains data for 1 week: from 10/10/2011(Sunday) to 16/10/2011(Saturday). Now, product with PRODUCT_ID '1' was sold on dates 10,11,12,13,16. Out of these 5 days 3 units were sold on 4 successive days (from 10-13). So output should be like :
    PRODUCT_ID ITEMS_SOLD NO_OF_DAYS
    1          3               4     
    as longest period of successive days is 4 where same no. of units were sold i.e 3 units (other period is of 1 day on 16th ).
    For PRODUCT_ID 2 we have only one period of 7 days where 4 units were sold each day. So we output :
    PRODUCT_ID ITEMS_SOLD NO_OF_DAYS
    2           4               7
    Other case where same PRODUCT_ID have different units sold on each day should be ignored.
    I hope that clarifies the problem more. Let me know in case I have missed out anything which should have been mentioned.
    -Akshay.

  • Need a Dynamic SQL statgement that returns multiple values.

    Hi,
    I'm using Oracle 10.1.0.5.
    In an anonymous block I have a dynamic SQL statement that finds the table name and column name that a string value resides in.
    It looks like this:
          l_sql := 'SELECT 1 FROM dual WHERE exists (SELECT 1 FROM '||
                   r.owner||'.'||r.table_name||' WHERE '||r.column_name||
                   ' = :b1)';
             EXECUTE IMMEDIATE l_sql INTO l_res USING l_contents;
             DBMS_OUTPUT.Put_Line(l_contents||' exists in '||r_owner||
                                  r.table_name||'.'||r.column_name);I'd then like to do a 'Select Distinct' to list all the other values in that column in the anonymous block,
    preferably as another dynamic SQL statement.
    How can I do this?

    user10382685 wrote:
    Hi,
    I'm using Oracle 10.1.0.5.
    In an anonymous block I have a dynamic SQL statement that finds the table name and column name that a string value resides in.
    It looks like this:
    l_sql := 'SELECT 1 FROM dual WHERE exists (SELECT 1 FROM '||
    r.owner||'.'||r.table_name||' WHERE '||r.column_name||
    ' = :b1)';
    EXECUTE IMMEDIATE l_sql INTO l_res USING l_contents;
    DBMS_OUTPUT.Put_Line(l_contents||' exists in '||r_owner||
    r.table_name||'.'||r.column_name);I'd then like to do a 'Select Distinct' to list all the other values in that column in the anonymous block,
    preferably as another dynamic SQL statement.
    How can I do this?Well, it would be nice for you to post the whole context of your present solution so we know what's going on. I'll assume r comes from a loop referencing user_tab_cols or some equivalent view.
    If so, you'll likely need to check the DATA_TYPE column.
    Keeping in mind, doing something like this is going to be pretty ridiculous if you have a large amount of distinct values ... I'm hoping/assuming this is a one off type of thing.
    declare
      type        l_date is table of date;
      v_date      l_date;
      type        l_char is table of varchar2(4000);
      v_char      l_char;
      type        l_numb is table of number;
      v_numb      l_numb;
      l_distinct_ set sys_refcursor;
    begin
      <current_code>
      open l_distinct_set for 'select distinct ' || r.column_name || ' from ' || r.owner||'.'||r.table_name;
      --expand on the data types you care about as needed, this is a BASIC set
      if r.data_type = 'DATE'
      then 
        fetch l_distinct_set bulk collect into v_date;
        <process_collection_as_wanted>
      elsif r.data_type in ('VARCHAR2', 'CHAR')
      then
        fetch l_distinct_set bulk collect into v_char;
        <process_collection_as_wanted>
      elsif r.data_type = 'NUMBER'
      then
        fetch l_distinct_set bulk collect into v_numb;
        <process_collection_as_wanted>
      end if;
      close l_distinct_set;

  • Help Needing in optimizing SQL

    I need help optimizing the following SQL.
    Following are the schema elements -
    cto_xref_job_comp - Contains the Job Data
    cto_mast_component - Contains component
    cto_mast_product - Contains product info
    cto_mast_model - Contains model info
    cto_xref_mod_prod - Contains model and product assoiciation
    cto_mast_model_scan - Contain the Scan order for each model family (the mod_id(should be renamed) refers to mod_fam_id on the cto_mast_model table).
    Here is what I am trying to achieve
    I want all the ATP components whose Travel card order (on cto_mast_model_scan > 0 ) and in addition I need the Phantoms that do not have any ATP components under them if they do not appear on ATP component list.
    SELECT f.travelcard_order, b.job_number,
    b.product_code,
    b.line_number,
                   b.component_type,
    b.component_item_number,
    b.parent_phantom,
    b.item_type,
    a.comp_id,
    a.comp_type_id,
    a.comp_desc_short,
    b.batch_id,
    b.quantity_per_unit,
    a.comp_notes,
                   b.COMPONENT_ITEM_DESCRPTION
    FROM      cto_xref_job_comp b,
                        cto_mast_component a,
                        cto_mast_product c,
    cto_xref_mod_prod d,
    cto_mast_model e,
                   cto_mast_model_scan f
    WHERE ( b.job_number = 'CTO2499814001' ) AND
    ( b.batch_id = 21 ) AND
    (b.item_type = 'ATP') AND
                   (b.parent_phantom = a.comp_desc_short ) and          
                   (b.product_code = c.prod_desc_short ) and
    (c.prod_id = d.prod_id ) and
    (d.mod_id = e.mod_id) and
    (e.mod_fam_id = f.mod_id) and
    (a.comp_type_id=f.comp_type_id) and
                                       (f.travelcard_order > 0)
    union
    SELECT distinct f.travelcard_order, b.job_number,
    b.product_code,
    b.line_number,
                   b.component_type,
    b.parent_phantom,
    b.item_type,
    a.comp_id,
    a.comp_type_id,
    a.comp_desc_short,
    b.batch_id,
    1,
    a.comp_notes,
    FROM      cto_xref_job_comp b,
                        cto_mast_component a,
                        cto_mast_product c,
    cto_xref_mod_prod d,
    cto_mast_model e,
                   cto_mast_model_scan f
    WHERE ( b.job_number = 'CTO2499814001' ) AND
    ( b.batch_id = 21 ) AND (b.item_type is null) and
                   (substr(b.parent_phantom,1,1)='C') and
                   (b.parent_phantom = a.comp_desc_short )
    and (b.parent_phantom not in (select parent_phantom from cto_xref_job_comp where job_number=b.job_number and batch_id=b.batch_id and item_type='ATP')) and           
                   (b.product_code = c.prod_desc_short ) and
    (c.prod_id = d.prod_id ) and
    (d.mod_id = e.mod_id) and
    (e.mod_fam_id = f.mod_id) and
    (a.comp_type_id=f.comp_type_id) and (f.travelcard_order > 0)

    Here is a small example.
    DECLARE
         my_table VARCHAR2(10) := 'DUAL';
         my_value INTEGER;
    BEGIN
         EXECUTE IMMEDIATE 'SELECT 1 FROM ' || my_table INTO my_value;
         DBMS_OUTPUT.PUT_LINE(my_value);
    END;
    you can use your cursor value in the place of my_table.
    Thanks,
    Karthick.
    http://www.karthickarp.blogspot.com/

  • Help needed in writing SQL CASE or DECODE statement

    Hi experts,
    I need to write a SQL to select order_num, cntry_cde, prod_id and Qty by joining order_num on PROD_ORDER and PROD_ORDER_TXT.
    Here is my sample data
    PRODORDER_               
    order_num     cntry_cde     Prod_id     Qty
    100     US     A1     5
    101     US     A2     10
    102     AU     A3     4
    103     AU     A4     9
    104     IN     A5     3
    PRODORDER_TXT_               
    order_num     cntry_cde     Prod_id     
    100     US     A1     
    101     US     A2     
    102     NZ     A3     
    103     AU     A4     
    104          A5     
    Here is the requirement,
    1) If the cntry_cde in PROD_ORDER is same as cntry_cde in PROD_ORDER_TXT then select PROD_ORDER.cntry_cde (orders 100, 101, 103)
    2) If they are different, pick the country code from PROD_ORDER_TXT (order 102, AU <> NZ)
    3) If they are different and PROD_ORDER_TXT.cntry_cde is NULL, I cannot use it as cntry_cde in my report (order 104). It happenend just because of the bad data at source.
    I cannot avoid it. Then simply use the cntry_cde from PROD_ORDER
    Output expected
    100     US     A1     5
    101     US     A2     10
    102     NZ     A3     4 -- AU changed to NZ
    103     AU     A4     9
    104     IN     A5     3 -- IN retained as PROD_ORDER_TXT.cntry_cde is null
    sample table creation and insert statements are below
    create table prod_order
    (order_num number,
    cntry_cde CHAR(2),
    prod_id VARCHAR2(6),
    qty number)
    create table prod_order_txt
    (order_num number,
    cntry_cde CHAR(2),
    prod_id VARCHAR2(6))
    insert into prod_order values (100, 'US', 'A1',5);
    insert into prod_order values (101, 'US', 'A2',1);
    insert into prod_order values (102, 'AU', 'A3',4);
    insert into prod_order values (103, 'AU', 'A4',9);
    insert into prod_order values (104, 'IN', 'A5',3);
    insert into prod_order_txt values (100,'US','A1');
    insert into prod_order_txt values (101,'US','A2');
    insert into prod_order_txt values (102,'NZ','A3');
    insert into prod_order_txt values (103,'AU','A4');
    insert into prod_order_txt values (104,NULL,'A5');
    commit;
    Thanks for your help in advance
    Edited by: sarvan on Mar 28, 2012 1:39 PM

    Hello
    Thank you for posting all of the ddl and test data along with your expected output - very helpful!. One small point would be to remember to type {noformat}{noformat} before and after any section of code or data in your post so that formatting is retained.  Anyway, this should be a simple join and a combination of CASE and NVL...Select
    po.order_num,
    CASE
    WHEN po.cntry_cde != NVL(pot.cntry_cde,po.cntry_cde)
    THEN
    pot.cntry_cde
    ELSE
    po.cntry_cde
    END cntry_code,
    po.prod_id,
    po.qty
    FROM
    prod_order po
    JOIN
    prod_order_txt pot
    ON
    ( po.order_num = pot.order_num
    ORDER_NUM CN PROD_I QTY
    100 US A1 5
    101 US A2 1
    102 NZ A3 4
    103 AU A4 9
    104 IN A5 3
    5 rows selected.
    HTH
    David
    Edited by: Bravid on Mar 28, 2012 8:32 AM
    corrected !=                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

  • Help needed in PL/SQL for updating the column for multiple records

    Hi,
    I am new to PL/SQL and need some help. What is the most effiecient way to update some field in a table as I may need to update thousands of records. I have a coulmn groupid can have multiple records tied to it. All the records attached to some groupid have a priority field also.
    How can I update the prorityfield value for all the groupids in a profiecient way. Here is a sample data
    GroupId     Priority
    1            1
    1            2
    1            3
    1            4
    1            5
    2            1
    2            2
    2            3
    3            1Here I have three groups 1, 2, 3. Now if any group contains only one record the priority remains same e.g. groupid=3 on top. If any group contains more than one record e.g. groupid=1 & 2 I want to re-arrange the priority fields e.g. If I want to update groupid=1 now if I change the priority of 2 to 5 (make it the last) I want to rearrange the remaing records priority i.e. if 2 becomes 5 as I have 5 rows for groupid=1 then 5 becomes 4, 4 becomes 3, 3 becomes 2 and 1 remains the same.
    Same wya if I want to make the priority 1 to 3 for groupid=2 then need 2 to become 1 and 3 to become 2 etc....
    Any help is appreciated.
    Thanks

    Hi,
    You don't need PL/SQL to do this (though you can put the following in PL/SQL if you want to):
    UPDATE     table_x
    SET     priority = CASE
                   WHEN  groupid     = 1
                   AND   priority = 2
                        THEN  5
                   WHEN  groupod     = 1
                   AND   priority     BETWEEN 3 AND 5
                        THEN  priority - 1
                   WHEN  groupid = 2
                   THEN
                        CASE
                             WHEN  prioity = 1
                             THEN  3
                             ELSE  priority - 1
                        END
                 END
    WHERE     groupId          IN (1, 2)
    AND     (     priority     BETWEEN 2 AND 5
         OR     groupid          = 2
         );There are lots of different techniques that can reduce your coidng: for example, the nested CASE statement used for groupid=2 above.
    You could do several smaller UPDATEs (for example, one just for groupid=1). Execution will be slower, but coding and testing will be faster.
    You could make the "magic numbers" 2 (for groupid=1) and 1 (for groupid=2) variables, even outside of PL/SQL.
    If you need more help, post the information that Satyaki requested.

  • Help needed, Createing Dynamic User input

    Hello,
    I am attempting to create some dynamic user input by "predicting" what the user requires in a text box.
    For example if the user enters "Smi" I have a select list pop up which gives the user all options that begin with "Smi".
    I am able to achieve the popups but the interface is quite jerky and not terribly responsive I am trying to solve this by using a thread which starts and stops when new input is received but it is still not quite right.
    The program uses a Sorted TreeSet to hold the data (I thought this would give me a quick search time) and a simple interface at this stage.
    Any help would be fantastic
    Thanks in advance :P
    import java.io.*;
    import java.awt.*;
    import javax.swing.*;
    import java.awt.event.*;
    import javax.swing.event.*;
    import java.text.*;
    import java.util.*;
       /** This program represents part of a larger user interface for allowing the
       user to select data from a file or database.
       <p>
       When the program starts up, it will read in data from a given file, and hold
       it in some type of container allowing rapid access.
       <p>
       The user may then type in the first few letters of the surname of a person,
       and this program should immediately present in a popup dialog the names which
       match.  The user will be able to click on one of the names in the popup and
       that will cause all data about that person to be displayed in the JTextArea
       at the bottom of the window.
       <p>
       This program requires the FormLayout.class, FormLayout$Placement.class, and
       FormLayout$Constraint.class files in the same directory
       (folder) or in its classpath.  These is provided separately.
    class PartMatch extends JFrame implements Runnable
                        /** Close down the program. */
       JButton quitbtn;
                        /** Field for the surname. */
       JTextField namefld;
                        /** Full details of the person(s). */
       JTextArea  results;
                        /** Popup dialog to display the names and addresses which
                        match the leading characters given in namefld. */
       Chooser matches;
                      /** Default background color for a window. */
       final static  Color            defBackground = new Color(0xD0C0C0);
                      /** Default foreground color for a window. */
       final static  Color            defForeground = new Color(0x000000);
                      /** Default background color for a field */
       final static  Color            fldBackground = new Color(0xFFFFFF);
                      /** Default background color for a button */
       final static  Color            btnBackground = new Color(0xF0E0E0);
       final static  Color            dkBackground = new Color(0xB0A0A0);
                      /** Larger font */
       final static  Font bold = new Font("Helvetica", Font.BOLD, 30);
       TreeSet members;
       String input;
       String[] found;
       public static void main(String arg[])
          UIManager.put("TextField.background",fldBackground);
          UIManager.put("TextField.foreground",defForeground);
          UIManager.put("TextField.selectionBackground",btnBackground);
          UIManager.put("TextArea.background",fldBackground);
          UIManager.put("TextArea.foreground",defForeground);
          UIManager.put("TextArea.selectionBackground",btnBackground);
          UIManager.put("Panel.background",defBackground);
          UIManager.put("Label.background",defBackground);
          UIManager.put("Label.foreground",defForeground);
          UIManager.put("Button.background",btnBackground);
          UIManager.put("Button.foreground",defForeground);
          UIManager.put("CheckBox.background",defBackground);
          UIManager.put("ScrollBar.background",defBackground);
          UIManager.put("ScrollBar.thumb",btnBackground);
          UIManager.put("ComboBox.background",btnBackground);
          UIManager.put("ComboBox.selectionBackground",dkBackground);
          PartMatch trial = new PartMatch(arg);
       public PartMatch( String [] arg )
          super("Part Match");
          setDefaultCloseOperation(EXIT_ON_CLOSE);
          Container cpane = getContentPane();
          FormLayout form = new FormLayout(cpane);
          JLabel lab1 = new JLabel("Fetch details") ;
          lab1.setFont( bold );
          form.setTopAnchor( lab1, 4 );
          form.setLeftAnchor( lab1, 4 );
          JLabel lab2 = new JLabel("Surname: ") ;
          form.setTopRelative( lab2, lab1, 4 );
          form.setLeftAlign( lab2, lab1 );
          namefld = new JTextField( 30 );
          form.setBottomAlign( namefld, lab2 );
          form.setLeftRelative( namefld, lab2, 4 );
          namefld.addCaretListener( new CaretListener()
             public void caretUpdate(CaretEvent e)
                 showMatches();
          quitbtn = new JButton( "Quit" );
          quitbtn.addActionListener( new ActionListener()
             public void actionPerformed(ActionEvent e)
                quitProcessing();
          form.setBottomAlign( quitbtn, namefld );
          form.setLeftRelative( quitbtn, namefld, 15 );
          results = new JTextArea( 10,50 );
          results.setEditable(false);
          JScrollPane jsp = new JScrollPane( results,
                                     JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
                                     JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED );
          form.setTopRelative( jsp, lab2, 6 );
          form.setLeftAlign( jsp, lab2 );
          form.setBottomAnchor( jsp, 5 );
          form.setRightAnchor( jsp, 5 );
          form.setRightAnchor( quitbtn, 5 );
          matches = new Chooser( this );
          //matches.setUndecorated(true);
          pack();
          setVisible(true);
          namefld.requestFocus();
          if (arg.length > 0) init(arg[0]);
          else init("triathlon.txt"); //<<<<<<<<<<<<<<<< Place the default filename here
          /** Called once only, at the end of the constructor, to read the data
            * from the membership file.
       public void init( String fname )
          members = new TreeSet();
           try {
               FileReader fr = new FileReader(new File (fname));
               Scanner scan = new Scanner(fr);
               trimember cmem;
               String cLine, eTag, memberNo, first, last, gender, yob, tel ,addr,
                       club;
               while(scan.hasNextLine())
                   cLine = scan.nextLine();
                   Scanner scan2 = new Scanner(cLine);
                   scan2.useDelimiter(";");
                   eTag = scan2.next().trim();
                   memberNo = scan2.next().trim();
                   first = scan2.next().trim();
                   last = scan2.next().trim();
                   gender = scan2.next().trim();
                   yob = scan2.next().trim();
                   tel = scan2.next().trim();
                   addr = scan2.next().trim();
                   club = scan2.next().trim();
                   cmem = new trimember(eTag, memberNo, first, last, gender, yob,
                           tel, addr, club);
                   members.add(cmem);
           catch (FileNotFoundException ex)
               results.append("Sorry can't find the input file\n");
               results.append("Please check file name and location and try again");
               ex.printStackTrace();
          /** Called every time there is a change in the contents of the text field
            * namefld.  It will first clear the text area.  It then needs to search
            * through the container of data to find all records where the surname
            * starts with the characters that have been typed.  The names and
            * addresses need to be set up as strings and placed in
            * an array of Strings.  This can be placed in the "matches" window and
            * displayed for the user, inviting one to be selected.
            * <p>
            * The performance of this is very important.  If necessary, it may be
            * necessary to run as a separate thread so that the user interface is
            * not delayed.  It is essential that the user be able to type letters at a
            * reasonable speed and not have the keystroke processing held up by
            * previous text.
       public void showMatches( )
           run();
                // First clear the text area
          //results.setText("");
                // Determine the leading characters of the surname that is wanted
                input = namefld.getText();
                // Locate the data for this name, and display each matching item
                //  in the JTextArea ...
                // Example of how to set the data in the popup dialog
          matches.list.setListData(found);
          matches.pack();   // resize the popup
                // set the location of the popup if it is not currently visible
          if ( ! matches.isVisible())
             Dimension sz = matches.getSize();
             Point mouse = getMousePosition();
             Point framepos = getLocation();
             int x=0, y=0;
             if (mouse == null)
                Point pt = results.getLocation();
                x = pt.x + 20 + framepos.x;
                y = pt.y + 20 + framepos.y;
             else
                x = mouse.x - 2 + framepos.x;
                y = mouse.y - 2 + framepos.y;
             matches.setLocation(x,y);
          matches.setVisible(true);
          namefld.requestFocus();
          /** Perform any final processing before closing down.
       public void quitProcessing( )
          // Any closing work.  Then
          System.exit(0);
        public void run()
            ArrayList<String> foundit = new ArrayList<String>();
            System.out.println(input);
            if(input != null)
            Iterator it = members.iterator();
            while(it.hasNext())
               trimember test = (trimember) it.next();
               if (test.last.startsWith(input))
                   foundit.add(test.last +", "+ test.first);
            found = new String[foundit.size()];
            for(int i=0; i<foundit.size();i++)
                found[i] = foundit.get(i);
         /** A window for displaying names and addresses from the data set which
          match the leading characters in namefld.
          <p>
          This will automatically pop down if the user moves the mouse out of the
          window.
          <p>
          It needs code added to it to respond to the user clicking on an item in
          the displayed list. */
       class Chooser extends JWindow
                /** To display a set of names and addresses that match the leading
                characters of the namefld text field. */
          public JList list = new JList();
          Chooser( JFrame parent )
             super( parent );
             Container cpane = getContentPane();
             cpane.addMouseListener( new MouseAdapter()
                public void mouseExited(MouseEvent e)
                   Chooser.this.setVisible(false);
             cpane.add("Center",list);
             list.addListSelectionListener( new ListSelectionListener()
                public void valueChanged(ListSelectionEvent e)
                   Chooser.this.setVisible(false);
                   System.out.println("ValueChanged");
                   // First clear the text area
                   results.setText("");
                   String in = (String) list.getSelectedValue();
                   System.out.println("Selected Value was : "+in);
                   String[] inlf = in.split(", ");
                   System.out.println("inlf[0]:"+inlf[0]+" inlf[1]:"+inlf[1]);
                   results.append("Surname \tFirst \teTag \tMemberNo \tSex \tYOB " +
                           "\tTel \tAddress \t\t\tClub\n");
                   Iterator it = members.iterator();
                   while(it.hasNext())
                       trimember test = (trimember) it.next();
                       if (test.last.equals(inlf[0])&&test.first.equals(inlf[1]))
                           results.append(test.toString()+"\n");
                   namefld.requestFocus();
          public class trimember implements Comparable
           String eTag;
           public String memberNo;
           public String first;
           public String last;
           String gender;
           String yob;
           String tel;
           String addr;
           String club;
           public trimember(String eT, String me, String fi, String la,
                   String ge, String yo, String te, String ad, String cl)
               eTag = eT;
               memberNo = me;
               first = fi;
               last = la;
               gender = ge;
               yob = yo;
               tel = te;
               addr = ad;
               club = cl;         
           //To String method to output string of details
           public String toString()
               return last + "\t" + first + "\t" + eTag + "\t" +
                       memberNo + "\t" + gender + "\t" + yob + "\t"+ tel + "\t" +
                       addr + "\t" + club;
           //Compare and sort on Last name
           public int compareTo(Object o)
               trimember com = (trimember) o;
               int lastCmp = last.compareTo(com.last);
               int firstCmp = first.compareTo(com.first);
               int memCmp = memberNo.compareTo(com.memberNo);
               if (lastCmp == 0 && firstCmp !=0)return firstCmp;
               else if (lastCmp==0&&firstCmp==0)return memCmp;
               else return lastCmp;
    }

    Please don't cross-post. It is considered very rude to do that here:
    http://forum.java.sun.com/thread.jspa?messageID=9953193

  • Help needed, Providing Dynamic User input

    Hello,
    I am attempting to create some dynamic user input by "predicting" what the user requires in a text box.
    For example if the user enters "Smi" I have a select list pop up which gives the user all options that begin with "Smi".
    I am able to achieve the popups but the interface is quite jerky and not terribly responsive I am trying to solve this by using a thread which starts and stops when new input is received but it is still not quite right.
    The program uses a Sorted TreeSet to hold the data (I thought this would give me a quick search time) and a simple interface at this stage.
    Any help would be fantastic
    Thanks in advance :P
    import java.io.*;
    import java.awt.*;
    import javax.swing.*;
    import java.awt.event.*;
    import javax.swing.event.*;
    import java.text.*;
    import java.util.*;
       /** This program represents part of a larger user interface for allowing the
       user to select data from a file or database.
       <p>
       When the program starts up, it will read in data from a given file, and hold
       it in some type of container allowing rapid access.
       <p>
       The user may then type in the first few letters of the surname of a person,
       and this program should immediately present in a popup dialog the names which
       match.  The user will be able to click on one of the names in the popup and
       that will cause all data about that person to be displayed in the JTextArea
       at the bottom of the window.
       <p>
       This program requires the FormLayout.class, FormLayout$Placement.class, and
       FormLayout$Constraint.class files in the same directory
       (folder) or in its classpath.  These is provided separately.
    class PartMatch extends JFrame implements Runnable
                        /** Close down the program. */
       JButton quitbtn;
                        /** Field for the surname. */
       JTextField namefld;
                        /** Full details of the person(s). */
       JTextArea  results;
                        /** Popup dialog to display the names and addresses which
                        match the leading characters given in namefld. */
       Chooser matches;
                      /** Default background color for a window. */
       final static  Color            defBackground = new Color(0xD0C0C0);
                      /** Default foreground color for a window. */
       final static  Color            defForeground = new Color(0x000000);
                      /** Default background color for a field */
       final static  Color            fldBackground = new Color(0xFFFFFF);
                      /** Default background color for a button */
       final static  Color            btnBackground = new Color(0xF0E0E0);
       final static  Color            dkBackground = new Color(0xB0A0A0);
                      /** Larger font */
       final static  Font bold = new Font("Helvetica", Font.BOLD, 30);
       TreeSet members;
       String input;
       String[] found;
       public static void main(String arg[])
          UIManager.put("TextField.background",fldBackground);
          UIManager.put("TextField.foreground",defForeground);
          UIManager.put("TextField.selectionBackground",btnBackground);
          UIManager.put("TextArea.background",fldBackground);
          UIManager.put("TextArea.foreground",defForeground);
          UIManager.put("TextArea.selectionBackground",btnBackground);
          UIManager.put("Panel.background",defBackground);
          UIManager.put("Label.background",defBackground);
          UIManager.put("Label.foreground",defForeground);
          UIManager.put("Button.background",btnBackground);
          UIManager.put("Button.foreground",defForeground);
          UIManager.put("CheckBox.background",defBackground);
          UIManager.put("ScrollBar.background",defBackground);
          UIManager.put("ScrollBar.thumb",btnBackground);
          UIManager.put("ComboBox.background",btnBackground);
          UIManager.put("ComboBox.selectionBackground",dkBackground);
          PartMatch trial = new PartMatch(arg);
       public PartMatch( String [] arg )
          super("Part Match");
          setDefaultCloseOperation(EXIT_ON_CLOSE);
          Container cpane = getContentPane();
          FormLayout form = new FormLayout(cpane);
          JLabel lab1 = new JLabel("Fetch details") ;
          lab1.setFont( bold );
          form.setTopAnchor( lab1, 4 );
          form.setLeftAnchor( lab1, 4 );
          JLabel lab2 = new JLabel("Surname: ") ;
          form.setTopRelative( lab2, lab1, 4 );
          form.setLeftAlign( lab2, lab1 );
          namefld = new JTextField( 30 );
          form.setBottomAlign( namefld, lab2 );
          form.setLeftRelative( namefld, lab2, 4 );
          namefld.addCaretListener( new CaretListener()
             public void caretUpdate(CaretEvent e)
                 showMatches();
          quitbtn = new JButton( "Quit" );
          quitbtn.addActionListener( new ActionListener()
             public void actionPerformed(ActionEvent e)
                quitProcessing();
          form.setBottomAlign( quitbtn, namefld );
          form.setLeftRelative( quitbtn, namefld, 15 );
          results = new JTextArea( 10,50 );
          results.setEditable(false);
          JScrollPane jsp = new JScrollPane( results,
                                     JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
                                     JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED );
          form.setTopRelative( jsp, lab2, 6 );
          form.setLeftAlign( jsp, lab2 );
          form.setBottomAnchor( jsp, 5 );
          form.setRightAnchor( jsp, 5 );
          form.setRightAnchor( quitbtn, 5 );
          matches = new Chooser( this );
          //matches.setUndecorated(true);
          pack();
          setVisible(true);
          namefld.requestFocus();
          if (arg.length > 0) init(arg[0]);
          else init("triathlon.txt"); //<<<<<<<<<<<<<<<< Place the default filename here
          /** Called once only, at the end of the constructor, to read the data
            * from the membership file.
       public void init( String fname )
          members = new TreeSet();
           try {
               FileReader fr = new FileReader(new File (fname));
               Scanner scan = new Scanner(fr);
               trimember cmem;
               String cLine, eTag, memberNo, first, last, gender, yob, tel ,addr,
                       club;
               while(scan.hasNextLine())
                   cLine = scan.nextLine();
                   Scanner scan2 = new Scanner(cLine);
                   scan2.useDelimiter(";");
                   eTag = scan2.next().trim();
                   memberNo = scan2.next().trim();
                   first = scan2.next().trim();
                   last = scan2.next().trim();
                   gender = scan2.next().trim();
                   yob = scan2.next().trim();
                   tel = scan2.next().trim();
                   addr = scan2.next().trim();
                   club = scan2.next().trim();
                   cmem = new trimember(eTag, memberNo, first, last, gender, yob,
                           tel, addr, club);
                   members.add(cmem);
           catch (FileNotFoundException ex)
               results.append("Sorry can't find the input file\n");
               results.append("Please check file name and location and try again");
               ex.printStackTrace();
          /** Called every time there is a change in the contents of the text field
            * namefld.  It will first clear the text area.  It then needs to search
            * through the container of data to find all records where the surname
            * starts with the characters that have been typed.  The names and
            * addresses need to be set up as strings and placed in
            * an array of Strings.  This can be placed in the "matches" window and
            * displayed for the user, inviting one to be selected.
            * <p>
            * The performance of this is very important.  If necessary, it may be
            * necessary to run as a separate thread so that the user interface is
            * not delayed.  It is essential that the user be able to type letters at a
            * reasonable speed and not have the keystroke processing held up by
            * previous text.
       public void showMatches( )
           run();
                // First clear the text area
          //results.setText("");
                // Determine the leading characters of the surname that is wanted
                input = namefld.getText();
                // Locate the data for this name, and display each matching item
                //  in the JTextArea ...
                // Example of how to set the data in the popup dialog
          matches.list.setListData(found);
          matches.pack();   // resize the popup
                // set the location of the popup if it is not currently visible
          if ( ! matches.isVisible())
             Dimension sz = matches.getSize();
             Point mouse = getMousePosition();
             Point framepos = getLocation();
             int x=0, y=0;
             if (mouse == null)
                Point pt = results.getLocation();
                x = pt.x + 20 + framepos.x;
                y = pt.y + 20 + framepos.y;
             else
                x = mouse.x - 2 + framepos.x;
                y = mouse.y - 2 + framepos.y;
             matches.setLocation(x,y);
          matches.setVisible(true);
          namefld.requestFocus();
          /** Perform any final processing before closing down.
       public void quitProcessing( )
          // Any closing work.  Then
          System.exit(0);
        public void run()
            ArrayList<String> foundit = new ArrayList<String>();
            System.out.println(input);
            if(input != null)
            Iterator it = members.iterator();
            while(it.hasNext())
               trimember test = (trimember) it.next();
               if (test.last.startsWith(input))
                   foundit.add(test.last +", "+ test.first);
            found = new String[foundit.size()];
            for(int i=0; i<foundit.size();i++)
                found[i] = foundit.get(i);
         /** A window for displaying names and addresses from the data set which
          match the leading characters in namefld.
          <p>
          This will automatically pop down if the user moves the mouse out of the
          window.
          <p>
          It needs code added to it to respond to the user clicking on an item in
          the displayed list. */
       class Chooser extends JWindow
                /** To display a set of names and addresses that match the leading
                characters of the namefld text field. */
          public JList list = new JList();
          Chooser( JFrame parent )
             super( parent );
             Container cpane = getContentPane();
             cpane.addMouseListener( new MouseAdapter()
                public void mouseExited(MouseEvent e)
                   Chooser.this.setVisible(false);
             cpane.add("Center",list);
             list.addListSelectionListener( new ListSelectionListener()
                public void valueChanged(ListSelectionEvent e)
                   Chooser.this.setVisible(false);
                   System.out.println("ValueChanged");
                   // First clear the text area
                   results.setText("");
                   String in = (String) list.getSelectedValue();
                   System.out.println("Selected Value was : "+in);
                   String[] inlf = in.split(", ");
                   System.out.println("inlf[0]:"+inlf[0]+" inlf[1]:"+inlf[1]);
                   results.append("Surname \tFirst \teTag \tMemberNo \tSex \tYOB " +
                           "\tTel \tAddress \t\t\tClub\n");
                   Iterator it = members.iterator();
                   while(it.hasNext())
                       trimember test = (trimember) it.next();
                       if (test.last.equals(inlf[0])&&test.first.equals(inlf[1]))
                           results.append(test.toString()+"\n");
                   namefld.requestFocus();
          public class trimember implements Comparable
           String eTag;
           public String memberNo;
           public String first;
           public String last;
           String gender;
           String yob;
           String tel;
           String addr;
           String club;
           public trimember(String eT, String me, String fi, String la,
                   String ge, String yo, String te, String ad, String cl)
               eTag = eT;
               memberNo = me;
               first = fi;
               last = la;
               gender = ge;
               yob = yo;
               tel = te;
               addr = ad;
               club = cl;         
           //To String method to output string of details
           public String toString()
               return last + "\t" + first + "\t" + eTag + "\t" +
                       memberNo + "\t" + gender + "\t" + yob + "\t"+ tel + "\t" +
                       addr + "\t" + club;
           //Compare and sort on Last name
           public int compareTo(Object o)
               trimember com = (trimember) o;
               int lastCmp = last.compareTo(com.last);
               int firstCmp = first.compareTo(com.first);
               int memCmp = memberNo.compareTo(com.memberNo);
               if (lastCmp == 0 && firstCmp !=0)return firstCmp;
               else if (lastCmp==0&&firstCmp==0)return memCmp;
               else return lastCmp;
    }Edited by: Roger on Nov 3, 2007 11:50 AM

    Please don't cross-post. It is considered very rude to do that here:
    http://forum.java.sun.com/thread.jspa?threadID=5233033&messageID=9953169#9953169

  • Help Needed with Dynamic RePort PAges

    I've created a link that dynamically will generate a data
    report from my db. I have about 30 reports the client needs to be
    able to run. Do I have to create a separate page for every single
    recordset?? Is there a more efficient way to do this??

    You could make a drop down menu with the name of the report
    in it and then show that report on the redirect page using an if
    statement to determine which sql statement to run. Also you can
    have multiple recordset on a page.
    Are you using php, asp or cfm?

  • Help needed on Dynamic XML PDF

    Hello,
    I have an urgent need of help. We had a client requirement to develolp a custom form fillable Flowable template. We used adobe LiveCycle Designer to create a flowable form where fields can be suppressed\expanded to save space. LiveCycle form fields are databinded with the XML Schema at design time. After creating forms, data is prepopulated using the 3rd party ITextsharp for .NET dll using a FillXFA API. Filled PDF document appears fine with the data by adobe reader.
    However, after we try to either convert this form to an Image I don't see DATA in the form and only see the static template. Our requirement is to take the populated PDF and merge it with another static PDF document. I am new to the adobe livecycle forms and needs assistance. I guess the issue is that final populated form is still XML, So If I open this form that is prepopulated with data into LiveCycle I don't see the data and only template, But we can view the populated form fine with data through adobe reader. Even through windows file preview I only see template, but after I open the file through reader I see the data. If through some way we can convert this snapshot (dynamic pdf = populated data with template) to a static pdf or flatten out the dynamic pdf, it will suffice our requirement.We are sort of stuck from past 10 days on this issue. Any help\feedback is greatly appreciated.
    Please let me know if you need any input or examples. Thanks for your time.
    Thank You,
    Himali Vaid

    Harshit Rungta:
    You have opened a number of related questions today. I'd like to see the other ones closed before you continue with this one.
    I'll lock this but will re-open it once the others are marked as solved.
    Rob

  • Help with using dynamic sql logic in a view please?

    Greetings,
    I want to create a dynamic union using all the databases on server. The following works:
    declare @sqlvarchar(max)
    select
    @sql=IsNull(@sql+'union
    all ','')+'select
    * from  '+name+'.[dbo].[A]''
    inner join '+name+'.[dbo].[B]'' on
    a.f1=b.f1'
    from
    sys.databases
    where
    name
    in(select
    name
    from
    sys.databases)
    exec
    (@sql)
    The problem is I need something tangible, like a view, to query using SSAS later. I've tried to use SELECT into to load a new table with a resulting dataset. It gives me a syntax error - the dynamic part can't be combined with static. I can't use OPENQUERY
    because it all happens on the same server. Assistance would be appreciated. Thanks

    Well, you could regenerate the view each time a database is created or dropped.
    Or you can define your cube using an empty view and load the cube using SSIS, eg with
    Dimension Processing Destination.
    Or you can use something like a CLR TVF inside your view.
    David
    David http://blogs.msdn.com/b/dbrowne/

  • Help needed when dynamically creating new stage sprites

    Morning folks,
    I'm feeling very rusty when asking this question! It feels
    like I should
    know the answer but simply unable to comprehend where I'm
    going wrong at the
    moment!!
    I'm in the process of creating a Director piece that involves
    the user
    having to drag "shapes" onto a pre-defined grid [drag and
    drop style] --
    there are currently three different types of shape that can
    be dragged of
    which many of the shapes can be of the same type. So I need
    to display the
    three shape types on one side of the screen and allow the
    user to drag and
    drop as many as they wish to the girded area.
    I've written the drag and drop routine but now having
    difficulty in
    producing the dynamic creation of a new draggable shape; so
    far I've managed
    to create a new "shape" sprite from my cast library and
    placed it in the
    correct location. Then I create and add a new instance of my
    "Drag and Drop"
    behaviour onto the newly created sprite, but this is where it
    goes wrong --
    although I can drag the dynamically created sprite, once
    dropped Director
    complains of not knowing what its local properties are, for
    example I'm
    unable to reference the locH and locV of the newly created
    sprite!
    I'm really at a loss on this one and would appreciate any
    kind of guidance!
    Many thanks in advance, Mark ;-)

    Hi Saravanan,
    >>>><b>First column - Welcome message , below Date , time and place</b>
       It is possible to add date, time and location in the welcome area. Jus add a table to the <td> of the welcome area container. Like this.
    <% Date d= new Date(); %>
    <TD nowrap class="prtlHdrWelcome" ti="0" tabIndex="0" id="welcome_message"><%=StringUtils.escapeToHTML(GetWelcomeMsg(componentRequest, welcomeClauseStr))%><table width="100"><tr><td nowrap><%=d%></td><td>INDIA</td></tr></table></TD>
    Hope it helps.
    Regards,
    Saravanan
    P.S: Hope you remember the thread
    <a href="http://">https://www.sdn.sap.com/irj/sdn/thread?threadID=152135&messageID=1703666</a>

Maybe you are looking for

  • Dreamweaver 8 help please!

    I'm having an issue with Dreamweaver 8, hope someone familiar with the program can help me. I've been neck deep in a website project for a client of my wife's work for the last couple of months now. I'm old school and code everything by hand in a pla

  • My volume buttons won't work on my iPod touch 4th gen.

    Whenever i try to turn it up, it won't work. So i go to the music and turn it up that way, but it slides down and is silent. it will stay for a couple seconds but not for a long time. everything else works, even though the volume pop up that comes on

  • BLAF -  Browser Look And Feel

    I have been looking at BLAF Guidline Specification. I am using it as a guid for building our Portal solution. But lately there have been som problem with this pages. The links to the gif are lost, and the education link does not work. I hope you can

  • Feature Request: Ability to modify corner radius on boxes after creation

    Hi. As an interface designer I often use the rounded box tool to create buttons. I noticed that you can only select the corner radius at the time the box is created and not modify it thereafter--your only option is to delete the shape and create a ne

  • Wat is the purpose of authorization?

    wat is the purpose of authorization?