Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.clipper.visual-objects > #3596 > unrolled thread
| Started by | "Bernhard Mayer" <Idonotexist@nowhere.com> |
|---|---|
| First post | 2012-06-12 16:05 +0200 |
| Last post | 2012-06-14 07:51 +0200 |
| Articles | 6 — 5 participants |
Back to article view | Back to comp.lang.clipper.visual-objects
DBF + Alias "Bernhard Mayer" <Idonotexist@nowhere.com> - 2012-06-12 16:05 +0200
Re: DBF + Alias "Wolfgang Riedmann" <wriedmann@gmail.com> - 2012-06-12 14:42 +0000
Re: DBF + Alias dlzc <dlzc1@cox.net> - 2012-06-12 12:13 -0700
Re: DBF + Alias John Martens <adsl672100@tiscali.nl> - 2012-06-12 21:34 +0200
Re: DBF + Alias "Stephen Quinn" <stevejqNO@bigpondSPAM.net.au> - 2012-06-13 07:39 +1000
Re: DBF + Alias "Bernhard Mayer" <Idonotexist@nowhere.com> - 2012-06-14 07:51 +0200
| From | "Bernhard Mayer" <Idonotexist@nowhere.com> |
|---|---|
| Date | 2012-06-12 16:05 +0200 |
| Subject | DBF + Alias |
| Message-ID | <4fd74cc4$0$18692$91cee783@newsreader03.highway.telekom.at> |
Dear fellow VO'ers!
In one of our very few modules which still use DBFs (= temp tables for
ReportPro) we create our temp DBFs the following way:
// 1. Create the DBF, cFile is an unique file name in the temp folder
IF !DBCREATE(SELF:oOption:cReDBFPath + cFile, aField, "DBFCDX", TRUE,
"TEMP", ,FALSE)
RETURN FALSE
ENDIF
// 2. Close it
IF TEMP->(Used())
TEMP->(DBCLOSEAREA())
ENDIF
// 3. Open it via dbServer which is filled with data, passed to ReportPro
and deleted afterwards
oDB := dbServer{...}
Generally, this works quite well and has been working for years but every
now and then, I'm getting an error 1011 (Alias already defined). Is there
another possibility to create the DBF with an "automatic alias" and close it
immediately afterwards? DBCloseAll() cannot be used.
TIA,
Bernhard
[toc] | [next] | [standalone]
| From | "Wolfgang Riedmann" <wriedmann@gmail.com> |
|---|---|
| Date | 2012-06-12 14:42 +0000 |
| Message-ID | <a3p2ppFniU1@mid.individual.net> |
| In reply to | #3596 |
Hi Bernhard,
I'm using the following function to get a unused alias:
function GetFreeAlias( cAlias as string ) as string
local nCounter as dword
local cPartAlias as string
nCounter := 0
cPartAlias := AllTrim( Left( cAlias, 6 ) ) + "_"
while ( Select( cAlias ) > 0 )
++nCounter
cAlias := cPartAlias + NTrim( nCounter )
end
return cAlias
And then you can use the found alias to open a table.
HTH
Wolfgang
[toc] | [prev] | [next] | [standalone]
| From | dlzc <dlzc1@cox.net> |
|---|---|
| Date | 2012-06-12 12:13 -0700 |
| Message-ID | <ce2f89a1-b923-4ed8-9dc4-c45c6db198a3@googlegroups.com> |
| In reply to | #3596 |
Dear Bernhard Mayer: On Tuesday, June 12, 2012 7:05:52 AM UTC-7, Bernhard Mayer wrote: ... > Generally, this works quite well and has been > working for years but every now and then, I'm > getting an error 1011 (Alias already defined). > Is there another possibility to create the > DBF with an "automatic alias" and close it > immediately afterwards? DBCloseAll() cannot > be used. Recommend you push the creation code into a UDF that returns NIL, 0, or an empty string, or the alias or work area number. Then do what you need to with that information, including closing. Alias is supposed to improve readability. If you don't use it, then stick with work areas by number. David A. Smith
[toc] | [prev] | [next] | [standalone]
| From | John Martens <adsl672100@tiscali.nl> |
|---|---|
| Date | 2012-06-12 21:34 +0200 |
| Message-ID | <4fd799a9$0$14711$5fc3050@news.tiscali.nl> |
| In reply to | #3596 |
Why not use
IF Used()
DBCLOSEAREA()
ENDIF
I think it will always work on the current work area which cuold be the
only one open after DbCreate.
If you do no need exclusive rights you could also delete the close lines
of code.
John
Op 12-6-2012 16:05, Bernhard Mayer schreef:
> Dear fellow VO'ers!
>
> In one of our very few modules which still use DBFs (= temp tables for
> ReportPro) we create our temp DBFs the following way:
>
> // 1. Create the DBF, cFile is an unique file name in the temp folder
> IF !DBCREATE(SELF:oOption:cReDBFPath + cFile, aField, "DBFCDX", TRUE,
> "TEMP", ,FALSE)
> RETURN FALSE
> ENDIF
>
> // 2. Close it
> IF TEMP->(Used())
> TEMP->(DBCLOSEAREA())
> ENDIF
>
> // 3. Open it via dbServer which is filled with data, passed to
> ReportPro and deleted afterwards
> oDB := dbServer{...}
>
> Generally, this works quite well and has been working for years but
> every now and then, I'm getting an error 1011 (Alias already defined).
> Is there another possibility to create the DBF with an "automatic alias"
> and close it immediately afterwards? DBCloseAll() cannot be used.
>
> TIA,
> Bernhard
>
[toc] | [prev] | [next] | [standalone]
| From | "Stephen Quinn" <stevejqNO@bigpondSPAM.net.au> |
|---|---|
| Date | 2012-06-13 07:39 +1000 |
| Message-ID | <BGOBr.7991$v14.3493@viwinnwfe02.internal.bigpond.com> |
| In reply to | #3596 |
Bernhard
Why use DBCREATE() at all??
DBFileSpec{} would be better
oFile := DBFileSpec{ SELF:oOption:cReDBFPath + cFile, 'DBFCDX' }
IF I oFile:Find
oFile:Create( SELF:oOption:cReDBFPath + cFile, aField, 'DBFCDX' )
ENDIF
No need to close it as it's never open other than for creation.
If you look at the SDK source for DBServer you'll see the functions VO uses
to get a UNIQUE ALIAS, nothing stopping you from using those as well<g> (if
you wish to stay with clipper syntax that is)
CYA
Steve
[toc] | [prev] | [next] | [standalone]
| From | "Bernhard Mayer" <Idonotexist@nowhere.com> |
|---|---|
| Date | 2012-06-14 07:51 +0200 |
| Message-ID | <4fd97bc4$0$1575$91cee783@newsreader04.highway.telekom.at> |
| In reply to | #3602 |
Thanks to all, I was not aware of DBFileSpec.
BR,
Bernhard
"Stephen Quinn" schrieb im Newsbeitrag
news:BGOBr.7991$v14.3493@viwinnwfe02.internal.bigpond.com...
Bernhard
Why use DBCREATE() at all??
DBFileSpec{} would be better
oFile := DBFileSpec{ SELF:oOption:cReDBFPath + cFile, 'DBFCDX' }
IF I oFile:Find
oFile:Create( SELF:oOption:cReDBFPath + cFile, aField, 'DBFCDX' )
ENDIF
No need to close it as it's never open other than for creation.
If you look at the SDK source for DBServer you'll see the functions VO uses
to get a UNIQUE ALIAS, nothing stopping you from using those as well<g> (if
you wish to stay with clipper syntax that is)
CYA
Steve
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.clipper.visual-objects
csiph-web