Convert SQL Query in SSRS

Can anyoone help me out to convert this SQL query in SSRS.
create table tickets_every_hour_ict(ddate datetime,dgroup varchar(50))
Insert into tickets_every_hour_ict
Select
--incident.actie,
incident.dataanmk ,
incident.ref_operatorgroup
/*,incident.ref_status as "Status",
incident.datumaangemeld as "Datum aanmelding" */
From incident
WHERE incident.dataanmk >= DATEADD(day,-7, GETDATE())
AND incident.ref_operatorgroup in ('Automatisering')
order by incident.dataanmk desc
Select ddate1,[00:00],[01:00],[02:00],[03:00],[04:00],[05:00],[06:00],[07:00],[08:00],[09:00],[10:00],[11:00],[12:00],
[13:00],[14:00],[15:00],[16:00],[17:00],[18:00],[19:00],[20:00],[21:00],[22:00],[23:00]
From
Select dgroup 'dgroup',cast(Convert(varchar(10),ddate,101)+' '+ convert(varchar(3),ddate,108) +'00' as date) ddate1,convert(varchar(3),ddate,108) +'00' dtime From tickets_every_hour_ict
)p
PIVOT
Count(dgroup) for dtime in([00:00],[01:00],[02:00],[03:00],[04:00],[05:00],[06:00],[07:00],[08:00],[09:00],[10:00],[11:00],[12:00],
[13:00],[14:00],[15:00],[16:00],[17:00],[18:00],[19:00],[20:00],[21:00],[22:00],[23:00])
)PVT

In SSRS you just need to use  matrix container and use query as below
Select dgroup 'dgroup',cast(Convert(varchar(10),ddate,101)+' '+ convert(varchar(3),ddate,108) +'00' as date) ddate1,convert(varchar(3),ddate,108) +'00' dtime From tickets_every_hour_ict
Then in report add dtime column inside column group of matrix and add
=Count(Fields!dgroup.value)
as expression inside data area.
add
ddate1 to row group and you'll get pivoted values
Please Mark This As Answer if it helps to solve the issue Visakh ---------------------------- http://visakhm.blogspot.com/ https://www.facebook.com/VmBlogs
I created it your way but then it will not show the tables with 0. I want it to show all hours even if the count is 0.

Similar Messages

  • How to convert sql query to oracle query?

    Hi all,
    Hope doing well,
    sir i am using oracle database where i am running my sql query in oracle. but this query is not working properly. i used sql developer translation scratch editor to convert that.
    it's converted but i am not getting the exact value.
    which i was getting in sql server.
    here is my query below:
    SELECT C.*,ISNULL(P.Comp_Name,'') + ' (' + ISNULL(P.Comp_ID,'') + ')' Parent FROM Comp_Master C LEFT JOIN Comp_Master P ON C.Parent_ID = P.Comp_ID Where C.Comp_ID='C02'
    please convert it into oracle so that i can use this query
    thanks in advance.

    Try --
    1. Use NVL instead of isNull
    2. Use *||* instead of +*
    /* Formatted on 9-13-2012 4:39:09 PM (QP5 v5.163.1008.3004) */
    SELECT c.*, NVL (p.comp_name, '') || ' (' || NVL (p.comp_id, '') || ')' parent
        FROM comp_master c LEFT JOIN comp_master p ON c.parent_id = p.comp_id
    WHERE c.comp_id = 'C02'
    PS - Do remember to mark the solutions as Helpful or Correct. Thanks for understanding.

  • Issue in converting sql query to oracle

    Hi Friends,
    I have a sql query as follows,
    Select Name From SysObjects Where XType = 'U' And Name = @NameI want to convert this to oracle. I have tried to convert this in someways. But I'm getting errors only. Please anyone help me to fix this issue.
    Thanks,
    Ram

    Most Oracle dictionary views come in DBA_, ALL_ and USER_ flavours. Probably you don't have privileges to view DBA_OBJECTS, in which case try ALL_OBJECTS or <a gref="http://download-uk.oracle.com/docs/cd/B19306_01/server.102/b14237/statviews_2005.htm">USER_OBJECTS</a>.
    Based on what I read, you might need something like
    SELECT * FROM all_objects WHERE owner &lt;> 'SYS' AND object_type = 'TABLE'btw a sure way to wind up Oracle professionals is to use "SQL" to mean another DBMS product and not Structured Query Language. As you may have noticed, we have SQL over here as well.

  • Write PL/SQL query from SSRS 2008

    Hello,
    I've need of writing the following statement as query or procedure within SSRS 2008(SQL Server Reporting Services 2008) to query Oracle data.
    IF :PARAMETER1 = 1
    SELECT A1,B1,C1 FROM TABLE1
    INNER JOIN TABLE2 ON TABLE2.X = TABLE1.X
    INNER JOIN TABLE3 ON TABLE3.Y = TABLE1.Y
    WHERE TABLE1.FIELD1 = :PARAMETER1
    ELSE IF :PARAMETER1 = 0
    SELECT A1,B1,C1 FROM TABLE1
    INNER JOIN TABLE2 ON TABLE2.X = TABLE1.X
    WHERE TABLE1.FIELD1 = :PARAMETER1
    Can someone please help since I am trying to write query with IF ELSE statement or block from SSRS 2008?
    Brief scenario - I'm trying to query data from Oracle db by using Oracle data source connection(11g client) from SSRS 2008 to display on SSRS report.
    Thanks,
    JS.

    user1378136 wrote:
    Thank you for the tip and sample snippet as you mentioned it may not work, it did not work.
    Probable I did not ask the question right way. Let me ask you this. If I were to write SQL or PL/SQL (which ever is required because of IF condition) to query Oracle DB how do I do below mentioned statements,
    IF condition = true
    do something.....
    Else IF condition = false
    do something.....
    Thank you,
    JS.Typically i'd create a function that returns a ref cursor for something like this (on the Oracle database you need to query) and then call that from wherever it is required.
    create or replace function get_some_data
       p_PARAMETER1   number
    return sys_refcursor
    is
       some_ref_cursor   sys_refcursor;
    begin
       IF p_PARAMETER1 = 1
       then
          open some_ref_cursor for
             SELECT A1,B1,C1 FROM TABLE1
             INNER JOIN TABLE2 ON TABLE2.X = TABLE1.X
             INNER JOIN TABLE3 ON TABLE3.Y = TABLE1.Y
             WHERE TABLE1.FIELD1 = 1;
       ELSIF p_PARAMETER1 = 0
       then
          open some_ref_cursor for for
             SELECT A1,B1,C1 FROM TABLE1
             INNER JOIN TABLE2 ON TABLE2.X = TABLE1.X
             WHERE TABLE1.FIELD1 = 0;
       end if;
       return some_ref_cursor;
    end get_some_data;
    /So you'd return a pointer to 1 of 2 queries via this function, and the client would process it accordingly.

  • SQL Query to SSRS Expression

    How can I convert the below two queries in SQL to SSRS expression?
    1) DATEADD(MONTH,DATEDIFF(MONTH,0,@DateFrom),0)
    2) DATEADD(DAY,-1,DATEADD(MONTH,DATEDIFF(MONTH,0,@DateTo)+1,0)) 
    Thank you,

    Thank you for your response Carnegie,
    I actually have two stored procedures as below. (columns and joined tables are excluded)
    I need to change the dates of @DateFrom and @DateTo parameter, I am passing @DateFrom_FD and @DateTo_LD as well.
    CREATE ROCEDURE [dbo].[Test]
    (@DateFrom
    SMALLDATETIME
      , @DateTo
    SMALLDATETIME
      , @program
    VARCHAR(MAX))
    AS
    DECLARE
    @DateFrom_FD
    SMALLDATETIME
           , @DateTo_LD
    SMALLDATETIME
    SET @DateFrom_FD = DATEADD(MONTH,DATEDIFF(MONTH,0,@DateFrom),0)
    SET @DateTo_LD = DATEADD(DAY,-1,DATEADD(MONTH,DATEDIFF(MONTH,0,@DateTo)+1,0)) 
    SELECT 
      DimDate.[Year]
    , DimDate.[Month]
    , DimDate.PK_Date
    , CustomerID
    FROM DimDate
    WHERE DimDate.PK_Date BETWEEN @DateFrom_FD AND @DateTo_LD
    Now I am using one of the SP as a main report and the other SP as a subreport.
    In order to configure the main report and the subreport, I believe that I need to link them with parameters.
    However, in the parameters of subreport properties, the option given are only @DateFrom and @DateTo.
    No @DateFrom_FD AND @DateTo_LD
    Therefore, I am thinking to use expressions to convert @DateFrom and @DateTo the same way I did in SQL.
    I am not sure if this works....but this is the only thing that I could think of.
    Thank you,
    YJB5151

  • How to convert sql query to hql format?

    I want to convert the following query from SQL to HQL.
    SELECT
    student.first_name AS student_first_name,
    course.name AS course_name,
    course.id AS course_id,
    admission.admission_no AS admission_admission_no,
    attendance.status AS attendance_status,
    case WHEN attendance.status=1 THEN 'P'
    WHEN attendance.status=2 THEN 'A'
    End as Status,
         count(course.id) as Periods,
         count(attendance.status) as Total,
    time_table_item.tt_date AS time_table_item_tt_date,
    attendance.student_batch_id AS attendance_student_batch_id
    FROM
    public.time_table_item time_table_item
    INNER JOIN public.attendance attendance ON time_table_item.id = attendance.time_table_item_id
    INNER JOIN public.syllabus_course syllabus_course ON syllabus_course.id = time_table_item.act_syl_course_id
    INNER JOIN public.course course ON syllabus_course.course_id = course.id
    INNER JOIN public.student_batch student_batch ON attendance.student_batch_id = student_batch.id
    INNER JOIN public.admission admission ON student_batch.admission_id = admission.id
    INNER JOIN public.student student ON admission.student_id = student.id
    AND course.id = syllabus_course.course_id
    INNER JOIN public.time_table time_table ON time_table_item.time_table_id = time_table.id
    where
         student_batch.batch_id= $P{Batch} and time_table.level_id= $P{Level} and syllabus_course.course_id = $P{Course} course.id=9142294     course.id=9142294
    group by
         course.id, admission.admission_no,time_table_item.tt_date,attendance.student_batch_id,
         student.first_name,attendance.status,course.name
    order by
         course.id, admission.admission_no,time_table_item.tt_date
    Can i get the corresponding HQL query for this?
    Please help

    Well, the Hibernate Query Language is only one degree of separation from Java. Javert has a Bacon number of 4: http://oracleofbacon.org/cgi-bin/oracle/movielinks?firstname=Bacon,%20Kevin&game=1&secondname=Javert

  • Convert SQL Query to Oracle

    Hi All,
    I have two queries of SQL for creating table.
    Query1.
    CREATE TABLE [dbo].[DocumentType] (
    [DocType] [varchar] (20) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL ,
    [SubCat] [varchar] (20) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL
    ) ON [PRIMARY]
    GO
    ALTER TABLE [dbo].[DocumentType] ADD
    CONSTRAINT [PK_DocumentType] PRIMARY KEY CLUSTERED
    [DocType],
    [SubCat]) ON [PRIMARY]
    Query2.
    CREATE TABLE [dbo].[SBU] (
    [SBU] [varchar] (51) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL
    ) ON [PRIMARY]
    GO
    ALTER TABLE [dbo].[SBU] ADD
    CONSTRAINT [PK_SBU] PRIMARY KEY CLUSTERED
    [SBU]
    ) ON [PRIMARY]
    What will be the Query in Oracle??
    Please suggest!!!
    Regards,
    Shah

    Hi,
    First of all you need to go to scheme in which you need to create those tables. Or you can do it from sys user by giving allias.
    I will explaing you by going to user account.
    open command prompt --> sqlplus --> userid@database_name enter-->password
    write below commands :-
    CREATE TABLE  DocumentType
    DocType varchar(20) NOT NULL ,
    SubCat varchar(20)  NOT NULL
    ALTER TABLE DocumentType ADD
    CONSTRAINT PK_DocumentType PRIMARY KEY on (DocType);And same for the second table.
    Enjoy.

  • SQL Query for SSRS has data but fields don't show that data

    I am having a strange issue here with my new report;
    First off, this report is an availability report for employees. If they are busy then a 0 should be displayed for that Hour and if they are free then a 1 is to be displayed. There are 2 parameters setup for use in this query, one is a Date/Time parameter
    and the other is a Text parameter where another Dataset Query is grabbing the data for (Departments)
    I have 2 Parameters, 1 is for a Department and the other is to select the date.
                           Hour1     Hour2    Hour3     Hour4    Hour5   
    Hour6    Hour7
    Smith, John     |     1     |     0     |     0     |     0     |   
    1     |     1     |     1     |
    Som, One        |     1     |     1     |     1     |     0
        |    0     |     1     |     1     |
    When I run the query in the Query Designer for the Dataset the information is displayed correctly and as I would expect it, however, when I run the Report and choose the same information for the 2 parameters then the report only ever shows all 1's;
    Smith, John     |     1     |     1     |     1     |     1     |   
    1     |     1     |     1     |
    Som, One        |     1     |     1     |     1     |     1    
    |    1     |     1     |     1     |
    I've tried searching but didn't know what term to use that describes what is going on.
    Like I said, this works if ran in SSMS and works when ran in the Query Builder of SSRS but when it comes to displaying the data on the report the incorrect information is displayed.
    Any help would be appreciated.
    EDIT
    I have also ran the Report Table Wizard with the same query and chosen Names as the row and Hours as the columns and the same thing happens - just all 1's are displayed even thought the query in Query Builder shows correct information.

    The difference running the query directly in query designer and when the report runs is that you manually type in values for the parameters when running query designer. It is likely that the parameter values from the report have a different syntax than you
    expect. This will happen especially when setting the available values of a parameter from a data cube query. A value from an analysis cube may be displayed in the query designer as "\Project\Iteration Node" while the actual value is "[Work Item].[Iteration
    Hierarchy].[Iteration2].&[-7189901615194941888]&[-8272609059741292246]". Very different as you can see. This example is from the TFS analysis server.
    The best way to validate that your parameters are passing the values (and syntax) you expect is to add text boxes to your report for each parameter and set them to display Parameters!ParameterName.Value.
    "You will find a fortune, though it will not be the one you seek." -
    Blind Seer, O Brother Where Art Thou
    Please Mark posts as answers or helpful so that others may find the fortune they seek.

  • Convert SQL Query to Derived Column Expression

    I'm in the process of reworking some SSIS packages I inherited. A lot of these use Execute SQL Statement components to update certain fields in the tables once they've been loaded. I'd like to replace these individual UPDATE statements with Derived Column
    components.
    I've got 95% of them converted, except for a couple, one of which has me a bit perplexed and was hoping someone could provide some insight.
    Essentially, there is a column called POSTPERIOD which is a date in string format YYYYMM (i.e., 201503). The SQL update parses out the month piece and converts it to the month name and populates a column called POSTPERIOD_MONTH.
    Here is the SQL:
    select DateName(month , DateAdd(month, CONVERT(INT, SUBSTRING(POST_PERIOD,5,2)), 0 ) - 1 )
    I'd like to accomplish this using a Derived Column, but not sure how to go about doing this...
    If someone could point me in the right direction, it would be greatly appreciated!
    Thanks!
    A. M. Robinson

    Visakh:
    Thank you for the reply! I've tried your solution but am getting the following error(s):
    Warning 17 Validation warning. Populate STAGING_DIM_AP_DETAIL - RADIO: {ACAA99C4-272C-4641-BF44-B4D4409D1EFB}: The expression "(DT_STR,8,1252)((DT_I4)[SUBSTRING](#85,5,2) == 1 ? (DT_STR,8,1252)"January" : ((DT_I4)[SUBSTRING](#85,5,2)
    == 2 ? (DT_STR,8,1252)"February" : ((DT_I4)[SUBSTRING](#85,5,2) == 3 ? (DT_STR,8,1252)"March" : ((DT_I4)[SUBSTRING](#85,5,2) == 4 ? (DT_STR,8,1252)"April" : ((DT_I4)[SUBSTRING](#85,5,2) == 5 ? (DT_STR,8,1252)"May" :
    ((DT_I4)[SUBSTRING](#85,5,2) == 6 ? (DT_STR,8,1252)"June" : ((DT_I4)[SUBSTRING](#85,5,2) == 7 ? (DT_STR,8,1252)"July" : ((DT_I4)[SUBSTRING](#85,5,2) == 8 ? (DT_STR,8,1252)"August" : ((DT_I4)[SUBSTRING](#85,5,2) == 9 ? (DT_STR,8,1252)"September"
    : ((DT_I4)[SUBSTRING](#85,5,2) == 10 ? (DT_STR,8,1252)"October" : ((DT_I4)[SUBSTRING](#85,5,2) == 11 ? (DT_STR,8,1252)"November" : (DT_STR,8,1252)"December")))))))))))" will always result in a truncation of data. The expression
    contains a static truncation (the truncation of a fixed value).   Dimension Finance - Load STAGING_DIM_AP_DETAIL_DERIVED_COLUMNS.dtsx 0 0 
    This is the derived column expression I'm using:
    (DT_STR,8,1252) ((DT_I4)SUBSTRING([POST_PERIOD],5,2) == 1? (DT_STR,8,1252) "January" : ((DT_I4)SUBSTRING([POST_PERIOD],5,2) == 2 ? (DT_STR,8,1252) "February" : ((DT_I4)SUBSTRING([POST_PERIOD],5,2) == 3 ? (DT_STR,8,1252) "March" :((DT_I4)SUBSTRING([POST_PERIOD],5,2) == 4 ? (DT_STR,8,1252) "April":((DT_I4)SUBSTRING([POST_PERIOD],5,2) == 5 ? (DT_STR,8,1252) "May" : ((DT_I4)SUBSTRING([POST_PERIOD],5,2) == 6 ? (DT_STR,8,1252) "June" : ((DT_I4)SUBSTRING([POST_PERIOD],5,2) == 7 ? (DT_STR,8,1252) "July" : ((DT_I4)SUBSTRING([POST_PERIOD],5,2) == 8 ? (DT_STR,8,1252) "August":((DT_I4)SUBSTRING([POST_PERIOD],5,2) == 9 ? (DT_STR,8,1252) "September":((DT_I4)SUBSTRING([POST_PERIOD],5,2) == 10? (DT_STR,8,1252) "October": ((DT_I4)SUBSTRING([POST_PERIOD],5,2) == 11 ? (DT_STR,8,1252) "November" : (DT_STR,8,1252)"December")))))))))))
    Some info that might be of some help in the matter...the POST_PERIOD field is a VARCHAR(8), the POST_PERIOD_MONTH field is also a VARCHAR(8).
    There is a computed column Any help would be appreciated once again!!!
    A. M. Robinson

  • Ssrs expression to sql query

    Hi,
    I am unable to convert the below ssrs expression to sql query. can you guys help.
    --          IIF(Parameters!parameter1.Value Is Nothing, 
    --               " 3>2 ", 
    --               "column1 NOT LIKE
    --                           Replace(IIF(Left(Parameters!parameter1.Value, 1) = "'", 
    --                                             Parameters!parameter1.Value, 
    --                                             "'" & Replace(Parameters!parameter1.Value, "'", "''")  "'"),
    Thanks.

    Thank you for your response Carnegie,
    I actually have two stored procedures as below. (columns and joined tables are excluded)
    I need to change the dates of @DateFrom and @DateTo parameter, I am passing @DateFrom_FD and @DateTo_LD as well.
    CREATE ROCEDURE [dbo].[Test]
    (@DateFrom
    SMALLDATETIME
      , @DateTo
    SMALLDATETIME
      , @program
    VARCHAR(MAX))
    AS
    DECLARE
    @DateFrom_FD
    SMALLDATETIME
           , @DateTo_LD
    SMALLDATETIME
    SET @DateFrom_FD = DATEADD(MONTH,DATEDIFF(MONTH,0,@DateFrom),0)
    SET @DateTo_LD = DATEADD(DAY,-1,DATEADD(MONTH,DATEDIFF(MONTH,0,@DateTo)+1,0)) 
    SELECT 
      DimDate.[Year]
    , DimDate.[Month]
    , DimDate.PK_Date
    , CustomerID
    FROM DimDate
    WHERE DimDate.PK_Date BETWEEN @DateFrom_FD AND @DateTo_LD
    Now I am using one of the SP as a main report and the other SP as a subreport.
    In order to configure the main report and the subreport, I believe that I need to link them with parameters.
    However, in the parameters of subreport properties, the option given are only @DateFrom and @DateTo.
    No @DateFrom_FD AND @DateTo_LD
    Therefore, I am thinking to use expressions to convert @DateFrom and @DateTo the same way I did in SQL.
    I am not sure if this works....but this is the only thing that I could think of.
    Thank you,
    YJB5151

  • Converting SQL Report Region to PLSQL Function Body Returning SQL Query

    All:
    I want to convert my SQL Report Region to a PLSQL-generated SQL Report Region so that I can eliminate where clauses dynamically and speed up my app, and also so that I can provide additional sorting options.
    <br><br>
    My problem is that I have lots of embedded single quotes that already are coded as 3 single quotes in the SQL Report Region. I am not sure at all how to code them within the PLSQL.
    <br><br>
    As example, here is one column from my query:
    <br><br>
    select decode(nvl(g.date_sub_1,g.date_rec_1), null, decode(g.article, 0, 'E', 1, 'U'), '< a href="javascript:unElevate( ' ' ' || g.grid || ' ' ',' ' ' || g.natca || ' ' ')">' || decode(g.article, 0, 'E', 1, 'U') || '< /a>') "Reverse" from g_table g
    <br><br>
    (Note that I added spaces within the code so it would display properly in the browser.)
    <br><br>
    To clarify, that's a double quote before javascript, and then 3 single quotes before the first concatenation group, then 3 single quotes after the second concatenation group, then 3 single quotes before the third, 3 single quotes after the fourth followed by an end-paren followed by a double quote etc.
    <br><br>
    My question is, what do I do with these triple-single quotes within PLSQL? Probably a no-brainer for the experienced folks, but I am thinking like a mobius strip at this point.
    <br><br>
    Bill
    Message was edited by:
    [email protected]
    Message was edited by:
    [email protected]
    Message was edited by:
    [email protected]

    Scott,
    I think that feature was made for my situation! I keep getting
    Function returning SQL query: Query cannot be parsed within the Builder. If you believe your query is syntactically correct, check the generic columns checkbox below the region source to proceed without parsing.
    (ORA-20001: Unable to bind :43 verify length of item is 30 bytes or less. Use v() syntax to reference items longer than 30 bytes. ORA-01006: bind variable does not exist)
    I did chop the query up into little bits, i.e.
    p_sql := p_sql || q'! ... !';
    p_sql := p_sql || q'! ... !';
    p_sql := p_sql || q'! ... !';
    return p_sql;
    But I'm not sure what I'm supposed to do here.
    Thank you.
    Bill

  • How to pass parameter value as "where [fieldname] = [fieldvalue]" in sql query under query type in SSRS report?

    I am having trouble with passing dynamic string to sql query for executing SSRS reports.
    I am using oracle database and I want to pass where clause parameter as "where LAND_NR = 6" to my select query.
    For example: I want to execute Select * from employee :p_where.
    where p_where parameter holds value "where LAND_NR = 6"
    So it will treat as "Select * from employee where LAND_NR = 6" statement which will give me the list of records to display in my reports.
    But it's not taking correct sql command throwing an error as "SQLcommand not properly ended."
    How can I achieve this?

    You need to use dynamic sql
    But please keep in mind that since you're using Oracle you may be better off posting this in some Oracle forums
    This forum is specifically for SQL Server
    Please Mark This As Answer if it helps to solve the issue Visakh ---------------------------- http://visakhm.blogspot.com/ https://www.facebook.com/VmBlogs

  • SQL query, function or SP for converting varbinary to image(.jpg format).

    Dear Sir/Mam
    I want SQL query, function or SP which converts binary data to image (.jpg format).
    I m able to convert image (.jpg format) to varbinary. But not able to convert vice versa.
    thanks in advance.

    Binary data is binary data - "image" is only an intrepretation of binary data.  Therefore your question makes little sense in the context of sql server since it does not have any facilities to utilize images.  Since you provide no context, I'm
    guessing that you are trying to retrieve an image stored in the database in a varbinary column and have your application use it as an image.  If so, you should post your question to a forum that is specific to your development environment.  

  • Re: How to converting from PL/SQL query to T-SQL query

    How to converting from PL/SQL query to T-SQL query... Its Urgent

    Download the
    SQL Server Migration Assistant for Oracle.  It will convert whole Oracle databases, or single queries or PL/SQL stored procedures.
    With caution that If your database is using Collation which is case sensitive SSMA will not work.SSMA doesnt guarantees 100% for conversion of Queries/stored proc /database if it fails to do so for some queries you will have to do it manually.
    But you can try
    Please mark this reply as the answer or vote as helpful, as appropriate, to make it useful for other readers

  • SQL Query converted to PL/SQL?

    I am trying to get my sql query here (which works) converted over to a pl/sql function so I can use an IF / THEN statement to determine whether my 2nd search field has been submitted with something in it.
    My current query:
    select
         comm_Devices.ID,
         comm_Devices.PhonePager,
         comm_Devices.FirstName,
         comm_Devices.LastName,
         comm_Devices.Vendor,
         comm_DeviceType.Device,
         comm_Devices.PhoneNo,
         comm_Devices.Location,
         comm_Vendors.VendorName
    from comm_Devices
         Inner Join comm_DeviceType
              on comm_Devices.DeviceTypeID = comm_DeviceType.ID
         Inner Join comm_Vendors
              on comm_Vendors.vendorId = comm_Devices.vendor
         where
    comm_Devices.LastName LIKE '%' || upper(:P1_SEARCH_LAST_NAME) || '%'
    and comm_Vendors.VendorName LIKE '%' || upper(:P1_SEARCH_VENDOR) || '%'
    What I am wanting to do is convert it to pl/sql so I can do this:
    if :P1_SEARCH_VENDOR != '' then
    q:=q||'and comm_Vendors.VendorName LIKE '%' || upper(:P1_SEARCH_VENDOR) || '%';
    end if;
    Any help would be greatly appreciated!

    You are fairly close to figuring this out. Basically you want to create a Quesry Region of type :SQL Query (Pl/SQL Function Body Returning Sql Query).
    Then as most of the Dynamic query examples shouw you would do something like
    declare
    q varchar2(32767); -- query
    w varchar2(4000); -- where clause
    we varchar2(1) :='N'; -- identifies if where clause exists
    begin
    q := 'select "comm_Devices"."ID", ' ||
    ' "comm_Devices"."PhonePager", ' ||
    ' "comm_Devices"."FirstName",' ||
    ' "comm_Devices"."LastName", ' ||
    ' from "comm_Devices" ' ||
    ' Inner Join "comm_DeviceType" on "comm_Devices"."DeviceTypeID" = "comm_DeviceType"."ID" ' ||
    ' Inner Join "comm_Vendors" on "comm_Vendors"."vendorId" = "comm_Devices". "vendor" ';
    if :P1_SEARCH_VENDOR != '' then
    w := "where statement";
    we := 'Y';
    END IF;
    IF we = 'Y' THEN
    q := q || w;
    END IF;
    return q;
    end;
    This should get you started.
    James
    Message was edited by:
    [email protected]

Maybe you are looking for

  • Diplaying of ordsys.ordimage field in a Report based on Query

    Hi, I have a table with a ordsys.ordimage field, where I am uploading images. I created a custom report based on that table but I just cant seem to find a way to show images in it. Could anyone please tell me how to do this. I tried using this "porta

  • VL01N - needs to trigger outbound idoc

    Hi all, As per requirement please tell me information of how to trigger the outbound idoc on save that consist of delivery data with ref to sales order data. I am not able to create the Output type please tell me steps if possible of provide me some

  • One fourth?

    Only the iMac seems to get knocked out by interference, the iBook, xBox, & dark-side pc all maintain good signal strength, all the time, for weeks on end. If I move the iMac, and/or move the AEBS, and/or change the channel, I get the signal back full

  • Business account Pre-order problem/question/help

    I pre-ordered with my business account online.  They allowed me to bill it to my account.  I got a confirmation E-mail that gave me a 8 digit Reference # starting in MB MBXXXXXXXX No order number or confirmation number so I cannot track my shipment.

  • 6630 offline!!! help !! help!!

    I have bought my 6630 in italy about 2 yrs ago, and worked perfectly well with all my sim cards (TIM, WIND, T-Mobile) all pre-paid sim cards. I am here in Brazil now, and my phone was working with a TIM sim card from Brazil until 2 weeks ago! now my