Quick SQL question
Hi DBAs,I am a part-time DBA and former DBA type configured SQL Prompt that shows something like this (User@SID) as sqlprompt
System@prod >
Now, if I need to stop and restart the database, this sqlprompt is suspended unless I have to press < ENTER > couple of times.
I want the default restore SQLPROMPT permanentely ' SQL > '
Please tell us how I can do it.
Thank you
-Samar-
Configuration of the SQL in SQL command prompt * more could be done in the file login.sql or glogin.sql
This file is probably located at $ORACLE_HOME/sqlplus/admin/glogin.sql (even though it may be, if the old administrator has configured a different SQLPATH). There is an article on [configuration SQL * more | http://download.oracle.com/docs/cd/B28359_01/server.111/b31189/ch2.htm#i1132910] which presents different options here. It can also be configured in the user-specific login.sql file, but I guess that is not the case here since, presumably, the former administrator does not configure login.sql file your account.
In glogin.sql, looking for a line SET SQLPROMPT, which attaches to the SQL prompt. Eliminate that should restore the SQL > prompt.
Justin
Tags: Database
Similar Questions
-
Hi all I have a basic sql question
Watch below two querries
I think as operator will not compare with all the values, but not the outcome it will compare with all values... When comparing with the value null, the result is automatically null1. select 1 from dual where 1 in (select 1 from dual union all select null from dual) It gives output as 1 but below one 2. select 1 from dual where 1 not in (select 2 from dual union all select null from dual) It gives output as no data found
I'm wrong
Please help me on this
and why performance wise in operator is more better than no of?
Thanks to all in advanceThanks for posting your explain plan command
Execution Plan ---------------------------------------------------------- Plan hash value: 3249215828 ----------------------------------------------------------------------------- | Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | ----------------------------------------------------------------------------- | 0 | SELECT STATEMENT | | 2 | 6 | 4 (0)| 00:00:01 | | 1 | NESTED LOOPS | | 2 | 6 | 4 (0)| 00:00:01 | | 2 | FAST DUAL | | 1 | | 2 (0)| 00:00:01 | | 3 | VIEW | VW_NSO_1 | 2 | 6 | 2 (0)| 00:00:01 | | 4 | SORT UNIQUE | | 2 | | 2 (0)| 00:00:01 | | 5 | UNION-ALL | | | | | | | 6 | FAST DUAL | | 1 | | 2 (0)| 00:00:01 | |* 7 | FILTER | | | | | | | 8 | FAST DUAL | | 1 | | 2 (0)| 00:00:01 | ----------------------------------------------------------------------------- Predicate Information (identified by operation id): --------------------------------------------------- 7 - filter(NULL IS NOT NULL) 02:12:54 SQL> select 1 from dual where 1 not in (select 2 from dual union all select null from dual); Elapsed: 00:00:00.01 Execution Plan ---------------------------------------------------------- Plan hash value: 3291682568 ----------------------------------------------------------------- | Id | Operation | Name | Rows | Cost (%CPU)| Time | ----------------------------------------------------------------- | 0 | SELECT STATEMENT | | 1 | 4 (0)| 00:00:01 | |* 1 | FILTER | | | | | | 2 | FAST DUAL | | 1 | 2 (0)| 00:00:01 | | 3 | UNION-ALL | | | | | |* 4 | FILTER | | | | | | 5 | FAST DUAL | | 1 | 2 (0)| 00:00:01 | | 6 | FAST DUAL | | 1 | 2 (0)| 00:00:01 | -----------------------------------------------------------------
-
Apex SQL question - weeks of the month
I have a sql question.
I want to create a dynamic list.
If the user select may2009, then I want a dynamic list of show
04/27/2009-05/03/2009
05/04/2009-05/10/2009
05/11/2009-05/17/2009
05/18/2009-05/24/2009
05/25/2009-05/31/2009
If the user selects Jun 2009, then the list will be
06/01/2009-06/07/2009
06/08/2009-06/14/2009
06/15/2009-06/21/2009
06/22/2009-06/28/2009
06/29/2009-07/05/2009
Thank you.Using this SQL statement, you can get this list:
SELECT w_start || ' - ' || w_end d, w_start r FROM (SELECT (week_start_list + (LEVEL - 1) * 7) + 1 w_start, week_start_list + (LEVEL) * 7 w_end FROM (SELECT TO_CHAR (TRUNC (TO_DATE (:my_date, 'dd.mm.yyyy'), 'mm' ), 'IW' ) week_begin, TRUNC (TO_DATE (:my_date, 'dd.mm.yyyy'), 'mm' ) m_begin, TO_CHAR (TRUNC (TO_DATE (:my_date, 'dd.mm.yyyy'), 'mm'), 'd' ) day_month_begin, TO_CHAR (TRUNC (ADD_MONTHS (TO_DATE (:my_date, 'dd.mm.yyyy' ), 1 ), 'mm' ), 'IW' ) week_end, TRUNC (ADD_MONTHS (TO_DATE (:my_date, 'dd.mm.yyyy'), 1 ), 'mm' ) m_end, TO_CHAR (TRUNC (ADD_MONTHS (TO_DATE (:my_date, 'dd.mm.yyyy' ), 1 ), 'mm' ), 'd' ) day_month_end, TRUNC (TO_DATE (:my_date, 'dd.mm.yyyy'), 'mm' ) - TO_NUMBER (TO_CHAR (TRUNC (TO_DATE (:my_date, 'dd.mm.yyyy' ), 'mm' ), 'd' ) ) week_start_list, TRUNC (ADD_MONTHS (TO_DATE (:my_date, 'dd.mm.yyyy'), 1 ), 'mm' ) + TO_NUMBER (TO_CHAR (TRUNC (ADD_MONTHS (TO_DATE (:my_date, 'dd.mm.yyyy' ), 1 ), 'mm' ), 'd' ) ) - 1 week_end_list FROM DUAL) CONNECT BY LEVEL <= (SELECT TO_NUMBER (TO_CHAR (TRUNC (ADD_MONTHS (TO_DATE (:my_date, 'dd.mm.yyyy' ), 1 ), 'mm' ), 'IW' ) ) - TO_NUMBER (TO_CHAR (TRUNC (TO_DATE (:my_date, 'dd.mm.yyyy' ), 'mm' ), 'IW' ) ) FROM DUAL))
It is a question of SQL and has nothing to do with the Apex.
Denes Kubicek
-------------------------------------------------------------------
http://deneskubicek.blogspot.com/
http://www.Opal-consulting.de/training
http://Apex.Oracle.com/pls/OTN/f?p=31517:1
------------------------------------------------------------------- -
I am a newbie to SQL and I studied the book of Fundamentals SQL Server Oracle OCA 12 c, but a section on natural joins to confuse me.
Basically, the author says:
SELECT r.region_name, d.department_name, l.city, c.country_name
DEPARTMENTS d
NATURAL JOIN places l, c countries, regions r;
The natural join between DEPARTMENTS and LOCATIONS creates a provisional result, consisting of 27 lines since they are implicitly attached on the column of location_id. This set is then Cartesian-joined to the table of the COUNTRY as a join condition is not implicitly or explicitly specified. 27 interim lines are attached to 25 lines in the COUNTRY table, which gives a new temp results set with 675 (27 × 25) rows and three columns: DEPARTMENT_NAME, CITY and COUNTRY_NAME. This set is then attached to the REGION table. Once more, a Cartesian join occurs because column REGION_ID is absent from any join condition. The final result set contains rows and four columns (675 × 4) 2700.
I can understand because you evaluate joins from the left. But then he wrote:
The JOIN... USE and JOIN... ON the syntaxes are better suited to join multiple tables. The following query joins four tables using the natural join syntax:
SELECT country_id region_id, c.country_name, l.city, d.department_name
DEPARTMENTS d
NATURAL JOIN places l
NATURAL JOIN country c
NATURAL JOIN region r;
This query generates correctly 27 lines in the final results set since the required join columns are listed in the SELECT clause. The following query illustrates how the JOIN... CLAUSE is used to extract the same 27 lines. A join condition can reference columns only in its scope. In the following example, the join of DEPARTMENTS slots can not reference columns in the COUNTRIES or REGIONS of tables, but the join between the COUNTRIES and REGIONS may refer to any column of four tables involved in the query.
This second method of the part of the natural writing joined confuses me. I don't understand the logic behind the 2nd series of States of Natural Join. For me, it seems that the first series and the 2nd set look alike, but they are apparently not.
Can someone tell me the differences?
Thank you!!
Hello
The more important thing to learn more about NATURAL JOIN is: never use it. If you add new columns, joins can get different results. I've never heard of someone uisng NATURAL JOIN apart from a manual or a question like yours.
There are a lot of things in Oracle that take the time to learn and are useful. All the time you spend learning things is better spent on them.
-
SQL * PLUS connects with SQL >; question
People,
I'm confused on the command. / sqlplus with Oracle database.
According to my understanding,. / sqlplus connected with SQL > using option 3: sysdba, sysoper, sysasm.
I connect with SQL > to run the rel853.sql script to create a table PSOPRDEFN but a field "OPERPSWDSALT" did not appear in the table PSOPRDEFN although it is in the Create Table statement.
I connect with SQL * in the directory/home/user/OracleDB_Home/bin as below:
$ export SYSTEM_PASS = AccessId/mypass$ export ORACLE_HOME = / home/user/OracleDB_Home
$ export ORACLE_SID = HRCS90
$. / lsnrctl start LISTENER
$. / AccessId/mypass sqlplus as sysdba
SQL > startup
SQL > @/opt/PT8.53/scripts/rel853.sql
SQL > select OPERPSWDSALT in the AccessId.PSOPRDEFN;
It returns: "OPERPSWDSALT": invalid identifier.
I checked the table PSOPRDEFN that the OPERPSWDSALT field did not appear in the table PSOPRDEFN.I tried the sysoper option as below:
$. / sqlplus AccessId/mypass as sysoper
SQL > startup
SQL > @/opt/PT8.53/scripts/rel853.sql
SQL > select OPERPSWDSALT in the AccessId.PSOPRDEFN;
It returns: "OPERPSWDSALT": invalid identifier.
The sysoper error is the same thing with sysdba error.
I tried the sysasm option as below:
$. / sqlplus AccessId/mypass as sysasm
He returned: connection refused.
Someone told me this connection as SYS causes this error. If not a sysdba, sysoper, or sysasm, use the command. / sqlplus AccessId/mypass cannot connect with SQL >.
My question is:
First of all, why is what OPERPSWDSALT did not appear in the PSOPRDEFN table while it is in the CREATE TABLE statement?
Seocond, if not use SYS which is one of the 3 options, how to run the command. / sqlplus AccessId/mypass to connect with SQL > so that CREATE TABLE PSOPRDEFN correctly?Thank you.
user8860348 wrote:
People,
Hello. Thanks much for the reply. I just do the commands below:
$ export SYSTEM_PASS = AccessId/mypass
$ export ORACLE_HOME = / home/user/OracleDB_Home
$ export ORACLE_SID = HRCS90
$. / lsnrctl start LISTENER
$. / AccessId/mypass sqlplus as sysdba
SQL > show user;
Its release: the USER is "SYS".
SQL > connect AccessId/mypass
Its output:
Error: ORA - 01034:ORACLE not available
ORA-27101: shared memory realm does not exist
64 - Linux_x86 error: no such file or directory.
As we see above, unable to connect to the Oracle database AccessId.
My question is:
What to do on AccessId, so that it can connect to the Oracle database?
Thank you.
so much for the use that you refuse to actually use COPY it PASTE & so that we can see the whole session.
In the past, you did
> SQL > startup
Maybe the database is out of order & must be started.
do exactly as below (line by line)
ID
sqlplus
/ as sysdba
startup
connect AccessId/mypass
COPY the results from above then PASTE all back here
-
Hi expert,
When I ran after SQL, error message reads "table or view does not exist" pointing to the table "dba_tab_cols" and "dba_all_tables". There is no other question for this statement, because if I changed table "user_tab_cols" and "user_all_tables", it works well.
declare
v_old_table DBA_tab_columns.table_name%type;
v_where Varchar2 (4000);
Boolean v_first_col: = true;
type rc is ref cursor;
c rc;
v_rowid varchar2 (20);
Val varchar2 (50): = "Test note";
Start
for r in)
Select
t.*
Of
dba_tab_cols t, dba_all_tables a
where t.table_name = a.table_name
and t.data_type like '% CHAR % '.
and a.owner = 'QA'
order by t.table_name loop)
If v_old_table is null then
v_old_table: = r.table_name;
end if;
If v_old_table <>r.table_name then
v_first_col: = true;
-dbms_output.put_line ('search' | v_old_table);
Open c for ' select rowid from ' ' |. ' v_old_table | '" ' || v_where;
extract the c in v_rowid;
loop
When the output c % notfound;
dbms_output.put_line (' rowid: ' | v_rowid |) "in" | v_old_table);
extract the c in v_rowid;
end loop;
v_old_table: = r.table_name;
end if;
If v_first_col then
v_where: = 'where ' | r.column_name | "as" %' | Val | '%''';
v_first_col: = false;
on the other
v_where: = v_where | "or" | r.column_name | "as" %' | Val | '%''';
end if;
end loop;
end;
But if I choose these DBA tables in the toad sql Editor, it works well, I am currently using my own credentials, not the administrator credentials. why he get different effects running in these two ways?
Thank you very much>
Hello
When I ran after SQL, error message reads "table or view does not exist" pointing to
Table 'dba_tab_cols' and 'dba_all_tables '. There is no other question for this statement, becauseIf I changed table "user_tab_cols" and "user_all_tables", it works well.
But if I choose these DBA tables in the toad sql Editor, it works well, I am currently using my own
credentials, not the administrator credentials. why he get different effects running in these two ways?You answered your own question - you know that you have the administrator privileges when you
Open a session under your own credentials - but your id user obviously does TOAD.You use SQL * for the query that fails?
BTW, you do not give us your version of Oracle - you must always tell us what it is
Please read the forum FAQ and also the thread "sticky" by BluShadow at the top of the list of positions
on the forum homepage. These forums are an excellent resource - you will get the best out of them if
you follow the instructions.HTH,
Paul...
Published by: Paulie July 24, 2012 16:40
-
Quick SEO question - new domain
Just a quick and I'm sure that the answer is a resounding no, but wanted to check I'm someone give the right info.
Basically, someone I know has a site for a company and had a falling out with his partner, who threatens to take down the site.
Then the other guy wants to make a copy of the site to a new domain that he has a master's degree.
So the question is will be the new site / domain keep / inherit all rankings SEO of the site existing under it is the same exact content?
As I said, I would be sure that the answer is no.
It would be only if the domain name is the same. Who has control of the domain name? That's who is listed as the owner of the domain for the domain name?
-
SQL question to get a top customer of the page
Hi all
I'm prasanna. I have a question about SQL, to get a customer based on name of the year and the customer. I wrote the request like this. But I got an error.
Select calendar_year, cust_first_name, max (sum (amount_sold)) in sale, the time the customers where sales.cust_id = customers.cust_id and times.time_id = sales.time_id of the calendar_year group, cust_first_name
The error is like this:
* Error from the 1 in the command line:
Select calendar_year, cust_first_name, max (sum (amount_sold)) in sale, the time the customers where sales.cust_id = customers.cust_id and times.time_id = sales.time_id of the calendar_year group, cust_first_name
Error in the command line: 1 column: 7
Error report:
SQL error: ORA-00937: not a function of simple-group
00937 00000 - 'not a single-group function. "
* Cause:
Action:
Thank you inadvace
Kind regards
Prasanna865016 wrote:
Your response, I had only one top customer with year, name of the client, amount_sold. But I need for each yearselect calendar_year, cust_first_name, total_amount_sold max_amount_sold from ( select calendar_year, cust_first_name, sum(amount_sold) total_amount_sold, row_number() over(partition by calendar_year order by sum(amount_sold) desc) rn from sales, times, customers where sales.cust_id=customers.cust_id and times.time_id=sales.time_id group by calendar_year, cust_first_name ) where rn = 1 /
I will give you a single customer by calendar_year.
SY.
-
SQL question for a beginner...
I have the following structure:
NUMBER OF PROCESSING_ITEM_ID
NUMBER OF PROJECT_ITEM_FK
START_TIME DATE
END_TIME DATE
NUMBER OF WORKSTATION_FK
examples of data
81,23,10-27-2010 08:00, 27/10/2010 10:00, 3
42,1,10-27-2010 08:00, 27/10/2010 11:00, 1
22,23,10-27-2010 13:00, 27/10/2010 17:00, 2
1,23,10-27-2010 15:00, 27/10/2010 16:00, 1
23,23,10-27-2010 17:00, 27/10/2010 20:00, 2
I'm trying to divide the data into lines of an hour. If this line we would be divided into:
81,23,10-27-2010 08:00, 27/10/2010 09:00, 3
81,23,10-27-2010 09:00, 27/10/2010 10:00, 3
third row would be divided into:
22,23,10-27-2010 13:00, 27/10/2010 14:00, 2
22,23,10-27-2010 14:00, 27/10/2010 15:00, 2
22,23,10-27-2010 15:00, 27/10/2010 16:00, 2
22,23,10-27-2010 16:00, 27/10/2010 17:00, 2
The statement that is made should display the data in this way...
John Brewer
City of SeattleQuestion delicate John, you should ask this in the SQL forums
This is the query
with temp AS ( SELECT 81 PROCESSING_ITEM_ID,23 PROJECT_ITEM_FK,TO_DATE('10-27-2010 08:00','MM-DD-YYYY HH24:MI') start_date,TO_DATE('10-27-2010 10:00','MM-DD-YYYY HH24:MI') end_date,3 WORKSTATION_FK from dual UNION ALL SELECT 22 PROCESSING_ITEM_ID,23 PROJECT_ITEM_FK,TO_DATE('10-27-2010 13:00','MM-DD-YYYY HH24:MI') start_date,TO_DATE('10-27-2010 17:00','MM-DD-YYYY HH24:MI') end_date,2 WORKSTATION_FK from dual ) ,time_span AS ( SELECT MAX( TO_NUMBER(TO_CHAR(end_date,'HH24')) - TO_NUMBER(TO_CHAR(start_date,'HH24')) ) TIME_SPAN FROM temp ) ,time_period_rows AS ( SELECT level-1 PERIOD FROM time_span connect by level <= TIME_SPAN ) SELECT T.PROCESSING_ITEM_ID,T.PROJECT_ITEM_FK,TO_CHAR(T.start_date+TR.PERIOD/24,'MM-DD-YYYY HH24:MI') start_time,TO_CHAR(T.start_date+(TR.PERIOD+1)/24,'MM-DD-YYYY HH24:MI') end_time ,T.WORKSTATION_FK FROM temp T ,time_period_rows TR WHERE PERIOD <= TO_NUMBER(TO_CHAR(end_date,'HH24')) - TO_NUMBER(TO_CHAR(start_date,'HH24')) ORDER BY T.PROCESSING_ITEM_ID,TR.PERIOD
Output
PROCESSING_ITEM_ID PROJECT_ITEM_FK START_TIME END_TIME WORKSTATION_FK 22 23 10-27-2010 13:00 10-27-2010 14:00 2 22 23 10-27-2010 14:00 10-27-2010 15:00 2 22 23 10-27-2010 15:00 10-27-2010 16:00 2 22 23 10-27-2010 16:00 10-27-2010 17:00 2 81 23 10-27-2010 08:00 10-27-2010 09:00 3 81 23 10-27-2010 09:00 10-27-2010 10:00 3 81 23 10-27-2010 10:00 10-27-2010 11:00 3
I used a view inline as data source ( temp ), you can change this to your table, name (then remove the display online)
-
Sorry guys, didn't know where otherwise put this hope so much he is allowed to post here. I currently have a field in my database that stores the date and time, however, I write a statemenet sql and need to use only the date of the datetime object, which would be the correct syntext to sowould I should use to_char etc.?
Thank you.Not a question of forms, but a database.
But check this for format masks: http://download.oracle.com/docs/cd/B19306_01/server.102/b14200/sql_elements004.htm
-
PL/SQL question (which is wrong)?
Hello
I read a book that has of the following statement
-------------------
DECLARE
type instructor_info is MADE
(name, instructor.first_name%type,
instructor.last_name%type last_name,
number of sections);
rv_instructor instructor_info;
BEGIN
Select rtrim (i.first_name),
RTrim (i.last_name),
Count (*)
the instructor,.
s section
in rv_instructor -.first_name, rv_instructor.last_name, rv_intructor.sections
where i.instructor_id = s.instructor_id
and i.instructor_id = 102
I.first_name group, i.last_name;
dbms_output.put_line (' instructor ' | rv_instructor.first_name |') '|| rv_instructor.last_name |', teaches ' | rv_instructor.sections | 'section (s)');
exception
When no_data_found then
dbms_output.put_line ('there no such instructor');
END;
-----------------
And the writer asks:
Explain what is declared in the previous example. Describe what happens to the record and explain how this translates into the output.
I look at the answers, and he says, that by operating, this example produces the following output:
Instructor Tom Wojick, teaches 9 item (s).
My question is that when I execute this example, he produced me the following error.
ORA-06550: line13, Column2:
PL/SQL: ORA-00933: SQL not correctly completed command
ORA-06550: framework8, Column2
PL/SQL: SQL statement ignored.
I tried the following:
Rv_instructor instructor_info % rowtype;
Or
In rv_instructor.first_name, rv_instructor.last_name, rv_intructor.sections
But the same error.
What's wrong?
Thank you very much.INTO clause would come before FROM clause.
Pass by ' this doc once...
http://download.Oracle.com/docs/CD/B19306_01/AppDev.102/b14261/selectinto_statement.htm#LNPLS01345
Kind regards
Prazy -
What kind of pl sql questions can you expect for a customer technical interview
Please notify all experienced professionals
What kind of questions can I expect in the customer facing interview technical I have to a PL SQL Developer with interview of performance tuning. The customer is primarily a financial project.
Yes of course I would essentially tell me about the projects that you been involved in based on who they ask the questions, basically I'm not very experienced 3 years and my experience involves performance limited tuning, to develop scripts to support front-end web applications.
What kind of questions (you do not need to enumerate the issues specifically, it would be useful that you could advise the areas where I should look into, all the links where I can read about the region suggest you also face a customer interview).
Example: Financial transaction processes much as treatment so I have to prepare for any question on the changing Table, blocking.
Also, I am aware of the Collections, external Tables. These would be discussed.
Any advice would be very helpful.
My experience does not imply strongly any financial experience and job specification does not state so I got through the 2 first interview series. It would be a disadvantage if I said that I have had no experience of finanicial, I guess just by hearing from some sources that the customer is finance.
I would be hired only if the customer agrees, so I need to deepen as much as possible, it's time to prepare for good trying to inform.
Kind regards.Rider wrote:
My experience does not imply strongly any financial experience and job specification does not state so I got through the 2 first interview series. It would be a disadvantage if I said that I have had no experience of finanicial, I guess just by hearing from some sources that the customer is finance.
Personally, when I interview candidates PL/SQL, the least important thing for me is real business knowledge. I want to rather a competent PL/SQL Developer who knows his stuff, a person having poor skills of PL/SQL and a good knowledge of the company.
We will pay that person for PL/SQL capabilities - and not knowledge of business (that of why we have analysts and managers of project and team leaders). Remember that the code ' + financial + "is no different code" + detail + "-the same language is used. The same concepts. The same methods to solve problems. As the problems you are dealing with a level of PL/SQL are technical - where business issues have already been processed by analysts and architects at a higher level.
I expect, however, that such a developer will resume business over time knowledge. But I don't see it as any kind of precondition.
-
Dynamic SQL question. What are these apostrophes for?
Here is a solution provided by Boneist in the two questions relating to a so-called simple dynamic SQL thread
When a tablename is extracted, it should be in single quotes as "DEPT". My question is about the quotes surrounding i.table_name (three quotes on the left) and 4 quotes on the right of the concatenationdeclare v_rs date; begin for i in (select table_name from user_tables) loop execute immediate 'select last_analyzed from user_tables where table_name = ''' || i.table_name||'''' into v_rs; dbms_output.put_line(i.table_name ||'----'||v_rs); end loop; end;
First quote on the left is the final quote from SELECT (' select last_analyzed)''' || i.table_name||''''
Second quote from left to right - I think this is the quote from beginning to the name of the table ("DEPT)
Quote from third starting on the left -?
I have not understant what 4 quotes on the right of the concatenation of c. I know one of them is the quotation from the end (right) for the name of the table (like DEPT')JOE_humble wrote:
When a tablename is extracted, it should be in single quotes as "DEPT". My question is about the quotes surrounding i.table_name (three quotes on the left) and 4 quotes on the right of the concatenationActually 4 quotes on the left quotation marks and 4 right...
execute immediate 'select last_analyzed from user_tables where table_name = ''' || i.table_name||'''' into v_rs; ^ ^^^ ^^^^ | ||| |||| \________________________________________________________/// \||/ | \| 4 quotes 4 quotes
Maybe better if you look at it like this...
Suppose we use a character # to indicate the beginning and the end of our strings...
execute immediate #select last_analyzed from user_tables where table_name = ''# || i.table_name||#''# into v_rs;
Now, you can see that we have two strings concatenated with the variable string representing the table name concatenated together.
Within each of these channels, we have two single quotes. When the parser crosses the two single quotes like this, in the string, which converts a quotation mark in the resulting string, rather than taking this means the end of the string itself.
-
I'm working on a system with a lot of postings to date. The validations that I built work very well as long someone is using the correct format. The code I use is:
DECLARE
DATE OF DATE_CHECK;
DATE OF DOB_CHECK;
BEGIN
BEGIN
DOB_CHECK: = to_date (: P32_DOB, "MM/DD/YYYY");
DATE_CHECK: = to_date (: P32_DI_UR_DT, "MM/DD/YYYY");
IF DOB_CHECK > DATE_CHECK
THEN
RETURN "Urine condition start date cannot occur before the date of birth.";
END IF;
EXCEPTION
WHILE OTHERS THEN
RETURN "appearance of Urine condition is not a valid date.";
END;
END;
As I said. This works fine, as long as someone using four-digit year. If they use only one year two-digit (04/08/09) he continues to throw the error that it takes place before the date of birth.
I used JavaScript in other programs so that I could automatically format any date that you put the format I want. The problem is that I can not use this feature in this case, because it will create an infinite loop.
So, my question is this: How can I isolate the year date in PL/SQL, so that I can add 19 or 20 at the beginning of the year so that it conforms to the format I use?
Thanks in advance.
JoshJosh,
Just use "RRRR" for part of the year of your mask format instead of "YYYY." If you enter '09' for AAAA, it will be interpreted as year 0009. If you enter '09' to RRRR, today it will be interpreted as the year 2009.
Run these statements in SQL commands and see for yourself:
Select to_char (to_date('07/04/09','MM/DD/YYYY'), ' MM/DD/YYYY') "with your Format' double.
Select to_char (to_date('07/04/09','MM/DD/RRRR'), ' MM/DD/YYYY') "with my suggested Format' double.
Joel
-
When I used the updated syntax, return always seems to be the total number of rows in the table updated (not updated lines):
create table a18 (identification number, name varchar2 (10));
create table b18 (identification number, name varchar2 (10));
Insert in b18 values (1, 'A');
Insert in b18 values (2, 'B')
insert into A18 (id) values (1);
insert into A18 (id) values (11);
Select * from a18;
name identity
1
11
Select * from b18.
name identity
2B
2B
update of a18 set a18.name = (select b18.name from b18 where b18.id = a18.id)
2 lines update
Select * from a18
name identity
2B
11
Question: why it returns "2 rows updated" while it is only a line update?
I tested with SQL Server 2005/2008 and the behavior is the same (2 rows affected).
Published by: Modeler on May 19, 2009 16:59
Published by: Modeler on May 19, 2009 17:02Your UPDATE statement has no WHERE clause, then it will update with each row in the table. It is one of the lines is being updated at the same value that it had before the update. But you still incur any overhead due to update the block, writing appropriate UNDO and REDO the vectors, etc. for the line that you update without changing.
Justin
Maybe you are looking for
-
Business PC HP Elite 8100 SFF: Problem upgrade memory with operating system to 64 b.
I have a small form Factor Business PC HP Compaq 8100 Elite, with 2 GB RAM and Intel Core i5-650 3.2GHz (n ° 2 x 1 GB 240pin DDR3 SDRAM Unbuffered DIMM DDR3-1333 - hynix HMT112U6TFR8C-H9 https://www.skhynix.com/products/computing/view.jsp?info.ramKin
-
Satellite L645 - problem with Internet connectivity Wireless 'limited access '.
Hi all I recently bought a Satellite L645 laptop, however, there is a big problem. Whenever I connect to a wireless network, it will connect in a minute, he removes the connections and said "limited access", he could return by being connected but the
-
I want to change the names of specific folders. How can I do this?
Original title: the folder names Under the C:\Cartoons\ I have subfolders. They look: Atlas Charlton EC Iger Turok Vintage I want to list them as below EC Iger Atlas Turok Vintage Charlton Much nicer looking. How can I do? Someone at - it an idea? Th
-
PhotoSmart HP 7520: Set up the cartridge
I've had my printer for about 1 to 2 years. All of a sudden, the printer does not print black - but I just replaced the large XL 564 black cartridge a few days ago. The printer indicates the little Set Up black cartridge is out of ink. Please advi
-
(another) album art probem
Hi I'm new here and I'm sorry if this question was asked millions of times but I'm not looking and cannot always solve my problem the question is, I have connected my Fuze in MTP mode, used Media Monkey and WMP11 for importing files, but sometimes ar