Steve, just a possible tip. As with so much SQL, it's mostly about the
SELECT-statement. I usually test it at the command line and, if it's getting'
really long, via a command file.
When I get to the command file, for statements like this, where one must
"balance" their source and target columns, I format my statements thusly:
INSERT INTO +
TARGET_TABLE +
(TargetColumn_A, +
TargetColumn_B, +
TargetColumn_C, +
...
TargetColumn_Z) +
SELECT +
SourceColumn_A, +
SourceColumn_B, +
SourceColumn_C, +
...
SourceColumn_Z +
WHERE +
MyData_Meets_My_Criteria -- Obviously, this is pseudo-code
With only a few columns, this isn't a big help, but I have often had to work
with (de-normalized) extracts from other systems which may contain dozens or
more fields. Doing it this way, I am able to quickly make sure that the number
of TargetColumns and SourceColumns (or SourceVariables, SourceLiterals,
SourceFunctions ...) are equal and in matching sequence. I can also quickly
comment out the INSERT-portion and just execute the SELECT-portion of the
command file.
Believe me, it is a rare occasion that I get one of these "big" ones correct on
the first attempt.
Maybe you already know/do this stuff, but I just wanted to share.
Steve in Memphis
From: [email protected] [mailto:[EMAIL PROTECTED] On Behalf Of [EMAIL PROTECTED]
Sent: Friday, March 14, 2008 8:45 AM
To: RBASE-L Mailing List
Subject: [RBASE-L] - Re: Insert Data into table
Do something like this. I can't really make sense of your variables and what
you're trying to achieve, but this is a start:
INSERT INTO bd_details ( pon, custnum2) SELECT pon, custnum2 FROM
master WHERE billstat like 'cv%' and pon = .vpon_entry
I am trying to insert data into a table based on a response (vpon_entry) into a
dialog box upon entry into a form.
Not sure of how to design a insert command.
set var vpon_entry text
set var vcust_nub2 text
Dialog box entry
-- vpon_entry = b109562
vcustnub2 = sel custnub2 from master where pon = vpon_entry
-- note: trying to insert this data into bd_details based on the fact that a
match with pon in master and where billstat in master = cv.
-- The column names in bd_details are pon and custnub2
insert vpon_entry vcust_nub2 into bd_details where vpon_entry = (sel pon from
master where +
billstat like 'cv')