A query as procedure parameter

Dear members,
(Forms 6i c/s)
I'd like to send a query through a parameter to a procedure.
The query has to be in a cursor.
How can I do ?
Can I send the text of the query, and tell Forms to use it as a query when declaring the cursor ?
Can I send the cursor through a parameter ?
Thanks for your help.

Can you, sure. Should you? At most, rarely.
You can use dynamic SQL (EXECUTE IMMEDIATE or DBMS_SQL) to execute an arbitrary string as a SQL statement. There are serious security issues if someone figures out how to pass a dangerous SQL statement in (i.e. update the USERS table, delete all the data from some important table, etc). If you are passing in a SELECT statement and you don't know the structure of the result set, you have to use DBMS_SQL rather than the simpler EXECUTE IMMEDIATE and use a more complicated API to describe the result set.
Justin

Similar Messages

  • XSQL query output as parameter for next xsql query

    Hi,
    Is it possible to use the output of one xsql query as input parameter for the next xsql query in the same file. I am trying to retreive an id from the query and use it in the next one. I cannot combine all the queries into one, since I intend to make the first query a database function that returns the id I am looking for. I am looking for something like this
    <xsql:query>
    select '1000' as myid
    from dual
    </xsql:query>
    <xsql:query>
    select add1,ro1
    from table1
    where id = {@myid}
    </xsql>
    I need the id returned by the first query to be used in the second one. Eventually my first query will be a stored procedure that validates the users rights and on sucess return the following tag <myid> 1000 <myid>.
    Please let me know , how I can achieve my goal of validating a user's priveleges and then executing the second query.
    Thanks
    Padmaja

    Hi ,
    Thanks for the response.This works if the first query is a select .
    If the first query was a call to a db procedure that returned the <myid>100<myid> would this still work?
    <xsql:set-page-param name="myid">
    <xsql:include-owa>
    xyz;
    </xsql:include-owa>
    </xsql:set-page-param>
    <xsql:include-param name="myid"/>
    <xsql:query>
    select name from mytable where id={@myid}
    </xsql:query>
    I have to use include-owa as the db procedure xyz does some cookie validations and then returns an id based on that. The procedure xyz returns an xml tag of form <myid>100<myid>
    This does not work as the value of myid is not available to the second query.
    Thanks
    Padmaja

  • Query builder, procedural builder - Oracle 8.17

    I'm running Oracle 8.17 and I can't find query builder, procedural builder, report builder form builder and other builders. Where can I get these? I tried the universal installer and there are no options to install them.

    Hi Fraser,
    Thank you for responding.
    I think I fixed that problem,actually there was a spelling
    mistake in one of the parameter files.
    But now I get another error message, says:
    "ORA: 02068: following severe error from MSOLEDB
    ORA: 28511: lost RPC connection to heterogenous
    remote agent using
    SID = (DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)
    (HOST=LOCAL_HOST)(PORT=1521)))(CONNECT_DATA=
    (SERVICE_NAME=<SERVICE_NAME>)))
    Do I have to configure the SQL Server network utilities?
    I pinged both the servers ,they talk to each other.
    But when I use tnsping ,the client machine (i.e.,the SQL Server
    machine)talks to server(Oracle machine) but the server doesn't
    talk to the client.
    I am definitely not doing something right.
    Asha.

  • SSRS report with tabular model - MDX query to filter parameter data based on Tuple value.

    Hello Everyone,
    I am working on SSRS report in which a tabular model is being used as a backend.
    I want to filter the report parameters which are dependent to other parameters. Like, country, state, and cities drop downs.
    All are multi-select parameters. I am using MDX queries to filter the parameters data.
    Based on selected one or more countries, the data of states needs to be filtered.
    The point is the text which is being displayed in state dropdown for each state name is combination of 3 different members.
    So, I created the following Tuple for the same and can see the expected display names in states dropdown.
    "("+
    [Location].[Code 1].CURRENTMEMBER.UNIQUENAME +","+
    [Location].[Code 2].CURRENTMEMBER.UNIQUENAME +","+
    [Location].[Descr].CURRENTMEMBER.UNIQUENAME +")"
    Now, when I would like filter the cities data based on selected one or more states, I am unable to pass the multiple Tuples (more than one selected Tuples) as parameter for cities dropdown.
    The following is my query for City parameter. It is working well when I select only one State from the dropdown.
    However, when I select multiple states, it is unable to convert the Tuple into SET in ELSE part of IIF condition specified in following query.
    Can anybody help me how to resolve the error that I am getting about STRTOSET function?
    Or
    Are there any other alternatives to achieve this requirement?
    Any help would be much appreciated.
    Query:
    WITH MEMBER [Measures].[ParameterCaption] AS [City].[City Business].CURRENTMEMBER.MEMBER_CAPTION
    MEMBER [Measures].[ParameterValue] AS [City].[City Business].CURRENTMEMBER.UNIQUENAME
    MEMBER [Measures].[ParameterLevel] AS [City].[City Business].CURRENTMEMBER.LEVEL.ORDINAL
    SELECT {[Measures].[ParameterCaption], [Measures].[ParameterValue], [Measures].[ParameterLevel]} ON COLUMNS ,
    [City].[City Business].Children ON ROWS
    FROM (
    SELECT ( STRTOSET(@State, CONSTRAINED) ) ON COLUMNS FROM [Model])
    WHERE ( IIF( STRTOSET(@State).Count= 1,
    STRTOTUPLE(@State, CONSTRAINED),
    STRTOSET("{
    ("+
    [Location].[Code 1].CURRENTMEMBER.UNIQUENAME +","+
    [Location].[Code 2].CURRENTMEMBER.UNIQUENAME +","+
    [Location].[Descr].CURRENTMEMBER.UNIQUENAME
    + ")
    }",CONSTRAINED )) ) CELL PROPERTIES VALUE
    Thanks, Ankit Shah
    Inkey Solutions, India.
    Microsoft Certified Business Management Solutions Professionals
    http://www.inkeysolutions.com/MicrosoftDynamicsCRM.html

    Hi,
    I used following dynamic query in expression of dataset of parameter and it works like a charm.
    "WITH MEMBER [Measures].[ParameterCaption] AS [City].[City Business].CURRENTMEMBER.MEMBER_CAPTION "&
    "MEMBER [Measures].[ParameterValue] AS [City].[City Business].CURRENTMEMBER.UNIQUENAME "&
    "MEMBER [Measures].[ParameterLevel] AS [City].[City Business].CURRENTMEMBER.LEVEL.ORDINAL "&
    "SELECT {[Measures].[ParameterCaption], [Measures].[ParameterValue], [Measures].[ParameterLevel]} ON COLUMNS , " &
    "[City].[City Business].Children ON ROWS " &
    " FROM [Model] WHERE ({"& join(Parameters!Location.Value,",") &"}) CELL PROPERTIES VALUE"
    Thanks, Ankit Shah
    Inkey Solutions, India.
    Microsoft Certified Business Management Solutions Professionals
    http://www.inkeysolutions.com/MicrosoftDynamicsCRM.html

  • Pass query result as parameter to javascript

    Hello,
    I'm a beginner with javascript, so (maybe) sorry for this
    question.
    Is it possible to use a query result as parameter in a
    javascript function
    for example like this?
    <cfquery name="select_data">
    select name from user_table
    </cfquery>
    <script language="javascript">
    function(#select_data.name#)
    </script>
    Background is: I have to validate an input field with some
    values which are saved in a database table.
    This values can be dynamic , so I don't want to put this
    values into the cfm-file.
    Any ideas?
    Claudia

    Each column in a cf query is effectively a 1D array. You can
    use the toscript function to send this array to js.

  • Stored Procedure parameter (@Carrier) used in report and can't be set via code

    I have a report that has regular Crystal parameters that I am setting correctly via code.  However, one report actually uses one of the database parameters from the stored procedure that the report was created from.  It is the only report like this and I'm using the same code in an attempt to set it's value.  Although no error is thown, if I look at the parameter value in the IDE it is set correctly, but the field on the report just shows up blank.  I have changed the way the report is created.  Previously, I used the report.export method to create the actual file via a stored procedure.  Now, I'm running the stored procedure first and creating a datatable.  This allows me to execute the SP only once to see if it has data, because only then do I want to create the actual report.  I'm using the SetDataSource method to pass the datatable into Crystal and then using the report.export method to create the report with data.  Everything seems to work, except this stored procedure parameter (@Carrier) is not actually being populated to display on the report.
    Not sure what to look at.  Any suggestions?
    Thanks.

    crpe32.dll is version 13.0.5.891.  This was developed in VS2012 and VB.NET.  I'm using ADO.Net to connect to a MS SQL Server database.
    MainReport.SetDataSource(DTbl)
    bRC = PopulateAllSubReports(MainReport)
    If Not bRC Then Throw New Exception("Received an error in PopulateAllSubReports.")
    bRC = PopulateCrystalParameters(MainReport, SP)
    If Not bRC Then Throw New Exception("Received an error in PopulateCrystalParameters.")
    'Actually create the output file.
    bRC = ExportData(MainReport)
    Private Function PopulateCrystalParameters(myReportDocument As ReportDocument, SP As ReportStoredProcedureCrystal) As Boolean
         Dim myParameterFieldDefinitions As ParameterFieldDefinitions = Nothing
         Dim myParameterFieldDefinition As ParameterFieldDefinition = Nothing, ParamValue As String = ""
         Dim bRC As Boolean, Param As SqlParameter = Nothing
         Try
         myParameterFieldDefinitions = myReportDocument.DataDefinition.ParameterFields
    '*********************Report Parameters***************************
         For Each myParameterFieldDefinition In myParameterFieldDefinitions
              myParameterFieldDefinition.CurrentValues.Clear()
              Select Case myParameterFieldDefinition.ParameterFieldName.Trim.ToUpper
              Case "@CARRIER"
                   If SP.DBParameters.ContainsKey("@CARRIER") Then
                        Param = SP.DBParameters("@CARRIER")
                        ParamValue = NullS(Param.Value).Trim
                        bRC = SetCurrentValueForParameterField(myParameterFieldDefinition, ParamValue)
                        If Not bRC Then Return False
                   End If                           
              End Select
         Next
         Return True
         Catch ex As Exception
         GmcLog.Error("ReportKey = " & Me.ReportKey.ToString & ", " & ex.Message, ex)
         Return False
         End Try
    End Function
    Private Function SetCurrentValueForParameterField(myParameterFieldDefinition As ParameterFieldDefinition, submittedValue As Object) As Boolean
         Dim currentParameterValues As ParameterValues = Nothing
         Dim myParameterDiscreteValue As ParameterDiscreteValue = Nothing
         Try
         myParameterDiscreteValue = New ParameterDiscreteValue
         myParameterDiscreteValue.Value = NullS(submittedValue).Trim
         currentParameterValues = New ParameterValues
         currentParameterValues.Add(myParameterDiscreteValue)
         myParameterFieldDefinition.ApplyCurrentValues(currentParameterValues)
         Return True
         Catch ex As Exception
         GmcLog.Error("ReportKey = " & Me.ReportKey.ToString & ", " & ex.Message, ex)
         Return False
         Finally
         myParameterDiscreteValue = Nothing
         currentParameterValues = Nothing
         End Try
    End Function
    Private Function SetDBSourceForSubReport(mySubReport As ReportDocument) As Boolean
         Dim myTables As Tables = Nothing, myTable As Table = Nothing, DTbl As DataTable, SP As StoredProcedure = Nothing
         Try
         myTables = mySubReport.Database.Tables
         For Each myTable In myTables
              Dim SPName As String = myTable.Location.Substring(0, myTable.Location.IndexOf(";"c))
              SP = New StoredProcedure(ConnectionString, SPName, CommandType.StoredProcedure)
              DTbl = SP.FillTable
              mySubReport.SetDataSource(DTbl)
              SP = Nothing
         Next
         Return True
         Catch ex As Exception
         GmcLog.Error("ReportKey = " & Me.ReportKey.ToString & ", " & ex.Message, ex)
         Return False
         Finally
         If Not SP Is Nothing Then SP = Nothing
         If Not myTable Is Nothing Then myTable = Nothing
         If Not myTables Is Nothing Then myTables = Nothing
         End Try
    End Function
    Private Function PopulateAllSubReports(myReportDocument As ReportDocument) As Boolean
         Try
         Dim mySections As Sections = myReportDocument.ReportDefinition.Sections
         For Each mySection As Section In mySections
              Dim myReportObjects As ReportObjects = mySection.ReportObjects
              For Each myReportObject As ReportObject In myReportObjects
                   If myReportObject.Kind = ReportObjectKind.SubreportObject Then
                        Dim mySubreportObject As SubreportObject = CType(myReportObject, SubreportObject)
                        Dim subReportDocument As ReportDocument = mySubreportObject.OpenSubreport(mySubreportObject.SubreportName)
                        Dim bRC = SetDBSourceForSubReport(subReportDocument)
                        If Not bRC Then Return False
                   End If
              Next
         Next
         Return True
         Catch ex As Exception
         GmcLog.Error("ReportKey = " & Me.ReportKey.ToString & ", " & ex.Message, ex)
         Return False
         End Try
    End Function

  • How to handle comma separated values in OLE DB Source query for a parameter variable from XML file in SSIS

    Hi,
    I am using OLE DB Source to fetch the records with Data Access Mode as SQL COMMAND which is using the below query with a parameter,
    SELECT CON.Title,CON.FirstName,EMP.MaritalStatus,EMP.Gender,EMP.Title AS Designation, EMP.HireDate, EMP.BirthDate,CON.EmailAddress, CON.Phone
    from HumanResources.Employee EMP INNER JOIN Person.Contact CON ON EMP.ContactID=CON.ContactID WHERE EMP.Title in (?) 
    In this query for the parameter I am passing the value from a variable and which is configured (XML Configuration). While passing value
    Buyer it works correctly. But while passing values Accountant,Buyer
    it is not working as expected.
    How to handle while passing such multiple values Or is it possible to pass such values or not in SSIS 2012 ?
    Kindly help me to find a solution.
    NOTE: I placed the whole query in a variable as a expression as below it is working fine.
    "select CON.Title,CON.FirstName,EMP.MaritalStatus,EMP.Gender,EMP.Title AS Designation,EMP.HireDate,EMP.BirthDate,CON.EmailAddress,CON.Phone from HumanResources.Employee EMP
    INNER JOIN Person.Contact CON ON EMP.ContactID=CON.ContactID WHERE EMP.Title in ('" + REPLACE(@[User::temp],",","','")  +"')"
    Any other solution is there ? without placing the query in a variable. May be a variable can have some limitations for no. of characters stored not sure just a thought.
    Sridhar

    Putting the whole thing into a variable is certainly a valid solution.  The other involves putting the comma delimited list into a table valued variable.
    http://gallery.technet.microsoft.com/scriptcenter/T-SQL-Script-to-Split-a-308206f3
    For an odd ball approach: 
    http://www.sqlmovers.com/shredding_multiline_column_using_xml/ .
    Russel Loski, MCT, MCSE Data Platform/Business Intelligence. Twitter: @sqlmovers; blog: www.sqlmovers.com

  • Query Approcal Procedure per line for SO

    Dear all expert,
    I would like to make query approval procedure that will tell user to ask approval every time they enter transaction that has gross margin < 0. This approval will work per line transaction. I mean if in line 1 has gross margin > 0 but in line 2, the gross margin is < 0, the approval procedures will run.
    Thanks for all your help

    Hi,
    AFAIK it's not possible to have query approvl on document lines, but only on document header or footer.
    Without using the SDK, I know no ways to achieve it.
    Regards,
    Eric

  • Submit query button on parameter form

    Hello.
    I have a problem with runing reports with parameter form.
    When i start report from form, parameter form is opened. When i check on AS, which report is running i see reportName.rdf.
    When i then press submit query button, report appears. But when i check it again on AS, i see reportName1.rdf (from another directory)is running.
    Why is that? How can i solve that? Why does submit query button on parameter form run another report (from another directory), then report i start from form?
    I can run two report from form (list item), but i have this problem only on one report.
    Thanks.

    Sorry. I just found the problem - in BEFOREPFORM trigger.

  • How to pass record set as procedure parameter.

    Hi All,
    I have a requirement, I want to pass the records that are fetched from a cursor to a procedure as a parameter.
    I dont want to use it inside the loop as we do it normally, as i might get huge volume of records using cursor, as a result the procedure also will be called number of times inside the loop.
    Can you suggest me the logic along with sample code?
    Thanks
    Suresh

    GSKumar wrote:
    I have a requirement, I want to pass the records that are fetched from a cursor to a procedure as a parameter.A cursor outputs rows - not "records".
    I dont want to use it inside the loop as we do it normally, as i might get huge volume of records using cursor, as a result the procedure also will be called number of times inside the loop.
    Can you suggest me the logic along with sample code?How else do you want to do it? If there are a million rows returned by the cursor, it means a million executions of that procedure - once for every row.
    This will be slow. And the primary reason is that executing a PL/SQL procedure (or any other code unit) for a million times, will be slow. Changing the cursor interface (from an implicit cursor to a ref cursor for example) does not change the fact there needs to be a million PL/SQL procedure executions - and does not make anything faster. To fetch rows from a cursor needs to a loop. Period.
    There are two basic ways to address this issue at hand.
    Use SQL and not PL/SQL. Instead of using PL/SQL code and logic, use SQL code and logic. This will be faster as the PL/SQL engine no longer plays a role and a million rows do not have to be send from the SQL engine to the PL/SQL engine. Instead that million rows are processed internally in the SQL engine - which will be faster. And which will provide scalable options such as using parallel query.
    Use "multi-threaded" PL/SQL. Assuming the PL/SQL code and logic are too complex to be done in SQL, the next best choice is PL/SQL. However, a single serialised PL/SQL process going through a million rows will be slow and will not scale. If parallel PL/SQL can be used, then 20 PL/SQL processes can each do 50,000 rows - as oppose to having to do a million rows.
    There are two options to "multi-thread" PL/SQL code. You can use DBMS_PARALLEL_EXECUTE (11g). You can use a parallel pipelined table function (10g and higher).

  • Convert normalized query to procedure to function

    Hi,
    I have a table with this structure:
    CREATE TABLE TRANS
      ITEM_ID    VARCHAR2(8 BYTE),
      ITEM_TYPE  VARCHAR2(20 BYTE),
      ITEM_YEAR  NUMBER,
      JAN        FLOAT(126),
      FEB        FLOAT(126),
      MAR        FLOAT(126),
      APR        FLOAT(126),
      MAY        FLOAT(126),
      JUN        FLOAT(126),
      JUL        FLOAT(126),
      AUG        FLOAT(126),
      SEP        FLOAT(126),
      OCT        FLOAT(126),
      NOV        FLOAT(126),
      DEC        FLOAT(126)
    )I wrote the following PL/SQL to normalize the data into a few columns. Now I need help converting this to a package procedure, and this is where I am stuck.
    DECLARE
       TYPE c IS REF CURSOR;
       cur    c;
       TYPE r IS RECORD (
          itm   trans.item_id%TYPE,
          mth   VARCHAR2 (3),
          val   FLOAT
       rec    r;
       stmt   VARCHAR2 (200);
       item   VARCHAR (8)    := 'AB054240';
    BEGIN
       FOR i IN 1 .. 12
       LOOP
    -- calls function to return abbreviated month name
          stmt :=
                'SELECT item_id,  get_month_abbrev ('
             || i
             || '), '
             || get_month_abbrev (i)
             || ' FROM trans t WHERE t.item_id = '''
             || item
             || '''';
          OPEN cur FOR stmt;
          LOOP
             FETCH cur
              INTO rec;
             EXIT WHEN cur%NOTFOUND;
    -- test
             DBMS_OUTPUT.put_line ( rec.itm || chr(9) || rec.mth || chr(9) || rec.val);
          END LOOP;
       END LOOP;
       CLOSE cur;
    END;In searching online, I got the idea of creating an Object Type for the 'record' type and a Collection Type for the table based on the former.
    I would then open the table using a sys_refcursorUnfortunately, I could not get this to work. Ideally I would like to keep it all encapsulated in one procedure. I can't figure out a way to make an OUT parameter that will hold the table.
    The end result is that I have a client program that will execute this procedure/function to return the normalized query result set for display.
    Any suggestion or critique would be appreciated.

    I still don't understand why you feel the need for looping round to create your dynamic SQL when you could just use static SQL (eg, like the query I gave you earlier)?
    If you're wanting to take a row and turn it on its side, then the query I provided would do what you wanted:
    with trans as (select 1 item_id, 'A' item_type, 2009 item_year, 10 jan, 20 feb, 30 mar, 40 apr, 50 may, 60 jun, 70 jul, 80 aug, 90 sep, 100 oct, 110 nov, 120 dec from dual union all
                   select 1 item_id, 'A' item_type, 2008 item_year, 110 jan, 120 feb, 130 mar, 140 apr, 150 may, 160 jun, 170 jul, 180 aug, 190 sep, 1100 oct, 1110 nov, 1120 dec from dual union all
                   select 2 item_id, 'C' item_type, 2009 item_year, 210 jan, 220 feb, 230 mar, 240 apr, 250 may, 260 jun, 270 jul, 280 aug, 290 sep, 2100 oct, 2100 nov, 2120 dec from dual),
    -- end of mimicking data in your table
    month_tab as (select 'JAN' month_name from dual union all
                   select 'FEB' month_name from dual union all
                   select 'MAR' month_name from dual union all
                   select 'APR' month_name from dual union all
                   select 'MAY' month_name from dual union all
                   select 'JUN' month_name from dual union all
                   select 'JUL' month_name from dual union all
                   select 'AUG' month_name from dual union all
                   select 'SEP' month_name from dual union all
                   select 'OCT' month_name from dual union all
                   select 'NOV' month_name from dual union all
                   select 'DEC' month_name from dual)
    SELECT tr.item_id "Item",
           mt.month_name "Month",
           DECODE(mt.month_name, 'JAN', tr.jan,
                                 'FEB', tr.feb,
                                 'MAR', tr.mar,
                                 'APR', tr.apr,
                                 'MAY', tr.may,
                                 'JUN', tr.jun,
                                 'JUL', tr.jul,
                                 'AUG', tr.aug,
                                 'SEP', tr.sep,
                                 'OCT', tr.oct,
                                 'NOV', tr.nov,
                                 'DEC', tr.dec) "Amount"
    FROM   trans tr,
           month_tab mt
    WHERE  tr.item_id = 1 --p_item_id
    AND    tr.item_year = 2009 --p_item_year;
          Item Month     Amount
             1 JAN           10
             1 FEB           20
             1 MAR           30
             1 APR           40
             1 MAY           50
             1 JUN           60
             1 JUL           70
             1 AUG           80
             1 SEP           90
             1 OCT          100
             1 NOV          110
             1 DEC          120There are several advantages for using one static query:
    1. Easier to debug: the query is right there - you can copy it out of the procedure, change the parameters and then run it to see what values were being returned. You do not have to manually construct the query prior to running it.
    2. Less code, less steps - therefore increased performance and easier maintenance. You no longer have an extra function call that the database needs to execute every time it runs the query.
    3. More efficient code; no need to access the table 12 times, as the above query only accesses the table once. Again, leading to improved performance.
    4. Easier to read and there maintain.
    5. The PL/SQL engine won't check dynamic sql until runtime; if you've made a syntax error, the code will still compile, but will fail at runtime. With static SQL, the code won't compile until you've fixed all syntax errors.
    6. Dynamic sql won't show up in the dependencies views (eg. user_dependencies), so makes it harder to track what tables are used by your code.
    In short, avoid dynamic SQL if you can, stick to doing as much of the work in SQL as you can and hopefully you'll have faster and easier-to-maintain code.

  • Passing the database name as a PL/SQL procedure parameter

    How do I pass the name of the database as a parameter to a procedure?
    If dbs is the variable name to which I pass the database name as shown in the example,
    CREATE OR REPLACE PROCEDURE Extract_gl_acct_Tbl(dbs varchar2)
    and I use dbs in the code as follows,
    SELECT ACCOUNT,
    SETID
    FROM SYSADM.PS_GL_ACCOUNT_TBL@dbs
    It gives me an error saying 'ORA-04054: database link DBS does not exist'.

    You will need to use dynamic SQL to handle this:
    create or replace ...
    is
    type rc is ref cursor;
    v_rc rc;
    begin
    open v_rc for 'select ... from sysadm.ps_gl_account_tbl@' || dbs;
    fetch v_rc into ... -- some variables
    -- if multiple rows, you'll need to do the fetch in a loop and exit when v_rc%notfound.
    close v_rc;
    end;

  • Pass parameter value to another parameter.... User query in user parameter

    Hello everyone, any help would be greatly appreciated.
    Problem:
    My report currently has 5 user parameters (3 Number, 2 Characters). I have an after parameter trigger that evaluates all the parameters to see which one has any value and then creates the “where clause”. Below is an example of two of the 5 parameters.
    The function works fine, I just cut out all the other stuff for this issue.
    function AfterPForm return boolean is
    IF :P_JOB_ID is not null then
         :P_WHERE_CLAUSE := 'where Job_num = :P_JOB_ID';
    ELSIF :P_QUES_DESC is not null then
    :P_WHERE_CLAUSE := 'where DESCRIPTION like :P_QUES_DESC’;
    ELSE :P_WHERE_CLAUSE := ‘where JOB_NUM = 0';
    The “P_WHERE_CLAUSE” is used as follows in a query.
    Select job_num
    from PROMOTION
    &P_W_CLAUSE
    Issue:
    The query result can be anywhere from 1 to 50 job_num’s. I need to show the end user running this report the values (job_num) in a drop down list. They in turn will select one job_num which will be used to run the report. I tried putting the Select job_num from PROMOTION &P_W_CLAUSE in a User Parameter but that does not work. I get an error. I feel that I am approaching this the wrong way. Because in the end I would end up with two queries, one for the Select statement containing the P_W_CLAUSE and another with the final report. This issue is sort of like cascading prompt where the values from one (or more) parameters are used in the select of another user parameter which in turn the value selected will be used in the final report. Also this report will be used somewhere between 50 - 75 times per day so storing the values in a temp table might not work.

    Sorry,
    as I know depending parameters like you want are not possible in Reports. You can use one reports as parameter-report-only to use a second as your original report, but this is not perfect. Or use a tool like Application Express (which is able to have depending fields) in front of reports to build your parameter forms.
    Regards
    Rainer

  • SAP Query creation procedure

    Hi,
    Can any one send me complete procedure for creation of query in SQ03. Please give me step by step procedure
    Thanks,
    Regards,
    Mukul

    hi,
    in sq02 define the infoset. here u define the tables and the join relation between them. generate the infoset. in sq03 create user grps (if not already existing) and then assign the infosets to them. assign user ids to the the user grps.   in sq01 create the query in the infoset and define the list and selection fields. make sure u check the query area in which the infodset and the query is created (global or client sprcific).
    saurabh

  • Pass unicode data in SQL Server 2008 stored procedure parameter

    Hi,
    I want to pass unicode data in a SQL stored procedure. But I am not sure that how to append N with NVarchar datatype.
    For example I Create a table LocalizationTest and wants to insert a few records.
    Create table LocalizationTest
        Field1 NVarchar(255)
    INSERT INTO LocalizationTest
    VALUES(N'123 Illini Dr, 東皮奧里亞, 8989')
    the above given statement works.
    To explain it more , script A works but script B does not work.
    DECLARE @X NVARCHAR(255)
    [A]
    SET @X=N '123 Illini Dr, 東皮奧里亞, 8989'
    INSERT INTO LocalizationTest
    VALUES(@X)
    [B]
    SET @X= '123 Illini Dr, 東皮奧里亞, 8989'
    INSERT INTO LocalizationTest
    VALUES(@X)
    What is the correct way to execute script B because @X will be passed in a SQL Stored Procedure?
    Thanks
    Sharma M.

    If you do not pass the value as a Unicode value there is nothing left of the Unicode characters but question marks. Once this has happened, AFAIK there is no way to undo it (other than resetting the value as Unicode characters again).
    Affirmative.
    Demo - This is what happens if you convert UNICODE (nvarchar) to varchar with implicit conversion (try to force 2 bytes into one byte).
    3F hex is '?'.
    CREATE TABLE #LocalizationTest (Field1 VARCHAR(255))
    INSERT INTO #LocalizationTest
    VALUES(N'123 Illini Dr, 東皮奧里亞, 8989')
    DECLARE @X NVARCHAR(255), @dSQL NVARCHAR(MAX)
    SET @X=N'123 Illini Dr, 東皮奧里亞, 8989'
    INSERT INTO #LocalizationTest VALUES(CONVERT(NVARCHAR(255),@X))
    SET @dSQL = N'INSERT INTO #LocalizationTest VALUES(N'''+@X+''')'
    PRINT @dSQL
    EXEC sp_ExecuteSQL @dSQL
    SELECT *, Field1Bin=convert(binary(30), Field1) FROM #LocalizationTest
    DROP TABLE #LocalizationTest
    123 Illini Dr, ?????, 8989 0x31323320496C6C696E692044722C203F3F3F3F3F2C203839383900000000
    123 Illini Dr, ?????, 8989 0x31323320496C6C696E692044722C203F3F3F3F3F2C203839383900000000
    123 Illini Dr, ?????, 8989 0x31323320496C6C696E692044722C203F3F3F3F3F2C203839383900000000
    Kalman Toth Database & OLAP Architect
    SQL Server 2014 Design & Programming
    New Book / Kindle: Exam 70-461 Bootcamp: Querying Microsoft SQL Server 2012

Maybe you are looking for

  • Verizon sent email - new 500 GB DVR is ready click this icon

    When i open the Verizon email to click here, your wait is over for the new 500GB DVR, nothing happens and it times out.  I cant find anything on my account about it.  So I called yesterday and they said it could be an internal problem they would get

  • FTP problem:  why do my uploaded files contain nothing?

    Hi, I'm using the sun.net.ftp package In my servlet I have, public void doGet(HttpServletRequest req, HttpServletResponse resp)           throws ServletException, IOException {           PrintWriter out = resp.getWriter();           out.println("Atte

  • Inserting and Updating records in ORACLE using WebDynpro Java

    Hi All I got connected to oracle backend (using my previous thread), but now i want to insert and update the records i have created views  for insert and update, Thanks in advance Sushma

  • Service Tax Recievable Opening Balance

    Dear All, How to update the Opening Balances for Service Tax recievables so that it appears in the Tax Payment Wizard also. As in the normal system when a the payment is made for an invoice with Service Tax the tax amount on the paid sum gets to refl

  • 8800 won't boot, tried wiping and reinstalling OS to no avail....

    I have an 8800 that won't boot! The red led stays solidly lit for a few seconds after putting in the battery and then nothing else happens... I've tried using JL_Cmder to reinstall the OS but it wouldn't connect so I went about it the alternate way a