1. Helge Tjelta
  2. as Valentina DB Server
  3. Mittwoch, Juni 14 2017, 09:55 PM
  4.  Abonnieren via E-Mail
Hi, I have an invoice system. But for doing credit note, I have to make a new invoice, ref to old, but when making a new invoice I wold like to copy all info I had in the first one, and maybe just change one field....

so how do I i.e.: copy all info in recID 10 to recID 13
Kommentar
There are no comments made yet.
Helge Tjelta Akzeptierte Antwort
Just in case let me ask: Question solved?


Yes!:D
Kommentar
There are no comments made yet.
Ruslan Zasukhin Akzeptierte Antwort
Just in case let me ask: Question solved?
Kommentar
There are no comments made yet.
Helge Tjelta Akzeptierte Antwort
This worked better, both a cursor and direct API. Then I got the picture to duplicate as well.


Dim feltnavn as string

session.Hent_Punkt(session.curs_dager.field("recID").GetString())
session.curs_punkt.Position = 1

Do

session.mTbl_Punkt.SetBlank()

for i as integer = 1 to antF

feltnavn = session.mTbl_punkt.field(i).name
if feltnavn = "Dagsplan" then
session.mTbl_punkt.field(i).setString( nyDag_recID )
else
session.mTbl_punkt.field(i).setString( session.curs_punkt.field(feltnavn).GetString() )
end if

next

call session.mTbl_Punkt.AddRecord()


Loop Until session.curs_punkt.NextRecord = FALSE

Kommentar
There are no comments made yet.
Helge Tjelta Akzeptierte Antwort
I like the thought of the API way... the moveTo is not in the API right ?

But the idea sounds nice... I'll wait :)

Mine had a problem with jpeg/PNG, as the get corrupted.
Kommentar
There are no comments made yet.
Ruslan Zasukhin Akzeptierte Antwort
Hi Helge,

well, you have write code, which builds SQL string with INSERT command.
This is quite universal way, I think our Valentina Studio, as wel as others GUI tools, which work with different SQL DBs do it in this way.



Actually, we can try simple way, e.g.

API WAY with Table:

1) tbl.MoveTo Record you want using any move commands: First Last Prev Next Goto -- this load field values from disk

2) tbl.AddRecord()

-- This way should work easy enough with Valentina Tables, if you not using PK fields and Table have no UNIQUEs.
-- also we not sure right now about BLOB/TEXT fields. IF they will make a copy of BLOB value for new record. Must be tested.

-- If you have some UNIQUE field or even PK field, then before AddRecord() you should assign some unique values for that fields.


Cursor way:

VCursor also have AddRecord() command, so this way can be tested for VCursor also.
Kommentar
There are no comments made yet.
Helge Tjelta Akzeptierte Antwort
This worked.


Dim ant, i, res as integer
Dim feltene, verdier, sql as string

ant = session.mTbl_Punkt.FieldCount

For i = 1 to ant-1
feltene = feltene +session.mTbl_punkt.Field(i).name+ ", "
Next
feltene = feltene +session.mTbl_punkt.Field(ant).name

For i = 1 to ant-1
if session.mTbl_punkt.Field(i).name <> "Nr" then // this is for checking numbering and add one to this field
verdier = verdier +session.mTbl_punkt.Field(i).GetString()+ "', '"
else
verdier = verdier +STR( VAL(session.mTbl_punkt.Field(i).GetString())+1) + "', '"
end if
Next
verdier = verdier +session.mTbl_punkt.Field(ant).GetString()

sql = "INSERT INTO Punkt ("+feltene+") VALUES ('"+verdier+"')"

res = session.mConnection.SqlExecute(SQL)

Kommentar
There are no comments made yet.
Helge Tjelta Akzeptierte Antwort
Xojo, and Server...

but I would like to do it either in API og SQL, and cursor is on server
Kommentar
There are no comments made yet.
Ruslan Zasukhin Akzeptierte Antwort
Hi Helge,

Xojo, VDB VServer?

You want answer for what? API? SQL? cursor?
Kommentar
There are no comments made yet.
  • Seite :
  • 1


There are no replies made for this post yet.
However, you are not allowed to reply to this post.

Categories

Announcements & News
  1. 0 subcategories
Valentina Studio
  1. 2 subcategories
Valentina Server
  1. 4 subcategories
Valentina Database ADK
  1. 0 subcategories
Valentina Reports ADK
  1. 0 subcategories
Other Discussions
  1. 2 subcategories
BETA Testing
  1. 0 subcategories
Education & Research
  1. 0 subcategories