Create view with dynamic from-clause
Dear all,
you might have some ideas to help me out of my issue that i just "created myself" ;-)
i have a unknown and non-constant amount of tables using the the same table-structure and i do have a master table
that contains all names of these kind of tables. I now want to create a single view that contains all columns of each table
and an additional column name containing the name of the corresponding table.
I found a solution for this but only if I knew all table names while creating my view.
Here's what I currently have:
master_table:
ID TABLENAME
1 table_01
2 table_02
table_01:
ID NAME
1 eins
2 zwei
3 drei
table_02:
ID NAME
1 one
2 two
3 three
my view "tab1tab2" on these 2 table looks like this:
ID NAME TABLENAME
1 eins table_01
2 zwei table_01
3 drei table_01
1 one table_02
2 two table_02
3 three table_02
i achieved this view by using:
CREATE OR REPLACE VIEW TAB1TAB2 ("ID", "NAME", "TABLENAME")
AS
SELECT id,name, 'table_01' AS tablename FROM table_01
UNION
SELECT id,name, 'table_02' AS tablename FROM table_02;
Is there a way to create as many select and union statements as i do have entries (tablenames) in my master_table to achive the same results as my hardcoded view ?
Many thanks in advance for your help
Best regards
majo
Is there a way to create as many select and union statements as i do have entries (tablenames) in my master_table to achive the same results as my hardcoded view ?You can achieve this also with some xml facilities as e.g. in
SQL> create table t1 as select empno, ename from emp where rownum <= 3
Table created.
SQL> create table t2 as select deptno empno, dname ename from dept
Table created.
SQL> create table master as (select 1 id, 't1' table_name from dual union all
select 2 id, 't2' table_name from dual)
Table created.
SQL> create or replace view v_t
as
select table_name, x.*
from (select table_name, 'ora:view("' || table_name || '")' tabs from master),
xmltable (tabs columns id int path 'EMPNO', ename varchar2(20) path 'ENAME') x
View created.
SQL> select * from v_t
TABLE_NAME ID ENAME
t1 7369 SMITH
t1 7499 ALLEN
t1 7521 WARD
t2 10 ACCOUNTING
t2 20 RESEARCH
t2 30 SALES
t2 40 OPERATIONS
t2 50 SALES
8 rows selected.
SQL> create table t3 as select object_id empno, object_name ename from user_objects where rownum <= 3
Table created.
SQL> insert into master values (3, 't3')
1 row created.
SQL> select * from v_t
TABLE_NAME ID ENAME
t1 7369 SMITH
t1 7499 ALLEN
t1 7521 WARD
t2 10 ACCOUNTING
t2 20 RESEARCH
t2 30 SALES
t2 40 OPERATIONS
t2 50 SALES
t3 187449 ABC
t3 187448 ADDRESSES_EXT_TAB
t3 187446 ADDRESSES_EXT_TYP
11 rows selected.Note: above will work only in 11g.
Similar Messages
-
Need help with writing a query with dynamic FROM clause
Hi Folks,
I need help with an query that should generate the "FROM" clause dynamically.
My main query is as follows
select DT_SKEY, count(*)
from *???*
where DT_SKEY between 20110601 and 20110719
group by DT_SKEY
having count(*) = 0
order by 1; The "from" clause of the above query should be generated as below
select 'Schema_Name'||'.'||TABLE_NAME
from dba_tables
where OWNER = 'Schema_Name'Simply sticking the later query in the first query does not work.
Any pointers will be appreciated.
Thanks
rogers42Hi,
rogers42 wrote:
Hi Folks,
I need help with an query that should generate the "FROM" clause dynamically.
My main query is as follows
select DT_SKEY, count(*)
from *???*
where DT_SKEY between 20110601 and 20110719
group by DT_SKEY
having count(*) = 0
order by 1; The "from" clause of the above query should be generated as below
select 'Schema_Name'||'.'||TABLE_NAME
from dba_tables
where OWNER = 'Schema_Name'
Remember that anything inside quotes is case-sensitive. Is the owner really "Schema_Name" with a capital S and a capital N, and 8 lower-case letters?
Simply sticking the later query in the first query does not work.Right; the table name must be given when you compile the query. It's not an expression that you can generate in the query itself.
Any pointers will be appreciated.In SQL*Plus, you can do something like the query bleow.
Say you want to count the rows in scott.emp, but you're not certain that the name is emp; it could be emp_2011 or emp_august, or anything else that starts with e. (And the name could change every day, so you can't just look it up now and hard-code it in a query that you want to run in the future.)
Typically, how dynamic SQL works is that some code (such as a preliminary query) gets some of the information you need to write the query first, and you use that information in a SQL statement that is compiled and run after that. For example:
-- Preliminary Query:
COLUMN my_table_name_col NEW_VALUE my_table_name
SELECT table_name AS my_table_name_col
FROM all_tables
WHERE owner = 'SCOTT'
AND table_name LIKE 'E%';
-- Main Query:
SELECT COUNT (*) AS cnt
FROM scott.&my_table_name
;This assumes that the preliminary query will find exactly one row; that is, it assumes that SCOTT has exactly one table whose name starts with E. Could you have 0 tables in the schema, or more than 1? If so, what results would you want? Give a concrete example, preferably suing commonly available tables (like those in the SCOTT schema) so that the poepl who want to help you can re-create the problem and test their ideas.
Edited by: Frank Kulash on Aug 11, 2011 2:30 PM -
Create View Object programattically from XML input
Hi,
I have requirement to create view object from xml at run time in ADF application. is there any way to create view object dynamically in java program from xml?
My requirement is to call a webservice and generate view object from the response of the web service call.
ThanksI want to create view objects from different web services and the same will be available to the developer at the time of development. I don't want to create web service proxies for each of the web service. this will simplify the developers task to create proxy and data controls. the one thing developer has to do is select the service and base on the service the view objects will be created to develop pages accordingly.
-
SQL Dev Child Reports - Dynamic From Clause Possible?
Hi All,
Trying to figure out this problem:
Master Report SQL:
select TABLE_NAME from USER_TAB_COLS where COLUMN_NAME = 'CREATION_DATE'
Results with some table names. Now I want to use the table name to formulate my child query
Child SQL:
select * from :TABLE_NAME where CREATION_DATE >= SYSDATE-7
or whatever.....but I want to somehow use the table_name dynamically.
Thanks!
-BrentI doubt that you can get dynamic from clause for Child Report if its style is table.
But you can get dynamic one in child with style script:
Say you have :
Master report for list tables which select owner and table name by some condition (I omit this):
SQL : select owner, table_name from all_tables ..So Child Report
SQL is follow:
COLUMN TN NEW_VALUE TNAME ;
select :OWNER||'.'||:TABLE_NAME as TN from dual;
select '&&TNAME' as tab_NAME, count(1) from &&TNAME;Hope it help.
Edited by: K_Serge on Jan 5, 2013 5:10 AM
Edited by: K_Serge on Jan 5, 2013 5:20 AM -
Is it possible to create views with parameters ?
Hi,
As MS-Access, is it possible to create views with parameters ?
Ms-Access syntax : parameters [a] text; select * from table where code = [a]
If yes, can you give samples ?
Regards
PascalI suggest you you write a stored procedure that returns a recordset in oracle. Then execute the stored procedure and loop through the record set.
Look in in MS Knowledgebase searching on ADO Stored Proceedures for the VB/C++/VBS .. code.
Look in in Oracle PL/SQL guide for the Stored Proceedure code. -
How I can create view with parameters?
I have very big query (2000 rows) and 2 parameters.
How I can create view with parameters?If I use this small part of my query than I have error :
java.lang.NullPointerException
at oracle.javatools.db.ora.OracleSQLQueryBuilder.buildQuery(OracleSQLQueryBuilder.java:199)
at oracle.javatools.db.ora.OracleSQLQueryBuilder.buildQuery(OracleSQLQueryBuilder.java:147)
What does it means?
select
' Payroll ' as Revenue
, t.umonth, nvl(p.hmy, 0), nvl(t.sMTD, 0), nvl(a.inormalbalance, 0), nvl(T.sbudget, 0), nvl(a.scode, 0)
from
acct a, total t, property p, param par
where
nvl(t.hacct, 0) = nvl(a.hmy, 0)
and nvl(par.hretain, 0) <> nvl(a.hmy, 0)
and nvl(t.iBook, 0) = 0
and nvl(a.iacctType, 0) = 0 /*Regular accts*/
and nvl(t.hppty, 0) = nvl(p.hmy, 0)
and ( nvl(a.scode, 0) between 60000 and 6009000 )
union all ---------------------------------------------------------------------------------------------------------------------------------
select
' Payroll Taxes '
, t.umonth, nvl(p.hmy, 0), nvl(t.sMTD, 0), nvl(a.inormalbalance, 0), nvl(T.sbudget, 0), nvl(a.scode, 0)
from
acct a, total t, property p, param par
where
nvl(t.hacct, 0) = nvl(a.hmy, 0)
and nvl(par.hretain, 0) <> nvl(a.hmy, 0)
and nvl(t.iBook, 0) = 0
and nvl(a.iacctType, 0) = 0 /*Regular accts*/
and nvl(t.hppty, 0) = nvl(p.hmy, 0)
and
(nvl(a.scode, 0) between 60100 and 60690 )
union all -------------------------------------------------------------------------------------------------------------------------------
select
' Workers Comp/Disability '
, t.umonth, nvl(p.hmy, 0), nvl(t.sMTD, 0), nvl(a.inormalbalance, 0), nvl(T.sbudget, 0), nvl(a.scode, 0)
from
acct a, total t, property p, param par
where
nvl(t.hacct, 0) = nvl(a.hmy, 0)
and nvl(par.hretain, 0) <> nvl(a.hmy, 0)
and nvl(t.iBook, 0) = 0
and nvl(a.iacctType, 0) = 0 /*Regular accts*/
and nvl(t.hppty, 0) = nvl(p.hmy, 0)
and
( nvl(a.scode, 0) between 61200 and 61260)
union all -------------------------------------------------------------------------------------------------------------------------------
select
' Pension and Hospitalization '
, t.umonth, nvl(p.hmy, 0), nvl(t.sMTD, 0), nvl(a.inormalbalance, 0), nvl(T.sbudget, 0), nvl(a.scode, 0)
from
acct a, total t, property p, param par
where
nvl(t.hacct, 0) = nvl(a.hmy, 0)
and nvl(par.hretain, 0) <> nvl(a.hmy, 0)
and nvl(t.iBook, 0) = 0
and nvl(a.iacctType, 0) = 0 /*Regular accts*/
and nvl(t.hppty, 0) = nvl(p.hmy, 0)
and
( nvl(a.scode, 0) between 61000 and 61550 )
union all -------------------------------------------------------------------------------------------------------------------------------
select
' Other Labor Costs '
, t.umonth, nvl(p.hmy, 0), nvl(t.sMTD, 0), nvl(a.inormalbalance, 0), nvl(T.sbudget, 0), nvl(a.scode, 0)
from
acct a, total t, property p, param par
where
nvl(t.hacct, 0) = nvl(a.hmy, 0)
and nvl(par.hretain, 0) <> nvl(a.hmy, 0)
and nvl(t.iBook, 0) = 0
and nvl(a.iacctType, 0) = 0 /*Regular accts*/
and nvl(t.hppty, 0) = nvl(p.hmy, 0)
and
( nvl(a.scode, 0) between 616000 and 616400 ) -
Makes it possible to create view with parameters
makes it possibel to create view with paramater, example
create or replace view v_test(segment varchar2)
select * from ref_user where segment = segmentThanksthanks..
select count(distinct substr(a.svm_id,1,10)) jumlah " +
" from daily_distribution_pop a, ref_toko b " +
" where " +
" substr(a.svm_id,1,10)=b.id and b.segment_type = 'A' and enable_flag='Y' " +
" and a.tgl_visit between to_date('" + fromStartDate + "', 'dd/MM/yyyy') and to_date('" + fromEndDate + "', 'dd/MM/yyyy')
and " + whereA + "= '" + whereB + "' " +
" and substr(a.pom_id,1,2) = 'DP' and (a.qty_instore <> 0 or a.qty_delivered <> 0) ";
{code}
where fromStartDate, fromEndDate, whereA, whereB is variable parameter from asp.net.
how to i can implement with view -
REPORT with dynamic WHERE CLAUSE (run RDF or REP) ?
Hi:
When running a REPORT (myreport.rep) with dynamic where clause using a lexical parameter, I got this error:
REP-1439: Cannot compile .REP or .PLX file as it does not have source
If i run the report specifiying RDF extension (myreport.rdf) the report run successfully! Is this normal ?
If I specify RDF extension will Report Server COMPILE the report everytime I execute it ?
When using dynamic WHERE CLAUSE I will have to run RDF files instead of REP ?
I'm running Reports 9i under Linux, with IDS under Windows.
Waiting Help
Joao OliveiraIt sounds like you are building the .rep files on one platform (windows) and running them on another (linux). The reason that the .rdf file continues to work is that Reports recompiles the PL/SQL within the report when you move from one platform to another or change schemas. .rep files can't be re-compiled in this way so you need to ensure they are compiled successfully when converting them.
You need to convert from .rdf to .rep on the platform that you are intending to run on. Try running rwconverter on the linux platform with "compile_all=yes" to produce the .rep file and running that .rep file. -
Create View with Force and No Force
Can Anyone Tell me how to create view with force and no force i have very little idea about this
This is the syntax.
CREATE [OR REPLACE] FORCE VIEW view
[(alias[, alias]...)]
AS subquery
[WITH CHECK OPTION [CONSTRAINT constraint]]
[WITH READ ONLY [CONSTRAINT constraint]];You can see interesting threads about this topic here.
Re: Creating view forcibly
Creating View forcefully
Cheers
Sarma. -
"create columns with a where clause" in BMM
Hi All,
I have a question about OBI EE Meta data layer.
We have OBIEE sitting on a Data Warehouse with a star schema.
Our Fact table holds the following fields...
EmployeeID
CompanyID
Measure ID
Measure Name
MEASURE
This is what we have in the physical layer, BMM layer and the presentation layer but I want to be able to "create columns with a where clause"
So my fact table in the presentation layer would look like this
Amount Sold
Unit Cost
Company Amount
I thought I could just create a logical column with
Amount Sold = Measure
where Measure Name = "Amount Sold"
But I can't seem to find any to do that.
Any ideas?
ThanksOr you simply map your measure in the Logical Table source as something like :
CASE WHEN MEASURE_NAME = 'Amount Sold' THEN MEASURE ELSE 0 END.
You need to decide if you want the where clause adding in the Logical table source (be careful you will need a seperate LTS for each measure, this will mean more than one SQL being fired when you have more than one measure in the report).
Or you go with this case method on each measure, be able to have all the measures mapped in 1 LTS, include all those in the report and they will be retrieved by one SQL block. -
Problem with creating/viewing PDF's from InDesign CS3
I have a problem with our PDF workflow and just cannot seem to resolve it.
The problem is as follows: My coworker and I (both designers running CS3 on iMac's running 10.5.6 Leopard) work daily on producing documents and graphic layouts.
Internally we can view and print PDF documents we create just fine with no troubles with the exception of our supervisor, who is running a mac with Tiger operating system. Our office environment is both Mac and PC. On may occasions he cannot print PDF's we create. Many times his prints will contain garbled characters, drop italics and formatting, replace fonts, or just print slowly.
This problem is also happening to our editor who is offsite. This is a fairly serious problem for her, considering her job relies heavily on being able to view and open PDF files we create. She was able to send a PDF file which shows the garbled mess her printer spit out when she printed. Apparently there were pages upon pages of messy garbled text. When documents do print from her, they are usually very slow in printing, taking up to a minute or more to print each page.
The sample of what she sent me is attached, and can also be found on my MobileMe iDisk at: http://public.me.com/rlcollier (document entitled Print Results.PDF)
My question really to the community is obviously what might be causing these problems. Its very frustrating not being able to determine if its something we're doing ourselves thats causing some incompatability or corruption in these files, or if its the users systems themselves. I can say that Debra our editor has can have a garbled mess of a 4 page file from us, and then turn around and print a graphic heavy 90 page PDF with ease from Boeing. Our PDF's seem to be the only ones she struggles with. That being said, my inclination is that its something on our end.
Any ideas of where to start looking? Any help at all would be greatly appreciated and welcomed. Thanks!I currently had our editor test printing of some of our files using both Foxit and Adobe Reader (as was suggested) in order to see if either made a difference in her printing ability and here is what she came back with:
I tried to print out both these pdfs (David's is the one you reworked and Lisa's HESSM-3, both sent yesterday).
With Adobe: David's first page printed quickly, but it had errors (part of his pants didn't print, and there's an arbitrary shaded box in the text). Page 2 didn't print--every time I tried it had a different "offending command" code. Printing Lisa's HESSM made it up to page 7 before problems showed up (stock photo only partially printed), and it stopped on page 8 (with the random "offending command" code).
With Foxit: Both David's and the HESSM pdfs printed completely and without error...but it took a long time. David's 2 pages took about 3 to 4 minutes, and HESSM's 16 pages took close to 20 minutes. The time is in the transfer of data to the printer; the physical printing goes pretty quickly.
I cant say that I believe email is the problem, although I cant rule it out. I've tested emailing vs. passing through our workgroup with my supervisor, and it does not make any difference in his ability (or lack of ability) to print our files. He was able to print to a different printer (an HP 4650 as opposed to a 4100) without troubles. He refuses to believe its a printer problem however because PDF files originating from our office are the only ones he has trouble with. Never has he had any trouble with a single PDF file produced from any other source. This is also the case for our editor who only has trouble with PDF files originating from either mine, or my coworkers systems.
PS: I've attached both files that were referenced by our editor above for viewing/testing. -
Create a view with datatype from dual
I have Windows XP with 10g 10.2.0.1.0
I need to create a view from dual and with data type, such as NUMBER(5,2), NUMBER or VARCHAR2(20) .
such as:
create view test(view_test varchar2(20)) as (select view_test from dual)
Please help. Thanks in advance.It does seem kind of odd, but you can do something like this with the CAST function:
SQL> create view dual_view as
2 select cast(null as number(5,2)) col1
3 ,cast(null as date) col2
4 ,cast(null as varchar2(30)) col3
5 from dual;
View created.
SQL> desc dual_view
Name Null? Type
COL1 NUMBER(5,2)
COL2 DATE
COL3 VARCHAR2(30)I used NULLs but you can use actual values if you want. -
Create images with dynamic width from 3 images each (left/center/right-part)
Hello,
i want to employ a script to create images of dynamic width for me. The whole process shall base on different sized sets of images, which contain a left-image, a right-image and a center-image. The desired width for the different cases shall be reached by duplicating the center-image between the two outer images and placing those images next to each other until the image extends to desired width.
The layers importet into Photoshop shall be importet as smart-layers (which i already solved).
Has anyone done something similar already and could give me some useful hints on that issue ?
I have come up to this until now:
#target Photoshop
// =========================== Opens a new document and asks for dimensions ============================
var myLayerset = File.openDialog ("Select the set of images you want to use!", "*.png",true)
var myName = prompt("How do you want to call the document?"); // askes for document name
var width = prompt("Please insert width for the output here!", ""); // askes for desired width
var height = prompt("Please insert height for the output here!", ""); //askes for desired height
var docName = myName +".psd"
var idMk = charIDToTypeID( "Mk " );
var desc3 = new ActionDescriptor();
var idNw = charIDToTypeID( "Nw " );
var desc4 = new ActionDescriptor();
var idNm = charIDToTypeID( "Nm " );
desc4.putString( idNm, """Wunschname""" );
var idMd = charIDToTypeID( "Md " );
var idRGBM = charIDToTypeID( "RGBM" );
desc4.putClass( idMd, idRGBM );
var idWdth = charIDToTypeID( "Wdth" );
var idRlt = charIDToTypeID( "#Rlt" );
desc4.putUnitDouble( idWdth, idRlt, width );
var idHght = charIDToTypeID( "Hght" );
var idRlt = charIDToTypeID( "#Rlt" );
desc4.putUnitDouble( idHght, idRlt, height );
var idRslt = charIDToTypeID( "Rslt" );
var idRsl = charIDToTypeID( "#Rsl" );
desc4.putUnitDouble( idRslt, idRsl, 72.000000 );
var idpixelScaleFactor = stringIDToTypeID( "pixelScaleFactor" );
desc4.putDouble( idpixelScaleFactor, 1.000000 );
var idFl = charIDToTypeID( "Fl " );
var idFl = charIDToTypeID( "Fl " );
var idTrns = charIDToTypeID( "Trns" );
desc4.putEnumerated( idFl, idFl, idTrns );
var idDpth = charIDToTypeID( "Dpth" );
desc4.putInteger( idDpth, 8 );
var idprofile = stringIDToTypeID( "profile" );
desc4.putString( idprofile, """sRGB IEC61966-2.1""" );
var idDcmn = charIDToTypeID( "Dcmn" );
desc3.putObject( idNw, idDcmn, desc4 );
executeAction( idMk, desc3, DialogModes.NO );
//==============================================save document================================================
var idsave = charIDToTypeID( "save" );
var desc4 = new ActionDescriptor();
var idAs = charIDToTypeID( "As " );
var desc5 = new ActionDescriptor();
var idmaximizeCompatibility = stringIDToTypeID( "maximizeCompatibility" );
desc5.putBoolean( idmaximizeCompatibility, true );
var idPhtthree = charIDToTypeID( "Pht3" );
desc4.putObject( idAs, idPhtthree, desc5 );
var idIn = charIDToTypeID( "In " );
desc4.putPath( idIn, new File( "C:\\Users\\ target folder goes here" + docName ) );
var idDocI = charIDToTypeID( "DocI" );
desc4.putInteger( idDocI, 308 );
var idsaveStage = stringIDToTypeID( "saveStage" );
var idsaveStageType = stringIDToTypeID( "saveStageType" );
var idsaveSucceeded = stringIDToTypeID( "saveSucceeded" );
desc4.putEnumerated( idsaveStage, idsaveStageType, idsaveSucceeded );
executeAction( idsave, desc4, DialogModes.NO );
//========================================================================================================
for (var i = 0; i < myLayerset.length; i++) {
if (myLayerset[i] instanceof File && myLayerset[i].hidden == false) {
// ======================================================= opens selected images as smart objects====================
var idOpn = charIDToTypeID( "Opn " );
var desc1 = new ActionDescriptor();
var idnull = charIDToTypeID( "null" );
desc1.putPath( idnull, myLayerset[i]);
var idsmartObject = stringIDToTypeID( "smartObject" );
desc1.putBoolean( idsmartObject, true );
executeAction( idOpn, desc1, DialogModes.NO );
//===================================duplicates opened layer into created document========================================
var idDplc = charIDToTypeID( "Dplc" );
var desc144 = new ActionDescriptor();
var idnull = charIDToTypeID( "null" );
var ref135 = new ActionReference();
var idLyr = charIDToTypeID( "Lyr " );
var idOrdn = charIDToTypeID( "Ordn" );
var idTrgt = charIDToTypeID( "Trgt" );
ref135.putEnumerated( idLyr, idOrdn, idTrgt );
desc144.putReference( idnull, ref135 );
var idT = charIDToTypeID( "T " );
var ref136 = new ActionReference();
var idDcmn = charIDToTypeID( "Dcmn" );
ref136.putName( idDcmn, docName);
desc144.putReference( idT, ref136 );
var idVrsn = charIDToTypeID( "Vrsn" );
desc144.putInteger( idVrsn, 5 );
executeAction( idDplc, desc144, DialogModes.NO );
// ======================================================= close tab without saving ==========
var idCls = charIDToTypeID( "Cls " );
var desc156 = new ActionDescriptor();
var idSvng = charIDToTypeID( "Svng" );
var idYsN = charIDToTypeID( "YsN " );
var idN = charIDToTypeID( "N " );
desc156.putEnumerated( idSvng, idYsN, idN );
executeAction( idCls, desc156, DialogModes.NO );I adapted a Script somewhat, so you may give this a test.
But it uses the open file so you would have to adapt it further.
// arranges the selected jpg, tif, psd in line;
// gutters may be irregular due to rounding effects;
// thanks to michael l hale and muppet mark;
// for mac and CS6;
// 2014, use it at your own risk;
#target photoshop
if (app.documents.length == 0) {
var myDocument = app.documents.add(UnitValue (300, "mm"), UnitValue (50, "mm"), 300, "new", NewDocumentMode.RGB, DocumentFill.TRANSPARENT)
else {myDocument = app.activeDocument};
// set to pixels;
var originalRulerUnits = app.preferences.rulerUnits;
app.preferences.rulerUnits = Units.PIXELS;
var theArray = [0, 0, myDocument.width, myDocument.height];
// select files;
if ($.os.search(/windows/i) != -1) {var theFiles = File.openDialog ("please select files", '*.jpg;*.tif;*.pdf;*.psd', true)}
else {var theFiles = File.openDialog ("please select exactly three files", getFiles, true)};
// do the arrangement
if (theFiles) {placeInLines (myDocument, theFiles, theArray)}
app.preferences.rulerUnits = originalRulerUnits;
////// function to place images in lines //////
function placeInLines (myDocument, theFiles, theArray) {
theFiles.sort();
// fit on screen;
var idslct = charIDToTypeID( "slct" );
var desc64 = new ActionDescriptor();
var idnull = charIDToTypeID( "null" );
var ref44 = new ActionReference();
var idMn = charIDToTypeID( "Mn " );
var idMnIt = charIDToTypeID( "MnIt" );
var idFtOn = charIDToTypeID( "FtOn" );
ref44.putEnumerated( idMn, idMnIt, idFtOn );
desc64.putReference( idnull, ref44 );
executeAction( idslct, desc64, DialogModes.NO );
// change pref;
var originalRulerUnits = app.preferences.rulerUnits;
app.preferences.rulerUnits = Units.PIXELS;
setToAccelerated();
app.togglePalettes();
var check = turnOffRescale ();
// create the arrangement;
if (theFiles.length > 0 && theFiles.length == 3) {
myDocument.activeLayer = myDocument.layers[0];
// create masked group;
var theGroup = myDocument.layerSets.add();
theGroup.name = "arrangement";
// determine the array’s values;
var areaWidth = theArray[2] - theArray[0];
var areaHeight = theArray[3] - theArray[1];
var theDocResolution = myDocument.resolution;
var areaRelation = areaHeight / areaWidth;
// center of placed non-pdf images;
var centerX = Number(myDocument.width / 2);
var centerY = Number(myDocument.height / 2);
// suppress dialogs;
var theDialogSettings = app.displayDialogs;
app.displayDialogs = DialogModes.NO;
var pdfSinglePages = new Array;
var nonPDFs = new Array;
var theDimPDFs = new Array;
var theLength = 0;
// collect the files’ measurements;
var theDimensions = new Array;
var theLengths = new Array;
// array to collect both files and placed pdf-pages;
var theseFiles = new Array;
var theLength = 0;
// collect the files’ measurements;
for (var o = 0; o < theFiles.length; o++) {
var thisFile = theFiles[o];
theseFiles.push(thisFile);
var theDim = getDimensions(thisFile);
theDimensions.push(theDim);
theRelativeWidth = 100 / theDim[1] * theDim[0];
theLength = theLength + theRelativeWidth;
// reset dialogmodes;
app.displayDialogs = DialogModes.ERROR;
// if three files;
if (theseFiles.length == 3) {
// create the layers;
var theNumber = 0;
var theAdded = 0;
var y = areaHeight / 2;
// add placed image’s width;
var thisLineWidth = 0 + theAdded;
var theLastFactor = Number (Number(myDocument.height) / theDimensions[2][1] * theDimensions[2][2] / theDocResolution * 100);
var theLastWidth = Math.round(theDimensions[2][0] * theLastFactor / 100 * theDocResolution / theDimensions[2][2]);
// place the files;
for (var x = 0; x < 3; x++) {
var theNumber = x;
var thisFile = theseFiles[theNumber];
var theFactor = Number (Number(myDocument.height) / theDimensions[theNumber][1] * theDimensions[theNumber][2] / theDocResolution * 100);
var theNewWidth = Math.round(theDimensions[theNumber][0] * theFactor / 100 * theDocResolution / theDimensions[theNumber][2]);
var offsetX = theNewWidth / 2 + thisLineWidth - centerX + theArray[0];
var offsetY = y - centerY + theArray[1];
var theLayer = placeScaleFile (thisFile, offsetX, offsetY, theFactor, theFactor);
myDocument.activeLayer.move(theGroup, ElementPlacement.PLACEATBEGINNING);
thisLineWidth = thisLineWidth + theNewWidth;
// duplicate the middle one;
if (theNumber == 1) {
while (thisLineWidth < myDocument.width - theLastWidth) {
theLayer = duplicateAndOffset (theLayer, theNewWidth, 0);
thisLineWidth = thisLineWidth + theNewWidth;
// reset;
app.togglePalettes();
turnOnRescale (check);
app.preferences.rulerUnits = originalRulerUnits;
////// playback to accelerated //////
function setToAccelerated () {
var idsetd = charIDToTypeID( "setd" );
var desc1 = new ActionDescriptor();
var idnull = charIDToTypeID( "null" );
var ref1 = new ActionReference();
var idPrpr = charIDToTypeID( "Prpr" );
var idPbkO = charIDToTypeID( "PbkO" );
ref1.putProperty( idPrpr, idPbkO );
var idcapp = charIDToTypeID( "capp" );
var idOrdn = charIDToTypeID( "Ordn" );
var idTrgt = charIDToTypeID( "Trgt" );
ref1.putEnumerated( idcapp, idOrdn, idTrgt );
desc1.putReference( idnull, ref1 );
var idT = charIDToTypeID( "T " );
var desc2 = new ActionDescriptor();
var idperformance = stringIDToTypeID( "performance" );
var idperformance = stringIDToTypeID( "performance" );
var idaccelerated = stringIDToTypeID( "accelerated" );
desc2.putEnumerated( idperformance, idperformance, idaccelerated );
var idPbkO = charIDToTypeID( "PbkO" );
desc1.putObject( idT, idPbkO, desc2 );
executeAction( idsetd, desc1, DialogModes.NO );
////// get psds, tifs and jpgs from files //////
function getFiles (theFile) {
if (theFile.name.match(/\.(jpg|tif|psd|pdf|)$/i)) {
return true
////// place //////
function placeScaleFile (file, xOffset, yOffset, theScale) {
// =======================================================
var idPlc = charIDToTypeID( "Plc " );
var desc5 = new ActionDescriptor();
var idnull = charIDToTypeID( "null" );
desc5.putPath( idnull, new File( file ) );
var idFTcs = charIDToTypeID( "FTcs" );
var idQCSt = charIDToTypeID( "QCSt" );
var idQcsa = charIDToTypeID( "Qcsa" );
desc5.putEnumerated( idFTcs, idQCSt, idQcsa );
var idOfst = charIDToTypeID( "Ofst" );
var desc6 = new ActionDescriptor();
var idHrzn = charIDToTypeID( "Hrzn" );
var idPxl = charIDToTypeID( "#Pxl" );
desc6.putUnitDouble( idHrzn, idPxl, xOffset );
var idVrtc = charIDToTypeID( "Vrtc" );
var idPxl = charIDToTypeID( "#Pxl" );
desc6.putUnitDouble( idVrtc, idPxl, yOffset );
var idOfst = charIDToTypeID( "Ofst" );
desc5.putObject( idOfst, idOfst, desc6 );
var idWdth = charIDToTypeID( "Wdth" );
var idPrc = charIDToTypeID( "#Prc" );
desc5.putUnitDouble( idWdth, idPrc, theScale );
var idHght = charIDToTypeID( "Hght" );
var idPrc = charIDToTypeID( "#Prc" );
desc5.putUnitDouble( idHght, idPrc, theScale );
var idLnkd = charIDToTypeID( "Lnkd" );
desc5.putBoolean( idLnkd, true );
executeAction( idPlc, desc5, DialogModes.NO );
return myDocument.activeLayer;
////// open pdf //////
function openPDF (theImage, x) {
// define pdfopenoptions;
var pdfOpenOpts = new PDFOpenOptions;
pdfOpenOpts.antiAlias = true;
pdfOpenOpts.bitsPerChannel = BitsPerChannelType.EIGHT;
pdfOpenOpts.cropPage = CropToType.TRIMBOX;
pdfOpenOpts.mode = OpenDocumentMode.CMYK;
pdfOpenOpts.resolution = 10;
pdfOpenOpts.suppressWarnings = true;
pdfOpenOpts.usePageNumber = true;
// suppress dialogs;
var theDialogSettings = app.displayDialogs;
app.displayDialogs = DialogModes.NO;
pdfOpenOpts.page = x;
var thePdf = app.open(theImage, pdfOpenOpts);
thePdf.close(SaveOptions.DONOTSAVECHANGES);
// reset dialogmodes;
app.displayDialogs = theDialogSettings;
////// turn off preference to scale placed image //////
function turnOffRescale () {
// determine if the resize prefernce is on;
var ref = new ActionReference();
ref.putEnumerated( charIDToTypeID("capp"), charIDToTypeID("Ordn"), charIDToTypeID("Trgt") );
var appDesc = executeActionGet(ref);
var prefDesc = appDesc.getObjectValue(charIDToTypeID( "GnrP" ));
var theResizePref = prefDesc.getBoolean(stringIDToTypeID( "resizePastePlace" ));
// turn off resize image during place;
if (theResizePref == true);{
// =======================================================
var idsetd = charIDToTypeID( "setd" );
var desc12 = new ActionDescriptor();
var idnull = charIDToTypeID( "null" );
var ref4 = new ActionReference();
var idPrpr = charIDToTypeID( "Prpr" );
var idGnrP = charIDToTypeID( "GnrP" );
ref4.putProperty( idPrpr, idGnrP );
var idcapp = charIDToTypeID( "capp" );
var idOrdn = charIDToTypeID( "Ordn" );
var idTrgt = charIDToTypeID( "Trgt" );
ref4.putEnumerated( idcapp, idOrdn, idTrgt );
desc12.putReference( idnull, ref4 );
var idT = charIDToTypeID( "T " );
var desc13 = new ActionDescriptor();
var idresizePastePlace = stringIDToTypeID( "resizePastePlace" );
desc13.putBoolean( idresizePastePlace, false );
var idGnrP = charIDToTypeID( "GnrP" );
desc12.putObject( idT, idGnrP, desc13 );
executeAction( idsetd, desc12, DialogModes.NO );
return theResizePref
////// turn on preference to scale plced image //////
function turnOnRescale (check) {
if (check == true) {
// =======================================================
var idsetd = charIDToTypeID( "setd" );
var desc14 = new ActionDescriptor();
var idnull = charIDToTypeID( "null" );
var ref5 = new ActionReference();
var idPrpr = charIDToTypeID( "Prpr" );
var idGnrP = charIDToTypeID( "GnrP" );
ref5.putProperty( idPrpr, idGnrP );
var idcapp = charIDToTypeID( "capp" );
var idOrdn = charIDToTypeID( "Ordn" );
var idTrgt = charIDToTypeID( "Trgt" );
ref5.putEnumerated( idcapp, idOrdn, idTrgt );
desc14.putReference( idnull, ref5 );
var idT = charIDToTypeID( "T " );
var desc15 = new ActionDescriptor();
var idresizePastePlace = stringIDToTypeID( "resizePastePlace" );
desc15.putBoolean( idresizePastePlace, true );
var idGnrP = charIDToTypeID( "GnrP" );
desc14.putObject( idT, idGnrP, desc15 );
executeAction( idsetd, desc14, DialogModes.NO );
////// convert to so if not one aready //////
function duplicateAndOffset (theLayer, theXOffset, theYOffset) {
app.activeDocument.activeLayer = theLayer;
// =======================================================
var idcopy = charIDToTypeID( "copy" );
var desc9 = new ActionDescriptor();
var idnull = charIDToTypeID( "null" );
var ref5 = new ActionReference();
var idLyr = charIDToTypeID( "Lyr " );
var idOrdn = charIDToTypeID( "Ordn" );
var idTrgt = charIDToTypeID( "Trgt" );
ref5.putEnumerated( idLyr, idOrdn, idTrgt );
desc9.putReference( idnull, ref5 );
var idT = charIDToTypeID( "T " );
var desc10 = new ActionDescriptor();
var idHrzn = charIDToTypeID( "Hrzn" );
var idRlt = charIDToTypeID( "#Pxl" );
desc10.putUnitDouble( idHrzn, idRlt, theXOffset );
var idVrtc = charIDToTypeID( "Vrtc" );
var idRlt = charIDToTypeID( "#Pxl" );
desc10.putUnitDouble( idVrtc, idRlt, theYOffset );
var idOfst = charIDToTypeID( "Ofst" );
desc9.putObject( idT, idOfst, desc10 );
executeAction( idcopy, desc9, DialogModes.NO );
return app.activeDocument.activeLayer
////// load pdf as smart object //////
function transformLayer (layer, percentage, xOffset, yOffset) {
app.activeDocument.activeLayer = layer;
// =======================================================
var idTrnf = charIDToTypeID( "Trnf" );
var desc4 = new ActionDescriptor();
var idFTcs = charIDToTypeID( "FTcs" );
var idQCSt = charIDToTypeID( "QCSt" );
var idQcsa = charIDToTypeID( "Qcsa" );
desc4.putEnumerated( idFTcs, idQCSt, idQcsa );
var idOfst = charIDToTypeID( "Ofst" );
var desc5 = new ActionDescriptor();
var idHrzn = charIDToTypeID( "Hrzn" );
var idPxl = charIDToTypeID( "#Pxl" );
desc5.putUnitDouble( idHrzn, idPxl, xOffset );
var idVrtc = charIDToTypeID( "Vrtc" );
var idPxl = charIDToTypeID( "#Pxl" );
desc5.putUnitDouble( idVrtc, idPxl, yOffset );
var idOfst = charIDToTypeID( "Ofst" );
desc4.putObject( idOfst, idOfst, desc5 );
var idWdth = charIDToTypeID( "Wdth" );
var idPrc = charIDToTypeID( "#Prc" );
desc4.putUnitDouble( idWdth, idPrc, percentage );
var idHght = charIDToTypeID( "Hght" );
var idPrc = charIDToTypeID( "#Prc" );
desc4.putUnitDouble( idHght, idPrc, percentage );
var idLnkd = charIDToTypeID( "Lnkd" );
desc4.putBoolean( idLnkd, true );
var idAntA = charIDToTypeID( "AntA" );
desc4.putBoolean( idAntA, true );
executeAction( idTrnf, desc4, DialogModes.NO );
return app.activeDocument.activeLayer
////// function to get file’s dimensions, thanks to michael l hale //////
function getDimensions( file ){
function divideString (theString) {
theString = String(theString);
var a = Number(theString.slice(0, theString.indexOf("\/")));
var b = Number(theString.slice(theString.indexOf("\/") + 1));
return (a / b)
// from a script by michael l hale;
function loadXMPLibrary(){
if ( !ExternalObject.AdobeXMPScript ){
try{
ExternalObject.AdobeXMPScript = new ExternalObject
('lib:AdobeXMPScript');
}catch (e){
alert( ErrStrs.XMPLIB );
return false;
return true;
function unloadXMPLibrary(){
if( ExternalObject.AdobeXMPScript ) {
try{
ExternalObject.AdobeXMPScript.unload();
ExternalObject.AdobeXMPScript = undefined;
}catch (e){
alert( ErrStrs.XMPLIB );
////// based on a script by muppet mark //////
function dimensionsShellScript (file) {
try {
// getMetaDataMDLS;
if (File(file) instanceof File && File(file).exists) {
var shellString = "/usr/bin/mdls ";
shellString += File(file).fsName;
// shellString += File(file).fullName;
shellString += ' > ~/Documents/StdOut2.txt';
app.system(shellString);
// read the file;
if (File('~/Documents/StdOut2.txt').exists == true) {
var file = File('~/Documents/StdOut2.txt');
file.open("r");
file.encoding= 'BINARY';
var theText = new String;
for (var m = 0; m < file.length; m ++) {
theText = theText.concat(file.readch());
file.close();
theText = theText.split("\n");
// get the dimensions;
var dim = new Array;
for (var m = 0; m < theText.length; m++) {
var theLine = theText[m];
if (theLine.indexOf("kMDItemPixelWidth") != -1) {dim.push(theLine.match(/[\d\.]+/g).join("") )}
if (theLine.indexOf("kMDItemPixelHeight") != -1) {dim.push(theLine.match(/[\d\.]+/g).join("") )}
if (theLine.indexOf("kMDItemResolutionWidthDPI") != -1) {dim.push(theLine.match(/[\d\.]+/g).join("") )}
if (theLine.indexOf("kMDItemResolutionHeightDPI") != -1) {dim.push(theLine.match(/[\d\.]+/g).join("") )}
// remove file and hand back;
File('~/Documents/StdOut2.txt').remove();
catch (e) {
if (File('~/Documents/StdOut2.txt').exists == true) {File('~/Documents/StdOut2.txt').remove()};
return dim
try{
loadXMPLibrary();
var xmpf = new XMPFile( file.fsName, XMPConst.UNKNOWN, XMPConst.OPEN_FOR_READ );
var xmp = xmpf.getXMP();
xmpf.closeFile();
var resolutionUnit = xmp.getProperty( XMPConst.NS_TIFF, 'ResolutionUnit', XMPConst.STRING);
var resFactor = 1;
if (resolutionUnit == 2) {
var resFactor = 1;
if (resolutionUnit == 3) {
var resFactor = 2.54;
var dim = [xmp.getProperty( XMPConst.NS_EXIF, 'PixelXDimension', XMPConst.STRING),
xmp.getProperty( XMPConst.NS_EXIF, 'PixelYDimension', XMPConst.STRING),
divideString (xmp.getProperty( XMPConst.NS_TIFF, 'XResolution', XMPConst.STRING)) * resFactor,
divideString (xmp.getProperty( XMPConst.NS_TIFF, 'YResolution', XMPConst.STRING)) * resFactor];
unloadXMPLibrary();
if(dim[0]=="undefined" || dim[1]=="undefined"){
var dim = undefined;
var res = undefined;
var bt = new BridgeTalk;
bt.target = "bridge";
var myScript = ("var ftn = " + psRemote.toSource() + "; ftn("+file.toSource()+");");
bt.body = myScript;
bt.onResult = function( inBT ) {myReturnValue(inBT.body); }
bt.send(10);
function myReturnValue(str){
res = str;
dim = str.split(',');
function psRemote(file){
var t= new Thumbnail(file);
return t.core.quickMetadata.width+','+t.core.quickMetadata.height;
}catch(e){unloadXMPLibrary()};
if (String(dim[2]).indexOf("\/") != -1) {
var a = divideString(dim[2]);
var b = divideString(dim[3]);
dim = [dim[0], dim[1], a, b]
// if dimensions are missing as might be the case with some bitmap tiffs for example try a shell-script;
if (dim[0] == undefined || dim[1] == undefined) {
var array = dimensionsShellScript(file);
dim = array;
// if shell-string failed open doc to get measurements;
if (dim[0] == undefined || dim[1] == undefined) {
var thisDoc = app.open (File(file));
// close ai without saving;
if (file.name.slice(-3).match(/\.(ai)$/i)) {
thisDoc.trim(TrimType.TRANSPARENT);
var dim = [thisDoc.width, thisDoc.height, thisDoc.resolution, thisDoc.resolution];
thisDoc.close(SaveOptions.DONOTSAVECHANGES)
else {
var dim = [thisDoc.width, thisDoc.height, thisDoc.resolution, thisDoc.resolution];
thisDoc.close(SaveOptions.PROMPTTOSAVECHANGES)
return dim; -
How to select value from database view with * in wher clause
Hi ,
I ahve a database view with some fields.
Now my requirement is to serach a single row on the basis of process type.
Process type can have values like ZBA,ZBC,ZBD,ZBE or similarly anything starting with ZB.
Now i know that starting two letters will be ZB , but dont knwo the last letter.
So how should i use select query for the same?
Should i use like operator for the same?
regards
PGhi,
u can use character '%'.sample code like this
SELECT reltype
instid_a
catid_a
instid_b
FROM /dbm/ord_docflow
INTO TABLE it_link
FOR ALL ENTRIES IN it_pnwtyh
WHERE instid_a = it_pnwtyh-instid_a AND
instid_b LIKE 'QMSM%' AND
typeid_a = 'BUS2400' AND
typeid_b = 'BUS2400' AND
catid_a = 'BO' AND
catid_b = 'BO' AND
reltype = 'VONA'.
this is similar to using* while we fetch values from table.in the above code only i no QMSM rest values not sure,so used QMSM% -
Using inline view with NOT IN clause
I have a query with a NOT IN clause in the where clause that I would like to convert to an inline view. The select looks something like this:
select uid, SYSDATE from tab1, tab2
where tab1.uid = tab2.uid
and ...
and tab1.uid not in (select uid from tab3 where....)
I've used inline queries elsewhere to great effect, but this one has me stumped. If anyone can help, it would be greatly appreciated.There can be problem with using not in or not exists depending on the amount of data in the tables and the relationship between them.
I didn't got if you had problem with the existing SQL-statement, created view or both.
Check statistics and look at explain plan for the sql-statement and the view.
The problem can actually be some where clause that you have in the sql-statement but not in the view, but apply later when using the view.
//Anders
Maybe you are looking for
-
How do I create calculations in Adobe Pro 9?
I have a table with "quan" and "unit price" and a "total cost" column. I created a text field in the "total cost" field and then went to the calculate tab, selected "value is the" and chose "product" and then selected the 2 items that I wanted to to
-
I have a 500gb Lacie external drive. Im trying to organize some files, moving all project files onto one drive (a 2gb internal drive) so Im trying to copy the files from the Lacie to the 2GB internal, but Lacie keeps kicking out and saying "device re
-
Compat-oracle-rhel4-1.0-3 : oracle 9i on RHAS v.4
I am a developer and I am installing 9.2.0.4 on RHAS v.4 I was reading about a library I needed call compat-oracle-rhel4-1.0-3. Do I need this and where do I get it ?
-
Suppressing 'Further Selections' in PNP LDB
Hi All, Can you please tell me how I can disable the 'Further Selections' button in the PNP logical database? I am unable to find anything suitable in the report category which can disable this feature. Thanks and Regards, Vidya.
-
Message "Do you want to save changes" to save when user clicks on other tab
Hi, I have a series of tabs embeded from the main template CustomerTemplate.jspx with <af:commandNavigationItem. I have tabs on BasicData, Accounts etc. I have backing bean (including update button for saving the changes in the same) writtend for Bas