Index: rules/annotations/database_general.rules =================================================================== --- rules/annotations/database_general.rules (revision 2287) +++ rules/annotations/database_general.rules (working copy) @@ -215,6 +215,12 @@ + + + + + + @@ -315,6 +321,10 @@ connOpts = create("java.util.ArrayList") + createAndAssign = null + createAndAssignBuf = null + createAndAssignFields = null + createAndAssignLiterals = null @@ -975,10 +985,67 @@ copy.remove() + + this.type == prog.kw_create and parent.type == prog.statement + ref = this.firstChild + ref.type == prog.temp_table + ref2 = parent.parent.getChildAt(parent.indexPos + 1) + ref2.type == prog.statement and ref2.downPath("KW_ASSIGN/ASSIGN") + createAndAssign = copy + createAndAssignBuf = ref.getAnnotation("bufname") + createAndAssignFields = create("java.util.ArrayList") + createAndAssignLiterals = create("java.util.ArrayList") + + + + + createAndAssign != null and + evalLib("fields") and + upPath("STATEMENT/KW_ASSIGN/ASSIGN") and + getNoteString("bufname") == createAndAssignBuf + createAndAssignFields.add(this.id) + + ref = this.parent.getChildAt(1) + ref.type == prog.expression + ref = ref.firstChild + evalLib("literals", ref.type) + + createAndAssignLiterals.add(ref.id) + + createAndAssign = null + createAndAssignBuf = null + createAndAssignFields = null + createAndAssignLiterals = null + + + - + createAndAssign != null and relativePath("STATEMENT/KW_ASSIGN") + + copy.parent.setHidden(true) + + idx = 0 + idx < createAndAssignFields.size() + + createAndAssign.putAnnotation("create_and_assign_fields", + #(java.lang.Long) createAndAssignFields.get(idx), + -1) + + ref = getAst(#(java.lang.Long) createAndAssignLiterals.get(idx)) + ref.move(createAndAssign, -1) + idx = idx + 1 + + + createAndAssign = null + createAndAssignFields = null + createAndAssignLiterals = null + createAndAssignBuf = null + + (type == prog.kw_for and getNoteBoolean("quick_delete")) or type == prog.embedded_sql unqualFields = false Index: rules/convert/database_access.rules =================================================================== --- rules/convert/database_access.rules (revision 2287) +++ rules/convert/database_access.rules (working copy) @@ -840,7 +840,11 @@ by database_references.rules), no kw_using support at this time --> type == prog.kw_create methodtype = java.method_call - methodtxt = "create" + + isNote("create_and_assign_fields") + methodtxt = "createAndAssign" + methodtxt = "create" + + idx = 0 + idx < this.annotationSize("create_and_assign_fields") + + ref = getAst(#(java.lang.Long) this.getAnnotation("create_and_assign_fields", idx)) + + + createJavaAst(java.string, + #(java.lang.String) ref.getAnnotation("fieldname"), + closestPeerId, + idx + 1) + + idx = idx + 1 + + (type == prog.func_logical and getNoteLong("oldtype") == prog.kw_can_find) Index: src/com/goldencode/p2j/persist/Buffer.java =================================================================== --- src/com/goldencode/p2j/persist/Buffer.java (revision 2287) +++ src/com/goldencode/p2j/persist/Buffer.java (working copy) @@ -519,6 +519,8 @@ */ public void create(); + public void createAndAssign(Object... fieldsAndLiterals); + /** * Delete the record currently in the buffer, if any. * Index: src/com/goldencode/p2j/persist/BufferImpl.java =================================================================== --- src/com/goldencode/p2j/persist/BufferImpl.java (revision 2287) +++ src/com/goldencode/p2j/persist/BufferImpl.java (working copy) @@ -1244,6 +1244,24 @@ buffer().create(); } + @Override + public void createAndAssign(Object... fieldsAndLiterals) + { + RecordBuffer buffer = buffer(); + buffer.create(); + RecordBuffer.batch(() -> + { + int size = fieldsAndLiterals.length / 2; + for (int i = 0; i < size; i++) + { + String field = (String) fieldsAndLiterals[i]; + Object value = fieldsAndLiterals[i + size]; + + // TODO: field is DMO property... not legacy + } + }); + } + /** * Delete the record currently in the buffer, if any. *