How to dynamic select based on runtime value ?

how to dynamic select based on runtime value ?
I want to write a select function, which do selecting based on parameters. eg,
CREATE OR REPLACE FUNCTION myfunction
(tableName VARCHAR2, pkName VARCHAR2, pkValue VARCHAR2, requestString VARCHAR2)
RETURN VARCHAR2 AS
BEGIN
select requestString from tableName where pkName=pkValue;
RETURN NULL;
END;
myfunction('users', 'user_id', '100', 'user_name'); it will select 'user_name' from table 'users' where 'user_id' = '100'.
This way could save lots of coding. but it can't pass compiler. how to work out ?
Thanks.

While this may save code, if used frequently it will be ineffecient as all [explicative deleted]. The danger is that it would be used even for repeatable statements.
This mode of operation ensures that every statement [calling the funciton] needs to be reparsed, which is extremely expensive in Oracle (in CPU cycles, recursive SQL and shared pool memory).
Such reparsing is rarely a good thing for the environment ... it could easily lead to buying more CPU (bigger box) and therefore adding more Oracle license ... which could quickly exceed the typical developer's salary.
However - if you really, really want to do this, look up 'execute immendiate' in the PL/SQL manuals.

Similar Messages

  • How to dynamically resize JPanel at runtime??

    Hello Sir:
    I met a problem, I need to resize a small JPanel called panel within a main Control JPanel (with null Layout) if I click the mouse then I can Drag and Resize this small JPanel Border to the size I need at runtime, I know I can use panel.setSize() or panel.setPreferredSize() methods at design time,
    But I have no idea how to do it even I search this famous fourm,
    How to dynamically resize JPanel at runtime??
    Can any guru throw some light or good example??
    Thanks

    Why are you using a null layout? Wouldn't having a layout manager help you in this situation?

  • How do I select a range of values in MySQL using a drop down menu

    Hi,
    I have a database of picture frames that have a value of
    frame width. I want to be able to select a range of values (i.e.
    .50" to 1") instead of each and every value (i.e. .50", .56", .76",
    etc.). I have a drop down menu (mnuWidth) with 5 ranges (see
    attached code).
    Each selection has a value from 1 to 5 indicating the range I
    want to search. In my results page I have let DW set up a recordset
    (see attached code)
    Can anyone tell me how to get this to choose a range instead
    of just the value entered by my menu?
    Thanks in advance.
    Tom

    I have been growing fond of lookup tables. Your lookup table would have your numbers in one column and the values you want returned in the next.
    Lookup table
    item
    Name
    1
    a
    2
    b
    3
    c
    4
    d
    5
    e
    6
    f
    7
    g
    8
    h
    9
    i
    Input table
    input
    Name
    1
    a
    B2 and copied down:
    LOOKUP(A2,lookup::$A$2:$A$11,lookup::$B$2:$B$11)
    Caution: Lookup will return the closest value so it it looks for "10" in this example it will return "i"
    If you don't want to see the error messages from blank inputs, wrap Lookup in IFERROR.
    hope this helps
    q

  • Apex 3.2 Tabular form - dynamic selection based on prev selection

    Hi guys,
    I am using apex 3.2. I am having difficulty in setting up a tabular form which provides an option to record information in other columns based on a value selected in the drop down.Here is an example
    I have a table product. All the products are added using a tabular form by selecting type from a drop down list.
    This allows the user to add multiple products without having to press save each time.
    e.g.
    product | type
    monopoly | game
    vase | home
    coffee | food
    cards | game
    Depending on the product type, I want the user to be able to multi-select other options using checkboxes based on the option selected.
    So for example if they add a product of type food, it should give additional options like beverage, cereal etc. If they select game, then they should get other options like for age_groups 10-12; 12-16; 18 and over;
    Is it posisble to do this on a tabular form in apex 3.2?
    If yes, please can someone help.
    Thanks
    Sam

    Closed

  • Sub Query selection based on parameter value selected

    I have a parameter, and based on the value selected, I want to run one of two queries. I thought I could do either an IF THEN ELSE, or a CASE, but neither seem to be working.
    What I'm trying to do is this:
    IF parameter_value = 338 THEN
    (RUN THIS SELECT QUERY)
    ELSE
    (RUN THIS SELECT QUERY)
    END IF
    or
    SELECT CASE WHEN parameter_value = 338 THEN (RUN THIS SELECT QUERY)
    ELSE (RUN THIS SELECT QUERY)
    END X
    I'm getting errors with both. For the CASE statement, it says "too many values". For the IF statement, it just says "invalid SQL statement".
    Any suggestions would be appreciated.
    Thanks.

    Looks like this is what you want
    SQL> WITH T
      2       AS (SELECT LEVEL col
      3             FROM DUAL
      4           CONNECT BY LEVEL <= 5)
      5  SELECT *
      6    FROM T;
           COL
             1
             2
             3
             4
             5
    SQL>
    SQL> VARIABLE parameter_value    NUMBER
    SQL> EXEC    :parameter_value := 338;
    PL/SQL procedure successfully completed.
    SQL>
    SQL> WITH T
      2       AS (SELECT LEVEL col
      3             FROM DUAL
      4           CONNECT BY LEVEL <= 5)
      5  SELECT col
      6    FROM T
      7   WHERE col = DECODE (:parameter_value, 338, col, :parameter_value);  --- If 338 then select all if not 338 select only the one with parameter_value.
           COL
             1
             2
             3
             4
             5
    SQL>
    SQL> EXEC :parameter_value := 2;
    PL/SQL procedure successfully completed.
    SQL>
    SQL> WITH T
      2       AS (SELECT LEVEL col
      3             FROM DUAL
      4           CONNECT BY LEVEL <= 5)
      5  SELECT col
      6    FROM T
      7   WHERE col = DECODE (:parameter_value, 338, col, :parameter_value);
           COL
             2
    SQL>
    SQL> EXEC :parameter_value := 3;
    PL/SQL procedure successfully completed.
    SQL>
    SQL> WITH T
      2       AS (SELECT LEVEL col
      3             FROM DUAL
      4           CONNECT BY LEVEL <= 5)
      5  SELECT col
      6    FROM T
      7   WHERE col = DECODE (:parameter_value, 338, col, :parameter_value);
           COL
             3
    SQL> You need to use following where clause in your query
    WHERE column_name = DECODE (parameter_value, 338, col, parameter_value); -- replace the column_name with name of the column you are comparing against.G.
    Edited by: G. on Mar 8, 2011 3:36 PM
    formatted and added comments

  • How to move selection based on word outline?

    Hello everyone,
    I am trying to write a script for adding TAGs as comment into word document. The idea is to add a tag for every heading and sub-heading present in document. The input word documents do not have 'word style' followed. I have following two questions.
    1.) How can I extract number of headings based on outline? The document do not use word styles for adding headings or sub-headings. This makes it difficult to use 'outlineLevel' to be used. As if a heading is written in normal text then outlineLevel will
    return '10' and script will miss this heading. I read on another forum that outlineNumber can be used but it does not seem to be working with paragraph object.
    2.) How to move selection from one heading to next? Currently my script is not able to move selection.
    Below is the script I manage to write. (I'm new to scripting and this is my first script)
    $filePath = "H:\Desktop\ashishk\F1K\FunctionalSafetyCopy.docx"
    $word = New-Object -comobject word.application
    $word.visible = $false
    $MinDepth = 1
    $MaxDepth = 9
    $TagPrefix = "TS_FS_"
    $TagStart = 1
    $TagStep = 1
    $TagNew = 0
    #Document object
    $doc = $word.documents.open($filePath)
    $section = $doc.sections.item(1)
    $range = $section.Range
    $outline = $doc.Paragraphs | ForEach-Object {
    if($_.outlineLevel -le $MaxDepth){
    Write-Host "outlineLevel:" $_.outlineLevel
    if($TagNew -eq 0){
    $_.Comments.Add($range, "$TagPrefix$TagStart")
    $TagNew = $TagStart + $TagStep
    Write-Host "New Tag number:" $TagNew
    Else{
    $doc.Comments.Add($range, "$TagPrefix$TagNew")
    $TagNew = $TagNew + $TagStep
    Write-Host "New Tag number:" $TagNew
    $doc.save()
    $doc.close()
    $word.quit()

    You will need to get the selection range object and reference it as a range.  If the outline is not really an outline then how would you use it?  I think if you clarify your question it might lead you to seeing an answer.
    If it is an outline you should be able to just walk the outline.  Any outline element can have a text (10) section attached. 
    I would suggest that you start in the Word Developers forum and try to understand how this would be done in VBA or C# then translate it into PowerShell.
    I would also recommend creating this as a callable macro or function in the word doc or a template. You can then just open and call the macro from PowerShell.
    ¯\_(ツ)_/¯

  • Dynamic selection screen fetching the value from table fields

    hi gurus,
    i have one table say ztable...and i should create a dynamic selection screen which should populate the selection screen by the table field names.
    example..if i have 3 fields im my table..my selection screen should have three selection option fields..and in future if i add one more field in my table it should automatically create another slection-option in selection screen..
    thanks
    Sudheer

    Do you mean like SE16 works. If so, you should notice that if you  amend the selection fields, the screen program is actually re-generated.
    That is what is happening. A program is being created and re-generated.
    To create a dynamic selection screen in a single program is not possible ( I may be wrong ). If it is possible, then you would have problems in defining selection screen field names and using them.

  • How do I format based on the value of the @status attribute?

    Example: I use the @status attribute to indicate that a step in a procedure is new or that a paragraph in a concept is new.
    For review purposes, I want to format new text as green - preferably a green highlight, but green text will do.
    Example: I use the @status attribute to indicate that a step in a procedure has been deleted or that a paragraph in a concept has been deleted.
    For review purposes, I want to format new text as crossed out.
    Can this be done? If so, where do I set up the formatting for attribute values?
    Thanks in advance.
    Marsha

    Hi Marsha,
    If you want the formatting to be "locked in," that is, driven by the EDD, then Lynne's advice is the way to go. If instead it would be sufficient to temporarily color the desired elements as a format override, you could use the AXCM plugin:
    http://www.weststreetconsulting.com/WSC_AXCM.htm
    This plugin can do any nature of coloring, strikethrough, etc. based on attribute values and other markup. The coloring is applied as a format override and easily removed by a refresh of the EDD. The coloring features were mainly designed for conditional text purposes, but it would work in this case too.
    AXCM is completely free. Disclaimer... I own West Street Consulting and this plugin.
    Russ

  • How to create dynamic strcture and accepting runtime value in work area

    Hi,
    I am using RFC_READ_TABLE for  joining more than table  and written select query but  into clause work area value is passed but it is short dump is displaying with too few many fields  in into clause .work area WA need some casting type conversion which accepts the some run time value  and should have some structure  for it.how to create dynamic structure?

    hi
    good
    go through this and use in your report accordingly.
    If you are trying to read some information from SAP and you can't find the right BAPI then RFC_READ_TABLE can do the job for you.
    RFC_READ_TABLE is powerful RFC it gives you the access to all tables and views in SAP. I basically used RFC_READ_TABLE for Material Master Search application on the Intranet.
    Now you may say there are lots of BAPI for this functionality. You are right but I had to work around the BAPI to get Prices (Moving Average Price) and it just did not work very well. Because of the nature of the application I had to use RFC_READ_TABLE because then I can use powerful SQL expression for searching. RFC_READ_TABLE give you the ability to code the where clause which is quite enough.
    I have included part of the code use in asp page to read ENT1027 for Mgroup and M description & number but without object creation. The other part of the code reads MBEW for price & quantity.
    Code
    lt;%
    '#######################Diming the Structures
    Call BAPIRFC.DimAs("Rfc_Read_Table", "FIELDS", MaterialSelection_RS)
    Call BAPIRFC.DimAs("Rfc_Read_Table", "OPTIONS", Selection_RS)
    '########################Search Type########################
    ' C contanis
    ' S Start with
    ' E Ends with
    if searchtype = "C" then
    FormatedSearch_Keyword = "%" & Search_Keyword & "%"
    elseif searchtype = "S" then
    FormatedSearch_Keyword = Search_Keyword & "%"
    else searchtype = "E" then
    FormatedSearch_Keyword = "%" & Search_Keyword
    end if
    '################# Flaged for deletion Materials #####################
    if showdeleted = "No"  then
    Selection_RS.AddNew Array("TEXT"),Array("LVORM <> 'X' AND")
    end if
    '############## users can search three material group ################
    '############## GROUPS: OFFICESUP TECOMHARD TECOMSOFT ###############
    '##USER STILL CAN NAROW THEIR SEARCH BY SELECTING ON OF THREE#########
    if MGroup = "ALL"  then
    Selection_RS.AddNew Array("TEXT"),Array("MATKL IN ('OFFICESUP','TECOMHARD','TECOMSOFT')")
    else
    Selection_RS.AddNew Array("TEXT"),Array("MATKL = '"& MGroup &"' and ")
    end if
    '#######################ADDING SEARCH KEYWORD TO STRUCTURE##############
    if not  Search_Keyword = "" then
    Selection_RS.AddNew Array("TEXT"),Array(" MAKTG LIKE '" & FormatedSearch_Keyword &  "'")
    end if
    Selection_RS.Update
    '#######################ADD RETURNED FIELDS#########################
    MaterialSelection_RS.AddNew array("FIELDNAME","OFFSET","LENGTH","TYPE","FIELDTEXT"),array("MATNR","000000","000000" ,"","")
    MaterialSelection_RS.AddNew array("FIELDNAME","OFFSET","LENGTH","TYPE","FIELDTEXT"),array("MATKL","000000","000000" ,"","")
    MaterialSelection_RS.AddNew array("FIELDNAME","OFFSET","LENGTH","TYPE","FIELDTEXT"),array("MAKTG","000000","000000" ,"","")
    MaterialSelection_RS.Update
    call BAPIRFC.Rfc_Read_Table("ENT1027", Material_RS, MaterialSelection_RS, Selection_RS, "~", "", "0", "0")
    If Err.Number > 0 then
                   Response.Write "Error:" & "<BR>"
                   Response.Write "   Err.number...... " & Err.Number & "<BR>"
                   Response.Write "   Err.Description. " & Err.Description & "<BR>"
    end if
    '###########LOOP THROUGH RECORDSET
    if not Material_RS is nothing then
    do while not Material_RS.eof
    loop
    end if
    %>
    thanks
    mrutyun^

  • Dynamic tabs based on table values

    Hi all,
    How can you display tabs dynamically based on user authorization and values in a table that contains the page id's and tab id's for example?

    based on user authorizationThat is already standard Apex functionality.
    and values in a tableYou can use jQuery to hide a tab. So, you create a tab in Apex, but hide it when necessary when running the page. Something like:
    if (<some condition>) {
       $("#tab_id").hide();
    };Put this in the "Execute when Page Loads" in the JavaScript section on the Page definition.

  • How to Dynamically Select the Data File for a Report at Print Time

    How do you configure a Crystal report to ask for the file to be reported on as the report is being printed, and allow the user to browse to the file?
    The environment is Crystal Reports XI, SP3, with ODBC connection to Sage Timberline Office data version 9.7.  The client names their Payroll unposted time file each pay period, and also needs to report on their posted data file, depending on the time period for the report.  The client will need to select both the date range and the file name.
    I have created a SQL statement in Add Command in Database Expert, which prompts for a file name, but it does not let you browse to select a file on the computer.
    Therefore, in the prompts when they print the report, the parameter offers the user a default file name similar to the name they currently use, so they only have to change the payroll period end date in the supplied file name to run the report successfully.
    The client is concerned that sometimes a user will name their data file differently, and not know how to input the file name into the Crystal report prompt at print time.
    My research on dynamic prompts showed you can link to fields inside the data record, but I did not see a way to dynamically link to select the actual files used in the report.
    Another question is that the naming convention used by the SQL query is different than the basic Windows file name, but I think I can handle that issue.
    The actual file name is typically similar to:
    04-10-11 BP NEW.PRT
    However, in the SQL query, the record ID looks like:
    PRT_00-00-00 BP NEW__TIME
    The SQL Statement using a parameter is:
    SELECT
    "PRT_CURRENT__TIME"."Employee",
    "EMPLOYEE1"."Employee_Name",
    "PRT_CURRENT__TIME"."Date",
    "PRT_CURRENT__TIME"."Units",
    "PRT_CURRENT__TIME"."Job",
    "JOB1"."BP_Emps_Used"
    FROM
    "PRT_CURRENT__TIME" AS "PRT_CURRENT__TIME"
    INNER JOIN "JCM_MASTER__JOB" AS "JOB1"
    ON "PRT_CURRENT__TIME"."Job"="JOB1"."Job"
    INNER JOIN "PRM_MASTER__EMPLOYEE" AS "EMPLOYEE1"
    ON "PRT_CURRENT__TIME"."Employee"="EMPLOYEE1"."Employee"
    WHERE "JOB1"."BP_Emps_Used" = 1
    AND
    ("PRT_CURRENT__TIME"."Date" BETWEEN
    {?As of Date} - 41 AND {?As of Date})
    UNION ALL
    ( SELECT
    "PRT_NEW__TIME"."Employee",
    "EMPLOYEE2"."Employee_Name",
    "PRT_NEW__TIME"."Date",
    "PRT_NEW__TIME"."Units",
    "PRT_NEW__TIME"."Job",
    "JOB2"."BP_Emps_Used"
    FROM
    "{?NEWPRT}" AS "PRT_NEW__TIME"
    INNER JOIN "JCM_MASTER__JOB" AS "JOB2"
    ON "PRT_NEW__TIME"."Job"="JOB2"."Job"
    INNER JOIN "PRM_MASTER__EMPLOYEE" AS "EMPLOYEE2"
    ON "PRT_NEW__TIME"."Employee"="EMPLOYEE2"."Employee"
    WHERE "JOB2"."BP_Emps_Used" = 1
    AND
    ("PRT_NEW__TIME"."Date" BETWEEN
    {?As of Date} - 41 AND {?As of Date})

    Hello,
    Sorry you'll have to contact Sage on how to do this. We can help you once you get connected but we can't help you get around their connection methods.
    There is no Preview Set Database Connection method you can use in CR Designer. The Designer assumes you select it first or use the Set Location option before previewing or refreshing the data.
    If you are doing this in the Sage program itself we can't help you, you'll have to contact Sage for assistance.
    Sage is an OEM Partner they are responsible for supporting their product and CR. If they have issues help you then they will contact us directly for assistance.
    Thank you
    Don

  • How to add -Select- as the first value in dropdownbox?

    Hi All,
    I am having a dropdownbox with the set of values. I need to add -SELECT- as the first and default value. Please do advise how to achieve this.
    Code and screenshot below.
    var oModel = new sap.ui.model.odata.ODataModel("../../services/admin/typesTable.xsodata/", false);
    var oSort = new sap.ui.model.Sorter("ID", false);
    var lblType = new sap.ui.commons.Label();
    lblType.setText("Type");
    var ddbType = new sap.ui.commons.DropdownBox();
    ddbType.setRequired(true);
    var oItemTemplate = new sap.ui.core.ListItem();
    oItemTemplate.bindProperty("text", "NAME");
    oItemTemplate.bindProperty("key", "ID");
    ddbType.setModel(oModel);
    ddbType.bindItems("/TYPES", oItemTemplate, oSort);
    lblType.setLabelFor(ddbType);
    oChildLayout.createRow(lblType, ddbType);
    Thanks in advance
    Aravindh

    Hi,
    Refer this discussion on exact requirement empty/"all" entry in DropdownBox with OData model - cleanest solution
    Regards,
    Chandra

  • How to create file based on date value

    Hi
    Hope you'll help me. I can't find right way to tackle the problem. I need to read a file which name is created based on month and years' value. File name format is as follows: INMMYY.log. So to read it I must create File object using this file name format. I tried to use Calendar class get necessary information using get() method. Unfortunatelly returned month's value is always 2,3,4 and so on..(I need 02,03). There is problem with year's value als. It's returned in form YYYY but I need YY.
    Does anybody have any idea how to create string INMMYY in the easiest way ??
    Thanks in advance :)

    Use java.text.SimpleDateFormat.

  • How to filter reports based on Prompt values

    Hi All,
    I have requirement in dash board.
    in my dash board it contains two reports which is having same column with different values.i.e.,
    one report contains Input method column with CSS value,
    another report contains Input method column with SFF value
    and i have dashboard prompt for INPUT METHOD column.
    when i need to select CSS value in prompt the first report should enable(display).second report should disable.
    when i need to select SFF value in prompt the second report should enable(display).first report should disable.
    But problem is when iam prompting values the 2 reports displaying same report only.Can any give solution for this one. how to solve this prob?
    Thanks in Advance response .
    Naveen

    Hi,
    Follow the steps from this link. I hope it will be helpfull
    http://oraclebizint.wordpress.com/2008/01/17/oracle-bi-101332-selecting-reports-from-dashboard-prompts-and-guided-navigation-sections/
    Phani.

  • Dynamic Images based on textfield values

    First time poster LONG time lurker.
    Im using the latest version of livecycle.
    My project is essentially creating a pdf that allows reps to just type in model numbers into a TEXTFIELD and based on the that will populate an image along with a description of what the product is based on the url's H1 tag within source code (More explanation below)
    1st box is a TEXTFIELD
    For this box people will be typing in 7 digit model numbers of products
    2nd is an IMAGE that needs to be dynamic & have the source href based on what was entered in the TEXTFIELD
    Problem is the structure would be http://mywebsite.com/products/[TEXTFIELD].jpg
    ***example 1 : if a user types in 1234567 in TEXTFIELD , then the image should be sourced from
    http://mywebsite.com/products/1234567.jpg
    Also the next crucial part is being able to pull out the data from an H1 tag from a URL's source
    So if I were to go to a product page [http://mywebsite.com/productid?=1234567]
    the product description is placed in a <h1> tag
    I will have to have at least a few rows of these fields so that a rep can just type in the model numbers while the image popup accordingly
    If anyone could please help me out with this I would be forever in your debt.

    based on user authorizationThat is already standard Apex functionality.
    and values in a tableYou can use jQuery to hide a tab. So, you create a tab in Apex, but hide it when necessary when running the page. Something like:
    if (<some condition>) {
       $("#tab_id").hide();
    };Put this in the "Execute when Page Loads" in the JavaScript section on the Page definition.

Maybe you are looking for