get my IPAddress through sql * more

Hello all;

I tried to use
select sys_context('Userenv', 'ip_address') from dual;
to get my ip address and it's back a white, again I tried to use
select utl_inaddr.get_host_address('johnp') from dual
and it gives me the following error below
       *
ERROR at line 1:
ORA-24247: network access denied by access control list (ACL)
ORA-06512: at "SYS.UTL_INADDR", line 19
ORA-06512: at "SYS.UTL_INADDR", line 40
ORA-06512: at line 1
and I give all the subsidy required to the user associated with the help
grant execute on utl_inaddr to financecc;
Published by: user13328581 on March 13, 2012 08:06

user13328581 wrote:

I know Ipconfig in the command windows... and I know the difference between the client and the server computer. I'm doing a simple test that is to know if there is an ip address any available when you have a client and a server running on the same computer

The server will see IP address of the client in this case if the client-server connection has been made by IP. A local connection using CPI (direct process-to-process communication). No IP involved. And so the server does not recognize the customer as a client IP.

Example:

// local connection that does not use TCP/IP
/usr/lib/oracle/xe> sqlplus "/ as sysdba"

SQL*Plus: Release 10.2.0.1.0 - Production on Wed Mar 14 18:10:16 2012
Copyright (c) 1982, 2005, Oracle.  All rights reserved.

Connected to:
Oracle Database 10g Express Edition Release 10.2.0.1.0 - Production

SQL> select sys_context('user', 'ip_address' ) as CLIENT_IP from dual;

CLIENT_IP
---------------

SQL> exit

Only when the client is an IP connection, the server has the means to determine the IP address of the client. For example

// force a TCP/IP connection via the Listener via localhost
/usr/lib/oracle/xe> sqlplus scott/tiger@"(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=127.0.0.1)(PORT=1521)) (CONNECT_DATA=(SID=vlk)))"

SQL*Plus: Release 10.2.0.1.0 - Production on Wed Mar 14 18:12:14 2012
Copyright (c) 1982, 2005, Oracle.  All rights reserved.

Connected to:
Oracle Database 10g Express Edition Release 10.2.0.1.0 - Production

SQL> select sys_context('user', 'ip_address' ) as CLIENT_IP from dual;

CLIENT_IP
---------------
127.0.0.1

by the way your syntax

! ipfconfig> 

does not work, it gives the following errors below

It depends on where run you it from. This command is intended for SQL * more and gives instructions to create a child process that calls the operating system command line. For example

SQL> ! /sbin/ifconfig eth0
eth0      Link encap:Ethernet  HWaddr 70:71:bc:ac:3d:49
          inet addr:10.251.93.30  Bcast:10.251.93.255  Mask:255.255.255.0
          inet6 addr: fe80::7271:bcff:feac:3d49/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:17171605 errors:0 dropped:2200 overruns:0 frame:0
          TX packets:9055411 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:11744534737 (11.7 GB)  TX bytes:1429625375 (1.4 GB)
          Interrupt:20 Memory:fe400000-fe420000

SQL>

This isn't a PL/SQL statement (language server).

Note that all side code Server (SQL and PL/SQL) is sent by SQL * more to the server process. In addition, SQL * Plus itself has a primitive vocabulary control and these commands it runs on the client.

This is why I pointed to the possible confusion of client-server, because there is a very clear and definitive separating SQL * more and its commands and the Oracle server and its languages SQL and PL/SQL.

Tags: Database

Similar Questions

  • BECAUSE a node: when to stop through SQL * more...


    Hello

    I installed a CCR node for the first time and playing with it to get better knowledge. The underlying cluster has two nodes, call them the Node_A and node_b.

    The cluster database itself is called upon to DEVELOP, DEVELOP_1 instance is running on the node Node_A, instance DEVELOP_2 is supposed to work on node_b. The preferred node is

    NŒUD_A.

    When testing database online relcation everything works as expected: DEVELOP_1 instance Gets the stop on Node_A node - instance DEVELOP_2 is started on node_b.

    But what closing instance DEVELOP_1 on Node_A with SQL * more I was surprised of the result:

    -C' is not instance DEVELOP_2 which began on node_b - it was DEVELOP_1 for instance!  (Because of this my control sews has changed - but is not the issue of this discussion).

    Now my questions are:

    -is the clusterware responsible for the DEVELOP_1 instance on node_b startup behavior when I stop instance DEVELOP_1 down on Node_A via SQL * more?

    - and if this behavior is documented? I went through the RAC documentation node, but could not find something useful

    Any help will be appreciated.

    Rgds

    Jan

    Hi Jan,

    Yes, its expected behavior in a node of the FCAC, please consult the document below.

    "Oracle Real Application Clusters one node Overview" (Page 1) (relocation of the database online)

    http://www.Oracle.com/technetwork/products/Clustering/overview/TWP-rac1nodev1-1-130698.PDF

  • Database demo of vision: how to access the database through SQL * more?

    I'm totally new in this space, so forgive my beginner questions.

    What I want to do, is to integrate EBS with APEX. To get there I downloaded (of delivery) and installed the Vision database unique node in a VirtualBox. To do this, I followed this video on YouTube: https://www.youtube.com/watch?v=8JgxMDPsd6s

    Now I want to install APEX and for this I need to access my database as SYS. Now for my questions:

    1. How can I use SQL * more in the VirtualBox?

    2. What is the default password for SYS with this demo database?

    Thanks, Alex

    File under $ORACLE_HOME and the owner is the user 'oracle '.

    You will need to source the file VISION_ebs.env , and then deliver "env | fate"and you should see the set env variables. You can connect as sysdba.

    Thank you

    Hussein

  • [Emergency] sqlplus gets "error 5 Initializing SQL * more NLS initialization.

    Hi all.

    I published sqlplus but I got the following error.

    What could be the reasons for the following error?

    Thanks in advance.
    Best regards.

    --------------------------------------------------------------------
    [esumedi (ngwapt1): esumedi/SG /] sqlplus
    Error Initializing SQL 5 * more
    Error of initialization of the NLS

    --------------------------------------------------------------------
    Profile of cat.
    --------------------------------------------------------------------

    export ORACLE_BASE = / ora_client
    Export ORACLE_HOME = $ORACLE_BASE/OraHome_1
    Export ORACLE_TERM = vt100
    Export ORA_NLS33 = $ORACLE_HOME/ocommon/sln/admin/data
    Export NLS_LANG = American_america. KO16KSC5601
    Export TNS_ADMIN = $ORACLE_HOME/network/admin
    export PATH=$PATH:$ORACLE_HOME/bin:.:/ bin: / usr/bin: / usr/sbin: / usr/ccs/bin: / usr/ucb: / opt/perf/bin: $ORACLE_HOME/OPatch: / oracle/app/oracle10/product/102
    0/bin:.
    Export SHLIB_PATH = $ORACLE_HOME/lib: $ORACLE_HOME/lib32: $ORACLE_HOME/network/lib: / usr/lib
    Export DISPLAY = 172.23.19.134:0.0
    export PATH=$PATH:/opt/java1.5/bin:/opt/java1.5/jre/bin
    --------------------------------------------------------------------------

    Hello
    By default, the software permissions do not allow most users to access and run the files under $ORACLE_HOME a lot. To change this and 'relax' the permissions, you must run $ORACLE_HOME/install/changePerm.sh.

    Kind regards
    Harry

    http://dbaharrison.blogspot.com/

    Published by: harry76 on July 13, 2011 16:37

  • Need to import via SQL more application advice

    Hello


    I have a sql file.
    I need to import the given in a workspace of some, but I have not access to Apex Builder request to do an import wizard.
    Can I please get some directions making this import via SQL Plus, where can I find documentation in this regard so that I can import successfully.

    Thanks in advance,
    Deepa

    Hi Deepa,

    I understand now, thanks.

    To import an application using SQL * Plus, the workspace must exist (with the ID of the same workspace). The best way to ensure that the workspace ID are the same is to export the workspace to one instance and import it in another.

    In addition, you cannot change the ID of the app through SQL * more - so, if you import the application via SQL * more, either one) this application ID cannot exist, or b) if exists, it must exist in the same workspace that you import into.

    Now - with all these conditions are met, the DBA can only run as a normal SQL through SQL script * more.

    Joel

  • Special characters could not load DB via SQL * MORE

    Hi, I have a pl as .accidentally sets sql script which will insert data in database. The question is there are some records are missing and these missing records contains a special character: Sansao and Strasse. The strange was if I run the script via F5 (Toad), all data can be inserted successfully but run through SQL * MORE (Toad), all records that contain special characters are not inserted.

    Anyone here know why it didn't load these special characters via SQL * MORE?

    Probably because you have given unicode (multi byte charsets) you read with a customer of standard single-byte character set.

    It's SILLY to loading data using SQL * more. It's the wrong tool used for loading the data. It does not support the bind variable. It doesn't support liaison in bulk. It does not support direct path inserts. It is not SQL * Loader.

  • Can I connect to SQL * more as SYS after connecting as a user and then run a GRANT?

    Oracle 11 g 2

    Linux RHEL 6.3

    SQL * Plus 11.2.0.2 on Windows 7

    ------------------------------------------------

    I am running a script SQL through SQL * more connected as "DOE, JOHN".

    In the SQL script, I need to connect as SYS to make a GRANT EXECUTE on a SYS package (e.g. GRANT EXECUTE ON DBMS_CRYPTO to JOHN;).

    But it fails with the following error:


    GRANT EXECUTE ON TO JOHN DBMS_CRYPTO
    *
    ERROR on line 1:
    ORA-01917: user or role 'JOHN' does not exist

    But of course, 'JOHN' are.  The rest of the SQL script is running "DOE, JOHN" without any problem.

    The code segment of SQL script in question is:

    connect sys/password as sysdba
    GRANT EXECUTE ON DBMS_CRYPTO TO ROYSECITYDATA;  <-fails here
    to connect/DOE

    Please advise on what my being the issue.

    tx103108 wrote:

    I connect to a remote database.  All dbs distance have the same instance name as they are all images.  I see where you're going (I think).  Should I try

    I'll try to connect sys/password@MYDB

    Sounds like a plan... (the instance_name returned with what you expected? or something else?)

  • How to get SQL * more to connect to my database of Apex?

    How can I get SQL * more to connect to my database of Apex? By using the username and password I use to connect to Apex does not (ORA-01017). What should I do to connect to my db Apex?

    Thank you
    Kim

    Connection string is "connect username/password@database".

    The analysis schema is a database account, that's why you can log on to SQL * more like that.

    This allows to get the database name

    select instance_name from v$instance;
    

    And if you forgot the password for the PT

    alter user PT identified by 'your_new_password';
    

    Scott

  • trying to get used to sql * more running and creating a simple procedure

    Hello all;

    I'm getting used to sql * more after using for a while using pl/sql developer.

    I am trying to create a simple procedure and run it. See my procedure below
    create or replace procedure test(t in varchar2(200), limit in number(30))
    begin
    select tbl_report.id from tbl_report where tbl_report.id like '|| t ||%' and rownum <= limit;
    end test;
    and then I type in run hr.test ("J", 10); to run this and then press ENTER, and it does nothing. How can I run and create a simple procedure in sql * more

    Hello

    In addition to all the good points, others have done:

    When you issue a SELECT statement in SQL * Plus (or any other front end) two things happen:
    (1) a result set, containing the results of your query, is produced, and
    (2) this result set is displayed.
    Given that these two things are always done together, it is easy to forget that they are two different things.
    In PL/SQL, you must explicitly do something to catch the result set, and you must explicitly do something else to view it (if you want to display it).

    A simple way to get the result set is to use a cursor FOR loop, to extract a line at a time and run code with this line in a record variable (called the country in the example below).
    View the results is to call dbms_output.put_line.

    Here is an example:

    CREATE OR REPLACE PROCEDURE     test
    (       t       IN      VARCHAR2
    ,     lmt      IN     NUMBER          -- LIMIT is an Oracle keyword; best not to use it as a variable name
    )
    IS
    BEGIN
        FOR  country  IN ( SELECT  country_name
                          FROM    hr.countries
                     WHERE   country_name     LIKE t || '%'
                     AND     ROWNUM          <= lmt
                   )
        LOOP
            dbms_output.put_line (  country.country_name
                        || ' = country_name'
                        );
        END LOOP;
    END test;
    /
    SHOW ERRORS
    

    You can use variables, such as t and lmt, in the query without using dynamic SQL, as long as the variables do not have the same names as the columns in the table. In this case, t and lmt are good names; country_name or region_id wouldn't. (In fact, t is a reputable insofar as it cannot be confused with a column in the table of the country. T is not a good reputation in the sense that it does not give much information about what contains the variable, or how it is used. Why not call the variable target_name or name_a_trouver?

    You can run the SQL procedure * more like this:

    SET     SERVEROUTPUT     ON
    
    EXEC  test ('I', 2);
    

    If you issue the SET SERVEROUTPUT ON command, then you will not see the output of dbms_output. You must only issue the command SET SERVEROUTPUT ON once per session, but nothing bad happens if you do it more than once.

    When I ran the procedure as stated above, I got this output:

    Israel = country_name
    India = country_name
    

    Notice that "The Italy" does not appear, because lmt has 2.

    Do not create your own procedures, tables or other objects in the HR schema, or among all the other patterns created by Oracle. Create your own schema and create procedures and other objects in it.

  • How can I get used five albums of table employees through SQL?

    I want albums n number of result of the table through SQL... as max 5 salaries employees...
    Thanks... :))
    select * from (select empno,empname,sal, rank() over (order by sal desc)rn from employee) where rn<=5
    

    Try this... Certainly will help you.

  • bad connect to Sql * more via command and cannot log on to the designer (need for connection string)

    I installed Oracle Developer with success, but having bad connect to Sql more than command line, also unable to connect via the developer tools, I get a TNS: Connect timeout occurred. This happens also for the "Plus" Sql for Windows.

    Oracle Forms connect error.png


    However, I can connect via the Sql Plus command window when it is executed from "Start-> all programs", but not when I first run the command window:

    sqlplus error.PNG


    I have a good Oracle 11 g install on Windows 7 and a good developer Sql install so I can connect to databases, but something does not work when you try to connect through these tools. Although Sql Plus works when called from 'Start-> all programs'

    sqlplus scott/tiger - don't use SQL * Net, you can connect like this even with the listener is stopped.

    Developer SQL can ONLY connect using SQL * Net & can be blocked by the firewall

    to connect using sqlplus & SQL * Net, you need to invoke it as below

    sqlplus scott/tiger@orcl

  • Connection with SQL * more is not possible

    Hello together,

    I have a problem with my database and SQL Plus.

    I can't connect to my DB via SQL Plus, I get the error message: > > ORA_12546: TNS: detonation verweigert (Permission denied) < <.

    I tried it with several users. When I try to log in to enterprise manager or connecting to the DB through SQL Developer works very well with the user > > sys < <, only the SQL more connection does not work.

    It works until yesterday that there are some problems with the DB and the processor and RAM were almost 100% occupied each.


    We use the Version 11 g Enterprise Edition Release 11.2.0.1.0 64 bit Production on a Windows Server 2008 R2 Enterprise Server.

    I am running SQL Plus, Enterprise Manager and SQL Developer directly on the DB server.

    When I start SQL Plus he asks me my username > > enter user name: < < and after that my password: > > password: < <.

    A connection as seen in many forums or document on the internet like > > scott/tiger@ORCL < < never worked on my system, which is also confused me.


    We have no listener.ora file in the folder: ORACLE_HOME/NETWORK/ADMIN only a sqlnet.ora with line > > SQLNET. AUTHENTICATION_SERVICES = (NTS) < < in it.



    Status of the listener:

    ---------------------------------------------------------------------------------------------------------------------------------------------------------

    C:\Windows\System32 > lsnrctl status

    LSNRCTL for 64-bit Windows: Version 11.2.0.1.0 - Production on 18 February 2014 12:14:32

    Copyright (c) 1991, 2010, Oracle.  All rights reserved.

    Connection to (ADDRESS = (PROTOCOL = tcp)(HOST=) (PORT = 1521))

    STATUS of the LISTENER

    ------------------------

    Alias LISTENER

    TNSLSNR for Windows 64-bit version: Version 11.2.0.1.0 - Production

    Start date February 18, 2014 10:15:54

    Uptime 0 days 1 hour 58 minutes 42 seconds

    Draw level off

    Security ON: OS Local Authentication

    SNMP OFF

    O:\app\administrator\diag\tnslsnr\QualisysDbNbg\listener\alert\log.XML log listener

    Summary of endpoints listening...

    (DESCRIPTION = (ADDRESS = (PROTOCOL = tcp)(HOST=QualisysDbNbg) (PORT = 1521)))

    Summary of services...

    Service "orcl" has 1 instance (s).

    Instance "orcl", State LOAN, has 1 operation for this service...

    The command completed successfully

    C:\Windows\System32 >

    ---------------------------------------------------------------------------------------------------------------------------------------------------------


    I hope someone can help me with this problem.


    Thank you you very much in forward for your answerand greetings

    Matthias


    The sys user must connect as sysdba

    have you tried

    sqlplus 'sys@ORCL as sysdba'

    or

    sqlplus 'sys/yoursyspwd@ORCL as sysdba'

    the first command should work without password for all users group ORA_DBA.

    Scott, the user cannot also exists in your database.

  • Privileges differ between SQL * more and stored procedure

    A user with the dba role can access dba_role_privs. But this is not possible in a stored procedure created by the same user.
    Normally, the example should work fine
    But with Oracle XE 11.02 - cost free database with some limitations - I get error 942

    I show a simple example in SQL * more:

    SQL > r
    1 * select distinct dba_role_privs recipient where the recipient as "SY %.

    DEALER
    ------------------------------
    SYSTEM
    SYS

    SQL > create or replace procedure x as
    2 start
    3 for rec in (select distinct dba_role_privs dealer where the beneficiary as 'SY %')
    4 loop
    5 zero;
    6 end of loop;
    7 end;
    8.

    Warnung: Prozedur wurde mit Kompilierungsfehlern standing.
    English translation: procedure created with compilation errors

    SQL > show error

    LINE/COL ERROR
    -------- -----------------------------------------------------------------
    3/14 PL/SQL: statement ignored
    3/43 PL/SQL: ORA-00942: table or view does not exist
    SQL >

    How can I fix?

    Why do you think the example should work properly?

    Normally, regardless of the version, the privileges granted through roles (such as DBA) not available for stored procedures. Stored procedure of a DEFINER rights can only take advantage of the privileges granted directly to the owner of the procedure. Stored procedure of the invoker rights can enjoy privileges granted by a role, but that requires that the appellant has independent privileges to query the table in question (and, in this case, would require dynamic SQL usage).

    Generally, the simplest approach would be to grant the privilege to CHOOSE ANY DICTIONARY to the owner of the procedure.

    Justin

  • SQL more unable to connect (computers connected via a DSL router)

    Hello!

    I have two computers connected locally via a DSL router. His IP address is 192.168.1.64 IP of the other is 192.168.1.65.
    "I'm trying to connect to 192.168.1.64 via SQL more 192.168.1.66 by running the following command: sqlplus system@"192.168.1.64/orcl.168.1.100 "and receive this error message:" ORA-12170: TNS: Connect timeout occurred. " I thought it was the default Windows Firewall that has caused this and changed the windows firewall settings in 192.168.1.64 adding port 1521 in the list of windows firewall. Now, I get this error: "ORA-12541: listener TNS:no.»

    Published by: totalnewby on June 12, 2010 10:53

    totalnewby wrote:
    Hello!

    I have two computers connected locally via a DSL router. His IP address is 192.168.1.64 IP of the other is 192.168.1.65.
    "I'm trying to connect to 192.168.1.64 via SQL more 192.168.1.66 by running the following command: sqlplus system@"192.168.1.64/orcl.168.1.100 "and receive this error message:" ORA-12170: TNS: Connect timeout occurred. " I thought it was the default Windows Firewall that has caused this and changed the windows firewall settings in 192.168.1.64 adding port 1521 in the list of windows firewall. Now, I get this error: "ORA-12541: listener TNS:no.»

    Published by: totalnewby on June 12, 2010 10:53

    =================================

    Suppose you have the following in your tnsnames.ora:

    Larry =
    (DESCRIPTION =
    (ADDRESS_LIST =
    (ADDRESS = (PROTOCOL = TCP)(HOST = myhost) (PORT = 1521))
    )
    (CONNECT_DATA =
    (SERVICE_NAME = curley)
    )
    )

    Now, when you issue a connect, say like this:

    $> sqlplus scott/tiger@larry

    TNS will appear in your tnsnames.ora for an entry called "larry". Then, tns sends a request to (PORT = 1521) on (HOST = myhost) to aid (PROTOCOL = TCP), requesting a connection to (SERVICE_NAME = curley).

    Where's (HOST = myhost) on the network? When the request is passed to tns to the next layer in the network stack, the name "myhost" resolves to an IP address, either via a file 'hosts' local, through DNS, or possibly other mechanisms being used less. Alternatively, you can hard-code the IP (HOST = 123.456.789.101) in the tnsnames.ora.

    Then, the request arrives at port 1521 myhost. If all goes well, there is a listener on myhost configured to listen on port 1521, and this listener knows SERVICE_NAME = curley. If so, you'll be connected.

    A few important points.

    First, the listener is a process only the side server. It's all in life seeks applications for reception for connections to the databases and set up these connections. Once the connection is established, the listener is out of the picture. It creates the connection. It does not support the connection. A listener, linking an oracle of the House, listening on a single port, use multiple instances of database in several versions of several houses. It is unnecessary complexity to try to have several headphones. It's like the telephone company, to build a separate table for each customer.

    Secondly, the tnsnames.ora file is a client-side problem. Its purpose is to address resolution - the equivalent of the 'hosts' file tns further to the bottom of the network stack. The only reason it exists on a host computer is because this machine also can run client processes.

    What can go wrong?

    First, there may not be an entry for 'larry' in your tnsnames file. In this case, you get "ORA-12154: TNS: could not resolve the connect identifier specified" no need to go looking for a problem on the host, with the listener, etc.. If you cannot place a phone call because you do not know the number (cannot find your phonebook (tnsnames.ora) or can not find the party looking for listed in it (no entry for larry)) you don't look at problems at the switchboard.

    Perhaps the entry for larry was found, but myhost could not be resolved to an IP address (for example there is no entry for myhost in the local hosts file). This will mean by "ORA-12545: Connect failed because target host or object does not exist.

    Maybe there is an entry for MyServer in the local hosts file, but it specified a bad IP address. This will mean by "ORA-12545: Connect failed because target host or object does not exist.

    Maybe the INVESTIGATION period was good, but there is no listener running: "ORA-12541: TNS:no listener.

    Maybe the INVESTIGATION period was good, there is a listener to myhost, but he is listening on a different port. "ORA-12560: TNS:protocol adapter error.

    Maybe the INVESTIGATION period was good, there is a listener to myhost, listening on the specified port, it's unknown SERVICE_NAME = curley. "ORA-12514: TNS:listener is not currently of service requested in connect descriptor.

    =====================================

  • SQL * more substitution vs bind variable question

    Hi all, I am trying to automate some SQL within SQL codes * more script that is triggered by a script .bat, the only parts that change are Dates...

    example:

    create table blah as

    Select * from table

    WHERE DATE between start_date and END_DAY;

    the DATE is a numeric field, YYYYMMDD

    The script runs always at the beginning of a new week, so a Monday, unless a public holiday, then a Tuesday.

    The END_DAY is * always * last Friday and I realized that:

    variable L_FRIDAY char (15);

    Start

    Select to_char (next_day(sysdate-7,'FRIDAY'), 'YYYYMMDD') as Last_Friday in: double L_FRIDAY;

    end;

    /

    The thing is that I get an error when I try to use the binding variable?

    create table blah as

    Select * from table

    WHERE DATE between start_date and: L_FRIDAY;

    Then once I found the end date, I was going to use add_months(L_FRIDAY,-12) for previous 12 months for the start_date...

    When I tried to use a variable Substitution I could just hard code the date, but I can not or do not know how to set the value of this exec to the variable?

    Help!

    :-)

    Basically my research reveals that - Bind variables are not allowed for operations of data definition, use substutions instead of bind variables

    I need an automated way to find the END_DAY which is last Friday and START_DATE that is 12 months before Friday and refer to those in the SQL without errors.

    Hello

    Kodiak_Seattle wrote:

    Hi all, I am trying to automate some SQL within SQL codes * more script that is triggered by a script .bat, the only parts that change are Dates...

    example:

    create table blah as

    Select * from table

    WHERE DATE between start_date and END_DAY;

    the DATE is a numeric field, YYYYMMDD

    The script runs always at the beginning of a new week, so a Monday, unless a public holiday, then a Tuesday.

    The END_DAY is * always * last Friday and I realized that:

    variable L_FRIDAY char (15);

    Start

    Select to_char (next_day(sysdate-7,'FRIDAY'), 'YYYYMMDD') as Last_Friday in: double L_FRIDAY;

    end;

    /

    The thing is that I get an error when I try to use the binding variable?

    create table blah as

    Select * from table

    WHERE DATE between start_date and: L_FRIDAY;

    Then once I found the end date, I was going to use add_months(L_FRIDAY,-12) for previous 12 months for the start_date...

    When I tried to use a variable Substitution I could just hard code the date, but I can not or do not know how to set the value of this exec to the variable?

    Help!

    :-)

    Basically my research reveals that - Bind variables are not allowed for operations of data definition, use substutions instead of bind variables

    I need an automated way to find the END_DAY which is last Friday and START_DATE that is 12 months before Friday and refer to those in the SQL without errors.

    Or SQL * more bind variable or variable substitution can be DATEs.  The best you can do is set a different type, as a string, representing a date.  A string as June 19, 2015"represents a date, but so strings like 'SYSDATE' and ' SYSDATE - 7', so you can do something like this:

    SET l_friday = ' NEXT_DAY ((SYSDATE-7), 'FRIDAY').

    DEFINE start_date = "ADD_MONTHS (& l_friday, - 12)"

    SELECT & start_date AS t_n

    , & l_friday AS l_f

    OF the double

    ;

    Output (when executed on 25 June 2015):

    L_F T_N

    ----------- -----------

    June 19, 2014 19 June 2015

Maybe you are looking for

  • Apple ID activation problem

    I forgot my apple id password and I have no access to my email or phone number I put in place this apple 3 years ago ID the only thing I remember is the e-mail what can I do?

  • Flash Player does not work on one site

    I can't view the puzzle of sudoku on this site: http://www.seattlepi.com/puzzles/?content_name=sud_classic. I get an error message "Load Library failed error #2036" I uninstalled Flash Player and reinstalled and I uninstalled Firefox, keeping my pers

  • People contacts courier

    People off of your contacts can see your messages if you send?

  • Sharing on a wireless network

    Hope this is right forum thr. Ive has set up a router to a pc and a laptop to share bandwidth network. Works ok but can share the printer connected to the PC?If so, how can I get the laptop to find the printer?

  • Send and receive messages question - Outlook

    Original title: saspencer Some forwarded messages sent out and go to the Outbox? This happens in Outlook. I also receive two duplicate incoming messages? Also, Outlook.