Trouble with simple Query by Example
Hey all, I am well aware that similar topics are all over the forums. I've exhausted myself fishing around for just the right thread.
I am new to APEX. I have this book "Easy Oracle HTML-DB". It is somewhat helpful, but its examples are hard to follow - possibly because the product keeps moving along.
I have a simple single table listing report. I wanted to add some selection criteria and was attempting to do so in a new region on the same page as outlined in this book. I added a few text fields and tied them into the query without issue. To submit the criteria, I added a "Go" button (just like the book says) and tied a "Reset Pagination" process to it.
The book example doesn't specify button branching conditions. Without any though, clicking "Go" causes an error: "ERR-1777: Page XX provided no page to branch to." . So I added a branch back to the same page. Now it appears to be working, but it resets all my selection field values and runs the same report over again.
I think a workaround is simply to put the criteria in a separate page altogether. I'm just about resigned to taking this approach. It sure looks like people do this all the time though. What did I miss ?
Thanks in advance,
Snake
Rene said: "It's also nice to add : onKeyPress="checkEnter(event)"
to the HTML Form Element Attributes of the items in the search region. This way you can also start the search by pressing Enter in the item."
Hi Rene,
I'd like to include the feature, but the action is no different with or without this attribute. When you press enter, it just stays there in the field.
Nice to note though that most every behavior I've checked is the same whether using Firefox or IE. I like browser independence.
Snake
Similar Messages
-
Trouble with Simple XNET CAN Example...
I am trying to get a simple XNET CAN write frame going. Here is the VI I created...
I keep getting this:
I looks like I have a frame set up, so what else could be the issue?Hey,
I am "trying" to create a session and send data on the fly. I changed my vi back to the simple one I had earlier in the day:
Attachments:
XNET_CAN_Write.vi 12 KB -
Having alot of trouble with a query
Hey, I'm having trouble with a query for an assignment. The questions states
Find the name of the highest earning employee in each location, excluding managers, salespeople and the president
The problem I'm having is that my query returns the highest earning employee from each location perfectly, but one of those returned is a salesperson, so the next highest earning person in that location should be returned.
We are also not allowed to create a temporary table
Here's my code so far
select
e.first_name,
e.last_name,
e.salary,
l.regional_group
from employee e
inner join department d
on d.department_id = e.department_id
inner join location l
on l.location_id = d.location_id
where e.salary = (select max(e2.salary) from employee e2
inner join department d2
on d2.department_id = e2.department_id
inner join location l2
on l2.location_id = d2.location_id
where l2.location_id = l.location_id
and e.job_id !=672;
the job_id refers to what job title they have
and here's the schema below
Schema
Any help you could give me on this would be fantastic as I have been pulling my hair out over this for the last day.
Edited by: 837562 on 17-Feb-2011 02:14Maybe you can try the below:
with job_location as
select 1 location_id, 'loc1' regional_group from dual
union
select 2 location_id, 'loc2' regional_group from dual
department as
select 1 department_id, 'dept1' dept_name, 1 location_id from dual
union
select 2 department_id, 'dept2' dept_name, 2 location_id from dual
job_FUNCTION as
select 1 job_id, 'MANAGER' job_function from dual
UNION
select 2 job_id, 'SALES' job_function from dual
UNION
select 3 job_id, 'PRESIDENT' job_function from dual
UNION
select 4 job_id, 'REST_1' job_function from dual
UNION
select 5 job_id, 'REST_2' job_function from dual
employee as
select 1 employee_id, 'a' last_name, 100 salary, 1 department_id, 4 JOB_ID from dual union
select 2 employee_id, 'b' last_name, 200 salary,1, 5 from dual union
select 3 employee_id, 'c' last_name, 300 salary,1, 2 from dual union
select 4 employee_id, 'd' last_name, 400 salary,1, 2 from dual union
select 5 employee_id, 'e' last_name, 500 salary,2, 3 from dual union
select 6 employee_id, 'f' last_name, 600 salary,2, 3 from dual union
select 7 employee_id, 'g' last_name, 700 salary,2, 4 from dual union
select 8 employee_id, 'h' last_name, 800 salary,2, 4 from dual
select
regional_group, employee_id, max_salary
from
select e.regional_group, b.department_id, employee_id, salary, max(b.salary) over (partition by b.department_id order by b.department_id) max_salary
from
employee b,
job_function c,
department d,
job_location e
where
b.job_id = c.job_id and
b.department_id = d.department_id and
e.location_id = d.location_id and
c.job_id not in (1,2,3)
) where salary = max_salary;
"REGIONAL_GROUP" "EMPLOYEE_ID" "MAX_SALARY"
"loc1" "2" "200"
"loc2" "8" "800" -
Trouble with customer-cmp-ear example for new sun application server 9.0
recently, i have been playing with sun Java system application server 9.0 and try a couple of examples, but i was in trouble. for example, i try customer-cmp-ear example, and i can create db, but i can not Set up JDBC resources, and i always get the following error:
CLI146 /path/to/passwordfile does not exist in the file system or read permission denied.
i take a look at the description of the example, one thing i do not quite understand, at the common instruction, i am required to set javaee.server.passwordfile property, does it mean i have to create a passwordfile? where do I put it ? i hope someone can help me, i will really appreciate it.
Message was edited by:
junjunI solved it.
Change the file"build.properties.sample" to
"build.properties"
Maybe it's a bug in J2ee TutorialThe instructions in the About chapter tell you to copy build.properties.sample to build.propertieshttp://java.sun.com/javaee/5/docs/tutorial/doc/?wp405013&About.html#wp87965
-Ian -
Having trouble with simple tasks in pages 09
I am trying to put a single horizontal line above the page footer in a pages document that I am trying to create as a template
I've spent quite a long time with it and cannot figure it out
As much as a pain Word is, doing something like this is very simple - I thought Pages would be even easier!sean
You look in exactly the same place, it is a paragraph (text) format.
+Inspector > Text > More > Border & Rules > choose a stroke > click on a position > choose color, thickness & offset (how far above the text)+
You can also draw a line, using the Shapes menu on the Toolbar.
Peter -
I have a problem with Oracle 10.2.0.5.0 and 11.2.0.1.0. Query result is wrong.
SELECT t.id
FROM (SELECT t.ID, MAX(t.nom) AS nom
FROM (SELECT 2 AS ID, 200 AS nom
FROM dual
UNION ALL
SELECT 3 AS ID, 0 AS nom FROM dual) t
LEFT JOIN (SELECT 0 AS ID_1, 0 AS nom_1 FROM dual) s
ON s.id_1 = t.ID
WHERE t.ID IN (2, 3)
GROUP BY t.ID
HAVING MAX(t.nom) != 0) t;Return nothing.
But on Oracle 10.2.0.4.0 result is correct:
ID NOM
2 200Looks like a bug related to ANSI joins.
Check Oracle Support, maybe it's fixed in 11.2.0.2.
It works with Oracle join syntax :
Connected to Oracle Database 11g Enterprise Edition Release 11.2.0.1.0
Connected as dev
SQL>
SQL> SELECT t.id
2 FROM (SELECT t.ID, MAX(t.nom) AS nom
3 FROM (SELECT 2 AS ID, 200 AS nom
4 FROM dual
5 UNION ALL
6 SELECT 3 AS ID, 0 AS nom FROM dual) t
7 ,(SELECT 0 AS ID_1, 0 AS nom_1 FROM dual) s
8 WHERE t.ID IN (2, 3)
9 AND s.id_1(+) = t.ID
10 GROUP BY t.ID
11 HAVING MAX(t.nom) != 0) t;
ID
2 -
Having trouble with join query
Hi,
I have two tables in my database, class and document. They look like this:
Class
Class
classdescription
Document
documentid
class
document.class is a foreign key pointing to class.class. I want to find out how many document there are for each class, so I have the SQL statement:
SELECT class.class, count(class.class) as numDocs, classDescription from class, document where class.class = document.class group by class.class, classDescription order by numDocs DESC
However, if there is a class with no document, I also want it listed with the value 0 for numdocs, however this query doesnt seem to return class which have no documents.
Can anyone provide me with help for this?
Thanks!Could this be what you wanted?
SELECT CLASS.CLASS, COUNT (document.documentid) AS numdocs, CLASS.classdescription
FROM CLASS, document
WHERE CLASS.CLASS = document.CLASS(+)
GROUP BY CLASS.CLASS, CLASS.classdescription
ORDER BY numdocs DESC;C. -
Trouble With Web Services Tutorial Examples
I am having trouble getting the Web Services Tutorial examples to run.
For example, when I compiled the hello1 example, and tried to run it, I got a directory listing. All the directory listing contained was the dukewaving.gif file.
When I tried to run hello2, I got something similar. This time though, there were two jsp files in the listing. By clicking on the first one, I was able to run the application.
Now I can't run the bookstore1 example. I went back a second time, to be sure that I was following the instructions exactly as written. I am gettng an HTTP Status 404 - Servlet BookStoreServlet is not available.
I don't know why this is happening. There were no errors when I ran the Ant targets, and the WAR file did get copied to the webapps directory.
I would be very grateful for any help. I am very new to Java and am finding this very frustrating.
Thank You,
ChrissyThis is what's in my log file. Why is the servlet being marked as unavailable?
2004-03-13 21:11:37 Manager: deploy: Deploying web application at '/bookstore1'
2004-03-13 21:11:37 Manager: Uploading WAR file to C:\jwsdp-1.3\webapps\bookstore1.war
2004-03-13 21:11:37 Manager: Extracting XML file to C:\jwsdp-1.3\conf\Catalina\localhost\bookstore1.xml
2004-03-13 21:11:37 Manager: install: Installing context configuration at 'file:/C:/jwsdp-1.3/conf/Catalina/localhost/bookstore1.xml' from 'jar:file:/C:/jwsdp-1.3/webapps/bookstore1.war!/'
2004-03-13 21:13:47 Marking servlet BookStoreServlet as unavailable -
Help with simple Query.
I have 2 tables. Table A and Table B
Table A
Client_ID
Client_Name
Table B
Document_ID
Client_ID
Document_Name
I need a SQL query that can return all Client Names and all of the Document Names that each client is missing.
I have seen lots examples all over the web about returning Client Names from Table A that are missing from Table B, but nothing about returning the Document Names from Table B as well.
RobA29>> Clients and Documents <<
Why do you think that those are good table names? Why did you fail to write DDL? This is minimal Netiquette for 30+ years of SQL forums.
Each entity gets table:
CREATE TABLE Clients
(client_id CHAR(10) NOT NULL PRIMARY KEY,
client_name VARCHAR(35) NOT NULL);
CREATE TABLE Documents
(document_id CHAR(10) NOT NULL PRIMARY KEY,
document_name VARCHAR(35) NOT NULL);
Here is one guess (based on nothing you bothered to tell us) at the relationship:
CREATE TABLE Document_Assignments
(client_id CHAR(10) NOT NULL
REFERENCES Clients (client_id),
document_id CHAR(10) NOT NULL
REFERENCES Documents (document_id),
PRIMARY KEY (document_id, client_id));
This is n:m, but put in some UNIQUE constraints and you can get 1:n or m:1 or 1:1; do you know what those terms mean? Why don't you read any book on RDBMS over the holidays before you try to write SQL again? It will help a lot.
--CELKO-- Books in Celko Series for Morgan-Kaufmann Publishing: Analytics and OLAP in SQL / Data and Databases: Concepts in Practice Data / Measurements and Standards in SQL SQL for Smarties / SQL Programming Style / SQL Puzzles and Answers / Thinking
in Sets / Trees and Hierarchies in SQL -
Hello All,
I have an unusual situation where I am trying to query the
database (MSSQL) using an IN statement and the PK list has
approximately 10,000 records in it. SQL throws an error "The query
processor ran out of stack space during query optimization" which
relates to a limitation in MSSQL Server: (
http://support.microsoft.com/kb/288095)
Microsoft's suggestion is to create a temporary table and
then JOIN the two tables to get the results you are looking for.
However, in my particular situation, I don't know how to create a
temporary table from just list data.
Here is an example of the coldFusion template:
Step 1: Get a list of IDs that this user is allowed to see
Query a bunch of records and sub records and generate a list
variable (#RecordsToGet#)
Note, this query loops several times because of parent/child
relationships in the table. After each loop, the list is appended
to.
Example:
<cfset currentparent = 0>
<CFLOOP condition="ContinueLoop IS 'yes'">
<cfset LoopCount = LoopCount + 1>
<cfquery datasource="#datasource#" name="getMyStuff">
Select ID, Parent
FROM myTable
WHERE Parent = #currentparent#
AND Criteria = '#bla#'
</cfquery>
<!-- assign the new parent to a value list and append the
master list -->
<cfset CurrentParent = ValueList(getMyStuff.ID)>
<cfset RecordsToGet =
ListAppend(RecordsToGet,CurrentParent)>
<cfset loopcount = loopcount + 1>
(continue loop until there are no more records (i.e. you
have reached the bottom of the tree)
</cfloop>
Step 2: Get the record details for the matching records in
the (#RecordsToGet#) list.
<cfquery datasource=#datasource# name="getTheRecords">
SELECT ID, Name, Description, Image, Etc...
FROM MyTable
WHERE ID IN (#RecordsToGet#) <-- the problem lies here
AND Name = '#MoreFilterCriteria1#'
AND IMAGE = '#MoreFilterCriteria2#'
</cfquery>
I have been able to fix the problem (temporarally) by
checking if #RecordsToGet# is has more than 1000 list elements, and
if so, get ALL of the records in the table and then use a QofQ to
filter out the records.
So the 2nd query above would become:
<cfquery datasource=#datasource# name="getTheRecords">
SELECT ID, Name, Description, Image, Etc...
FROM MyTable
WHERE ID <cfif ListLen(RecordsToGet) GT 1000>IN
(#RecordsToGet#) <cfelse>1=1</cfif>
AND Name = '#MoreFilterCriteria1#'
AND IMAGE = '#MoreFilterCriteria2#'
</cfquery>
<cfif ListLen(RecordsToGet) GT 1000>
<cfquery dbtype="query" name="getTheRecords">
SELECT * FROM getTheRecords
WHERE ID IN (#RecordsToGet#)
</cfquery>
</cfif>
Although this has temporarally fixed the problem, the
performance of these queries is VERY slow.
Does anyone have any suggestions or tips?
Thanks so much.I think I'll need to read a bit more about advancd SQL
statements like the one you posted above in order to understand it
better. I'm still not sure how that query gets all of the values
and assigns it to a temporary table. On a side note, Do you know if
MS Access databases can accept WHILE EXISTS statements as well?
If I wanted to use your method on the initial cfquery how
would I write it out?
The table structure looks something like this:
ID, Name, Parent
(where Parent is 0 if it is the top level, or the number
value of the ID if it is a child of that ID)
currently my query looks like:
<CFLOOP condition="ContinueLoop IS 'yes'">
<cfset LoopCount = LoopCount + 1>
<cfquery datasource="#datasource#" name="getMyStuff">
Select ID, Parent
FROM myTable
WHERE Parent = #currentparent#
AND Criteria = '#bla#'
</cfquery>
<!-- assign the new parent to a value list and append the
master list -->
<cfset CurrentParent = ValueList(getMyStuff.ID)>
<cfset RecordsToGet =
ListAppend(RecordsToGet,CurrentParent)>
<cfset loopcount = loopcount + 1>
(continue loop until there are no more records (i.e. you have
reached the bottom of the tree)
</cfloop> -
Trouble with power query as import facebook
Hi I am using Windows 7 64 bit with Office 2013 Pro 64 bit. I am using the Microsoft power query add
in 64 bit .
View comment of feed error follow:
DataSource.Error: An unknown error occurred
Details:
https://graph.facebook.com/136807033073095/feed?limit=1000&until...
Please help!Sorry it took so long for you to get any reply! Are you still having this issue? Could you please provide some more information about the steps you took to get the error?
-
Select deptno,sum(sal) from emp group by deptno order by deptno;
This gives the below output
Deptno Sum(Sal)
10 8750
20 10875
30 9400
But i need the Below Output
10 20 30
8750 10875 9400
Help neededi tried with a example go around a glance and try it with yours
CREATE TABLE CHIPTRUCK_SALES
(LOCATION VARCHAR(20),
DATE DATE,
HOTDOGS_SOLD INT);
INSERT INTO CHIPTRUCK_SALES VALUES
('Claremont', '1/1/2001', 10),
('Brougham', '1/1/2001', 20),
('Greenwood', '1/1/2001', 8),
('Whitevale', '1/1/2001', 5),
('Claremont', '1/2/2001', 11),
('Brougham', '1/2/2001', 22),
('Greenwood', '1/2/2001', 15),
('Whitevale', '1/2/2001', 17),
('Claremont', '1/3/2001', 8),
('Brougham', '1/3/2001', 19),
('Greenwood', '1/3/2001', 12),
('Whitevale', '1/3/2001', 7);
SELECT
LOCATION,
MAX(CASE WHEN date = '1/1/2001' THEN hotdogs_sold END) AS "1/1/2001",
MAX(CASE WHEN date = '1/2/2001' THEN hotdogs_sold END) AS "1/2/2001",
MAX(CASE WHEN date = '1/3/2001' THEN hotdogs_sold END) AS "1/3/2001"
FROM CHIPTRUCK_SALES GROUP BY LOCATION ORDER BY LOCATION;
=>
LOCATION 1/1/2001 1/2/2001 1/3/2001
Brougham 20 22 19
Claremont 10 11 8
Greenwood 8 15 12
Whitevale 5 17 7
4 record(s) selected. -
Having trouble with simple word game, mainly records
OK. I need help with a lot of stuff. This is an applescript I made to be a lot like the game Jotto, except one player. Here it is:
set yescontinue to true
set totallyfinished to false
set tip10jots to false
repeat while totallyfinished is false
repeat while yescontinue is true
set finish to false
set totallyfinished to true
set yescontinue to false
set x to {"abaca", "abaci", "aback"}
set setx2 to {"ninth", "nipas", "nippy"}
set abcde to (random number from 1 to 2)
if abcde is 1 then
set y to (some item of x)
else
set y to (some item of setx2)
end if
set z to count characters of y
set y to characters of y as list
if z is 5 then
set yescontinue to true
end if
set guessamount to 0
set listofrecords to ""
set recordofgame to {}
if yescontinue is true then
repeat while finish is false
set jots to 0
set guess1 to text returned of (display dialog "Please type your guess:" default answer "")
set zguess to count characters of guess1
if zguess is 5 then
set kldsafjhlasdkjfhaslkdjfhalskdjfh to true
else
display dialog "Please only use 5 letter words."
if yescontinue is true then
set yescontinue to false
end if
end if
if yescontinue is true then
set guess1 to characters of guess1 as list
repeat with theletter in y
repeat with theletter2 in guess1
if (theletter as string) is (theletter2 as string) then
set jots to jots + 1
end if
end repeat
end repeat
if guess1 is y then
set jots to "won"
end if
set guessamount to guessamount + 1
if jots is 1 then
set listofrecords to listofrecords & guessamount & ". " & guess1 & " " & jots & " jot" & return
else if jots is "won" then
set jots to "Jotto"
if (guess1 as string) is (y as string) then
set listofrecords to listofrecords & guessamount & ". " & guess1 & " " & jots & return
display dialog "You win! The entire game:" & return & return & listofrecords
set jots to 10
else
set jots to 10
set tip10jots to true
end if
else
set listofrecords to listofrecords & guessamount & ". " & guess1 & " " & jots & " jots" & return
end if
set listofrecords to listofrecords as string
if jots is 1 then
if tip10jots is true then
display dialog "OK. " & guess1 & " was " & jots & " jots. That was guess #" & guessamount & ". Tip: Ten jots means you have all of the letters correct, but they're in the wrong order. Here is the entire game so far:" & return & return & listofrecords
else
display dialog "OK. " & guess1 & " was " & jots & " jot. That was guess #" & guessamount & ". Here is the entire game so far:" & return & return & listofrecords
end if
else
if tip10jots is true then
display dialog "OK. " & guess1 & " was " & jots & " jots. That was guess #" & guessamount & ". Tip: Ten jots means you have all of the letters correct, but they're in the wrong order. Here is the entire game so far:" & return & return & listofrecords
else
display dialog "OK. " & guess1 & " was " & jots & " jots. That was guess #" & guessamount & ". Here is the entire game so far:" & return & return & listofrecords
end if
end if
else
set yescontinue to true
end if
end repeat
end if
end repeat
end repeat
As you can see, for now I only have 6 sample words to save time compiling and running for now on my bad computer.
I need help creating a record instead of listofrecords, and also if anybody could shorten all the extra code I probably have. I also would like to limit being able to guess fake words, for example guessing aaaaa. Thank you so much, and if you have any ideas to help, please let me know.Hello
I had fun on this. You may try the following script.
(Please copy the code from this web page, not from subscribed email text)
It has been tested except for the parts using 'do shell script' and 'TextEdit'.
The 'do shell script' is used in looking up dictionary and 'TextEdit' is used in keeping a log.
(Perl code has been tested with MacPerl 5.6.1under OS9.1.)
You may use any dictionary file that contains words (one word per paragraph delimited by LF) encoded in UTF-8. (For code points in U0000..U007F, UTF-8 is identical to ASCII)
By default, it uses /usr/share/dict/words.
Cheers,
H
PS. The word game 'Jotto' may have been copyrighted in a way such that it's not allowed to reproduce the (part of) game protocol in this sort of computer programme without permission. If such is the case, (cough-cough,) please just disregard this.
--SCRIPT
Guess Word
v0.3
* The dictionary file must be a text file that -
1) is encoded in UTF-8; and
2) consists of paragraphs (delimited by LF (U+000A)) each of which represents one word.
guessword()
on guessword()
script o
--property dict : choose file with prompt "Choose dictionary file (in UTF-8)"
property dict : "/usr/share/dict/words" as POSIX file as alias
property wordLength : 5 -- length of word
property maxGuesses : 20 -- maximum guess count
property wonSign : ""
property givenUpSign : "?"
property exhaustedSign : "#"
property NL : return
property mss1 : "Please enter your guess word of " & wordLength & " letters."
property mss2 : "Current results:"
property mss3a : "You won!" & NL & "Secret word = "
property mss3b : "You gave up." & NL & "Secret word = "
property mss3c : "You have exhausted guess count." & NL & "Secret word = "
property btt1 : {"Give Up", "OK"}
property btt2 : {"Quit", "New Game"}
property errs1 : "Specified word is not found in the dictionary. Please choose other word."
property errs2 : "Specified word has been already used. Please choose other word."
property errs3 : "Word must consist of " & wordLength & " letters. Please choose other word."
property errs4 : "Couldn't get word from dictionary."
property line1a : "# New game started at "
property line1b : "# Word length = " & wordLength
property line1c : "# Maximum round = " & maxGuesses
property line2 : "Round" & tab & "Guess" & tab & "Match"
property line3a : "# You have guessed right. The secret word is "
property line3b : "# You have given up. The secret word is "
property line3c : "# You have exhausted guess count. The secret word is "
property line4 : "# This game ended at "
property rr : {} -- work list for result
property aa : {} -- work list for bsearch()
property tt : {} -- list of used guess words
on bsearch(xx, x)
list xx : source list
anything x : item to be searched in xx
property aa : working list
return integer : index of x in xx if {x} is in xx, or 0 if not.
local i, j, k
set my aa to xx
if {x} is not in my aa then return 0
set i to 1
set j to count my aa
repeat while j > i
set k to i + (j - i) div 2
if {x} is in my aa's items i thru k then
set j to k
else
set i to k + 1
end if
end repeat
return i
end bsearch
on matchWords(x, y)
string x, y : source strings
return integer : number of characters that are in both x and y, where each common character is counted once.
e.g. Given x = "every" and y = "river", result = 3 (i.e. {"e", "v", "r"})
local yy, s, k
set yy to y's characters
set s to 0
repeat with x in x's characters
set k to bsearch(yy, x's contents)
if k > 0 then
set yy's item k to 0 -- set to non-character not to count again
set s to s + 1
end if
end repeat
return s
end matchWords
on lookup(re, dict) -- english-only (word does not contain letters in [U+0080,])
string re : regexp pattern to search
string/alias dict : HFS path (or alias) of dictionary text file (which contains one word per paragraph)
try
return (do shell script "egrep " & quoted form of re & " " & quoted form of POSIX path of dict)
on error
error errs4 number 9016
end try
end lookup
on lookup(re, dict) -- multi-lingual
string re : regexp pattern to search
string/alias dict : HFS path (or alias) of dictionary text file (which contains one word per paragraph)
local s_, r
set s_ to "perl -e 'use strict; use utf8;
open DICT, \"< " & (POSIX path of dict) & "\" or die \"Can't open dictionary file: $!\";
local $/ = \"\\n\";
my @a = grep {/" & re & "/} <DICT>;
close DICT;
chomp @a;
local $, = \"\\n\";
print @a;'"
try
set r to (do shell script s_)
if r = "" then error number 9016 -- probably redundant
return r
on error
error errs4 number 9016
end try
end lookup
on makeGuess()
local b, t
repeat
display dialog mss1 default answer "" buttons btt1 default button 2 --with icon 1
set {b, t} to {button returned, text returned} of result
if b = btt1's item 1 then return givenUpSign
if (count t) = wordLength then
if t is not in my tt then
try
lookup("^" & t & "$", dict)
exit repeat
on error
display dialog errs1 with icon 2 buttons {"OK"} default button 1
end try
else
display dialog errs2 with icon 2 buttons {"OK"} default button 1
end if
else
display dialog errs3 with icon 2 buttons {"OK"} default button 1
end if
end repeat
set end of my tt to t
return t
end makeGuess
on logText(t, {append:append})
--tell application "AppleWorks 6"
tell application "TextEdit"
if not _append then
make new document at front
end if
tell document 1
make new paragraph at end with data t --with properties {font:"Palatino"}
end tell
end tell
end logText
local _done, _exit, w, t, s, r, l, m, sgn
logText("", {_append:false}) -- open new empty log file
set _done to false
repeat until _done
-- (1) set secret word (w = some (wordLength)-letters word)
set w to some paragraph of lookup("^.{" & wordLength & "}$", dict)
logText(NL & line1a & (current date) & NL & line1b & NL & line1c & NL & NL & line2 & NL, {_append:true})
set my rr to {line2}
set my tt to {} -- reset used guess words list
repeat with i from 1 to maxGuesses
-- (2) get guess word
set t to makeGuess()
-- (3) evaluate number of matches
set s to matchWords(t, w)
-- (4) check exit conditions and set game summary if necessary
set {_exit, sgn} to {false, ""}
if t = w then -- guessed right
set {l, m, _exit, sgn} to {line3a & w & "." & NL & line4, mss3a & w, true, space & wonSign}
else if t = givenUpSign then -- gave up
set {l, m, _exit, sgn} to {line3b & w & "." & NL & line4, mss3b & w, true, space & givenUpSign}
else if i = maxGuesses then -- exhausted guesses
set {l, m, _exit, sgn} to {line3c & w & "." & NL & line4, mss3c & w, true, space & exhaustedSign}
end if
-- (5) log latest result and show results of this game
set r to "" & i & tab & t & tab & s & sgn
set end of my rr to r
logText(r & NL, {_append:true})
choose from list my rr default items my rr's item -1 with prompt mss2 with empty selection allowed
-- (6) log and show game summary
if _exit then
logText(NL & l & (current date) & NL & NL, {_append:true})
display dialog m buttons btt2 default button 2 with icon 1
if button returned of result = btt2's item 1 then set _done to true
exit repeat
end if
end repeat
end repeat
end script
tell o to run
end guessword
--END OF SCRIPT -
Help with simple XML reading example using StAX
Please, could somebody help me with this issue?
Or, could somebody point me to a comprehensive StAX tutorial?
thanks!
I have prepared a simple sample that looks like 'homework', but this newbie task is getting me crazy...
I just want to store in the object Shop[] shopsArray; the next XML file, using StAX:
<?xml version="1.0" encoding="ISO-8859-1"?>
<shops>
<shop>
<name>Amazon</name>
<code>AMZ</code>
<url>www.amazon.com</url>
<product>
<book>
<name>Core JSF</name>
<code>cojsf</code>
<price>136</price>
<pages>333</pages>
</book>
</product>
<product>
<book>
<name>Java forr Dummies</name>
<code>jfd</code>
<price>68</price>
<pages>400</pages>
</book>
</product>
<product>
<video>
<name>Braveheart</name>
<code>brvh</code>
<price>15</price>
<duration>3h</duration>
</video>
</product>
</shop>
<!-- <shop>Other types of shops</shop> -->
</shops>Having the related classes below:
public class Shop {
String name;
String code;
String url;
Product[] productsArray;
public class Product {
String name;
String code;
String price;
public class Book extends Product {
String pages;
public class Video extends Product {
String duration;
}[http://vtd-xml.sf.net|http://vtd-xml.sf.net] While I am not an expert on StAX, I think you may be interested in vtd-xml to simplify coding as it
supports random access and XPath
http://vtd-xml.sf.net -
Trouble with Simple RegExp_Instr
We have a need to examine a string to see if there are any alpha characters and I decided to learn something new and use some of the new RegExp functions. I hope someone can show me the error of my ways. I am using the class alpha but the only letter I find is "A" or "a".
DB and SQLPlus version 11.1.0.6.0 or 10.2.0.4.0.
07:54:55 sys@itsdb>
07:54:55 sys@itsdb> SELECT REGEXP_INSTR ('ABCDEFG',
07:54:55 2 '[:alpha:]',
07:54:55 3 1,
07:54:55 4 1,
07:54:55 5 0,
07:54:55 6 'i'
07:54:55 7 ) alpha_pos
07:54:55 8 FROM DUAL;
ALPHA_POS
1
1 row selected.
07:54:55 sys@itsdb>
07:54:55 sys@itsdb> SELECT REGEXP_INSTR ('123456ABCDEFG',
07:54:55 2 '[:alpha:]',
07:54:55 3 1,
07:54:55 4 1,
07:54:55 5 0,
07:54:55 6 'i'
07:54:55 7 ) alpha_pos
07:54:55 8 FROM DUAL;
ALPHA_POS
7
1 row selected.
07:54:55 sys@itsdb>
07:54:55 sys@itsdb> SELECT REGEXP_INSTR ('GFEDCBA123456',
07:54:55 2 '[:alpha:]',
07:54:55 3 1,
07:54:55 4 1,
07:54:55 5 0,
07:54:55 6 'i'
07:54:55 7 ) alpha_pos
07:54:55 8 FROM DUAL;
ALPHA_POS
7
1 row selected.
07:54:55 sys@itsdb>
07:54:55 sys@itsdb> SELECT REGEXP_INSTR ('BCDEFG123456',
07:54:55 2 '[:alpha:]',
07:54:55 3 1,
07:54:55 4 1,
07:54:55 5 0,
07:54:55 6 'i'
07:54:55 7 ) alpha_pos
07:54:55 8 FROM DUAL;
ALPHA_POS
0
1 row selected.Very true, my bad, thanks Max ;)
Borrowing from your suggestion and moving to the other point Marc mentioned about obtaining the information on whether the 4th position in the string is a letter or not:
SQL> with t as (
2 select 'ABCDEFG' col1 from dual union
3 select 'abc4' col1 from dual union
4 select '123456ABCDEFG' col1 from dual union
5 select '123.56' col1 from dual union
6 select 'ZZZ123456ABCDEFG' col1 from dual union
7 select '11111' col1 from dual union
8 select '123A56' col1 from dual union
9 select 'GFEDCBA123456' col1 from dual)
10 -- end of sample data
11 select col1,
12 regexp_instr(col1, '[[:alpha:]]') ex1,
13 regexp_instr(col1, '^(.{3}[[:alpha:]])', 1, 1, 0, 'i') is_pos_4_letter
14 from t
15 /
COL1 EX1 IS_POS_4_LETTER
11111 0 0
123.56 0 0
123456ABCDEFG 7 0
123A56 4 1
ABCDEFG 1 1
GFEDCBA123456 1 1
ZZZ123456ABCDEFG 1 0
abc4 1 0
8 rows selected
SQL>
Maybe you are looking for
-
I have done something terrible! now some of my photos will not open up, I can see them in the 'event' but if I click on some of them I get a gray triangle with an exclamation point. What have I done and how do I rectify it?
-
Clubbing of purchase requisition at the time of PO Creation
Dear All; We need a requirement to to club all the PR requirements of same item in PO ,but same PR item is from different project . Joydeep
-
How do I restore my iPad to a previous backup made on another computer (Mac)?
How do I restore my iPad to a previous backup made on another computer (a Mac)? I made copies of the backup in the /mobilesync folder and put them on a hard drive. Now I'm in an endless cycle of restoring/syncing which keeps erasing data off of my iP
-
How do I create an iDVD slide show that does not compress the photos making them low-res? When I insert the iDVD I have made into a DVD player connected to an HDTV, the playback quality of the pictures are very low. Is there a way to correct this wh
-
4) Numerial input for a group of data
LookoutDirect 4.5 4) I have a table of hundreds of data, and all of them need a input. How can I make only one numeral input for all of them? That means I click any data in the table I can get to the same numeral input popup window and enter a number