Prompt in pl/sql

Hi,
I have written a procedure in Oracle 9i pl/sql and want to prompt the user with 'Are you sure? (Y/N)' before the procedure is commited and execute accordingly on whether the user types Y or N.
I have seen in many forums that you can use something like this
ACCEPT Emp_ID Prompt 'Please Enter the Employee ID > '
in SQL Plus, but I cannot find the equivalent for PL/SQL...does it exist?
Can someone advise, please?
Thanks

Hi,
If the PL/SQL routine is running in SQL*Plus (or some similar environment) then you can use dbms_output.put_line to prompt the user (that is, to send messages to the user). This is very much like the SQL*Plus PROMPT command.
The problem is, there's no way to accept input from the user. PL/SQL has nothing like the SQL*Plus ACCEPT command.
As Blushadow said, PL/SQL runs in the back end; user interaction takes place in the front end, so this needs to be done using your front-end tool.

Similar Messages

  • Prompted value corrupts SQL WHERE clause - bug?

    Using 10.1.3.4...
    I implemented a simple pivot based request that navigates to a second request when the user drill down on one of the fields. This field is set to "value is prompted" in my second request. (I chose navigate method above drill (dimensions) for a few reasons not really important to this posting, mainly to do with format of requests at different levels)
    All good and the drill down works well, parameters are passed correctly, except then I noticed that totals in my second request doesn't accurately tie back to my first request. After some research I found a very odd reason for this, my WHERE clause is getting corrupted - which almost looks like a bug in OBIEE and were wondering if anybody else has seen this behaviour from OBIEE and know a work around (before I try the Oracle support channels)
    From Answers the request SQL is (I'll highlight the lines getting messed up):
    SET VARIABLE DISABLE_CACHE_HIT = 1;
    SELECT
    BUSINESS_UNIT.Segment saw_0, BUSINESS_UNIT."Business Unit" saw_1, OPPORTUNITY.CLOSEPROBABILITY saw_2, OPPORTUNITY.CLOSEPROBABILITY saw_3, YEAR(OPPORTUNITY.ESTIMATEDCLOSE) saw_4, OPPORTUNITY_ADDON.TCV_IN_USD/1000000 saw_5, OPPORTUNITY_ADDON.WEIGHTED_TCV_IN_USD/1000000 saw_6, CASE OPPORTUNITY.CLOSEPROBABILITY WHEN 100 THEN OPPORTUNITY_ADDON.TCV_IN_USD/1000000 ELSE 0 END saw_7 FROM "Sales"
    WHERE (OPPORTUNITY.STAGE NOT IN ('Lost', 'On Hold')) AND (YEAR(OPPORTUNITY.ESTIMATEDCLOSE) >= YEAR(CURRENT_DATE)) AND
    ((({color:#ff0000}OPPORTUNITY.CLOSEPROBABILITY > 25) AND (TIMESTAMPDIFF(SQL_TSI_MONTH, CURRENT_DATE,OPPORTUNITY.ESTIMATEDCLOSE) <= 4)) OR ((OPPORTUNITY.CLOSEPROBABILITY >= 10) AND (TIMESTAMPDIFF(SQL_TSI_MONTH, CURRENT_DATE,OPPORTUNITY.ESTIMATEDCLOSE) > 4{color})))
    ORDER BY saw_0, saw_1, saw_2, saw_3, saw_4, saw_5, saw_6, saw_7
    Which results in the following SQL request (from NQQuery.log)... The prompted value (BUSINESS_UNIT.Segment) is added correctly to the WHERE clause, but see how the remainder get's changed:
    SQL Request:
    SET VARIABLE QUERY_SRC_CD='Report',SAW_DASHBOARD='/shared/01 - Financials/_portal/4. Pipeline',SAW_DASHBOARD_PG='Pipeline',SAW_SRC_PATH='/shared/01 - Financials/4. Pipeline/Pipeline - Current - T2',DISABLE_CACHE_HIT = 1;
    SELECT
    BUSINESS_UNIT.Segment saw_0, BUSINESS_UNIT."Business Unit" saw_1, OPPORTUNITY.CLOSEPROBABILITY saw_2, OPPORTUNITY.CLOSEPROBABILITY saw_3, YEAR(OPPORTUNITY.ESTIMATEDCLOSE) saw_4, OPPORTUNITY_ADDON.TCV_IN_USD/1000000 saw_5, OPPORTUNITY_ADDON.WEIGHTED_TCV_IN_USD/1000000 saw_6, CASE OPPORTUNITY.CLOSEPROBABILITY WHEN 100 THEN OPPORTUNITY_ADDON.TCV_IN_USD/1000000 ELSE 0 END saw_7 FROM "Sales"
    WHERE (BUSINESS_UNIT.Segment = 'Enterprise') AND (OPPORTUNITY.STAGE NOT IN ('Lost', 'On Hold')) AND (YEAR(OPPORTUNITY.ESTIMATEDCLOSE) >= YEAR(CURRENT_DATE)) AND
    ((({color:#ff0000}OPPORTUNITY.CLOSEPROBABILITY >= 10) AND (TIMESTAMPDIFF(SQL_TSI_MONTH, CURRENT_DATE,OPPORTUNITY.ESTIMATEDCLOSE) > 4)) OR ((OPPORTUNITY.CLOSEPROBABILITY >= 10) AND (TIMESTAMPDIFF(SQL_TSI_MONTH, CURRENT_DATE,OPPORTUNITY.ESTIMATEDCLOSE) > 4{color})))
    ORDER BY saw_0, saw_1, saw_2, saw_3, saw_4, saw_5, saw_6, saw_7
    Which definitely explains why my totals do not add up when drilling down. Interestingly, if I run my second request without the prompt from Answers, the SQL request works like a charm:
    SET VARIABLE QUERY_SRC_CD='Report',SAW_SRC_PATH='/shared/01 - Financials/4. Pipeline/Pipeline - Current - T2',DISABLE_CACHE_HIT = 1;
    SELECT BUSINESS_UNIT.Segment saw_0, BUSINESS_UNIT."Business Unit" saw_1, OPPORTUNITY.CLOSEPROBABILITY saw_2, OPPORTUNITY.CLOSEPROBABILITY saw_3, YEAR(OPPORTUNITY.ESTIMATEDCLOSE) saw_4, OPPORTUNITY_ADDON.TCV_IN_USD/1000000 saw_5, OPPORTUNITY_ADDON.WEIGHTED_TCV_IN_USD/1000000 saw_6, CASE OPPORTUNITY.CLOSEPROBABILITY WHEN 100 THEN OPPORTUNITY_ADDON.TCV_IN_USD/1000000 ELSE 0 END saw_7 FROM "Sales"
    WHERE (OPPORTUNITY.STAGE NOT IN ('Lost', 'On Hold')) AND (YEAR(OPPORTUNITY.ESTIMATEDCLOSE) >= YEAR(CURRENT_DATE)) AND
    ((({color:#ff0000}OPPORTUNITY.CLOSEPROBABILITY > 25) AND (TIMESTAMPDIFF(SQL_TSI_MONTH, CURRENT_DATE,OPPORTUNITY.ESTIMATEDCLOSE) <= 4)) OR ((OPPORTUNITY.CLOSEPROBABILITY >= 10) AND (TIMESTAMPDIFF(SQL_TSI_MONTH, CURRENT_DATE,OPPORTUNITY.ESTIMATEDCLOSE) > 4{color})))
    ORDER BY saw_0, saw_1, saw_2, saw_3, saw_4, saw_5, saw_6, saw_7
    Anybody had the same problem before?

    Here's the excerpt (it's relative to crashing, but I think it should also address the bug):
    # PRESENTATION SERVER CRASH AFTER UPGRADING TO 10.1.3.4 (Doc ID 756541.1)
    crash when they run the reports containing Pivot Table. This has been a known issue with version ... subsequently upgraded to version
    Doc Type:ALERTModified:2/10/2009

  • Issue Related to limit the result in prompt by using SQL statement.

    Hello Gurus,
    I am facing one issue rite now with our testing environment in some Dashboard Prompt. it seems like they are working fine in our Development environment.
    basically I am using SQL statement in prompt to limit the values for current + last 2 years in drop down.
    Here is the SQL that I am using SELECT Time."Fiscal Year" FROM "Financials - AP Overview" where Time."Fiscal Year" <= VALUEOF(NQ_SESSION.CURRENT_FSCL_YEAR) AND Time."Fiscal Year" >= (VALUEOF(NQ_SESSION.CURRENT_FSCL_YEAR)-2) ORDER BY TIme."Fiscal Year" desc
    Now it's working fine in our Dev but geeting failed in Test environment.
    it's giving below error.
    Odbc driver returned an error (SQLExecDirectW).
    State: HY000. Code: 10058. [NQODBC] [SQL_STATE: HY000] [nQSError: 10058] A general error has occurred.
    [nQSError: 43113] Message returned from OBIS.
    [nQSError: 43119] Query Failed:
    [nQSError: 22023] An arithmetic operation is being carried out on a non-numeric type. (HY000)
    SQL Issued: SELECT Time."Fiscal Year" FROM "Financials - AP Overview" where Time."Fiscal Year" <= VALUEOF(NQ_SESSION.CURRENT_FSCL_YEAR) AND Time."Fiscal Year" >= (VALUEOF(NQ_SESSION.CURRENT_FSCL_YEAR)-2) ORDER BY TIme."Fiscal Year" desc
    Please let me know your output.
    Thanking You..

    Couple of possibilities..
    1. environments may be at different patch sets, may be causing the issue.
    2. data in working environment is fine but in other environment.
    to further debug use the same logical sql in both environments and compare the results..
    hope this helps..

  • Prompt in PL/SQL block

    Hi,
    I want to prompt procedure name and it's version during execution of procedure...?
    I am new in PL/SQL part, not sure whether it's possible or not? dbms_output.put_line gives output after execution and after setting serveroutput 'ON'.. Is there any alternative?

    you can use the dbms_output.enable(1000000); but this will only display the text you put on the dbms_output.put_line() after execution of the code at SQL*Plus. other third party development tools such as the PL/SQL Developer also supports it.
    dbms_output.put_line() is limited to a max size of 1000000. alternatively you can build a code that capture your message and insert it into a log table. in that way you can query the same table for the info or data that you might need.

  • Command prompt from pl/sql

    hi,
    is there any way to execute command prompt statements (like IMP for example) from within pl/sql procedures.

    I didn't particularly want to have to start writing java utilities etc, just wanted to execute commands from within pl/sql. In sqlserver you can do this in transact-sql by running xp_cmdshell. I am trying to find ways of exporting table data and being able to reimport it on another machine or even different databases - so want a comma delimited file (preferably with a format file to go with it to identify what columns there are etc.
    Is this not possible then ?

  • Prompts in PL/SQL qry

    Hi experts,
    I normally work in Microsoft tools but using SQL Server Reporting Services I am developing a report against an Oracle dB because the source dB is Oracle.
    I have in past developed T-SQL queries to include prompts but obviously the same format isn't working for Oracle dB.
    Need your help urgently to amend the below query in order to include prompts
    I need to have 2 prompts - StartTime and EndTime which the user can manually select to run the report.
    SELECT
    SALES_ORDER.SOH_CLASS,
    to_char(SALES_ORDER.SOH_DATE_RELEASED,'dd/mm/yyyy') as DATE_RELEASED,
    to_char(SALES_ORDER.SOH_TIME_RELEASED,'HH24:MI') as TIME_RELEASED,
    count(SALES_ORDER.SOH_ORDER_NO) as COUNT_ORDERS
    FROM
    SALES_ORDER
    WHERE
    TIME_RELEASED >= @StartTime
    AND TIME_RELEASED <= @EndTime
    GROUP BY
    SALES_ORDER.SOH_CLASS,
    to_char(SALES_ORDER.SOH_DATE_RELEASED,'dd/mm/yyyy'),
    to_char(SALES_ORDER.SOH_TIME_RELEASED,'HH24:MI')
    Thanks in advance !

    Note that you can't reference your aliased columns in the where clauseWell spotted, I missed that one...
    +it must be the missing tags...+ ;)                                                                                                                                                                                                                                                                                                                   

  • Using Presentation variables in Prompt Default using SQL Results.

    I have set a presentation variable in a prompt(say 1st prompt). In the 2nd prompt, using default option, when I try to reference this variable in SQL Results, I get this error.
    State: HY000. Code: 10058. [NQODBC] [SQL_STATE: HY000] [nQSError: 10058] A general error has occurred. [nQSError: 27002] Near <@>: Syntax error [nQSError: 26012] . (HY000)
    The syntax used for SQL is:
    SELECT <tab>.<col1> FROM <subject area> WHERE <tab>.<col2> = @{variables.myvar}
    Note: However the same SQL works fine in SHOW option.
    Thanks in advance..
    Edited by: user457687 on Feb 27, 2009 3:13 PM
    Edited by: user457687 on Feb 27, 2009 4:49 PM

    - OK. In the second prompt, instead of setting Default to SQL Results, set it to Specific Value.
    - Then insert '{pres_var}' in the window. I got it to work this way.
    - It supplied the PV as the default in the second prompt after hitting "Go" on the first prompt.
    Hi, thanks for your suggestion but I don't need to have the value of the presentation variable itself as the prompt default. The variable is a filter for a specific SQL clause and the default is the result of this SQL.
    Cheers
    DrPlexi

  • Using Sql Result and Limit Value in Prompt OBIEE 11.1.1.5

    Dear Gurus,
    I have prompt hierarchy like this:
    Year
    Quarter
    Month
    Which are using limit value (Quarter depend on Year, Month depend on Quarter), but I have issue because appear null also in those prompt
    I have checked my database, view, repository there are not null.
    My questions is, how to remove null in prompt when sql result can't use together with limit value, I don't know how to remove it using column filter.
    NB:I already using presentation variable in sql result in order to remove null and using constraint, but it show nothing in prompt view unless we press apply button.
    So I don't use this
    Please help, kindly appreciated
    JOE
    Edited by: JoeSSI on Mar 27, 2012 2:03 AM

    Hi,
    Can you edit your prompt here you can find show option then select SQL Result please modify statement like below.
    SELECT your column name FROM subject area where your column name is not null
    Go--> Edit your prompt--> Show--> Select Sql result---> change statement like above.
    Second way.
    Go to physical layer then double click your column name here you can find *"nullable"* option please check that.
    Go--> Physical Layer--> Extract table --> select your column name-->double click your column name--> here you can find option like Nullable please check it.
    Award points it is useful.
    Thanks,
    Satya

  • Prompt For User Input in SQL Developer

    I am using the '&' in a very basic SQL select script, but I do not get a prompt for my input. However, i have used the '&' in update scripts and it does prompt me.
    For example:
    select DCC_DESCRIPTION
    from S_TBLDTMINOR
    where DCC_DTMINOR = &Minor;
    Gives an ORA-01008 error (not all variables bound).
    If it's a varchar field and I use '&Minor' - it executes with no error, but does not prompt for data. Please note:  this script works when it's run in SQL*Plus, but not in SQL Developer.
    If I execute:
    update S_TBLDTMINOR
    set DCC_DESCRIPTION = 'Mark & Wilson'
    where DCC_DTMINOR = 'AAA';
    It does prompt me for a value (but I do not want it to).
    So I know prompting works in SQL Developer, but it does not work in select statements.
    Is this a configuration setting I can change in SQL Developer? I know I can use the escape in the update statement to avoid the prompt, but I'm not concerned with that. I'm trying to get the prompting to work in the select statement.
    Edited by: user12289057 on Feb 23, 2012 11:17 AM

    Hi user12289057,
    1/Not sure what your testcase is (including table definition), I was trying to reproduce with:
    select * from dual where dummy = '&myin'
    2/Try
    undefine Minor
    to ensure Minor is not already set.
    3/Minor may need to be quoted if it is a string.
    Short blog post on substitution and bind variables.
    http://totierne.blogspot.com/2010/04/substitution-and-bind-variables.html
    -Turloch
    SQLDeveloper team.

  • Sql default for prompt

    Hi all,
    in OBIEE 11.1.1.6.4 I created a prompt with a default like:
    SET VARIABLE DISABLE_CACHE_HIT=1, DISABLE_CACHE_SEED=1; SELECT "Current Date Varchar" FROM "Servizi Business Model"."Common" where 1=1
    When I use the prompt in a Dashboard the default value is not updated, even if I refresh the page. The analysis using "Servizi Business Model"."Common".Current Date Varchar" shows the right and updated value. The tables in RPD are not cached
    It seems to me that the query is executed on creation level but not a runtime?
    Is it possible???

    THIS IS MY FINAL STATE OF ART: PLEASE IF SOMEONE HAS SOMETHING BETTER ANSWER ME:
    The prompt problem: the SQL CURSOR QUERY is cached! If database changes bu the query code is still the same, OBIEE USES THE CACHED RESULT
    At the moment:
    SET VARIABLE DISABLE_CACHE_HIT=1; --> not usefull at all
    instanceconfig.xml
    <Cache>
    <Query>
    <MaxEntries>1</MaxEntries>
    <MaxExpireMinutes>1</MaxExpireMinutes>
    <MinExpireMinutes>1</MinExpireMinutes>
    <MinUserExpireMinutes>1</MinUserExpireMinutes>
    </Query>
    </Cache>
    SELECT "Common"."Current Date Varchar" FROM "Servizi Business Model" WHERE <b>'@{system.currentTime}' = '@{system.currentTime}'</b>
    By this hack, each query is different and the cache is bypassed...
    The number of SQL queries increases but the cache is purged quickly.

  • PL SQL Query Question PROMPT

    I have a pl sql block in which I have the following script
    set serveroutput on
    set verify off
    PROMPT MENU
    PROMPT
    PROMPT 1) TOTAL INDEX
    PROMPT
    ACCEPT option PROMPT "Enter here the option "
    declare
    result number:=0;
    begin
    if (&&option=1) then
    select count(1) as total into result from dba_tables where owner='SYS';
    end if;
    dbms_output.put_line('Total is: '||result);
    end;
    I need to do, add an option in the menu in which says "out" and get me out of the menu,
    but if choose other options that I have to show and re-list the menu;
    can any1 help me with this please ?
    sorry for my bad english.
    Regards,

    Rafael M. wrote:
    I have a pl sql block in which I have the following scriptNot a good idea.
    PL/SQL is a server side language.
    You are now mixing that with client side language commands like prompt and accept (SQL*Plus client commands) .
    Do not confuse PL/SQL as part of the SQL*Plus tool and its (very primitive) macro language. They have nothing in common.
    All PL/SQL code in a script needs to be send by the client to the database server. There it is parsed. Compiled. Executed. And a response returned to the client.
    Given the fact that SQL*Plus does not support conditional processing, it makes it extremely difficult (and usually very much a hack) to create even a primitive console interface for an user - despite the power of PL/SQL as PL/SQL executes in an Oracle server process that is not connected to a mouse, keyboard or display device.
    IMO, what you are doing is simply not worth it. And I say that as a SQL*Plus user of many years and still using it every single day extensively (I prefer a CLI client over a GUI client like TOAD for the type of Oracle work/development I do).

  • Uninstall SQL Server 2012 in Command Prompt

    I need to make an  uninstall script for SQL Server 2012 Express but I can't figger it out.
    After I uninstalled the SQL instance with following command:
    C:\Program Files\Microsoft SQL Server\110\Setup Bootstrap\SQLServer2012\setup.exe /Action=Uninstall /FEATURES=SQL,AS /INSTANCENAME=SQLEXPRESS /QUIETSIMPLE
    There are still a couple of programs that I want to remove:
    Microsoft SQL Server 2008 Setup Support Files
    Microsoft SQL Server 2012 Transact-SQL ScriptDom
    Microsoft SQL Server 2012 Native Client
    SQL Server Browser for SQL Server 2012
    Microsoft VSS Writer for SQL Server 2012
    Microsoft - SQL Server 2012 Express
    Microsoft SQL Server 2012 Setup (English)
    Can someone please help me removing them without using 'Add or Remove Programs'
    and preferably without any interaction.

    Hi Michael1105,
    Are there any other instances except SQL Server Express in your system?
    To completely uninstall SQL Server Express include the Browser, Writer and other SQL Server components, I recommend you use the
    ConfigurationFile.ini file. Below is an example for you.
    Firstly, you can perform the following steps to generate a configuration file.
    1. Right click SQL Server 2012 from control panel and select Remove
    2. Follow the wizard through to the Ready to Remove page. The path to the configuration file is specified in the
    Ready to Remove page in the configuration file path section.
    3. Cancel the setup without actually completing the uninstallation, to generate the INI file.
    Secondly, you can specify the configuration file at the command prompt and uninstall SQL Server 2012 Express, or you can change the scripts in configuration file to meet your requirement, then copy the scripts
     in command prompt to uninstall SQL Server 2012 Express.
    Reference:
    Install SQL Server 2012 Using a Configuration File
    Thanks,
    Lydia Zhang
    Lydia Zhang
    TechNet Community Support

  • Unable to exit a PL/SQL Begin and End Statement

    All,
    OS: Solaris Unix
    DB: Oracle 9.2.0.4
    I'm calling and SQL files from the SQL PLUS prompt using
    @mysqlfile.sql
    which contains the following:
    declare
    current_month varchar2(20) := trim(to_char(sysdate,'Month'));
    current_year varchar2(20) := trim(to_char(sysdate,'YYYY'));
    begin
    PR_BUILD_REPORTS(current_month,current_year);
    end;
    This call to mysqlfile.sql is called from a Unix Shell script.
    The shell script hangs because the operation does not exit from teh mysqlfile.sql call. I have tried including and explict exit command after the proc call. I have also tried using exec <proc_name>;
    Can anyone shed some light on the above?

    Your anonymous pl/sql block will not run without a forward slash :
    current_year varchar2(20) := trim(to_char(sysdate,'YYYY'));
    begin
    PR_BUILD_REPORTS(current_month,current_year);
    end;
    AMM

  • Order in Multi-Select Prompt

    Hello friends!
    I have a problem doing a multiselect prompt. I have a Time dimension that it has Year, Month, Day. In my prompt I have only Month (because I have another prompt in my dashboard with Year).
    In my month prompt I have SQL Results with this formula: SELECT DISTINCT("- Dim TimeDim"."Month") FROM "Consulting". I put DISTINCT because I see only twelve months one time but my problem is that I see from dashboard when I click to select some months with alphabetical order (April, August... and I want to see: January, February...
    Any help??
    Thanks!!!

    I have this property in Administration Tab. I have Set Order by CodMes.
    For example if in my prompt I don't have SQL Results I can see sort my month correctly but I see all months of my time dimension january,february...january again,february again... so I have DISTINCT but I lose the order...
    Any Help?

  • OBIEE 11g Dashboard Prompts

    Hi,
    I need some help on possible designs for dashboard prompts. We have a number of prompts which are based on SQL Results (custom query) in some dashboards. Unfortunately obi cannot "Limit values by" or constrain values returned by the selected values of another prompt.
    My questions is what solutions have you tried & implemented to constraint the values returned by the selection values of another prompt when using SQL Results prompt?
    Thanks in advance
    Phil

    Hi,
    What we tried is having a presentation variable for the first prompt and according to the value of the first prompt, second prompt will show values.
    For example,
    First prompt has a presentation variable as @{first_prompt}
    Second prompt has sql results as -SELECT "dim1_column1" from sh where "dim1_column2"=@{first_prompt}
    Hope this helps.
    Regards
    MuRam

Maybe you are looking for

  • To Decode and play  MPEG-2 Video files with JMF

    Hi ALL, I amin serious trouble with a problem. I am developing a Simulator, a function of which is to decode MPEG-2 Video files in real time and play it as well.I have got a MPEG-2 Decoder implemented in C from an open source and need to integrate wi

  • How to Pass the data from the class to the BSP application(ie. .html page)

    hi i had created one .html page. This page is getting opened after clicking on one of the buttton of the toolbar(say Bank Data). Now the problem is , to show the data of the bank which user had entered in the PCUI application on the .html page. Pleas

  • CD/DVD Drive

    The CD/DVD Drive on my H215 Desktop takes a while to properly read the disc.  When I insert a music CD to play, the music begins right away bit the CD has not "seated" properly and the music "skips".  The light on the CPU blinks until the CD is seate

  • Thinkpad Yoga Brightness turn off backlight

    I have an "issue" with my Yoga. It used to be that when I turned down brightness completely the screen would go black because there was no more backlight at all. However it now seems that even completely turned down there is still some backlight left

  • Can't believe it happened again

    Hello all!.So I've spent the last week reading the forums hoping to find some reassurance, but I haven't found any situations like mine. I'm sure I'm not alone, so I decided to reach out.After filing chapter 7 in Oct 2008 ( dc Jan '09) , I find mysel