SQL Commands window
Can HTML_DB do multiple commands ?
Im trying to update a column in a table using update but I want to chain multiple updates togeather to save time.
all the updates work but I cant figure how to chain them together.
I have tried adding a comma after each statement also adding a semi colon but to no avail.
Any ideas?
There's another way to do this, which I have found very useful in the past. Basically, do a select on the data that needs to be updated, and create a sql statement that creates the script to do the update. This works because you can quote strings in the select clause and have them appear in the result, as:
Select 'update <table name> set <field name> = <new value>
where <field name> = '||<value retrieved by query>
from <table name>
where <field name> = <search string>
For each selected value, a query in this form will return a runnable update statement, as:
select 'update emp set dept = ''manager''
where dept = '||dept||';'
from emp
where dept = 'clerk';
returns
update emp set dept = 'manager'
where dept = 'clerk';
If you get the quoted syntax right, and are careful with the quotes so that you get proper quoting in the output ( note the '' and concat requirements) you can generate a runnable script. I've done this for deduping, for example, using a select that returned rowid, and deleting the duplicate record that had the lowest rowid (select min(rowid) where <selection criteria> and count(*) > 1, or something more or less like that. You have to test the select in order to make sure that the script returns the records you need to modify. Oh, and keep autocommit set off....
Similar Messages
-
Short cut to run SQL under SQL Commands window
Hi people
what is the keyboard key to run the sql statements under SQL Commands windows in APEX. like in PL/SQL Developer its F8.
ThanksThanks dccase
It works
Appreciate ur help -
Does CTAS evaluate "order by" in APEX SQL Command window?
I need to recreate my table in order to change the column order. When I use the SQL Commands window and run the SQL, it runs successfully, creates the new table, but doesn't reorder the columns.
Is this expected behavior?user648567 wrote:
Please update your forum profile with a real handle instead of "user648567".
I need to recreate my table in order to change the column order. When I use the SQL Commands window and run the SQL, it runs successfully, creates the new table, but doesn't reorder the columns.
What do you mean by "order by"?
Using an "ORDER BY" clause in a CTAS (in APEX or anywhare else) will have no effect on column order, which is determined by the order in which columns appear in the projection. It will affect the order in which rows are returned by that query, and it will not determine the order in which rows will be returned by querying the new table in the future.
To change the column order the columns in the SELECT clause of the CTAS would have to be in a different order from those in the original table, -
Access to Previously-saved SQL in SQL Commands Window
Hi all,
If I've saved some SQL in the SQL Commands window, shouldn't that be available to other developers when they click on the Saved SQL tab? I saved a sample query and one of my other developers doesn't see it. I don't see any setting available in the developer account that controls whether or not the account can see others' saved SQL.
If this isn't allowed, then I don't really see the point of the Owner drop-down in the Saved SQL tab.
Any advice?
Thanks!!
JohnHi Sc0tt,
I think you may be referring to the Schema drop-down that appears in the upper-right area in SQL Commands, Object Browser, etc. That isn't the drop-down I'm referring to. I'm referring to the Owner drop-down that appears in the lower-half of the SQL Commands window then you click the Saved SQL link. I understand that to be the ApEx developer who saved the SQL - nothing to do with database schemas.
I saved some SQL using the Save button assuming I could tell my other developers that if they click Saved SQL they'd see it listed. They don't, and the only choices in the Owner drop-down for any of us are "-- All Users --" or our own user. I don't see any setting I can change for our accounts to allow/prevent seeing others' Saved SQL, so either it's a bug, or if it's intentional that a user can only bring back their own saved SQL then there doesn't appear to be any point in having an Owner drop-down.
Thanks,
John -
SQL*PLUS Verus using new Oracle10 xe SQL commands window
Can I run all manor of queries in SQL COMMAND as in sql*plus .Put another way
does the new orcale 10 xe (SQL command window) have any restrictions at all in terms
of code ?
P.S. Up to now I think this DATABASE program is great.( still testing large files)
Thanks
BobGreat that's exactly the answer I was hoping to get, I am new to Oracle products
but not new to SQL and find the new Oracle interface to be top notch compared to any
"FREE" programs out there right now! I tried the free microsoft SQL server program
and found almost no help or free tutorials like Oracle 10 xe has ( Way to go Oracle !)
Thanks
Bob -
Adding more statements to the sql commands window
Hi, I'm using oracle database express edition10g and I just started using oracle.
And I'm having a problem adding more then one statement inside the sql commands gui window.
I write:
CREATE TABLE "testTable" (
"field1" VARCHAR2(2),
"field2" NUMBER(2,0),
"field3" NUMBER(2,0),
CONSTRAINT "Test_PK" PRIMARY KEY("field1")
Oracle reports: table created
I write
DROP TABLE testTable;
CREATE TABLE "testTable" (
"field1" VARCHAR2(2),
"field2" NUMBER(2,0),
"field3" NUMBER(2,0),
CONSTRAINT "Test_PK" PRIMARY KEY("field1")
Oracle reports: ORA-00911: invalid character
I remove the ; char
ORA-00933: SQL command not properly ended
I look in the help files and it sais that ; / and nothing is allowed to end a operation.
I gues ; is a valid char so it's reporting something else?
I tried pasting my code inside wordpad and even retyping it. Mayby I have a hidden char? =>same error.
When I run drop and create seperatly it works.
When I run both sql statements inside sql+ it works
What m I doing wrong?To run multiple SQL in one shot, you need to save them as SQL batch file,
Save your statements as recreate.sql
DROP TABLE testTable;
CREATE TABLE "testTable" (
"field1" VARCHAR2(2),
"field2" NUMBER(2,0),
"field3" NUMBER(2,0),
CONSTRAINT "Test_PK" PRIMARY KEY("field1")
);Then call it from SQLPlus,
@recreate.sql -
Is sql command window available
I thought i could do away with that scratchpad/Enterprise manager set of tools for development with this VS add in.
I'm trying to find a way to run sql (plus?) queries from with VS (not using Microsoft's OLE db for oracle - that does not provide syntax colouring). You can do this for Microsoft's SQL server in their server explorer.
is it doable from ODT for VS ?A query window will be available in the production release which is less than a week away.
Christian -
Run procedure from SQL Workshop Command window?
hi, this one is simple.
how to run a created procedure from APEX SQL Workshop SQL Command window?
simonSimon,
begin [proc_name]; end;
-Carsten -
using apex 4.1 i'm entering the following query in the sql command window and I keep getting a pop-up for Entering Bind Variable. I'm not using bind variables though, anyone else see this issue before?
SELECT A.FIRST,A.LAST,A.COMPANY AS CNAME,
J.TOT_MAN_HOURS,
J.ACREAGE,
W.NUM_WORKERS,
W.START_DT
FROM EW_ACCOUNTS A, EW_WORK_ORDER W, EW_JOBS J
WHERE A.ID = J.ACCT_ID
AND J.JOB_ID = W.JOB_ID
AND W.START_DT >= SYSDATE
AND W.START_DT < SYSDATE+1
ORDER BY W.START_DTI tried that and it didn't seem to help either.
Funny though, if I write a new query against just one of the tables and write out each column name. it works. If I use the * instead of writing each column name, I have the same issue.
This is in apex.appshosting.com free demo environment. I sent them an email asking about it and they told me it was a code issue and they don't support the demo environment. -
"Between NVL" - Works in SQL Command, not in APEX report region
First, I realize I could use dynamic SQL (model 4), but I don't want to (too hard just yet).
I have a select statement with a series of Where conditions that employ values, in bind variables, supplied by the user.
I want the choice of parameters to be optional, so I am checking for and replacing nulls.
Select emp_name from employee_table where
emp_rating between nvl(:p7_rating_choice, 0) and nvl(:p7_rating_choice, 99)
and
emp_language_no between nvl(:p7_lang_choice, 0) and nvl(:p7_lang_choice, 99);
(the binds should be numeric).
The actual statement is quite a bit longer, but the point is that the BETWEEN NVL(:x, min) AND NVL(:x, max) piece does not seem to work when used in a report region.
It works fine if ALL parameters are provided, but returns an error if one or more are null.
In the SQL command window it works (with a pop-up) just fine.
By the way, the :p7_lang_choice bind variable is chosen from a LOV list which works in all other cases.
Also, if I disable nulls (choosing "no" in ITEM page), everything works fine. It seems that the substitution of the min and max values via the NVL returns the wrong data type.
Any ideas what I have done wrong?Thanks Scott.
Every day brings a little more understanding!
I also noticed a simplified method in the APEX documentation (although there was no explanation of the code) as follows:
Where
(column = :p1_user_input_1 OR :p1_user_input_1 = [null substitution value])
AND
(column = :p1_user_input_2 OR :p1_user_input_2 = [null substitution value])
AND
etc...
Using the value you provide in the LOV section for the null, the second part of the OR handles the null situation.
For some reason I was so tied up with comparing to the column that I never thought to have an OR with a compare to something else.
Oh well.
Thanks,
Norm -
CR2008 - How to run a Stored Procedure using Command Window
Hi everybody,
To generate my reports, I always adopted the foll. strategy:
(a) Create a SQL Stored Procedure (with Input parameters) in Management Studio
(b) Design a report in Crystal Report using the SP as datasource
I want to experiment something different.
Instead of using the SP as datasource, I wish to use the SQL Command window in CR2008.
I have never succeeded to make it work.
So, I am giving a simple example below , listing all my steps, so you can spot where my problem is:
(A) Create a simple Stored Procedure in SSMS called [dbo].[usp_2014]
USE [SIMUL02]
GO
/****** Object: StoredProcedure [dbo].[usp_2014] Script Date: 07/21/2014 12:40:22 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER PROCEDURE [dbo].[usp_2014] @Project nvarchar(15)
AS
SELECT DocEntry, DocDate, U_ShipDept, DocTotalSy FROM ORDR
WHERE U_ShipCode = @Project
(B) Create a Crystal Report called TEST.rpt
I typed the following in the Command Window (see Capture.jpg)
{CALL "SIMUL02"."dbo"."usp_2014";1({?Project1})}
(C) I verify the database. I get this error message:
Failed to retrieve data from the database
Invalid character value for cast specification
I am blocked from here.
Please let me know what has gone and what I must do to continue my tests.
Thanks
Leon LaiHi Abhilash
I copied and pasted your formula:
Exec "SIMUL02"."dbo"."usp_2014" '{?Project}'
Now it works!
So, probably I typed something wrong, and did not notice
Thanks a lot for your patience and great reply
Closing
Leon Lai -
Hi, omniscient all!
I have a code sample where I try to request some URL from an inactive server:
declare
l_text varchar2(32000);
begin
l_text := utl_http.request('http://inactive.url:7777');
exception
when others then
declare
l_errcode number := utl_http.get_detailed_sqlcode;
begin
dbms_output.put_line(l_errcode);
dbms_output.put_line(sqlerrm(l_errcode));
end;
end;
/When I run it in Oracle SQL Developer it shows:
anonymous block completed
-12541
ORA-12541: TNS:no listenerWhen I run it in the APEX 4.0 SQL Commands window it shows:
-29263
ORA-29263: HTTP protocol error
Statement processed.The question is: why?
In real world, I need to make a HTTP POST request (no problem) and catch some exceptions. But instead of the usual ORA-12541 error APEX throws an ORA-29261 one.Any thoughts?
-
SQL command editor doesn't take more than 1 insert command
i am trying to copy whole table from a text file with creat table
command and insert in to (with data) in the same table but SQL command
editor giving me error and only allow me to enter one row of data at a
time, any help would be much appriciated. 10g Express edition. started
Oracle first time last week. You guys see me here a lot un till i get
on the stage where i can start helping others.
INSERT INTO LOCATIONS VALUES (9,'Poole');
INSERT INTO LOCATIONS VALUES (10,'Durham');
INSERT INTO LOCATIONS VALUES (11,'Doncaster');
Column Name Data Type Nullable Default Primary Key
LOCATION_ID NUMBER No - 1
DESCRIPTION VARCHAR2(50) No - -
error message:
ORA-00911: invalid character
but its working with same line of code in a one at a time
Edited by: mrHarris on 20-Oct-2008 04:11Hi,
you have multiple options here:
1) upload as a script:
a) save the statements in a file
b) go to sql workshop > sql scripts
c) upload script and run the script
2) run the script line by line in the sql commands window directly:
a) go to sql workshop > sql commands
b) copy all statements there
c) highlight the first statement with the mouse
d) click "run" or press <ctrl>+enter
3) use sql developer
a) go to http://www.oracle.com/technology/products/database/sql_developer/index.html
b) download and install
c) connect to XE
d) run the statements there
Regards,
~Dietmar. -
Code block works in SQL Command Processor but not in application
Hello forum,
Been struggling with this for a few days without success:
I have a form with a popup LOV called P6_POPUP, a file browse item called P6_BROWSE, a SUBMIT button, and a Process with the following code:
declare
q_image_id number;
begin
select host_family_photos_seq.nextval into q_image_id from dual;
insert into host_family_photos (image_id, file_object_id, image_name)
select q_image_id, id, filename
from htmldb_application_files where filename = :P6_BROWSE;
update host_family set image_id = q_image_id where family_name = :P6_POPUP;
end;
The Process Point is set to On Submit after Computations and Validations and When Button Pressed is set to the Submit button.
When I run the page the file is imported into HTMLDB_APPLICATION_FILES
but the insert and update do not occur.
The URL header after submitting is as follows:
http://127.0.0.1:8080/apex/f?p=115:1:480837828458787::NO:::&success_msg=Photo%20Imported%2FB87C5A54684B0DF005D09D0DFE6E98D6%2F
However if I run the above code in the APEX SQL Command window and supply the required variables it works every time - most confusing.
Not sure what to try from here.
thanks for your time,
BrettScott:
I always thought that the File Browse item maps to the NAME column in the view (below) and that is guaranteed to be unique. The NAME column seems to have a system-generated "F1234" id embedded in it (to guarantee uniqueness, I thought).
In other words, when we put a File Browse item on the page, submitting the page uploads the file into the HTMLDB_APPLICATION_FILES table and the way to access that record (to copy/move it into our own custom table) is by doing
from htmldb_application_files
where name = :P1_BROWSEThanks
SQL> desc htmldb_application_files
Name Null? Type
ID NOT NULL NUMBER
FLOW_ID NOT NULL NUMBER
NAME NOT NULL VARCHAR2(90)
FILENAME VARCHAR2(400)
TITLE VARCHAR2(255)
MIME_TYPE VARCHAR2(48)
DOC_SIZE NUMBER
DAD_CHARSET VARCHAR2(128)
CREATED_BY VARCHAR2(255)
CREATED_ON DATE
UPDATED_BY VARCHAR2(255)
UPDATED_ON DATE
LAST_UPDATED DATE
CONTENT_TYPE VARCHAR2(128)
BLOB_CONTENT BLOB
LANGUAGE VARCHAR2(30)
DESCRIPTION VARCHAR2(4000)
FILE_TYPE VARCHAR2(255)
FILE_CHARSET VARCHAR2(128) -
Mixing SQL Command parameters and UI created parameters
Post Author: shecter
CA Forum: Data Connectivity and SQL
I'm using Crystal Reports XI. I've created a report with an SQL Command - no other tables or views. I want to allow my users to be able to choose data from a dynamic parameter and have the SQL read that and spit out the results. I was able to add a parameter to the SQL using the Parameter column in the Command window. This allows my user to type in a parameter. However, when I run the report after creating a parameter using the UI (i.e. Field Explorer/Parameters/right clicking and selecting "new" and then adding the parameter to a field using the selection wizard), i first get a screen that shows me the parameter that I created in the SQL Command window, then I get a screen that shows me the UI created parameters. How can I make it show only one screen with all the parameters? -MarcPost Author: jenxia
CA Forum: General
SQL Command is :
SELECT UNIQUE ContactID, incomingAddress,applicationid,
MediaStatus, MediaDirection, EndDateTime, StartDateTime
FROM MMCAContactMediaViewwhere EndDateTime>= {?1-reportstarttime} and EndDateTime <= {?2-reportendtime}
Order by ContactID
Select formula using dynamic prompts as
{Command.contactid} = {?ContactID} and{Command.applicationid} = {?ApplicationID} and{Command.incomingaddress} = {?IncomingAddress}
Maybe you are looking for
-
Unable to download iTunes 10.7 on my Macbook, hence, cannot use my iphone 5. How could I upgrade my OSX?( apart from buying a new Macbook, thx)
-
My finger print access to my phone is not working how do I repair it
My finger print access on my iPhone was working now it is not. How do I fix it?
-
ECC 6.0 Source Systems are added to 2 Different Folders - BI and SAP
Hi Experts: Our BASIS team added 2 ECC 6.0 Source Systems to BI 7.0. One of the ECC 6.0 System is added under BI Folder ( where DataMart Source stays) and other ECC 6.0 system is added under SAP folder where all other R/3 Source Syste
-
How to create a link to another transaction on a record in ALV report.
Hi All, I have an ALV report output ,if i click on any record in the report i want it to show me the details of the record which is another transaction code in my case.So basically i want to execute that T-code on clicking on the record of the ALV re
-
Shipping data in stock transfer order
Hi friends, I try to configure stock transfer process between two plants, Here is what I 've done create shipping point and assign it to supplying plant create supplying plant as affiliate vendor create receiving plant as a affiliate customer set up